diff --git a/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp b/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp index d9b76a5b664..770b2bfa68f 100644 --- a/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp +++ b/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp @@ -3484,7 +3484,7 @@ void TemplateTable::invokevirtual(int byte_no) { __ testbitdi(CCR0, R0, Rflags, ResolvedMethodEntry::is_vfinal_shift); __ bfalse(CCR0, LnotFinal); - if (RewriteBytecodes && !UseSharedSpaces && !CDSConfig::is_dumping_static_archive()) { + if (RewriteBytecodes && !CDSConfig::is_using_archive() && !CDSConfig::is_dumping_static_archive()) { patch_bytecode(Bytecodes::_fast_invokevfinal, Rnew_bc, R12_scratch2); } invokevfinal_helper(Rcache, R11_scratch1, R12_scratch2, Rflags /* tmp */, Rrecv /* tmp */); diff --git a/src/hotspot/os/posix/vmError_posix.cpp b/src/hotspot/os/posix/vmError_posix.cpp index 7d7fe6c13c1..30ebf8092f8 100644 --- a/src/hotspot/os/posix/vmError_posix.cpp +++ b/src/hotspot/os/posix/vmError_posix.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2020 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -24,6 +24,7 @@ */ #include "precompiled.hpp" +#include "cds/cdsConfig.hpp" #include "cds/metaspaceShared.hpp" #include "os_posix.hpp" #include "runtime/javaThread.hpp" @@ -112,7 +113,7 @@ void VMError::install_secondary_signal_handler() { // and the offending address points into CDS archive. void VMError::check_failing_cds_access(outputStream* st, const void* siginfo) { #if INCLUDE_CDS - if (siginfo && UseSharedSpaces) { + if (siginfo && CDSConfig::is_using_archive()) { const siginfo_t* const si = (siginfo_t*)siginfo; if (si->si_signo == SIGBUS || si->si_signo == SIGSEGV) { const void* const fault_addr = si->si_addr; diff --git a/src/hotspot/os/windows/vmError_windows.cpp b/src/hotspot/os/windows/vmError_windows.cpp index dd19ee91513..363ec3192ce 100644 --- a/src/hotspot/os/windows/vmError_windows.cpp +++ b/src/hotspot/os/windows/vmError_windows.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ */ #include "precompiled.hpp" +#include "cds/cdsConfig.hpp" #include "cds/metaspaceShared.hpp" #include "runtime/arguments.hpp" #include "runtime/javaThread.hpp" @@ -44,7 +45,7 @@ void VMError::install_secondary_signal_handler() { // and the offending address points into CDS archive. void VMError::check_failing_cds_access(outputStream* st, const void* siginfo) { #if INCLUDE_CDS - if (siginfo && UseSharedSpaces) { + if (siginfo && CDSConfig::is_using_archive()) { const EXCEPTION_RECORD* const er = (const EXCEPTION_RECORD*)siginfo; if (er->ExceptionCode == EXCEPTION_IN_PAGE_ERROR && er->NumberParameters >= 2) { diff --git a/src/hotspot/share/cds/cdsConfig.cpp b/src/hotspot/share/cds/cdsConfig.cpp index 25b7a94f0aa..a0a562eca21 100644 --- a/src/hotspot/share/cds/cdsConfig.cpp +++ b/src/hotspot/share/cds/cdsConfig.cpp @@ -67,7 +67,7 @@ void CDSConfig::initialize() { // This must be after set_ergonomics_flags() called so flag UseCompressedOops is set properly. // // UseSharedSpaces may be disabled if -XX:SharedArchiveFile is invalid. - if (is_dumping_static_archive() || UseSharedSpaces) { + if (is_dumping_static_archive() || is_using_archive()) { init_shared_archive_paths(); } @@ -305,7 +305,7 @@ void CDSConfig::check_unsupported_dumping_module_options() { } bool CDSConfig::has_unsupported_runtime_module_options() { - assert(UseSharedSpaces, "this function is only used with -Xshare:{on,auto}"); + assert(is_using_archive(), "this function is only used with -Xshare:{on,auto}"); if (ArchiveClassesAtExit != nullptr) { // dynamic dumping, just return false for now. // check_unsupported_dumping_properties() will be called later to check the same set of @@ -370,10 +370,10 @@ bool CDSConfig::check_vm_args_consistency(bool patch_mod_javabase, bool mode_fla } } - if (UseSharedSpaces && patch_mod_javabase) { + if (is_using_archive() && patch_mod_javabase) { Arguments::no_shared_spaces("CDS is disabled when " JAVA_BASE_NAME " module is patched."); } - if (UseSharedSpaces && has_unsupported_runtime_module_options()) { + if (is_using_archive() && has_unsupported_runtime_module_options()) { UseSharedSpaces = false; } @@ -389,7 +389,7 @@ bool CDSConfig::check_vm_args_consistency(bool patch_mod_javabase, bool mode_fla } bool CDSConfig::is_using_archive() { - return UseSharedSpaces; // TODO: UseSharedSpaces will be eventually replaced by CDSConfig::is_using_archive() + return UseSharedSpaces; } bool CDSConfig::is_logging_lambda_form_invokers() { @@ -417,7 +417,7 @@ bool CDSConfig::is_using_full_module_graph() { return false; } - if (UseSharedSpaces && ArchiveHeapLoader::can_use()) { + if (is_using_archive() && ArchiveHeapLoader::can_use()) { // Classes used by the archived full module graph are loaded in JVMTI early phase. assert(!(JvmtiExport::should_post_class_file_load_hook() && JvmtiExport::has_early_class_hook_env()), "CDS should be disabled if early class hooks are enabled"); diff --git a/src/hotspot/share/cds/dynamicArchive.cpp b/src/hotspot/share/cds/dynamicArchive.cpp index f255b337d14..5effa4e458c 100644 --- a/src/hotspot/share/cds/dynamicArchive.cpp +++ b/src/hotspot/share/cds/dynamicArchive.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -470,7 +470,7 @@ int DynamicArchive::num_array_klasses() { } void DynamicArchive::check_for_dynamic_dump() { - if (CDSConfig::is_dumping_dynamic_archive() && !UseSharedSpaces) { + if (CDSConfig::is_dumping_dynamic_archive() && !CDSConfig::is_using_archive()) { // This could happen if SharedArchiveFile has failed to load: // - -Xshare:off was specified // - SharedArchiveFile points to an non-existent file. @@ -522,7 +522,7 @@ void DynamicArchive::dump_at_exit(JavaThread* current, const char* archive_name) // This is called by "jcmd VM.cds dynamic_dump" void DynamicArchive::dump_for_jcmd(const char* archive_name, TRAPS) { - assert(UseSharedSpaces && RecordDynamicDumpInfo, "already checked in arguments.cpp"); + assert(CDSConfig::is_using_archive() && RecordDynamicDumpInfo, "already checked in arguments.cpp"); assert(ArchiveClassesAtExit == nullptr, "already checked in arguments.cpp"); assert(CDSConfig::is_dumping_dynamic_archive(), "already checked by check_for_dynamic_dump() during VM startup"); MetaspaceShared::link_shared_classes(true/*from jcmd*/, CHECK); diff --git a/src/hotspot/share/cds/filemap.cpp b/src/hotspot/share/cds/filemap.cpp index 5d56eb2153f..5b352b54e4b 100644 --- a/src/hotspot/share/cds/filemap.cpp +++ b/src/hotspot/share/cds/filemap.cpp @@ -371,7 +371,7 @@ void SharedClassPathEntry::copy_from(SharedClassPathEntry* ent, ClassLoaderData* } const char* SharedClassPathEntry::name() const { - if (UseSharedSpaces && is_modules_image()) { + if (CDSConfig::is_using_archive() && is_modules_image()) { // In order to validate the runtime modules image file size against the archived // size information, we need to obtain the runtime modules image path. The recorded // dump time modules image path in the archive may be different from the runtime path @@ -383,7 +383,7 @@ const char* SharedClassPathEntry::name() const { } bool SharedClassPathEntry::validate(bool is_class_path) const { - assert(UseSharedSpaces, "runtime only"); + assert(CDSConfig::is_using_archive(), "runtime only"); struct stat st; const char* name = this->name(); @@ -935,7 +935,7 @@ bool FileMapInfo::check_module_paths() { } bool FileMapInfo::validate_shared_path_table() { - assert(UseSharedSpaces, "runtime only"); + assert(CDSConfig::is_using_archive(), "runtime only"); _validating_shared_path_table = true; @@ -981,7 +981,7 @@ bool FileMapInfo::validate_shared_path_table() { log_info(class, path)("ok"); } else { if (_dynamic_archive_info != nullptr && _dynamic_archive_info->_is_static) { - assert(!UseSharedSpaces, "UseSharedSpaces should be disabled"); + assert(!CDSConfig::is_using_archive(), "UseSharedSpaces should be disabled"); } return false; } @@ -990,7 +990,7 @@ bool FileMapInfo::validate_shared_path_table() { log_info(class, path)("ok"); } else { if (_dynamic_archive_info != nullptr && _dynamic_archive_info->_is_static) { - assert(!UseSharedSpaces, "UseSharedSpaces should be disabled"); + assert(!CDSConfig::is_using_archive(), "UseSharedSpaces should be disabled"); } return false; } @@ -1038,7 +1038,7 @@ void FileMapInfo::validate_non_existent_class_paths() { // loading of archived platform/app classes (currently there's no way to disable just the // app classes). - assert(UseSharedSpaces, "runtime only"); + assert(CDSConfig::is_using_archive(), "runtime only"); for (int i = header()->app_module_paths_start_index() + header()->num_module_paths(); i < get_number_of_shared_paths(); i++) { @@ -2087,7 +2087,7 @@ bool FileMapInfo::can_use_heap_region() { // The actual address of this region during dump time. address FileMapInfo::heap_region_dumptime_address() { FileMapRegion* r = region_at(MetaspaceShared::hp); - assert(UseSharedSpaces, "runtime only"); + assert(CDSConfig::is_using_archive(), "runtime only"); assert(is_aligned(r->mapping_offset(), sizeof(HeapWord)), "must be"); if (UseCompressedOops) { return /*dumptime*/ narrow_oop_base() + r->mapping_offset(); @@ -2099,7 +2099,7 @@ address FileMapInfo::heap_region_dumptime_address() { // The address where this region can be mapped into the runtime heap without // patching any of the pointers that are embedded in this region. address FileMapInfo::heap_region_requested_address() { - assert(UseSharedSpaces, "runtime only"); + assert(CDSConfig::is_using_archive(), "runtime only"); FileMapRegion* r = region_at(MetaspaceShared::hp); assert(is_aligned(r->mapping_offset(), sizeof(HeapWord)), "must be"); assert(ArchiveHeapLoader::can_map(), "cannot be used by ArchiveHeapLoader::can_load() mode"); @@ -2227,7 +2227,7 @@ bool FileMapInfo::map_heap_region_impl() { } narrowOop FileMapInfo::encoded_heap_region_dumptime_address() { - assert(UseSharedSpaces, "runtime only"); + assert(CDSConfig::is_using_archive(), "runtime only"); assert(UseCompressedOops, "sanity"); FileMapRegion* r = region_at(MetaspaceShared::hp); return CompressedOops::narrow_oop_cast(r->mapping_offset() >> narrow_oop_shift()); @@ -2316,7 +2316,7 @@ GrowableArray* FileMapInfo::_non_existent_class_paths = nullptr; // [2] validate_shared_path_table - this is done later, because the table is in the RW // region of the archive, which is not mapped yet. bool FileMapInfo::initialize() { - assert(UseSharedSpaces, "UseSharedSpaces expected."); + assert(CDSConfig::is_using_archive(), "UseSharedSpaces expected."); assert(Arguments::has_jimage(), "The shared archive file cannot be used with an exploded module build."); if (JvmtiExport::should_post_class_file_load_hook() && JvmtiExport::has_early_class_hook_env()) { diff --git a/src/hotspot/share/cds/heapShared.cpp b/src/hotspot/share/cds/heapShared.cpp index b9f5d963c85..7b519a57d57 100644 --- a/src/hotspot/share/cds/heapShared.cpp +++ b/src/hotspot/share/cds/heapShared.cpp @@ -231,7 +231,7 @@ objArrayOop HeapShared::roots() { return nullptr; } } else { - assert(UseSharedSpaces, "must be"); + assert(CDSConfig::is_using_archive(), "must be"); } objArrayOop roots = (objArrayOop)_roots.resolve(); @@ -242,7 +242,7 @@ objArrayOop HeapShared::roots() { // Returns an objArray that contains all the roots of the archived objects oop HeapShared::get_root(int index, bool clear) { assert(index >= 0, "sanity"); - assert(!CDSConfig::is_dumping_heap() && UseSharedSpaces, "runtime only"); + assert(!CDSConfig::is_dumping_heap() && CDSConfig::is_using_archive(), "runtime only"); assert(!_roots.is_empty(), "must have loaded shared heap"); oop result = roots()->obj_at(index); if (clear) { @@ -253,7 +253,7 @@ oop HeapShared::get_root(int index, bool clear) { void HeapShared::clear_root(int index) { assert(index >= 0, "sanity"); - assert(UseSharedSpaces, "must be"); + assert(CDSConfig::is_using_archive(), "must be"); if (ArchiveHeapLoader::is_in_use()) { if (log_is_enabled(Debug, cds, heap)) { oop old = roots()->obj_at(index); @@ -906,7 +906,7 @@ static void verify_the_heap(Klass* k, const char* which) { // ClassFileLoadHook is enabled, it's possible for this class to be dynamically replaced. In // this case, we will not load the ArchivedKlassSubGraphInfoRecord and will clear its roots. void HeapShared::resolve_classes(JavaThread* current) { - assert(UseSharedSpaces, "runtime only!"); + assert(CDSConfig::is_using_archive(), "runtime only!"); if (!ArchiveHeapLoader::is_in_use()) { return; // nothing to do } diff --git a/src/hotspot/share/cds/metaspaceShared.cpp b/src/hotspot/share/cds/metaspaceShared.cpp index b0857386b10..30b240b27ca 100644 --- a/src/hotspot/share/cds/metaspaceShared.cpp +++ b/src/hotspot/share/cds/metaspaceShared.cpp @@ -287,7 +287,7 @@ void MetaspaceShared::initialize_for_static_dump() { // Called by universe_post_init() void MetaspaceShared::post_initialize(TRAPS) { - if (UseSharedSpaces) { + if (CDSConfig::is_using_archive()) { int size = FileMapInfo::get_number_of_shared_paths(); if (size > 0) { CDSProtectionDomain::allocate_shared_data_arrays(size, CHECK); @@ -924,7 +924,7 @@ void MetaspaceShared::unrecoverable_writing_error(const char* message) { } void MetaspaceShared::initialize_runtime_shared_and_meta_spaces() { - assert(UseSharedSpaces, "Must be called when UseSharedSpaces is enabled"); + assert(CDSConfig::is_using_archive(), "Must be called when UseSharedSpaces is enabled"); MapArchiveResult result = MAP_ARCHIVE_OTHER_FAILURE; FileMapInfo* static_mapinfo = open_static_archive(); @@ -1414,7 +1414,7 @@ static int archive_regions[] = { MetaspaceShared::rw, MetaspaceShared::ro }; static int archive_regions_count = 2; MapArchiveResult MetaspaceShared::map_archive(FileMapInfo* mapinfo, char* mapped_base_address, ReservedSpace rs) { - assert(UseSharedSpaces, "must be runtime"); + assert(CDSConfig::is_using_archive(), "must be runtime"); if (mapinfo == nullptr) { return MAP_ARCHIVE_SUCCESS; // The dynamic archive has not been specified. No error has happened -- trivially succeeded. } @@ -1444,7 +1444,7 @@ MapArchiveResult MetaspaceShared::map_archive(FileMapInfo* mapinfo, char* mapped } void MetaspaceShared::unmap_archive(FileMapInfo* mapinfo) { - assert(UseSharedSpaces, "must be runtime"); + assert(CDSConfig::is_using_archive(), "must be runtime"); if (mapinfo != nullptr) { mapinfo->unmap_regions(archive_regions, archive_regions_count); mapinfo->unmap_region(MetaspaceShared::bm); @@ -1542,7 +1542,7 @@ void MetaspaceShared::initialize_shared_spaces() { bool MetaspaceShared::remap_shared_readonly_as_readwrite() { assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); - if (UseSharedSpaces) { + if (CDSConfig::is_using_archive()) { // remap the shared readonly space to shared readwrite, private FileMapInfo* mapinfo = FileMapInfo::current_info(); if (!mapinfo->remap_shared_readonly_as_readwrite()) { @@ -1560,7 +1560,7 @@ bool MetaspaceShared::remap_shared_readonly_as_readwrite() { } void MetaspaceShared::print_on(outputStream* st) { - if (UseSharedSpaces) { + if (CDSConfig::is_using_archive()) { st->print("CDS archive(s) mapped at: "); address base = (address)MetaspaceObj::shared_metaspace_base(); address static_top = (address)_shared_metaspace_static_top; diff --git a/src/hotspot/share/classfile/classLoader.cpp b/src/hotspot/share/classfile/classLoader.cpp index 76084ff1685..b317aaa071c 100644 --- a/src/hotspot/share/classfile/classLoader.cpp +++ b/src/hotspot/share/classfile/classLoader.cpp @@ -1483,7 +1483,7 @@ void ClassLoader::classLoader_init2(JavaThread* current) { // entries will be added to the exploded build array. if (!has_jrt_entry()) { assert(!CDSConfig::is_dumping_archive(), "not supported with exploded module builds"); - assert(!UseSharedSpaces, "UsedSharedSpaces not supported with exploded module builds"); + assert(!CDSConfig::is_using_archive(), "UsedSharedSpaces not supported with exploded module builds"); // Set up the boot loader's _exploded_entries list. Note that this gets // done before loading any classes, by the same thread that will // subsequently do the first class load. So, no lock is needed for this. diff --git a/src/hotspot/share/classfile/classLoaderDataShared.cpp b/src/hotspot/share/classfile/classLoaderDataShared.cpp index b6d93eace4e..8abe469ea25 100644 --- a/src/hotspot/share/classfile/classLoaderDataShared.cpp +++ b/src/hotspot/share/classfile/classLoaderDataShared.cpp @@ -102,7 +102,7 @@ void ArchivedClassLoaderData::init_archived_entries(ClassLoaderData* loader_data } void ArchivedClassLoaderData::restore(ClassLoaderData* loader_data, bool do_entries, bool do_oops) { - assert(UseSharedSpaces, "must be"); + assert(CDSConfig::is_using_archive(), "must be"); assert_valid(loader_data); if (_modules != nullptr) { // Could be null if we have archived no modules for platform/system loaders ModuleEntryTable* modules = loader_data->modules(); @@ -120,7 +120,7 @@ void ArchivedClassLoaderData::restore(ClassLoaderData* loader_data, bool do_entr } void ArchivedClassLoaderData::clear_archived_oops() { - assert(UseSharedSpaces, "must be"); + assert(CDSConfig::is_using_archive(), "must be"); if (_modules != nullptr) { for (int i = 0; i < _modules->length(); i++) { _modules->at(i)->clear_archived_oops(); diff --git a/src/hotspot/share/classfile/classLoaderExt.cpp b/src/hotspot/share/classfile/classLoaderExt.cpp index 506d50e99c1..78e29f990d7 100644 --- a/src/hotspot/share/classfile/classLoaderExt.cpp +++ b/src/hotspot/share/classfile/classLoaderExt.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,7 +60,7 @@ bool ClassLoaderExt::_has_platform_classes = false; bool ClassLoaderExt::_has_non_jar_in_classpath = false; void ClassLoaderExt::append_boot_classpath(ClassPathEntry* new_entry) { - if (UseSharedSpaces) { + if (CDSConfig::is_using_archive()) { warning("Sharing is only supported for boot loader classes because bootstrap classpath has been appended"); FileMapInfo::current_info()->set_has_platform_or_app_classes(false); if (DynamicArchive::is_mapped()) { diff --git a/src/hotspot/share/classfile/javaClasses.cpp b/src/hotspot/share/classfile/javaClasses.cpp index 077b05f936e..5a3fe239324 100644 --- a/src/hotspot/share/classfile/javaClasses.cpp +++ b/src/hotspot/share/classfile/javaClasses.cpp @@ -5328,7 +5328,7 @@ void java_lang_InternalError::serialize_offsets(SerializeClosure* f) { // Compute field offsets of all the classes in this file void JavaClasses::compute_offsets() { - if (UseSharedSpaces) { + if (CDSConfig::is_using_archive()) { JVMTI_ONLY(assert(JvmtiExport::is_early_phase() && !(JvmtiExport::should_post_class_file_load_hook() && JvmtiExport::has_early_class_hook_env()), "JavaClasses::compute_offsets() must be called in early JVMTI phase.")); diff --git a/src/hotspot/share/classfile/moduleEntry.cpp b/src/hotspot/share/classfile/moduleEntry.cpp index 9d2a76e9e51..78478d282c5 100644 --- a/src/hotspot/share/classfile/moduleEntry.cpp +++ b/src/hotspot/share/classfile/moduleEntry.cpp @@ -61,7 +61,7 @@ void ModuleEntry::set_location(Symbol* location) { if (location != nullptr) { location->increment_refcount(); - CDS_ONLY(if (UseSharedSpaces) { + CDS_ONLY(if (CDSConfig::is_using_archive()) { _shared_path_index = FileMapInfo::get_module_shared_path_index(location); }); } @@ -513,14 +513,14 @@ void ModuleEntry::verify_archived_module_entries() { #endif // PRODUCT void ModuleEntry::load_from_archive(ClassLoaderData* loader_data) { - assert(UseSharedSpaces, "runtime only"); + assert(CDSConfig::is_using_archive(), "runtime only"); set_loader_data(loader_data); _reads = restore_growable_array((Array*)_reads); JFR_ONLY(INIT_ID(this);) } void ModuleEntry::restore_archived_oops(ClassLoaderData* loader_data) { - assert(UseSharedSpaces, "runtime only"); + assert(CDSConfig::is_using_archive(), "runtime only"); Handle module_handle(Thread::current(), HeapShared::get_root(_archived_module_index, /*clear=*/true)); assert(module_handle.not_null(), "huh"); set_module(loader_data->add_handle(module_handle)); @@ -541,7 +541,7 @@ void ModuleEntry::restore_archived_oops(ClassLoaderData* loader_data) { } void ModuleEntry::clear_archived_oops() { - assert(UseSharedSpaces, "runtime only"); + assert(CDSConfig::is_using_archive(), "runtime only"); HeapShared::clear_root(_archived_module_index); } @@ -586,7 +586,7 @@ void ModuleEntryTable::init_archived_entries(Array* archived_modul void ModuleEntryTable::load_archived_entries(ClassLoaderData* loader_data, Array* archived_modules) { - assert(UseSharedSpaces, "runtime only"); + assert(CDSConfig::is_using_archive(), "runtime only"); for (int i = 0; i < archived_modules->length(); i++) { ModuleEntry* archived_entry = archived_modules->at(i); @@ -596,7 +596,7 @@ void ModuleEntryTable::load_archived_entries(ClassLoaderData* loader_data, } void ModuleEntryTable::restore_archived_oops(ClassLoaderData* loader_data, Array* archived_modules) { - assert(UseSharedSpaces, "runtime only"); + assert(CDSConfig::is_using_archive(), "runtime only"); for (int i = 0; i < archived_modules->length(); i++) { ModuleEntry* archived_entry = archived_modules->at(i); archived_entry->restore_archived_oops(loader_data); diff --git a/src/hotspot/share/classfile/packageEntry.cpp b/src/hotspot/share/classfile/packageEntry.cpp index 97cd041f3f1..c6236e51c0a 100644 --- a/src/hotspot/share/classfile/packageEntry.cpp +++ b/src/hotspot/share/classfile/packageEntry.cpp @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "cds/archiveBuilder.hpp" #include "cds/archiveUtils.hpp" +#include "cds/cdsConfig.hpp" #include "classfile/classLoaderData.hpp" #include "classfile/moduleEntry.hpp" #include "classfile/packageEntry.hpp" @@ -316,7 +317,7 @@ void PackageEntryTable::init_archived_entries(Array* archived_pac } void PackageEntryTable::load_archived_entries(Array* archived_packages) { - assert(UseSharedSpaces, "runtime only"); + assert(CDSConfig::is_using_archive(), "runtime only"); for (int i = 0; i < archived_packages->length(); i++) { PackageEntry* archived_entry = archived_packages->at(i); diff --git a/src/hotspot/share/classfile/systemDictionary.cpp b/src/hotspot/share/classfile/systemDictionary.cpp index 3a6c372cc50..852416e30f5 100644 --- a/src/hotspot/share/classfile/systemDictionary.cpp +++ b/src/hotspot/share/classfile/systemDictionary.cpp @@ -139,7 +139,7 @@ void SystemDictionary::compute_java_loaders(TRAPS) { _java_system_loader = OopHandle(Universe::vm_global(), system_loader); } else { // It must have been restored from the archived module graph - assert(UseSharedSpaces, "must be"); + assert(CDSConfig::is_using_archive(), "must be"); assert(CDSConfig::is_using_full_module_graph(), "must be"); DEBUG_ONLY( oop system_loader = get_system_class_loader_impl(CHECK); @@ -152,7 +152,7 @@ void SystemDictionary::compute_java_loaders(TRAPS) { _java_platform_loader = OopHandle(Universe::vm_global(), platform_loader); } else { // It must have been restored from the archived module graph - assert(UseSharedSpaces, "must be"); + assert(CDSConfig::is_using_archive(), "must be"); assert(CDSConfig::is_using_full_module_graph(), "must be"); DEBUG_ONLY( oop platform_loader = get_platform_class_loader_impl(CHECK); @@ -1262,7 +1262,7 @@ InstanceKlass* SystemDictionary::load_instance_class_impl(Symbol* class_name, Ha InstanceKlass* k = nullptr; #if INCLUDE_CDS - if (UseSharedSpaces) + if (CDSConfig::is_using_archive()) { PerfTraceTime vmtimer(ClassLoader::perf_shared_classload_time()); InstanceKlass* ik = SystemDictionaryShared::find_builtin_class(class_name); @@ -1617,7 +1617,7 @@ void SystemDictionary::initialize(TRAPS) { // Resolve basic classes vmClasses::resolve_all(CHECK); // Resolve classes used by archived heap objects - if (UseSharedSpaces) { + if (CDSConfig::is_using_archive()) { HeapShared::resolve_classes(THREAD); } } diff --git a/src/hotspot/share/classfile/systemDictionaryShared.cpp b/src/hotspot/share/classfile/systemDictionaryShared.cpp index 44d7da5c4a4..8bb06e6dca4 100644 --- a/src/hotspot/share/classfile/systemDictionaryShared.cpp +++ b/src/hotspot/share/classfile/systemDictionaryShared.cpp @@ -85,7 +85,7 @@ DEBUG_ONLY(bool SystemDictionaryShared::_class_loading_may_happen = true;) InstanceKlass* SystemDictionaryShared::load_shared_class_for_builtin_loader( Symbol* class_name, Handle class_loader, TRAPS) { - assert(UseSharedSpaces, "must be"); + assert(CDSConfig::is_using_archive(), "must be"); InstanceKlass* ik = find_builtin_class(class_name); if (ik != nullptr && !ik->shared_loading_failed()) { @@ -107,7 +107,7 @@ InstanceKlass* SystemDictionaryShared::lookup_from_stream(Symbol* class_name, Handle protection_domain, const ClassFileStream* cfs, TRAPS) { - if (!UseSharedSpaces) { + if (!CDSConfig::is_using_archive()) { return nullptr; } if (class_name == nullptr) { // don't do this for hidden classes @@ -389,7 +389,7 @@ bool SystemDictionaryShared::has_platform_or_app_classes() { InstanceKlass* SystemDictionaryShared::find_or_load_shared_class( Symbol* name, Handle class_loader, TRAPS) { InstanceKlass* k = nullptr; - if (UseSharedSpaces) { + if (CDSConfig::is_using_archive()) { if (!has_platform_or_app_classes()) { return nullptr; } @@ -841,7 +841,7 @@ InstanceKlass* SystemDictionaryShared::retrieve_lambda_proxy_class(const RunTime } InstanceKlass* SystemDictionaryShared::get_shared_nest_host(InstanceKlass* lambda_ik) { - assert(!CDSConfig::is_dumping_static_archive() && UseSharedSpaces, "called at run time with CDS enabled only"); + assert(!CDSConfig::is_dumping_static_archive() && CDSConfig::is_using_archive(), "called at run time with CDS enabled only"); RunTimeClassInfo* record = RunTimeClassInfo::get_for(lambda_ik); return record->nest_host(); } @@ -892,7 +892,7 @@ InstanceKlass* SystemDictionaryShared::prepare_shared_lambda_proxy_class(Instanc void SystemDictionaryShared::check_verification_constraints(InstanceKlass* klass, TRAPS) { - assert(!CDSConfig::is_dumping_static_archive() && UseSharedSpaces, "called at run time with CDS enabled only"); + assert(!CDSConfig::is_dumping_static_archive() && CDSConfig::is_using_archive(), "called at run time with CDS enabled only"); RunTimeClassInfo* record = RunTimeClassInfo::get_for(klass); int length = record->_num_verifier_constraints; @@ -1002,7 +1002,7 @@ void SystemDictionaryShared::record_linking_constraint(Symbol* name, InstanceKla // returns true IFF there's no need to re-initialize the i/v-tables for klass for // the purpose of checking class loader constraints. bool SystemDictionaryShared::check_linking_constraints(Thread* current, InstanceKlass* klass) { - assert(!CDSConfig::is_dumping_static_archive() && UseSharedSpaces, "called at run time with CDS enabled only"); + assert(!CDSConfig::is_dumping_static_archive() && CDSConfig::is_using_archive(), "called at run time with CDS enabled only"); LogTarget(Info, class, loader, constraints) log; if (klass->is_shared_boot_class()) { // No class loader constraint check performed for boot classes. @@ -1290,7 +1290,7 @@ void SystemDictionaryShared::serialize_vm_classes(SerializeClosure* soc) { const RunTimeClassInfo* SystemDictionaryShared::find_record(RunTimeSharedDictionary* static_dict, RunTimeSharedDictionary* dynamic_dict, Symbol* name) { - if (!UseSharedSpaces || !name->is_shared()) { + if (!CDSConfig::is_using_archive() || !name->is_shared()) { // The names of all shared classes must also be a shared Symbol. return nullptr; } @@ -1427,7 +1427,7 @@ void SystemDictionaryShared::ArchiveInfo::print_table_statistics(const char* pre } void SystemDictionaryShared::print_shared_archive(outputStream* st, bool is_static) { - if (UseSharedSpaces) { + if (CDSConfig::is_using_archive()) { if (is_static) { _static_archive.print_on("", st); } else { @@ -1444,7 +1444,7 @@ void SystemDictionaryShared::print_on(outputStream* st) { } void SystemDictionaryShared::print_table_statistics(outputStream* st) { - if (UseSharedSpaces) { + if (CDSConfig::is_using_archive()) { _static_archive.print_table_statistics("Static ", st); if (DynamicArchive::is_mapped()) { _dynamic_archive.print_table_statistics("Dynamic ", st); diff --git a/src/hotspot/share/classfile/vmClasses.cpp b/src/hotspot/share/classfile/vmClasses.cpp index 82c2ff8fa7b..0b9b437c67b 100644 --- a/src/hotspot/share/classfile/vmClasses.cpp +++ b/src/hotspot/share/classfile/vmClasses.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "cds/archiveHeapLoader.hpp" +#include "cds/cdsConfig.hpp" #include "classfile/classLoader.hpp" #include "classfile/classLoaderData.hpp" #include "classfile/dictionary.hpp" @@ -86,7 +87,7 @@ bool vmClasses::resolve(vmClassID id, TRAPS) { InstanceKlass** klassp = &_klasses[as_int(id)]; #if INCLUDE_CDS - if (UseSharedSpaces && !JvmtiExport::should_post_class_prepare()) { + if (CDSConfig::is_using_archive() && !JvmtiExport::should_post_class_prepare()) { InstanceKlass* k = *klassp; assert(k->is_shared_boot_class(), "must be"); @@ -128,7 +129,7 @@ void vmClasses::resolve_all(TRAPS) { resolve_through(VM_CLASS_ID(Object_klass), scan, CHECK); CollectedHeap::set_filler_object_klass(vmClasses::Object_klass()); #if INCLUDE_CDS - if (UseSharedSpaces) { + if (CDSConfig::is_using_archive()) { // It's unsafe to access the archived heap regions before they // are fixed up, so we must do the fixup as early as possible // before the archived java objects are accessed by functions @@ -167,7 +168,7 @@ void vmClasses::resolve_all(TRAPS) { Universe::initialize_basic_type_mirrors(CHECK); Universe::fixup_mirrors(CHECK); - if (UseSharedSpaces) { + if (CDSConfig::is_using_archive()) { // These should already have been initialized during CDS dump. assert(vmClasses::Reference_klass()->reference_type() == REF_NONE, "sanity"); assert(vmClasses::SoftReference_klass()->reference_type() == REF_SOFT, "sanity"); @@ -208,7 +209,7 @@ void vmClasses::resolve_all(TRAPS) { //_box_klasses[T_ARRAY] = vmClasses::object_klass(); #ifdef ASSERT - if (UseSharedSpaces) { + if (CDSConfig::is_using_archive()) { JVMTI_ONLY(assert(JvmtiExport::is_early_phase(), "All well known classes must be resolved in JVMTI early phase")); for (auto id : EnumRange{}) { diff --git a/src/hotspot/share/classfile/vmSymbols.cpp b/src/hotspot/share/classfile/vmSymbols.cpp index 172d074255b..5a531f7cbd9 100644 --- a/src/hotspot/share/classfile/vmSymbols.cpp +++ b/src/hotspot/share/classfile/vmSymbols.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ */ #include "precompiled.hpp" +#include "cds/cdsConfig.hpp" #include "cds/serializeClosure.hpp" #include "classfile/symbolTable.hpp" #include "classfile/vmSymbols.hpp" @@ -81,7 +82,7 @@ void vmSymbols::initialize() { assert(SID_LIMIT*5 > (1<{}) { Symbol* sym = SymbolTable::new_permanent_symbol(string); diff --git a/src/hotspot/share/interpreter/zero/bytecodeInterpreter.cpp b/src/hotspot/share/interpreter/zero/bytecodeInterpreter.cpp index abebfc998fd..36b01bb0802 100644 --- a/src/hotspot/share/interpreter/zero/bytecodeInterpreter.cpp +++ b/src/hotspot/share/interpreter/zero/bytecodeInterpreter.cpp @@ -2443,7 +2443,7 @@ run: CHECK_NULL(STACK_OBJECT(-(entry->number_of_parameters()))); if (entry->is_vfinal()) { callee = entry->method(); - if (REWRITE_BYTECODES && !UseSharedSpaces && !CDSConfig::is_dumping_archive()) { + if (REWRITE_BYTECODES && !CDSConfig::is_using_archive() && !CDSConfig::is_dumping_archive()) { // Rewrite to _fast_invokevfinal. REWRITE_AT_PC(Bytecodes::_fast_invokevfinal); } diff --git a/src/hotspot/share/memory/metaspace.cpp b/src/hotspot/share/memory/metaspace.cpp index 22ec4d942a6..7e01b42a873 100644 --- a/src/hotspot/share/memory/metaspace.cpp +++ b/src/hotspot/share/memory/metaspace.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, 2021 SAP SE. All rights reserved. - * Copyright (c) 2023, Red Hat, Inc. All rights reserved. + * Copyright (c) 2023, 2024, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -691,7 +691,7 @@ void Metaspace::global_initialize() { metaspace::ChunkHeaderPool::initialize(); if (CDSConfig::is_dumping_static_archive()) { - assert(!UseSharedSpaces, "sanity"); + assert(!CDSConfig::is_using_archive(), "sanity"); MetaspaceShared::initialize_for_static_dump(); } @@ -707,7 +707,7 @@ void Metaspace::global_initialize() { #if INCLUDE_CDS // case (a) - if (UseSharedSpaces) { + if (CDSConfig::is_using_archive()) { if (!FLAG_IS_DEFAULT(CompressedClassSpaceBaseAddress)) { log_warning(metaspace)("CDS active - ignoring CompressedClassSpaceBaseAddress."); } @@ -720,7 +720,7 @@ void Metaspace::global_initialize() { #ifdef _LP64 if (using_class_space() && !class_space_is_initialized()) { - assert(!UseSharedSpaces, "CDS archive is not mapped at this point"); + assert(!CDSConfig::is_using_archive(), "CDS archive is not mapped at this point"); // case (b) (No CDS) ReservedSpace rs; diff --git a/src/hotspot/share/memory/metaspace/metaspaceReporter.cpp b/src/hotspot/share/memory/metaspace/metaspaceReporter.cpp index a7674fb1b81..c154fd1db25 100644 --- a/src/hotspot/share/memory/metaspace/metaspaceReporter.cpp +++ b/src/hotspot/share/memory/metaspace/metaspaceReporter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2020 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -116,7 +116,7 @@ static void print_settings(outputStream* out, size_t scale) { out->print("Current GC threshold: "); print_human_readable_size(out, MetaspaceGC::capacity_until_GC(), scale); out->cr(); - out->print_cr("CDS: %s", (UseSharedSpaces ? "on" : (CDSConfig::is_dumping_static_archive() ? "dump" : "off"))); + out->print_cr("CDS: %s", (CDSConfig::is_using_archive() ? "on" : (CDSConfig::is_dumping_static_archive() ? "dump" : "off"))); Settings::print_on(out); } diff --git a/src/hotspot/share/memory/universe.cpp b/src/hotspot/share/memory/universe.cpp index 4a16b3d89a8..8f20f331235 100644 --- a/src/hotspot/share/memory/universe.cpp +++ b/src/hotspot/share/memory/universe.cpp @@ -361,7 +361,7 @@ void Universe::check_alignment(uintx size, uintx alignment, const char* name) { static void initialize_basic_type_klass(Klass* k, TRAPS) { Klass* ok = vmClasses::Object_klass(); #if INCLUDE_CDS - if (UseSharedSpaces) { + if (CDSConfig::is_using_archive()) { ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data(); assert(k->super() == ok, "u3"); if (k->is_instance_klass()) { @@ -394,7 +394,7 @@ void Universe::genesis(TRAPS) { // determine base vtable size; without that we cannot create the array klasses compute_base_vtable_size(); - if (!UseSharedSpaces) { + if (!CDSConfig::is_using_archive()) { // Initialization of the fillerArrayKlass must come before regular // int-TypeArrayKlass so that the int-Array mirror points to the // int-TypeArrayKlass. @@ -425,7 +425,7 @@ void Universe::genesis(TRAPS) { #if INCLUDE_CDS - if (UseSharedSpaces) { + if (CDSConfig::is_using_archive()) { // Verify shared interfaces array. assert(_the_array_interfaces_array->at(0) == vmClasses::Cloneable_klass(), "u3"); @@ -527,7 +527,7 @@ void Universe::genesis(TRAPS) { void Universe::initialize_basic_type_mirrors(TRAPS) { #if INCLUDE_CDS_JAVA_HEAP - if (UseSharedSpaces && + if (CDSConfig::is_using_archive() && ArchiveHeapLoader::is_in_use() && _basic_type_mirrors[T_INT].resolve() != nullptr) { assert(ArchiveHeapLoader::can_use(), "Sanity"); @@ -565,7 +565,7 @@ void Universe::fixup_mirrors(TRAPS) { assert(vmClasses::Class_klass_loaded(), "java.lang.Class should be loaded"); HandleMark hm(THREAD); - if (!UseSharedSpaces) { + if (!CDSConfig::is_using_archive()) { // Cache the start of the static fields InstanceMirrorKlass::init_offset_of_static_fields(); } @@ -877,7 +877,7 @@ jint universe_init() { #if INCLUDE_CDS DynamicArchive::check_for_dynamic_dump(); - if (UseSharedSpaces) { + if (CDSConfig::is_using_archive()) { // Read the data structures supporting the shared spaces (shared // system dictionary, symbol table, etc.) MetaspaceShared::initialize_shared_spaces(); @@ -1062,7 +1062,7 @@ bool universe_post_init() { assert(!is_init_completed(), "Error: initialization not yet completed!"); Universe::_fully_initialized = true; EXCEPTION_MARK; - if (!UseSharedSpaces) { + if (!CDSConfig::is_using_archive()) { reinitialize_vtables(); reinitialize_itables(); } diff --git a/src/hotspot/share/oops/arrayKlass.cpp b/src/hotspot/share/oops/arrayKlass.cpp index 5685bbb6bb5..275913e3f7f 100644 --- a/src/hotspot/share/oops/arrayKlass.cpp +++ b/src/hotspot/share/oops/arrayKlass.cpp @@ -43,7 +43,7 @@ #include "runtime/handles.inline.hpp" ArrayKlass::ArrayKlass() { - assert(CDSConfig::is_dumping_static_archive() || UseSharedSpaces, "only for CDS"); + assert(CDSConfig::is_dumping_static_archive() || CDSConfig::is_using_archive(), "only for CDS"); } int ArrayKlass::static_size(int header_size) { diff --git a/src/hotspot/share/oops/constantPool.cpp b/src/hotspot/share/oops/constantPool.cpp index b540ec6c160..85cc5a77f1e 100644 --- a/src/hotspot/share/oops/constantPool.cpp +++ b/src/hotspot/share/oops/constantPool.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -105,7 +105,7 @@ static bool tag_array_is_zero_initialized(Array* tags) { #endif ConstantPool::ConstantPool() { - assert(CDSConfig::is_dumping_static_archive() || UseSharedSpaces, "only for CDS"); + assert(CDSConfig::is_dumping_static_archive() || CDSConfig::is_using_archive(), "only for CDS"); } ConstantPool::ConstantPool(Array* tags) : diff --git a/src/hotspot/share/oops/instanceClassLoaderKlass.cpp b/src/hotspot/share/oops/instanceClassLoaderKlass.cpp index fc6981009b8..386f0b457ef 100644 --- a/src/hotspot/share/oops/instanceClassLoaderKlass.cpp +++ b/src/hotspot/share/oops/instanceClassLoaderKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,5 +27,5 @@ #include "oops/instanceClassLoaderKlass.hpp" InstanceClassLoaderKlass::InstanceClassLoaderKlass() { - assert(CDSConfig::is_dumping_static_archive() || UseSharedSpaces, "only for CDS"); + assert(CDSConfig::is_dumping_static_archive() || CDSConfig::is_using_archive(), "only for CDS"); } diff --git a/src/hotspot/share/oops/instanceKlass.cpp b/src/hotspot/share/oops/instanceKlass.cpp index dcc38360399..d66ce5ce247 100644 --- a/src/hotspot/share/oops/instanceKlass.cpp +++ b/src/hotspot/share/oops/instanceKlass.cpp @@ -502,7 +502,7 @@ static Monitor* create_init_monitor(const char* name) { } InstanceKlass::InstanceKlass() { - assert(CDSConfig::is_dumping_static_archive() || UseSharedSpaces, "only for CDS"); + assert(CDSConfig::is_dumping_static_archive() || CDSConfig::is_using_archive(), "only for CDS"); } InstanceKlass::InstanceKlass(const ClassFileParser& parser, KlassKind kind, ReferenceType reference_type) : @@ -4036,7 +4036,7 @@ void InstanceKlass::verify_on(outputStream* st) { Array* method_ordering = this->method_ordering(); int length = method_ordering->length(); if (JvmtiExport::can_maintain_original_method_order() || - ((UseSharedSpaces || CDSConfig::is_dumping_archive()) && length != 0)) { + ((CDSConfig::is_using_archive() || CDSConfig::is_dumping_archive()) && length != 0)) { guarantee(length == methods()->length(), "invalid method ordering length"); jlong sum = 0; for (int j = 0; j < length; j++) { diff --git a/src/hotspot/share/oops/instanceMirrorKlass.cpp b/src/hotspot/share/oops/instanceMirrorKlass.cpp index 993e693ddb3..a90c9284b1a 100644 --- a/src/hotspot/share/oops/instanceMirrorKlass.cpp +++ b/src/hotspot/share/oops/instanceMirrorKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ int InstanceMirrorKlass::_offset_of_static_fields = 0; InstanceMirrorKlass::InstanceMirrorKlass() { - assert(CDSConfig::is_dumping_static_archive() || UseSharedSpaces, "only for CDS"); + assert(CDSConfig::is_dumping_static_archive() || CDSConfig::is_using_archive(), "only for CDS"); } size_t InstanceMirrorKlass::instance_size(Klass* k) { diff --git a/src/hotspot/share/oops/instanceRefKlass.cpp b/src/hotspot/share/oops/instanceRefKlass.cpp index b549f00b82f..1fea112dc87 100644 --- a/src/hotspot/share/oops/instanceRefKlass.cpp +++ b/src/hotspot/share/oops/instanceRefKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ #include "oops/oop.inline.hpp" InstanceRefKlass::InstanceRefKlass() { - assert(CDSConfig::is_dumping_static_archive() || UseSharedSpaces, "only for CDS"); + assert(CDSConfig::is_dumping_static_archive() || CDSConfig::is_using_archive(), "only for CDS"); } static ReferenceType reference_subclass_name_to_type(const Symbol* name) { @@ -99,7 +99,7 @@ void InstanceRefKlass::update_nonstatic_oop_maps(Klass* k) { const unsigned int new_count = 2; // queue and next // Verify existing map is as expected, and update if needed. - if (UseSharedSpaces) { + if (CDSConfig::is_using_archive()) { assert(map->offset() == new_offset, "just checking"); assert(map->count() == new_count, "just checking"); } else { diff --git a/src/hotspot/share/oops/instanceStackChunkKlass.cpp b/src/hotspot/share/oops/instanceStackChunkKlass.cpp index 8171188d357..bf215e1c13e 100644 --- a/src/hotspot/share/oops/instanceStackChunkKlass.cpp +++ b/src/hotspot/share/oops/instanceStackChunkKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,7 +53,7 @@ void InstanceStackChunkKlass::serialize_offsets(SerializeClosure* f) { #endif InstanceStackChunkKlass::InstanceStackChunkKlass() { - assert(CDSConfig::is_dumping_static_archive() || UseSharedSpaces, "only for CDS"); + assert(CDSConfig::is_dumping_static_archive() || CDSConfig::is_using_archive(), "only for CDS"); } InstanceStackChunkKlass::InstanceStackChunkKlass(const ClassFileParser& parser) diff --git a/src/hotspot/share/oops/klass.cpp b/src/hotspot/share/oops/klass.cpp index ea3b5e756d0..1fed317a860 100644 --- a/src/hotspot/share/oops/klass.cpp +++ b/src/hotspot/share/oops/klass.cpp @@ -252,7 +252,7 @@ void* Klass::operator new(size_t size, ClassLoaderData* loader_data, size_t word } Klass::Klass() : _kind(UnknownKlassKind) { - assert(CDSConfig::is_dumping_static_archive() || UseSharedSpaces, "only for cds"); + assert(CDSConfig::is_dumping_static_archive() || CDSConfig::is_using_archive(), "only for cds"); } // "Normal" instantiation is preceded by a MetaspaceObj allocation diff --git a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp index 4e0a429ffb2..84010493dbc 100644 --- a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp +++ b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp @@ -23,6 +23,7 @@ */ #include "precompiled.hpp" +#include "cds/cdsConfig.hpp" #include "cds/metaspaceShared.hpp" #include "classfile/classFileStream.hpp" #include "classfile/classLoaderDataGraph.hpp" @@ -245,7 +246,7 @@ void VM_RedefineClasses::doit() { } #if INCLUDE_CDS - if (UseSharedSpaces) { + if (CDSConfig::is_using_archive()) { // Sharing is enabled so we remap the shared readonly space to // shared readwrite, private just in case we need to redefine // a shared class. We do the remap during the doit() phase of diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp index 9a4c0756889..a45be186aa4 100644 --- a/src/hotspot/share/prims/whitebox.cpp +++ b/src/hotspot/share/prims/whitebox.cpp @@ -2059,7 +2059,7 @@ WB_ENTRY(jobject, WB_GetDefaultArchivePath(JNIEnv* env, jobject wb)) WB_END WB_ENTRY(jboolean, WB_IsSharingEnabled(JNIEnv* env, jobject wb)) - return UseSharedSpaces; + return CDSConfig::is_using_archive(); WB_END WB_ENTRY(jint, WB_GetCDSGenericHeaderMinVersion(JNIEnv* env, jobject wb)) diff --git a/src/hotspot/share/runtime/abstract_vm_version.cpp b/src/hotspot/share/runtime/abstract_vm_version.cpp index 69a96747aa3..96da109dafe 100644 --- a/src/hotspot/share/runtime/abstract_vm_version.cpp +++ b/src/hotspot/share/runtime/abstract_vm_version.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ */ #include "precompiled.hpp" +#include "cds/cdsConfig.hpp" #include "compiler/compilerDefinitions.hpp" #include "jvm_io.h" #include "runtime/arguments.hpp" @@ -136,9 +137,9 @@ const char* Abstract_VM_Version::vm_vendor() { const char* Abstract_VM_Version::vm_info_string() { switch (Arguments::mode()) { case Arguments::_int: - return UseSharedSpaces ? "interpreted mode, sharing" : "interpreted mode"; + return CDSConfig::is_using_archive() ? "interpreted mode, sharing" : "interpreted mode"; case Arguments::_mixed: - if (UseSharedSpaces) { + if (CDSConfig::is_using_archive()) { if (CompilationModeFlag::quick_only()) { return "mixed mode, emulated-client, sharing"; } else { @@ -153,9 +154,9 @@ const char* Abstract_VM_Version::vm_info_string() { } case Arguments::_comp: if (CompilationModeFlag::quick_only()) { - return UseSharedSpaces ? "compiled mode, emulated-client, sharing" : "compiled mode, emulated-client"; + return CDSConfig::is_using_archive() ? "compiled mode, emulated-client, sharing" : "compiled mode, emulated-client"; } - return UseSharedSpaces ? "compiled mode, sharing" : "compiled mode"; + return CDSConfig::is_using_archive() ? "compiled mode, sharing" : "compiled mode"; } ShouldNotReachHere(); return ""; diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index 7befe9cd734..6c98f379db0 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -3618,7 +3618,7 @@ jint Arguments::parse(const JavaVMInitArgs* initial_cmd_args) { "DumpLoadedClassList is not supported in this VM\n"); return JNI_ERR; } - if ((UseSharedSpaces && xshare_auto_cmd_line) || + if ((CDSConfig::is_using_archive() && xshare_auto_cmd_line) || log_is_enabled(Info, cds)) { warning("Shared spaces are not supported in this VM"); UseSharedSpaces = false; diff --git a/src/hotspot/share/services/diagnosticCommand.cpp b/src/hotspot/share/services/diagnosticCommand.cpp index 6e6a7172290..b440a6cbb5e 100644 --- a/src/hotspot/share/services/diagnosticCommand.cpp +++ b/src/hotspot/share/services/diagnosticCommand.cpp @@ -23,6 +23,7 @@ */ #include "precompiled.hpp" +#include "cds/cdsConfig.hpp" #include "cds/cds_globals.hpp" #include "classfile/classLoaderDataGraph.hpp" #include "classfile/classLoaderHierarchyDCmd.hpp" @@ -1023,7 +1024,7 @@ void DumpSharedArchiveDCmd::execute(DCmdSource source, TRAPS) { } else if (strcmp(scmd, "dynamic_dump") == 0) { is_static = JNI_FALSE; output()->print("Dynamic dump: "); - if (!UseSharedSpaces) { + if (!CDSConfig::is_using_archive()) { output()->print_cr("Dynamic dump is unsupported when base CDS archive is not loaded"); return; }