8320147: Remove DumpSharedSpaces

Reviewed-by: ccheung, matsaave
This commit is contained in:
Ioi Lam 2023-11-20 17:09:55 +00:00
parent 6e86904a94
commit 0712b22a3a
50 changed files with 166 additions and 101 deletions

View file

@ -25,6 +25,7 @@
#include "precompiled.hpp" #include "precompiled.hpp"
#include "asm/macroAssembler.inline.hpp" #include "asm/macroAssembler.inline.hpp"
#include "cds/cdsConfig.hpp"
#include "compiler/disassembler.hpp" #include "compiler/disassembler.hpp"
#include "gc/shared/barrierSetAssembler.hpp" #include "gc/shared/barrierSetAssembler.hpp"
#include "gc/shared/tlab_globals.hpp" #include "gc/shared/tlab_globals.hpp"
@ -3483,7 +3484,7 @@ void TemplateTable::invokevirtual(int byte_no) {
__ testbitdi(CCR0, R0, Rflags, ResolvedMethodEntry::is_vfinal_shift); __ testbitdi(CCR0, R0, Rflags, ResolvedMethodEntry::is_vfinal_shift);
__ bfalse(CCR0, LnotFinal); __ bfalse(CCR0, LnotFinal);
if (RewriteBytecodes && !UseSharedSpaces && !DumpSharedSpaces) { if (RewriteBytecodes && !UseSharedSpaces && !CDSConfig::is_dumping_static_archive()) {
patch_bytecode(Bytecodes::_fast_invokevfinal, Rnew_bc, R12_scratch2); patch_bytecode(Bytecodes::_fast_invokevfinal, Rnew_bc, R12_scratch2);
} }
invokevfinal_helper(Rcache, R11_scratch1, R12_scratch2, Rflags /* tmp */); invokevfinal_helper(Rcache, R11_scratch1, R12_scratch2, Rflags /* tmp */);

View file

@ -239,7 +239,7 @@ void ArchiveBuilder::gather_klasses_and_symbols() {
#endif #endif
doit.finish(); doit.finish();
if (DumpSharedSpaces) { if (CDSConfig::is_dumping_static_archive()) {
// To ensure deterministic contents in the static archive, we need to ensure that // To ensure deterministic contents in the static archive, we need to ensure that
// we iterate the MetaspaceObjs in a deterministic order. It doesn't matter where // we iterate the MetaspaceObjs in a deterministic order. It doesn't matter where
// the MetaspaceObjs are located originally, as they are copied sequentially into // the MetaspaceObjs are located originally, as they are copied sequentially into
@ -339,7 +339,7 @@ address ArchiveBuilder::reserve_buffer() {
// The bottom of the archive (that I am writing now) should be mapped at this address by default. // The bottom of the archive (that I am writing now) should be mapped at this address by default.
address my_archive_requested_bottom; address my_archive_requested_bottom;
if (DumpSharedSpaces) { if (CDSConfig::is_dumping_static_archive()) {
my_archive_requested_bottom = _requested_static_archive_bottom; my_archive_requested_bottom = _requested_static_archive_bottom;
} else { } else {
_mapped_static_archive_bottom = (address)MetaspaceObj::shared_metaspace_base(); _mapped_static_archive_bottom = (address)MetaspaceObj::shared_metaspace_base();
@ -367,7 +367,7 @@ address ArchiveBuilder::reserve_buffer() {
MetaspaceShared::unrecoverable_writing_error(); MetaspaceShared::unrecoverable_writing_error();
} }
if (DumpSharedSpaces) { if (CDSConfig::is_dumping_static_archive()) {
// We don't want any valid object to be at the very bottom of the archive. // We don't want any valid object to be at the very bottom of the archive.
// See ArchivePtrMarker::mark_pointer(). // See ArchivePtrMarker::mark_pointer().
rw_region()->allocate(16); rw_region()->allocate(16);
@ -642,7 +642,7 @@ void ArchiveBuilder::make_shallow_copy(DumpRegion *dump_region, SourceObjInfo* s
memcpy(dest, src, bytes); memcpy(dest, src, bytes);
// Update the hash of buffered sorted symbols for static dump so that the symbols have deterministic contents // Update the hash of buffered sorted symbols for static dump so that the symbols have deterministic contents
if (DumpSharedSpaces && (src_info->msotype() == MetaspaceObj::SymbolType)) { if (CDSConfig::is_dumping_static_archive() && (src_info->msotype() == MetaspaceObj::SymbolType)) {
Symbol* buffered_symbol = (Symbol*)dest; Symbol* buffered_symbol = (Symbol*)dest;
assert(((Symbol*)src)->is_permanent(), "archived symbols must be permanent"); assert(((Symbol*)src)->is_permanent(), "archived symbols must be permanent");
buffered_symbol->update_identity_hash(); buffered_symbol->update_identity_hash();
@ -825,7 +825,7 @@ uintx ArchiveBuilder::any_to_offset(address p) const {
#if INCLUDE_CDS_JAVA_HEAP #if INCLUDE_CDS_JAVA_HEAP
narrowKlass ArchiveBuilder::get_requested_narrow_klass(Klass* k) { narrowKlass ArchiveBuilder::get_requested_narrow_klass(Klass* k) {
assert(DumpSharedSpaces, "sanity"); assert(CDSConfig::is_dumping_heap(), "sanity");
k = get_buffered_klass(k); k = get_buffered_klass(k);
Klass* requested_k = to_requested(k); Klass* requested_k = to_requested(k);
address narrow_klass_base = _requested_static_archive_bottom; // runtime encoding base == runtime mapping start address narrow_klass_base = _requested_static_archive_bottom; // runtime encoding base == runtime mapping start
@ -916,7 +916,7 @@ void ArchiveBuilder::relocate_to_requested() {
size_t my_archive_size = buffer_top() - buffer_bottom(); size_t my_archive_size = buffer_top() - buffer_bottom();
if (DumpSharedSpaces) { if (CDSConfig::is_dumping_static_archive()) {
_requested_static_archive_top = _requested_static_archive_bottom + my_archive_size; _requested_static_archive_top = _requested_static_archive_bottom + my_archive_size;
RelocateBufferToRequested<true> patcher(this); RelocateBufferToRequested<true> patcher(this);
patcher.doit(); patcher.doit();
@ -1238,7 +1238,7 @@ public:
static void log(ArchiveBuilder* builder, FileMapInfo* mapinfo, static void log(ArchiveBuilder* builder, FileMapInfo* mapinfo,
ArchiveHeapInfo* heap_info, ArchiveHeapInfo* heap_info,
char* bitmap, size_t bitmap_size_in_bytes) { char* bitmap, size_t bitmap_size_in_bytes) {
log_info(cds, map)("%s CDS archive map for %s", DumpSharedSpaces ? "Static" : "Dynamic", mapinfo->full_path()); log_info(cds, map)("%s CDS archive map for %s", CDSConfig::is_dumping_static_archive() ? "Static" : "Dynamic", mapinfo->full_path());
address header = address(mapinfo->header()); address header = address(mapinfo->header());
address header_end = header + mapinfo->header()->header_size(); address header_end = header + mapinfo->header()->header_size();

View file

@ -29,6 +29,7 @@
#include "classfile/classLoaderDataShared.hpp" #include "classfile/classLoaderDataShared.hpp"
#include "logging/log.hpp" #include "logging/log.hpp"
bool CDSConfig::_is_dumping_static_archive = false;
bool CDSConfig::_is_dumping_dynamic_archive = false; bool CDSConfig::_is_dumping_dynamic_archive = false;
// The ability to dump the FMG depends on many factors checked by // The ability to dump the FMG depends on many factors checked by
@ -37,10 +38,6 @@ bool CDSConfig::_is_dumping_dynamic_archive = false;
bool CDSConfig::_dumping_full_module_graph_disabled = false; bool CDSConfig::_dumping_full_module_graph_disabled = false;
bool CDSConfig::_loading_full_module_graph_disabled = false; bool CDSConfig::_loading_full_module_graph_disabled = false;
bool CDSConfig::is_dumping_static_archive() {
return DumpSharedSpaces;
}
#if INCLUDE_CDS_JAVA_HEAP #if INCLUDE_CDS_JAVA_HEAP
bool CDSConfig::is_dumping_heap() { bool CDSConfig::is_dumping_heap() {
// heap dump is not supported in dynamic dump // heap dump is not supported in dynamic dump

View file

@ -30,6 +30,7 @@
class CDSConfig : public AllStatic { class CDSConfig : public AllStatic {
#if INCLUDE_CDS #if INCLUDE_CDS
static bool _is_dumping_static_archive;
static bool _is_dumping_dynamic_archive; static bool _is_dumping_dynamic_archive;
static bool _dumping_full_module_graph_disabled; static bool _dumping_full_module_graph_disabled;
static bool _loading_full_module_graph_disabled; static bool _loading_full_module_graph_disabled;
@ -38,7 +39,8 @@ class CDSConfig : public AllStatic {
public: public:
// Basic CDS features // Basic CDS features
static bool is_dumping_archive() { return is_dumping_static_archive() || is_dumping_dynamic_archive(); } static bool is_dumping_archive() { return is_dumping_static_archive() || is_dumping_dynamic_archive(); }
static bool is_dumping_static_archive() NOT_CDS_RETURN_(false); static bool is_dumping_static_archive() { return CDS_ONLY(_is_dumping_static_archive) NOT_CDS(false); }
static void enable_dumping_static_archive() { CDS_ONLY(_is_dumping_static_archive = true); }
static bool is_dumping_dynamic_archive() { return CDS_ONLY(_is_dumping_dynamic_archive) NOT_CDS(false); } static bool is_dumping_dynamic_archive() { return CDS_ONLY(_is_dumping_dynamic_archive) NOT_CDS(false); }
static void enable_dumping_dynamic_archive() { CDS_ONLY(_is_dumping_dynamic_archive = true); } static void enable_dumping_dynamic_archive() { CDS_ONLY(_is_dumping_dynamic_archive = true); }
static void disable_dumping_dynamic_archive() { CDS_ONLY(_is_dumping_dynamic_archive = false); } static void disable_dumping_dynamic_archive() { CDS_ONLY(_is_dumping_dynamic_archive = false); }

View file

@ -24,6 +24,7 @@
#include "precompiled.hpp" #include "precompiled.hpp"
#include "cds/archiveBuilder.hpp" #include "cds/archiveBuilder.hpp"
#include "cds/cdsConfig.hpp"
#include "cds/classPrelinker.hpp" #include "cds/classPrelinker.hpp"
#include "classfile/systemDictionary.hpp" #include "classfile/systemDictionary.hpp"
#include "classfile/vmClasses.hpp" #include "classfile/vmClasses.hpp"
@ -182,13 +183,10 @@ Klass* ClassPrelinker::maybe_resolve_class(constantPoolHandle cp, int cp_index,
#if INCLUDE_CDS_JAVA_HEAP #if INCLUDE_CDS_JAVA_HEAP
void ClassPrelinker::resolve_string(constantPoolHandle cp, int cp_index, TRAPS) { void ClassPrelinker::resolve_string(constantPoolHandle cp, int cp_index, TRAPS) {
if (!DumpSharedSpaces) { if (CDSConfig::is_dumping_heap()) {
// The archive heap is not supported for the dynamic archive. int cache_index = cp->cp_to_object_index(cp_index);
return; ConstantPool::string_at_impl(cp, cp_index, cache_index, CHECK);
} }
int cache_index = cp->cp_to_object_index(cp_index);
ConstantPool::string_at_impl(cp, cp_index, cache_index, CHECK);
} }
#endif #endif

View file

@ -216,7 +216,7 @@ void CppVtableCloner<T>::init_orig_cpp_vtptr(int kind) {
CppVtableInfo** CppVtables::_index = nullptr; CppVtableInfo** CppVtables::_index = nullptr;
char* CppVtables::dumptime_init(ArchiveBuilder* builder) { char* CppVtables::dumptime_init(ArchiveBuilder* builder) {
assert(DumpSharedSpaces, "must"); assert(CDSConfig::is_dumping_static_archive(), "cpp tables are only dumped into static archive");
size_t vtptrs_bytes = _num_cloned_vtable_kinds * sizeof(CppVtableInfo*); size_t vtptrs_bytes = _num_cloned_vtable_kinds * sizeof(CppVtableInfo*);
_index = (CppVtableInfo**)builder->rw_region()->allocate(vtptrs_bytes); _index = (CppVtableInfo**)builder->rw_region()->allocate(vtptrs_bytes);
@ -284,7 +284,7 @@ intptr_t* CppVtables::get_archived_vtable(MetaspaceObj::Type msotype, address ob
} }
void CppVtables::zero_archived_vtables() { void CppVtables::zero_archived_vtables() {
assert(DumpSharedSpaces, "dump-time only"); assert(CDSConfig::is_dumping_static_archive(), "cpp tables are only dumped into static archive");
for (int kind = 0; kind < _num_cloned_vtable_kinds; kind ++) { for (int kind = 0; kind < _num_cloned_vtable_kinds; kind ++) {
_index[kind]->zero(); _index[kind]->zero();
} }

View file

@ -24,8 +24,10 @@
#ifndef SHARE_CDS_DUMPTIMECLASSINFO_HPP #ifndef SHARE_CDS_DUMPTIMECLASSINFO_HPP
#define SHARE_CDS_DUMPTIMECLASSINFO_HPP #define SHARE_CDS_DUMPTIMECLASSINFO_HPP
#include "cds/archiveBuilder.hpp" #include "cds/archiveBuilder.hpp"
#include "cds/archiveUtils.hpp" #include "cds/archiveUtils.hpp"
#include "cds/cdsConfig.hpp"
#include "cds/metaspaceShared.hpp" #include "cds/metaspaceShared.hpp"
#include "classfile/compactHashtable.hpp" #include "classfile/compactHashtable.hpp"
#include "memory/metaspaceClosure.hpp" #include "memory/metaspaceClosure.hpp"
@ -217,7 +219,7 @@ public:
template <typename T> template <typename T>
inline unsigned DumpTimeSharedClassTable_hash(T* const& k) { inline unsigned DumpTimeSharedClassTable_hash(T* const& k) {
if (DumpSharedSpaces) { if (CDSConfig::is_dumping_static_archive()) {
// Deterministic archive contents // Deterministic archive contents
uintx delta = k->name() - MetaspaceShared::symbol_rs_base(); uintx delta = k->name() - MetaspaceShared::symbol_rs_base();
return primitive_hash<uintx>(delta); return primitive_hash<uintx>(delta);

View file

@ -127,7 +127,7 @@ void LambdaFormInvokers::regenerate_holder_classes(TRAPS) {
if (!PENDING_EXCEPTION->is_a(vmClasses::OutOfMemoryError_klass())) { if (!PENDING_EXCEPTION->is_a(vmClasses::OutOfMemoryError_klass())) {
log_error(cds)("%s: %s", PENDING_EXCEPTION->klass()->external_name(), log_error(cds)("%s: %s", PENDING_EXCEPTION->klass()->external_name(),
java_lang_String::as_utf8_string(java_lang_Throwable::message(PENDING_EXCEPTION))); java_lang_String::as_utf8_string(java_lang_Throwable::message(PENDING_EXCEPTION)));
if (DumpSharedSpaces) { if (CDSConfig::is_dumping_static_archive()) {
log_error(cds)("Failed to generate LambdaForm holder classes. Is your classlist out of date?"); log_error(cds)("Failed to generate LambdaForm holder classes. Is your classlist out of date?");
} else { } else {
log_error(cds)("Failed to generate LambdaForm holder classes. Was the base archive generated with an outdated classlist?"); log_error(cds)("Failed to generate LambdaForm holder classes. Was the base archive generated with an outdated classlist?");

View file

@ -244,7 +244,7 @@ static char* compute_shared_base(size_t cds_max) {
} }
void MetaspaceShared::initialize_for_static_dump() { void MetaspaceShared::initialize_for_static_dump() {
assert(DumpSharedSpaces, "should be called for dump time only"); assert(CDSConfig::is_dumping_static_archive(), "sanity");
log_info(cds)("Core region alignment: " SIZE_FORMAT, core_region_alignment()); log_info(cds)("Core region alignment: " SIZE_FORMAT, core_region_alignment());
// The max allowed size for CDS archive. We use this to limit SharedBaseAddress // The max allowed size for CDS archive. We use this to limit SharedBaseAddress
// to avoid address space wrap around. // to avoid address space wrap around.

View file

@ -44,7 +44,7 @@
// a JAR file. // a JAR file.
InstanceKlass* UnregisteredClasses::load_class(Symbol* name, const char* path, TRAPS) { InstanceKlass* UnregisteredClasses::load_class(Symbol* name, const char* path, TRAPS) {
assert(name != nullptr, "invariant"); assert(name != nullptr, "invariant");
assert(DumpSharedSpaces, "this function is only used with -Xshare:dump"); assert(CDSConfig::is_dumping_static_archive(), "this function is only used with -Xshare:dump");
PerfClassTraceTime vmtimer(ClassLoader::perf_app_classload_time(), PerfClassTraceTime vmtimer(ClassLoader::perf_app_classload_time(),
THREAD->get_thread_stat()->perf_timers_addr(), THREAD->get_thread_stat()->perf_timers_addr(),

View file

@ -5519,7 +5519,7 @@ ClassFileParser::ClassFileParser(ClassFileStream* stream,
assert(0 == _access_flags.as_int(), "invariant"); assert(0 == _access_flags.as_int(), "invariant");
// Figure out whether we can skip format checking (matching classic VM behavior) // Figure out whether we can skip format checking (matching classic VM behavior)
if (DumpSharedSpaces) { if (CDSConfig::is_dumping_static_archive()) {
// verify == true means it's a 'remote' class (i.e., non-boot class) // verify == true means it's a 'remote' class (i.e., non-boot class)
// Verification decision is based on BytecodeVerificationRemote flag // Verification decision is based on BytecodeVerificationRemote flag
// for those classes. // for those classes.
@ -5850,7 +5850,7 @@ void ClassFileParser::mangle_hidden_class_name(InstanceKlass* const ik) {
// use an illegal char such as ';' because that causes serialization issues // use an illegal char such as ';' because that causes serialization issues
// and issues with hidden classes that create their own hidden classes. // and issues with hidden classes that create their own hidden classes.
char addr_buf[20]; char addr_buf[20];
if (DumpSharedSpaces) { if (CDSConfig::is_dumping_static_archive()) {
// We want stable names for the archived hidden classes (only for static // We want stable names for the archived hidden classes (only for static
// archive for now). Spaces under default_SharedBaseAddress() will be // archive for now). Spaces under default_SharedBaseAddress() will be
// occupied by the archive at run time, so we know that no dynamically // occupied by the archive at run time, so we know that no dynamically

View file

@ -1129,7 +1129,7 @@ InstanceKlass* ClassLoader::load_class(Symbol* name, bool search_append_only, TR
// Dynamic dumping requires UseSharedSpaces to be enabled. Since --patch-module // Dynamic dumping requires UseSharedSpaces to be enabled. Since --patch-module
// is not supported with UseSharedSpaces, we can never come here during dynamic dumping. // is not supported with UseSharedSpaces, we can never come here during dynamic dumping.
assert(!CDSConfig::is_dumping_dynamic_archive(), "sanity"); assert(!CDSConfig::is_dumping_dynamic_archive(), "sanity");
if (!DumpSharedSpaces) { if (!CDSConfig::is_dumping_static_archive()) {
stream = search_module_entries(THREAD, _patch_mod_entries, class_name, file_name); stream = search_module_entries(THREAD, _patch_mod_entries, class_name, file_name);
} }
} }
@ -1490,8 +1490,7 @@ void ClassLoader::classLoader_init2(JavaThread* current) {
// As more modules are defined during module system initialization, more // As more modules are defined during module system initialization, more
// entries will be added to the exploded build array. // entries will be added to the exploded build array.
if (!has_jrt_entry()) { if (!has_jrt_entry()) {
assert(!DumpSharedSpaces, "DumpSharedSpaces not supported with exploded module builds"); assert(!CDSConfig::is_dumping_archive(), "not supported with exploded module builds");
assert(!CDSConfig::is_dumping_dynamic_archive(), "not supported with exploded module builds");
assert(!UseSharedSpaces, "UsedSharedSpaces not supported with exploded module builds"); assert(!UseSharedSpaces, "UsedSharedSpaces not supported with exploded module builds");
// Set up the boot loader's _exploded_entries list. Note that this gets // Set up the boot loader's _exploded_entries list. Note that this gets
// done before loading any classes, by the same thread that will // done before loading any classes, by the same thread that will

View file

@ -71,7 +71,7 @@ static ArchivedClassLoaderData _archived_system_loader_data;
static ModuleEntry* _archived_javabase_moduleEntry = nullptr; static ModuleEntry* _archived_javabase_moduleEntry = nullptr;
void ArchivedClassLoaderData::iterate_symbols(ClassLoaderData* loader_data, MetaspaceClosure* closure) { void ArchivedClassLoaderData::iterate_symbols(ClassLoaderData* loader_data, MetaspaceClosure* closure) {
assert(DumpSharedSpaces, "must be"); assert(CDSConfig::is_dumping_full_module_graph(), "must be");
assert_valid(loader_data); assert_valid(loader_data);
if (loader_data != nullptr) { if (loader_data != nullptr) {
loader_data->packages()->iterate_symbols(closure); loader_data->packages()->iterate_symbols(closure);
@ -80,7 +80,7 @@ void ArchivedClassLoaderData::iterate_symbols(ClassLoaderData* loader_data, Meta
} }
void ArchivedClassLoaderData::allocate(ClassLoaderData* loader_data) { void ArchivedClassLoaderData::allocate(ClassLoaderData* loader_data) {
assert(DumpSharedSpaces, "must be"); assert(CDSConfig::is_dumping_full_module_graph(), "must be");
assert_valid(loader_data); assert_valid(loader_data);
if (loader_data != nullptr) { if (loader_data != nullptr) {
// We can't create hashtables at dump time because the hashcode depends on the // We can't create hashtables at dump time because the hashcode depends on the
@ -93,7 +93,7 @@ void ArchivedClassLoaderData::allocate(ClassLoaderData* loader_data) {
} }
void ArchivedClassLoaderData::init_archived_entries(ClassLoaderData* loader_data) { void ArchivedClassLoaderData::init_archived_entries(ClassLoaderData* loader_data) {
assert(DumpSharedSpaces, "must be"); assert(CDSConfig::is_dumping_full_module_graph(), "must be");
assert_valid(loader_data); assert_valid(loader_data);
if (loader_data != nullptr) { if (loader_data != nullptr) {
loader_data->packages()->init_archived_entries(_packages); loader_data->packages()->init_archived_entries(_packages);

View file

@ -276,11 +276,11 @@ void ClassLoaderExt::record_result(const s2 classpath_index, InstanceKlass* resu
result->set_shared_classpath_index(classpath_index); result->set_shared_classpath_index(classpath_index);
result->set_shared_class_loader_type(classloader_type); result->set_shared_class_loader_type(classloader_type);
#if INCLUDE_CDS_JAVA_HEAP #if INCLUDE_CDS_JAVA_HEAP
if (DumpSharedSpaces && AllowArchivingWithJavaAgent && classloader_type == ClassLoader::BOOT_LOADER && if (CDSConfig::is_dumping_heap() && AllowArchivingWithJavaAgent && classloader_type == ClassLoader::BOOT_LOADER &&
classpath_index < 0 && HeapShared::can_write() && redefined) { classpath_index < 0 && redefined) {
// During static dump, classes for the built-in loaders are always loaded from // When dumping the heap (which happens only during static dump), classes for the built-in
// known locations (jimage, classpath or modulepath), so classpath_index should // loaders are always loaded from known locations (jimage, classpath or modulepath),
// always be >= 0. // so classpath_index should always be >= 0.
// The only exception is when a java agent is used during dump time (for testing // The only exception is when a java agent is used during dump time (for testing
// purposes only). If a class is transformed by the agent, the CodeSource of // purposes only). If a class is transformed by the agent, the CodeSource of
// this class may point to an unknown location. This may break heap object archiving, // this class may point to an unknown location. This may break heap object archiving,

View file

@ -802,9 +802,7 @@ GrowableArray<Klass*>* java_lang_Class::_fixup_module_field_list = nullptr;
inline static void assert_valid_static_string_field(fieldDescriptor* fd) { inline static void assert_valid_static_string_field(fieldDescriptor* fd) {
assert(fd->has_initial_value(), "caller should have checked this"); assert(fd->has_initial_value(), "caller should have checked this");
assert(fd->field_type() == T_OBJECT, "caller should have checked this"); assert(fd->field_type() == T_OBJECT, "caller should have checked this");
// Can't use vmSymbols::string_signature() as fd->signature() may have been relocated assert(fd->signature() == vmSymbols::string_signature(), "just checking");
// during DumpSharedSpaces
assert(fd->signature()->equals("Ljava/lang/String;"), "just checking");
} }
#endif #endif

View file

@ -25,6 +25,7 @@
#include "precompiled.hpp" #include "precompiled.hpp"
#include "cds/archiveBuilder.hpp" #include "cds/archiveBuilder.hpp"
#include "cds/archiveUtils.hpp" #include "cds/archiveUtils.hpp"
#include "cds/cdsConfig.hpp"
#include "cds/filemap.hpp" #include "cds/filemap.hpp"
#include "cds/heapShared.hpp" #include "cds/heapShared.hpp"
#include "classfile/classLoader.hpp" #include "classfile/classLoader.hpp"
@ -488,7 +489,7 @@ void ModuleEntry::init_as_archived_entry() {
} }
void ModuleEntry::update_oops_in_archived_module(int root_oop_index) { void ModuleEntry::update_oops_in_archived_module(int root_oop_index) {
assert(DumpSharedSpaces, "static dump only"); assert(CDSConfig::is_dumping_full_module_graph(), "sanity");
assert(_archived_module_index == -1, "must be set exactly once"); assert(_archived_module_index == -1, "must be set exactly once");
assert(root_oop_index >= 0, "sanity"); assert(root_oop_index >= 0, "sanity");
@ -576,7 +577,7 @@ Array<ModuleEntry*>* ModuleEntryTable::allocate_archived_entries() {
} }
void ModuleEntryTable::init_archived_entries(Array<ModuleEntry*>* archived_modules) { void ModuleEntryTable::init_archived_entries(Array<ModuleEntry*>* archived_modules) {
assert(DumpSharedSpaces, "dump time only"); assert(CDSConfig::is_dumping_full_module_graph(), "sanity");
for (int i = 0; i < archived_modules->length(); i++) { for (int i = 0; i < archived_modules->length(); i++) {
ModuleEntry* archived_entry = archived_modules->at(i); ModuleEntry* archived_entry = archived_modules->at(i);
archived_entry->init_as_archived_entry(); archived_entry->init_as_archived_entry();

View file

@ -486,7 +486,6 @@ static bool _seen_system_unnamed_module = false;
// //
// Returns true iff the oop has an archived ModuleEntry. // Returns true iff the oop has an archived ModuleEntry.
bool Modules::check_archived_module_oop(oop orig_module_obj) { bool Modules::check_archived_module_oop(oop orig_module_obj) {
assert(DumpSharedSpaces, "must be");
assert(CDSConfig::is_dumping_full_module_graph(), "must be"); assert(CDSConfig::is_dumping_full_module_graph(), "must be");
assert(java_lang_Module::is_instance(orig_module_obj), "must be"); assert(java_lang_Module::is_instance(orig_module_obj), "must be");
@ -641,7 +640,7 @@ void Modules::define_archived_modules(Handle h_platform_loader, Handle h_system_
} }
void Modules::check_cds_restrictions(TRAPS) { void Modules::check_cds_restrictions(TRAPS) {
if (DumpSharedSpaces && Universe::is_module_initialized() && CDSConfig::is_dumping_full_module_graph()) { if (CDSConfig::is_dumping_full_module_graph() && Universe::is_module_initialized()) {
THROW_MSG(vmSymbols::java_lang_UnsupportedOperationException(), THROW_MSG(vmSymbols::java_lang_UnsupportedOperationException(),
"During -Xshare:dump, module system cannot be modified after it's initialized"); "During -Xshare:dump, module system cannot be modified after it's initialized");
} }

View file

@ -155,8 +155,9 @@ public:
assert(value.is_permanent() || (value.refcount() == 1) || (value.refcount() == 0), assert(value.is_permanent() || (value.refcount() == 1) || (value.refcount() == 0),
"refcount %d", value.refcount()); "refcount %d", value.refcount());
#if INCLUDE_CDS #if INCLUDE_CDS
if (DumpSharedSpaces) { if (CDSConfig::is_dumping_static_archive()) {
// no deallocation is needed // We have allocated with MetaspaceShared::symbol_space_alloc(). No deallocation is needed.
// Unreferenced Symbols will not be copied into the archive.
return; return;
} }
#endif #endif
@ -183,7 +184,7 @@ private:
static void* allocate_node_impl(size_t size, Value const& value) { static void* allocate_node_impl(size_t size, Value const& value) {
size_t alloc_size = size + value.byte_size() + value.effective_length(); size_t alloc_size = size + value.byte_size() + value.effective_length();
#if INCLUDE_CDS #if INCLUDE_CDS
if (DumpSharedSpaces) { if (CDSConfig::is_dumping_static_archive()) {
MutexLocker ml(DumpRegion_lock, Mutex::_no_safepoint_check_flag); MutexLocker ml(DumpRegion_lock, Mutex::_no_safepoint_check_flag);
// To get deterministic output from -Xshare:dump, we ensure that Symbols are allocated in // To get deterministic output from -Xshare:dump, we ensure that Symbols are allocated in
// increasing addresses. When the symbols are copied into the archive, we preserve their // increasing addresses. When the symbols are copied into the archive, we preserve their
@ -492,7 +493,7 @@ Symbol* SymbolTable::do_add_if_needed(const char* name, int len, uintx hash, boo
const int alloc_size = Symbol::byte_size(len); const int alloc_size = Symbol::byte_size(len);
u1* u1_buf = NEW_RESOURCE_ARRAY_IN_THREAD(current, u1, alloc_size); u1* u1_buf = NEW_RESOURCE_ARRAY_IN_THREAD(current, u1, alloc_size);
Symbol* tmp = ::new ((void*)u1_buf) Symbol((const u1*)name, len, Symbol* tmp = ::new ((void*)u1_buf) Symbol((const u1*)name, len,
(is_permanent || DumpSharedSpaces) ? PERM_REFCOUNT : 1); (is_permanent || CDSConfig::is_dumping_static_archive()) ? PERM_REFCOUNT : 1);
do { do {
if (_local_table->insert(current, lookup, *tmp, &rehash_warning, &clean_hint)) { if (_local_table->insert(current, lookup, *tmp, &rehash_warning, &clean_hint)) {

View file

@ -414,7 +414,7 @@ InstanceKlass* SystemDictionary::resolve_super_or_fail(Symbol* class_name,
assert(super_name != nullptr, "null superclass for resolving"); assert(super_name != nullptr, "null superclass for resolving");
assert(!Signature::is_array(super_name), "invalid superclass name"); assert(!Signature::is_array(super_name), "invalid superclass name");
#if INCLUDE_CDS #if INCLUDE_CDS
if (DumpSharedSpaces) { if (CDSConfig::is_dumping_static_archive()) {
// Special processing for handling UNREGISTERED shared classes. // Special processing for handling UNREGISTERED shared classes.
InstanceKlass* k = SystemDictionaryShared::lookup_super_for_unregistered_class(class_name, InstanceKlass* k = SystemDictionaryShared::lookup_super_for_unregistered_class(class_name,
super_name, is_superclass); super_name, is_superclass);
@ -878,7 +878,7 @@ InstanceKlass* SystemDictionary::resolve_class_from_stream(
InstanceKlass* k = nullptr; InstanceKlass* k = nullptr;
#if INCLUDE_CDS #if INCLUDE_CDS
if (!DumpSharedSpaces) { if (!CDSConfig::is_dumping_static_archive()) {
k = SystemDictionaryShared::lookup_from_stream(class_name, k = SystemDictionaryShared::lookup_from_stream(class_name,
class_loader, class_loader,
cl_info.protection_domain(), cl_info.protection_domain(),

View file

@ -460,7 +460,7 @@ bool SystemDictionaryShared::add_unregistered_class(Thread* current, InstanceKla
InstanceKlass* SystemDictionaryShared::lookup_super_for_unregistered_class( InstanceKlass* SystemDictionaryShared::lookup_super_for_unregistered_class(
Symbol* class_name, Symbol* super_name, bool is_superclass) { Symbol* class_name, Symbol* super_name, bool is_superclass) {
assert(DumpSharedSpaces, "only when static dumping"); assert(CDSConfig::is_dumping_static_archive(), "only when static dumping");
if (!ClassListParser::is_parsing_thread()) { if (!ClassListParser::is_parsing_thread()) {
// Unregistered classes can be created only by ClassListParser::_parsing_thread. // Unregistered classes can be created only by ClassListParser::_parsing_thread.
@ -723,7 +723,7 @@ bool SystemDictionaryShared::add_verification_constraint(InstanceKlass* k, Symbo
} }
void SystemDictionaryShared::add_enum_klass_static_field(InstanceKlass* ik, int root_index) { void SystemDictionaryShared::add_enum_klass_static_field(InstanceKlass* ik, int root_index) {
assert(DumpSharedSpaces, "static dump only"); assert(CDSConfig::is_dumping_heap(), "sanity");
DumpTimeClassInfo* info = get_info_locked(ik); DumpTimeClassInfo* info = get_info_locked(ik);
info->add_enum_klass_static_field(root_index); info->add_enum_klass_static_field(root_index);
} }
@ -841,7 +841,7 @@ InstanceKlass* SystemDictionaryShared::retrieve_lambda_proxy_class(const RunTime
} }
InstanceKlass* SystemDictionaryShared::get_shared_nest_host(InstanceKlass* lambda_ik) { InstanceKlass* SystemDictionaryShared::get_shared_nest_host(InstanceKlass* lambda_ik) {
assert(!DumpSharedSpaces && UseSharedSpaces, "called at run time with CDS enabled only"); assert(!CDSConfig::is_dumping_static_archive() && UseSharedSpaces, "called at run time with CDS enabled only");
RunTimeClassInfo* record = RunTimeClassInfo::get_for(lambda_ik); RunTimeClassInfo* record = RunTimeClassInfo::get_for(lambda_ik);
return record->nest_host(); return record->nest_host();
} }
@ -892,7 +892,7 @@ InstanceKlass* SystemDictionaryShared::prepare_shared_lambda_proxy_class(Instanc
void SystemDictionaryShared::check_verification_constraints(InstanceKlass* klass, void SystemDictionaryShared::check_verification_constraints(InstanceKlass* klass,
TRAPS) { TRAPS) {
assert(!DumpSharedSpaces && UseSharedSpaces, "called at run time with CDS enabled only"); assert(!CDSConfig::is_dumping_static_archive() && UseSharedSpaces, "called at run time with CDS enabled only");
RunTimeClassInfo* record = RunTimeClassInfo::get_for(klass); RunTimeClassInfo* record = RunTimeClassInfo::get_for(klass);
int length = record->_num_verifier_constraints; 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 // returns true IFF there's no need to re-initialize the i/v-tables for klass for
// the purpose of checking class loader constraints. // the purpose of checking class loader constraints.
bool SystemDictionaryShared::check_linking_constraints(Thread* current, InstanceKlass* klass) { bool SystemDictionaryShared::check_linking_constraints(Thread* current, InstanceKlass* klass) {
assert(!DumpSharedSpaces && UseSharedSpaces, "called at run time with CDS enabled only"); assert(!CDSConfig::is_dumping_static_archive() && UseSharedSpaces, "called at run time with CDS enabled only");
LogTarget(Info, class, loader, constraints) log; LogTarget(Info, class, loader, constraints) log;
if (klass->is_shared_boot_class()) { if (klass->is_shared_boot_class()) {
// No class loader constraint check performed for boot classes. // No class loader constraint check performed for boot classes.
@ -1343,7 +1343,7 @@ InstanceKlass* SystemDictionaryShared::find_builtin_class(Symbol* name) {
} }
void SystemDictionaryShared::update_shared_entry(InstanceKlass* k, int id) { void SystemDictionaryShared::update_shared_entry(InstanceKlass* k, int id) {
assert(DumpSharedSpaces, "supported only when dumping"); assert(CDSConfig::is_dumping_static_archive(), "class ID is used only for static dump (from classlist)");
DumpTimeClassInfo* info = get_info(k); DumpTimeClassInfo* info = get_info(k);
info->_id = id; info->_id = id;
} }

View file

@ -23,6 +23,7 @@
*/ */
#include "precompiled.hpp" #include "precompiled.hpp"
#include "cds/cdsConfig.hpp"
#include "classfile/classFileStream.hpp" #include "classfile/classFileStream.hpp"
#include "classfile/classLoader.hpp" #include "classfile/classLoader.hpp"
#include "classfile/javaClasses.hpp" #include "classfile/javaClasses.hpp"
@ -198,12 +199,12 @@ bool Verifier::verify(InstanceKlass* klass, bool should_verify_class, TRAPS) {
split_verifier.verify_class(THREAD); split_verifier.verify_class(THREAD);
exception_name = split_verifier.result(); exception_name = split_verifier.result();
// If DumpSharedSpaces is set then don't fall back to the old verifier on // If dumping static archive then don't fall back to the old verifier on
// verification failure. If a class fails verification with the split verifier, // verification failure. If a class fails verification with the split verifier,
// it might fail the CDS runtime verifier constraint check. In that case, we // it might fail the CDS runtime verifier constraint check. In that case, we
// don't want to share the class. We only archive classes that pass the split // don't want to share the class. We only archive classes that pass the split
// verifier. // verifier.
bool can_failover = !DumpSharedSpaces && bool can_failover = !CDSConfig::is_dumping_static_archive() &&
klass->major_version() < NOFAILOVER_MAJOR_VERSION; klass->major_version() < NOFAILOVER_MAJOR_VERSION;
if (can_failover && !HAS_PENDING_EXCEPTION && // Split verifier doesn't set PENDING_EXCEPTION for failure if (can_failover && !HAS_PENDING_EXCEPTION && // Split verifier doesn't set PENDING_EXCEPTION for failure

View file

@ -24,6 +24,7 @@
*/ */
#include "precompiled.hpp" #include "precompiled.hpp"
#include "cds/cdsConfig.hpp"
#include "gc/g1/g1Arguments.hpp" #include "gc/g1/g1Arguments.hpp"
#include "gc/g1/g1CardSet.hpp" #include "gc/g1/g1CardSet.hpp"
#include "gc/g1/g1CardSetContainers.inline.hpp" #include "gc/g1/g1CardSetContainers.inline.hpp"
@ -173,10 +174,10 @@ void G1Arguments::initialize() {
vm_exit_during_initialization("The flag -XX:+UseG1GC can not be combined with -XX:ParallelGCThreads=0", nullptr); vm_exit_during_initialization("The flag -XX:+UseG1GC can not be combined with -XX:ParallelGCThreads=0", nullptr);
} }
// When dumping the CDS archive we want to reduce fragmentation by // When dumping the CDS heap we want to reduce fragmentation by
// triggering a full collection. To get as low fragmentation as // triggering a full collection. To get as low fragmentation as
// possible we only use one worker thread. // possible we only use one worker thread.
if (DumpSharedSpaces) { if (CDSConfig::is_dumping_heap()) {
FLAG_SET_ERGO(ParallelGCThreads, 1); FLAG_SET_ERGO(ParallelGCThreads, 1);
} }

View file

@ -23,6 +23,7 @@
*/ */
#include "precompiled.hpp" #include "precompiled.hpp"
#include "cds/cdsConfig.hpp"
#include "classfile/javaClasses.hpp" #include "classfile/javaClasses.hpp"
#include "jfr/dcmd/jfrDcmds.hpp" #include "jfr/dcmd/jfrDcmds.hpp"
#include "jfr/recorder/service/jfrMemorySizer.hpp" #include "jfr/recorder/service/jfrMemorySizer.hpp"
@ -150,7 +151,7 @@ bool JfrOptionSet::allow_retransforms() {
} }
bool JfrOptionSet::allow_event_retransforms() { bool JfrOptionSet::allow_event_retransforms() {
return allow_retransforms() && (DumpSharedSpaces || can_retransform()); return allow_retransforms() && (CDSConfig::is_dumping_static_archive() || can_retransform());
} }
// default options for the dcmd parser // default options for the dcmd parser

View file

@ -24,6 +24,7 @@
*/ */
#include "precompiled.hpp" #include "precompiled.hpp"
#include "cds/cdsConfig.hpp"
#include "cds/metaspaceShared.hpp" #include "cds/metaspaceShared.hpp"
#include "classfile/classLoaderData.hpp" #include "classfile/classLoaderData.hpp"
#include "gc/shared/collectedHeap.hpp" #include "gc/shared/collectedHeap.hpp"
@ -725,7 +726,7 @@ void Metaspace::global_initialize() {
metaspace::ChunkHeaderPool::initialize(); metaspace::ChunkHeaderPool::initialize();
if (DumpSharedSpaces) { if (CDSConfig::is_dumping_static_archive()) {
assert(!UseSharedSpaces, "sanity"); assert(!UseSharedSpaces, "sanity");
MetaspaceShared::initialize_for_static_dump(); MetaspaceShared::initialize_for_static_dump();
} }

View file

@ -24,6 +24,7 @@
*/ */
#include "precompiled.hpp" #include "precompiled.hpp"
#include "cds/cdsConfig.hpp"
#include "classfile/classLoaderData.hpp" #include "classfile/classLoaderData.hpp"
#include "classfile/classLoaderDataGraph.hpp" #include "classfile/classLoaderDataGraph.hpp"
#include "memory/metaspace.hpp" #include "memory/metaspace.hpp"
@ -115,7 +116,7 @@ static void print_settings(outputStream* out, size_t scale) {
out->print("Current GC threshold: "); out->print("Current GC threshold: ");
print_human_readable_size(out, MetaspaceGC::capacity_until_GC(), scale); print_human_readable_size(out, MetaspaceGC::capacity_until_GC(), scale);
out->cr(); out->cr();
out->print_cr("CDS: %s", (UseSharedSpaces ? "on" : (DumpSharedSpaces ? "dump" : "off"))); out->print_cr("CDS: %s", (UseSharedSpaces ? "on" : (CDSConfig::is_dumping_static_archive() ? "dump" : "off")));
Settings::print_on(out); Settings::print_on(out);
} }

View file

@ -240,7 +240,7 @@ void Universe::metaspace_pointers_do(MetaspaceClosure* it) {
#if INCLUDE_CDS_JAVA_HEAP #if INCLUDE_CDS_JAVA_HEAP
void Universe::set_archived_basic_type_mirror_index(BasicType t, int index) { void Universe::set_archived_basic_type_mirror_index(BasicType t, int index) {
assert(DumpSharedSpaces, "dump-time only"); assert(CDSConfig::is_dumping_heap(), "sanity");
assert(!is_reference_type(t), "sanity"); assert(!is_reference_type(t), "sanity");
_archived_basic_type_mirror_indices[t] = index; _archived_basic_type_mirror_indices[t] = index;
} }
@ -484,7 +484,7 @@ void Universe::initialize_basic_type_mirrors(TRAPS) {
CDS_JAVA_HEAP_ONLY(_archived_basic_type_mirror_indices[i] = -1); CDS_JAVA_HEAP_ONLY(_archived_basic_type_mirror_indices[i] = -1);
} }
} }
if (DumpSharedSpaces) { if (CDSConfig::is_dumping_heap()) {
HeapShared::init_scratch_objects(CHECK); HeapShared::init_scratch_objects(CHECK);
} }
} }
@ -804,8 +804,6 @@ jint universe_init() {
return JNI_EINVAL; return JNI_EINVAL;
} }
// Create memory for metadata. Must be after initializing heap for
// DumpSharedSpaces.
ClassLoaderData::init_null_class_loader_data(); ClassLoaderData::init_null_class_loader_data();
// We have a heap so create the Method* caches before // We have a heap so create the Method* caches before

View file

@ -23,6 +23,7 @@
*/ */
#include "precompiled.hpp" #include "precompiled.hpp"
#include "cds/cdsConfig.hpp"
#include "cds/metaspaceShared.hpp" #include "cds/metaspaceShared.hpp"
#include "classfile/javaClasses.hpp" #include "classfile/javaClasses.hpp"
#include "classfile/moduleEntry.hpp" #include "classfile/moduleEntry.hpp"
@ -41,6 +42,10 @@
#include "oops/oop.inline.hpp" #include "oops/oop.inline.hpp"
#include "runtime/handles.inline.hpp" #include "runtime/handles.inline.hpp"
ArrayKlass::ArrayKlass() {
assert(CDSConfig::is_dumping_static_archive() || UseSharedSpaces, "only for CDS");
}
int ArrayKlass::static_size(int header_size) { int ArrayKlass::static_size(int header_size) {
// size of an array klass object // size of an array klass object
assert(header_size <= InstanceKlass::header_size(), "bad header size"); assert(header_size <= InstanceKlass::header_size(), "bad header size");

View file

@ -47,7 +47,7 @@ class ArrayKlass: public Klass {
// The constructor with the Symbol argument does the real array // The constructor with the Symbol argument does the real array
// initialization, the other is a dummy // initialization, the other is a dummy
ArrayKlass(Symbol* name, KlassKind kind); ArrayKlass(Symbol* name, KlassKind kind);
ArrayKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for cds"); } ArrayKlass();
public: public:
// Testing operation // Testing operation

View file

@ -104,6 +104,10 @@ static bool tag_array_is_zero_initialized(Array<u1>* tags) {
#endif #endif
ConstantPool::ConstantPool() {
assert(CDSConfig::is_dumping_static_archive() || UseSharedSpaces, "only for CDS");
}
ConstantPool::ConstantPool(Array<u1>* tags) : ConstantPool::ConstantPool(Array<u1>* tags) :
_tags(tags), _tags(tags),
_length(tags->length()) { _length(tags->length()) {

View file

@ -162,7 +162,7 @@ class ConstantPool : public Metadata {
} }
ConstantPool(Array<u1>* tags); ConstantPool(Array<u1>* tags);
ConstantPool() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); } ConstantPool();
public: public:
static ConstantPool* allocate(ClassLoaderData* loader_data, int length, TRAPS); static ConstantPool* allocate(ClassLoaderData* loader_data, int length, TRAPS);

View file

@ -447,7 +447,7 @@ void ConstantPoolCache::clear_archived_references() {
} }
void ConstantPoolCache::set_archived_references(int root_index) { void ConstantPoolCache::set_archived_references(int root_index) {
assert(DumpSharedSpaces, "called only during runtime"); assert(CDSConfig::is_dumping_heap(), "sanity");
_archived_references_index = root_index; _archived_references_index = root_index;
} }
#endif #endif

View file

@ -0,0 +1,31 @@
/*
* Copyright (c) 2023, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "cds/cdsConfig.hpp"
#include "oops/instanceClassLoaderKlass.hpp"
InstanceClassLoaderKlass::InstanceClassLoaderKlass() {
assert(CDSConfig::is_dumping_static_archive() || UseSharedSpaces, "only for CDS");
}

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -46,7 +46,7 @@ private:
InstanceClassLoaderKlass(const ClassFileParser& parser) : InstanceKlass(parser, Kind) {} InstanceClassLoaderKlass(const ClassFileParser& parser) : InstanceKlass(parser, Kind) {}
public: public:
InstanceClassLoaderKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); } InstanceClassLoaderKlass();
// Oop fields (and metadata) iterators // Oop fields (and metadata) iterators
// //

View file

@ -501,6 +501,10 @@ static Monitor* create_init_monitor(const char* name) {
return new Monitor(Mutex::safepoint, name); return new Monitor(Mutex::safepoint, name);
} }
InstanceKlass::InstanceKlass() {
assert(CDSConfig::is_dumping_static_archive() || UseSharedSpaces, "only for CDS");
}
InstanceKlass::InstanceKlass(const ClassFileParser& parser, KlassKind kind, ReferenceType reference_type) : InstanceKlass::InstanceKlass(const ClassFileParser& parser, KlassKind kind, ReferenceType reference_type) :
Klass(kind), Klass(kind),
_nest_members(nullptr), _nest_members(nullptr),
@ -822,8 +826,8 @@ bool InstanceKlass::link_class_or_fail(TRAPS) {
} }
bool InstanceKlass::link_class_impl(TRAPS) { bool InstanceKlass::link_class_impl(TRAPS) {
if (DumpSharedSpaces && SystemDictionaryShared::has_class_failed_verification(this)) { if (CDSConfig::is_dumping_static_archive() && SystemDictionaryShared::has_class_failed_verification(this)) {
// This is for CDS dumping phase only -- we use the in_error_state to indicate that // This is for CDS static dump only -- we use the in_error_state to indicate that
// the class has failed verification. Throwing the NoClassDefFoundError here is just // the class has failed verification. Throwing the NoClassDefFoundError here is just
// a convenient way to stop repeat attempts to verify the same (bad) class. // a convenient way to stop repeat attempts to verify the same (bad) class.
// //

View file

@ -145,7 +145,7 @@ class InstanceKlass: public Klass {
InstanceKlass(const ClassFileParser& parser, KlassKind kind = Kind, ReferenceType reference_type = REF_NONE); InstanceKlass(const ClassFileParser& parser, KlassKind kind = Kind, ReferenceType reference_type = REF_NONE);
public: public:
InstanceKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); } InstanceKlass();
// See "The Java Virtual Machine Specification" section 2.16.2-5 for a detailed description // See "The Java Virtual Machine Specification" section 2.16.2-5 for a detailed description
// of the class loading & initialization procedure, and the use of the states. // of the class loading & initialization procedure, and the use of the states.

View file

@ -23,6 +23,7 @@
*/ */
#include "precompiled.hpp" #include "precompiled.hpp"
#include "cds/cdsConfig.hpp"
#include "cds/serializeClosure.hpp" #include "cds/serializeClosure.hpp"
#include "classfile/javaClasses.inline.hpp" #include "classfile/javaClasses.inline.hpp"
#include "gc/shared/collectedHeap.inline.hpp" #include "gc/shared/collectedHeap.inline.hpp"
@ -39,6 +40,10 @@
int InstanceMirrorKlass::_offset_of_static_fields = 0; int InstanceMirrorKlass::_offset_of_static_fields = 0;
InstanceMirrorKlass::InstanceMirrorKlass() {
assert(CDSConfig::is_dumping_static_archive() || UseSharedSpaces, "only for CDS");
}
size_t InstanceMirrorKlass::instance_size(Klass* k) { size_t InstanceMirrorKlass::instance_size(Klass* k) {
if (k != nullptr && k->is_instance_klass()) { if (k != nullptr && k->is_instance_klass()) {
return align_object_size(size_helper() + InstanceKlass::cast(k)->static_field_size()); return align_object_size(size_helper() + InstanceKlass::cast(k)->static_field_size());

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -53,7 +53,7 @@ class InstanceMirrorKlass: public InstanceKlass {
InstanceMirrorKlass(const ClassFileParser& parser) : InstanceKlass(parser, Kind) {} InstanceMirrorKlass(const ClassFileParser& parser) : InstanceKlass(parser, Kind) {}
public: public:
InstanceMirrorKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); } InstanceMirrorKlass();
static InstanceMirrorKlass* cast(Klass* k) { static InstanceMirrorKlass* cast(Klass* k) {
return const_cast<InstanceMirrorKlass*>(cast(const_cast<const Klass*>(k))); return const_cast<InstanceMirrorKlass*>(cast(const_cast<const Klass*>(k)));

View file

@ -23,6 +23,7 @@
*/ */
#include "precompiled.hpp" #include "precompiled.hpp"
#include "cds/cdsConfig.hpp"
#include "classfile/classFileParser.hpp" #include "classfile/classFileParser.hpp"
#include "classfile/javaClasses.hpp" #include "classfile/javaClasses.hpp"
#include "classfile/vmClasses.hpp" #include "classfile/vmClasses.hpp"
@ -30,6 +31,10 @@
#include "oops/instanceRefKlass.inline.hpp" #include "oops/instanceRefKlass.inline.hpp"
#include "oops/oop.inline.hpp" #include "oops/oop.inline.hpp"
InstanceRefKlass::InstanceRefKlass() {
assert(CDSConfig::is_dumping_static_archive() || UseSharedSpaces, "only for CDS");
}
static ReferenceType reference_subclass_name_to_type(const Symbol* name) { static ReferenceType reference_subclass_name_to_type(const Symbol* name) {
if ( name == vmSymbols::java_lang_ref_SoftReference()) { if ( name == vmSymbols::java_lang_ref_SoftReference()) {
return REF_SOFT; return REF_SOFT;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -56,7 +56,7 @@ class InstanceRefKlass: public InstanceKlass {
InstanceRefKlass(const ClassFileParser& parser); InstanceRefKlass(const ClassFileParser& parser);
public: public:
InstanceRefKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); } InstanceRefKlass();
// Oop fields (and metadata) iterators // Oop fields (and metadata) iterators
// //

View file

@ -23,6 +23,7 @@
*/ */
#include "precompiled.hpp" #include "precompiled.hpp"
#include "cds/cdsConfig.hpp"
#include "cds/serializeClosure.hpp" #include "cds/serializeClosure.hpp"
#include "classfile/vmClasses.hpp" #include "classfile/vmClasses.hpp"
#include "compiler/oopMap.inline.hpp" #include "compiler/oopMap.inline.hpp"
@ -51,6 +52,10 @@ void InstanceStackChunkKlass::serialize_offsets(SerializeClosure* f) {
} }
#endif #endif
InstanceStackChunkKlass::InstanceStackChunkKlass() {
assert(CDSConfig::is_dumping_static_archive() || UseSharedSpaces, "only for CDS");
}
InstanceStackChunkKlass::InstanceStackChunkKlass(const ClassFileParser& parser) InstanceStackChunkKlass::InstanceStackChunkKlass(const ClassFileParser& parser)
: InstanceKlass(parser, Kind) { : InstanceKlass(parser, Kind) {
// Change the layout_helper to use the slow path because StackChunkOops are // Change the layout_helper to use the slow path because StackChunkOops are

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -113,7 +113,7 @@ private:
InstanceStackChunkKlass(const ClassFileParser& parser); InstanceStackChunkKlass(const ClassFileParser& parser);
public: public:
InstanceStackChunkKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); } InstanceStackChunkKlass();
// Casting from Klass* // Casting from Klass*
static InstanceStackChunkKlass* cast(Klass* k) { static InstanceStackChunkKlass* cast(Klass* k) {

View file

@ -195,6 +195,10 @@ void* Klass::operator new(size_t size, ClassLoaderData* loader_data, size_t word
return Metaspace::allocate(loader_data, word_size, MetaspaceObj::ClassType, THREAD); return Metaspace::allocate(loader_data, word_size, MetaspaceObj::ClassType, THREAD);
} }
Klass::Klass() : _kind(UnknownKlassKind) {
assert(CDSConfig::is_dumping_static_archive() || UseSharedSpaces, "only for cds");
}
// "Normal" instantiation is preceded by a MetaspaceObj allocation // "Normal" instantiation is preceded by a MetaspaceObj allocation
// which zeros out memory - calloc equivalent. // which zeros out memory - calloc equivalent.
// The constructor is also used from CppVtableCloner, // The constructor is also used from CppVtableCloner,

View file

@ -193,9 +193,8 @@ private:
protected: protected:
// Constructor
Klass(KlassKind kind); Klass(KlassKind kind);
Klass() : _kind(UnknownKlassKind) { assert(DumpSharedSpaces || UseSharedSpaces, "only for cds"); } Klass();
void* operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw(); void* operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw();

View file

@ -2945,7 +2945,7 @@ static void thread_entry(JavaThread* thread, TRAPS) {
JVM_ENTRY(void, JVM_StartThread(JNIEnv* env, jobject jthread)) JVM_ENTRY(void, JVM_StartThread(JNIEnv* env, jobject jthread))
#if INCLUDE_CDS #if INCLUDE_CDS
if (DumpSharedSpaces) { if (CDSConfig::is_dumping_static_archive()) {
// During java -Xshare:dump, if we allow multiple Java threads to // During java -Xshare:dump, if we allow multiple Java threads to
// execute in parallel, symbols and classes may be loaded in // execute in parallel, symbols and classes may be loaded in
// random orders which will make the resulting CDS archive // random orders which will make the resulting CDS archive
@ -3703,7 +3703,8 @@ JVM_LEAF(jboolean, JVM_IsSharingEnabled(JNIEnv* env))
JVM_END JVM_END
JVM_ENTRY_NO_ENV(jlong, JVM_GetRandomSeedForDumping()) JVM_ENTRY_NO_ENV(jlong, JVM_GetRandomSeedForDumping())
if (DumpSharedSpaces) { if (CDSConfig::is_dumping_static_archive()) {
// We do this so that the default CDS archive can be deterministic.
const char* release = VM_Version::vm_release(); const char* release = VM_Version::vm_release();
const char* dbg_level = VM_Version::jdk_debug_level(); const char* dbg_level = VM_Version::jdk_debug_level();
const char* version = VM_Version::internal_vm_info_string(); const char* version = VM_Version::internal_vm_info_string();

View file

@ -2615,7 +2615,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
mode_flag_cmd_line = true; mode_flag_cmd_line = true;
// -Xshare:dump // -Xshare:dump
} else if (match_option(option, "-Xshare:dump")) { } else if (match_option(option, "-Xshare:dump")) {
DumpSharedSpaces = true; CDSConfig::enable_dumping_static_archive();
// -Xshare:on // -Xshare:on
} else if (match_option(option, "-Xshare:on")) { } else if (match_option(option, "-Xshare:on")) {
UseSharedSpaces = true; UseSharedSpaces = true;
@ -3036,7 +3036,7 @@ jint Arguments::finalize_vm_init_args(bool patch_mod_javabase) {
} }
#if INCLUDE_CDS #if INCLUDE_CDS
if (DumpSharedSpaces) { if (CDSConfig::is_dumping_static_archive()) {
if (!mode_flag_cmd_line) { if (!mode_flag_cmd_line) {
// By default, -Xshare:dump runs in interpreter-only mode, which is required for deterministic archive. // By default, -Xshare:dump runs in interpreter-only mode, which is required for deterministic archive.
// //
@ -3083,7 +3083,7 @@ jint Arguments::finalize_vm_init_args(bool patch_mod_javabase) {
if (UseSharedSpaces && patch_mod_javabase) { if (UseSharedSpaces && patch_mod_javabase) {
no_shared_spaces("CDS is disabled when " JAVA_BASE_NAME " module is patched."); no_shared_spaces("CDS is disabled when " JAVA_BASE_NAME " module is patched.");
} }
if (UseSharedSpaces && !DumpSharedSpaces && check_unsupported_cds_runtime_properties()) { if (UseSharedSpaces && check_unsupported_cds_runtime_properties()) {
UseSharedSpaces = false; UseSharedSpaces = false;
} }
@ -3364,7 +3364,7 @@ jint Arguments::parse_options_buffer(const char* name, char* buffer, const size_
} }
void Arguments::set_shared_spaces_flags_and_archive_paths() { void Arguments::set_shared_spaces_flags_and_archive_paths() {
if (DumpSharedSpaces) { if (CDSConfig::is_dumping_static_archive()) {
if (RequireSharedSpaces) { if (RequireSharedSpaces) {
warning("Cannot dump shared archive while using shared archive"); warning("Cannot dump shared archive while using shared archive");
} }
@ -3375,7 +3375,7 @@ void Arguments::set_shared_spaces_flags_and_archive_paths() {
// This must be after set_ergonomics_flags() called so flag UseCompressedOops is set properly. // This must be after set_ergonomics_flags() called so flag UseCompressedOops is set properly.
// //
// UseSharedSpaces may be disabled if -XX:SharedArchiveFile is invalid. // UseSharedSpaces may be disabled if -XX:SharedArchiveFile is invalid.
if (DumpSharedSpaces || UseSharedSpaces) { if (CDSConfig::is_dumping_static_archive() || UseSharedSpaces) {
init_shared_archive_paths(); init_shared_archive_paths();
} }
#endif // INCLUDE_CDS #endif // INCLUDE_CDS
@ -3445,7 +3445,7 @@ void Arguments::extract_shared_archive_paths(const char* archive_path,
void Arguments::init_shared_archive_paths() { void Arguments::init_shared_archive_paths() {
if (ArchiveClassesAtExit != nullptr) { if (ArchiveClassesAtExit != nullptr) {
assert(!RecordDynamicDumpInfo, "already checked"); assert(!RecordDynamicDumpInfo, "already checked");
if (DumpSharedSpaces) { if (CDSConfig::is_dumping_static_archive()) {
vm_exit_during_initialization("-XX:ArchiveClassesAtExit cannot be used with -Xshare:dump"); vm_exit_during_initialization("-XX:ArchiveClassesAtExit cannot be used with -Xshare:dump");
} }
check_unsupported_dumping_properties(); check_unsupported_dumping_properties();
@ -3467,7 +3467,7 @@ void Arguments::init_shared_archive_paths() {
"Cannot have more than 1 archive file specified in -XX:SharedArchiveFile during CDS dumping"); "Cannot have more than 1 archive file specified in -XX:SharedArchiveFile during CDS dumping");
} }
if (DumpSharedSpaces) { if (CDSConfig::is_dumping_static_archive()) {
assert(archives == 1, "must be"); assert(archives == 1, "must be");
// Static dump is simple: only one archive is allowed in SharedArchiveFile. This file // Static dump is simple: only one archive is allowed in SharedArchiveFile. This file
// will be overwritten no matter regardless of its contents // will be overwritten no matter regardless of its contents
@ -3932,7 +3932,7 @@ jint Arguments::parse(const JavaVMInitArgs* initial_cmd_args) {
set_object_alignment(); set_object_alignment();
#if !INCLUDE_CDS #if !INCLUDE_CDS
if (DumpSharedSpaces || RequireSharedSpaces) { if (CDSConfig::is_dumping_static_archive() || RequireSharedSpaces) {
jio_fprintf(defaultStream::error_stream(), jio_fprintf(defaultStream::error_stream(),
"Shared spaces are not supported in this VM\n"); "Shared spaces are not supported in this VM\n");
return JNI_ERR; return JNI_ERR;

View file

@ -23,6 +23,7 @@
*/ */
#include "precompiled.hpp" #include "precompiled.hpp"
#include "cds/cdsConfig.hpp"
#include "classfile/javaClasses.hpp" #include "classfile/javaClasses.hpp"
#include "classfile/moduleEntry.hpp" #include "classfile/moduleEntry.hpp"
#include "classfile/systemDictionary.hpp" #include "classfile/systemDictionary.hpp"
@ -630,7 +631,7 @@ void* os::malloc(size_t size, MEMFLAGS memflags, const NativeCallStack& stack) {
// Special handling for NMT preinit phase before arguments are parsed // Special handling for NMT preinit phase before arguments are parsed
void* rc = nullptr; void* rc = nullptr;
if (NMTPreInit::handle_malloc(&rc, size)) { if (NMTPreInit::handle_malloc(&rc, size)) {
// No need to fill with 0 because DumpSharedSpaces doesn't use these // No need to fill with 0 because CDS static dumping doesn't use these
// early allocations. // early allocations.
return rc; return rc;
} }
@ -661,7 +662,7 @@ void* os::malloc(size_t size, MEMFLAGS memflags, const NativeCallStack& stack) {
void* const inner_ptr = MemTracker::record_malloc((address)outer_ptr, size, memflags, stack); void* const inner_ptr = MemTracker::record_malloc((address)outer_ptr, size, memflags, stack);
if (DumpSharedSpaces) { if (CDSConfig::is_dumping_static_archive()) {
// Need to deterministically fill all the alignment gaps in C++ structures. // Need to deterministically fill all the alignment gaps in C++ structures.
::memset(inner_ptr, 0, size); ::memset(inner_ptr, 0, size);
} else { } else {

View file

@ -23,6 +23,7 @@
*/ */
#include "precompiled.hpp" #include "precompiled.hpp"
#include "cds/cdsConfig.hpp"
#include "classfile/javaClasses.inline.hpp" #include "classfile/javaClasses.inline.hpp"
#include "classfile/moduleEntry.hpp" #include "classfile/moduleEntry.hpp"
#include "classfile/packageEntry.hpp" #include "classfile/packageEntry.hpp"
@ -457,9 +458,9 @@ Reflection::VerifyClassAccessResults Reflection::verify_class_access(
// module boundaries // module boundaries
if (new_class->is_public()) { if (new_class->is_public()) {
// Ignore modules for DumpSharedSpaces because we do not have any package // Ignore modules for -Xshare:dump because we do not have any package
// or module information for modules other than java.base. // or module information for modules other than java.base.
if (DumpSharedSpaces) { if (CDSConfig::is_dumping_static_archive()) {
return ACCESS_OK; return ACCESS_OK;
} }

View file

@ -25,6 +25,7 @@
#include "precompiled.hpp" #include "precompiled.hpp"
#include "cds/cds_globals.hpp" #include "cds/cds_globals.hpp"
#include "cds/cdsConfig.hpp"
#include "cds/metaspaceShared.hpp" #include "cds/metaspaceShared.hpp"
#include "classfile/classLoader.hpp" #include "classfile/classLoader.hpp"
#include "classfile/javaClasses.hpp" #include "classfile/javaClasses.hpp"
@ -815,7 +816,7 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
_vm_complete = true; _vm_complete = true;
#endif #endif
if (DumpSharedSpaces) { if (CDSConfig::is_dumping_static_archive()) {
MetaspaceShared::preload_and_dump(); MetaspaceShared::preload_and_dump();
} }

View file

@ -40,7 +40,6 @@ int BytesPerHeapOop = 0;
int BitsPerHeapOop = 0; int BitsPerHeapOop = 0;
// Old CDS options // Old CDS options
bool DumpSharedSpaces;
bool RequireSharedSpaces; bool RequireSharedSpaces;
extern "C" { extern "C" {
JNIEXPORT jboolean UseSharedSpaces = true; JNIEXPORT jboolean UseSharedSpaces = true;

View file

@ -553,7 +553,6 @@ const int max_method_code_size = 64*K - 1; // JVM spec, 2nd ed. section 4.8.1 (
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// old CDS options // old CDS options
extern bool DumpSharedSpaces;
extern bool RequireSharedSpaces; extern bool RequireSharedSpaces;
extern "C" { extern "C" {
// Make sure UseSharedSpaces is accessible to the serviceability agent. // Make sure UseSharedSpaces is accessible to the serviceability agent.