--- old/src/hotspot/share/classfile/compactHashtable.cpp 2018-10-02 09:20:20.517728512 -0700 +++ new/src/hotspot/share/classfile/compactHashtable.cpp 2018-10-02 09:20:20.129713645 -0700 @@ -174,7 +174,7 @@ // The CompactHashtable implementation // -void SimpleCompactHashtable::serialize(SerializeClosure* soc) { +void SimpleCompactHashtable::serialize_header(SerializeClosure* soc) { soc->do_ptr((void**)&_base_address); soc->do_u4(&_entry_count); soc->do_u4(&_bucket_count); --- old/src/hotspot/share/classfile/compactHashtable.hpp 2018-10-02 09:20:21.413762846 -0700 +++ new/src/hotspot/share/classfile/compactHashtable.hpp 2018-10-02 09:20:21.025747978 -0700 @@ -222,8 +222,8 @@ _entries = entries; } - // For reading from/writing to the CDS archive - void serialize(SerializeClosure* soc) NOT_CDS_RETURN; + // Read/Write the table's header from/to the CDS archive + void serialize_header(SerializeClosure* soc) NOT_CDS_RETURN; inline bool empty() { return (_entry_count == 0); --- old/src/hotspot/share/classfile/stringTable.cpp 2018-10-02 09:20:22.365799325 -0700 +++ new/src/hotspot/share/classfile/stringTable.cpp 2018-10-02 09:20:22.057787523 -0700 @@ -867,8 +867,8 @@ writer.dump(&_shared_table, "string"); } -void StringTable::serialize(SerializeClosure* soc) { - _shared_table.serialize(soc); +void StringTable::serialize_shared_table_header(SerializeClosure* soc) { + _shared_table.serialize_header(soc); if (soc->writing()) { // Sanity. Make sure we don't use the shared table at dump time --- old/src/hotspot/share/classfile/stringTable.hpp 2018-10-02 09:20:23.301835191 -0700 +++ new/src/hotspot/share/classfile/stringTable.hpp 2018-10-02 09:20:22.853818025 -0700 @@ -170,7 +170,7 @@ static bool shared_string_mapped() { return _shared_string_mapped; } static void shared_oops_do(OopClosure* f) NOT_CDS_JAVA_HEAP_RETURN; static void write_to_archive() NOT_CDS_JAVA_HEAP_RETURN; - static void serialize(SerializeClosure* soc) NOT_CDS_JAVA_HEAP_RETURN; + static void serialize_shared_table_header(SerializeClosure* soc) NOT_CDS_JAVA_HEAP_RETURN; // Jcmd static void dump(outputStream* st, bool verbose=false); --- old/src/hotspot/share/classfile/symbolTable.cpp 2018-10-02 09:20:24.349875349 -0700 +++ new/src/hotspot/share/classfile/symbolTable.cpp 2018-10-02 09:20:23.841855883 -0700 @@ -634,7 +634,7 @@ assert(value != NULL, "expected valid value"); assert(*value != NULL, "value should point to a symbol"); Symbol* sym = *value; - unsigned int fixed_hash = hash_shared_symbol((const char*)sym->bytes(), sym->utf8_length()); + unsigned int fixed_hash = hash_shared_symbol((const char*)sym->bytes(), sym->utf8_length()); assert(fixed_hash == hash_symbol((const char*)sym->bytes(), sym->utf8_length(), false), "must not rehash during dumping"); @@ -674,8 +674,8 @@ assert(sym == _shared_table.lookup(name, hash, len), "sanity"); } -void SymbolTable::serialize(SerializeClosure* soc) { - _shared_table.serialize(soc); +void SymbolTable::serialize_shared_table_header(SerializeClosure* soc) { + _shared_table.serialize_header(soc); if (soc->writing()) { // Sanity. Make sure we don't use the shared table at dump time --- old/src/hotspot/share/classfile/symbolTable.hpp 2018-10-02 09:20:25.333913053 -0700 +++ new/src/hotspot/share/classfile/symbolTable.hpp 2018-10-02 09:20:24.953898493 -0700 @@ -243,7 +243,7 @@ static void copy_shared_symbol_table(CompactHashtableWriter* ch_table); public: static void write_to_archive() NOT_CDS_RETURN; - static void serialize(SerializeClosure* soc) NOT_CDS_RETURN; + static void serialize_shared_table_header(SerializeClosure* soc) NOT_CDS_RETURN; static void metaspace_pointers_do(MetaspaceClosure* it); // Jcmd --- old/src/hotspot/share/memory/heapShared.cpp 2018-10-02 09:20:26.201946314 -0700 +++ new/src/hotspot/share/memory/heapShared.cpp 2018-10-02 09:20:25.889934359 -0700 @@ -50,6 +50,7 @@ // there is no existing one for k. The subgraph_info records the relocated // Klass* of the original k. KlassSubGraphInfo* HeapShared::get_subgraph_info(Klass* k) { + assert(DumpSharedSpaces, "dump time only"); Klass* relocated_k = MetaspaceShared::get_relocated_klass(k); KlassSubGraphInfo* info = _dump_time_subgraph_info_table->get(relocated_k); if (info == NULL) { @@ -171,7 +172,6 @@ CopyKlassSubGraphInfoToArchive(CompactHashtableWriter* writer) : _writer(writer) {} bool do_entry(Klass* klass, KlassSubGraphInfo& info) { - if (info.subgraph_object_klasses() != NULL || info.subgraph_entry_fields() != NULL) { ArchivedKlassSubGraphInfoRecord* record = (ArchivedKlassSubGraphInfoRecord*)MetaspaceShared::read_only_space_alloc(sizeof(ArchivedKlassSubGraphInfoRecord)); @@ -194,7 +194,7 @@ // back to the corresponding field at runtime. // - A list of klasses that need to be loaded/initialized before archived // java object sub-graph can be accessed at runtime. -void HeapShared::create_hashtables() { +void HeapShared::write_subgraph_info_table() { // Allocate the contents of the hashtable(s) inside the RO region of the CDS archive. DumpTimeKlassSubGraphInfoTable* d_table = _dump_time_subgraph_info_table; CompactHashtableStats stats; @@ -209,15 +209,15 @@ writer.dump(&_run_time_subgraph_info_table, "subgraphs"); } -// Read/write the headers of the hashtable(s) so they can be accessed quickly at runtime. -void HeapShared::serialize_hashtables(SerializeClosure* soc) { - _run_time_subgraph_info_table.serialize(soc); +void HeapShared::serialize_subgraph_info_table_header(SerializeClosure* soc) { + _run_time_subgraph_info_table.serialize_header(soc); } void HeapShared::initialize_from_archived_subgraph(Klass* k) { if (!MetaspaceShared::open_archive_heap_region_mapped()) { return; // nothing to do } + assert(!DumpSharedSpaces, "Should not be called with DumpSharedSpaces"); unsigned int hash = primitive_hash(k); ArchivedKlassSubGraphInfoRecord* record = _run_time_subgraph_info_table.lookup(k, hash, 0); @@ -228,7 +228,7 @@ Thread* THREAD = Thread::current(); if (log_is_enabled(Info, cds, heap)) { ResourceMark rm; - log_info(cds, heap)("initialize_from_archived_subgraph %p %s", k, + log_info(cds, heap)("initialize_from_archived_subgraph " PTR_FORMAT " %s", p2i(k), k->external_name()); } @@ -279,7 +279,7 @@ m->obj_field_put(field_offset, v); i += 2; - log_debug(cds, heap)(" %p init field @ %2d = %p", k, field_offset, (address)v); + log_debug(cds, heap)(" " PTR_FORMAT " init field @ %2d = " PTR_FORMAT, p2i(k), field_offset, p2i(v)); } // Done. Java code can see the archived sub-graphs referenced from k's --- old/src/hotspot/share/memory/heapShared.hpp 2018-10-02 09:20:26.965975589 -0700 +++ new/src/hotspot/share/memory/heapShared.hpp 2018-10-02 09:20:26.625962561 -0700 @@ -121,7 +121,7 @@ : public ResourceHashtable { public: int _count; @@ -226,8 +226,8 @@ static void init_archivable_static_fields(Thread* THREAD) NOT_CDS_JAVA_HEAP_RETURN; static void archive_static_fields(Thread* THREAD) NOT_CDS_JAVA_HEAP_RETURN; - static void create_hashtables() NOT_CDS_JAVA_HEAP_RETURN; - static void serialize_hashtables(SerializeClosure* soc) NOT_CDS_JAVA_HEAP_RETURN; + static void write_subgraph_info_table() NOT_CDS_JAVA_HEAP_RETURN; + static void serialize_subgraph_info_table_header(SerializeClosure* soc) NOT_CDS_JAVA_HEAP_RETURN; #if INCLUDE_CDS_JAVA_HEAP static ResourceBitMap calculate_oopmap(MemRegion region); --- old/src/hotspot/share/memory/metaspaceShared.cpp 2018-10-02 09:20:27.758005937 -0700 +++ new/src/hotspot/share/memory/metaspaceShared.cpp 2018-10-02 09:20:27.437993675 -0700 @@ -419,13 +419,10 @@ vmSymbols::serialize(soc); soc->do_tag(--tag); - // Dump/restore the symbol and string tables - SymbolTable::serialize(soc); - StringTable::serialize(soc); - - // Dump/restore the tables related to shared heap objects - HeapShared::serialize_hashtables(soc); - soc->do_tag(--tag); + // Dump/restore the symbol/string/subgraph_info tables + SymbolTable::serialize_shared_table_header(soc); + StringTable::serialize_shared_table_header(soc); + HeapShared::serialize_subgraph_info_table_header(soc); JavaClasses::serialize_offsets(soc); InstanceMirrorKlass::serialize_offsets(soc); @@ -1835,7 +1832,7 @@ { ArchiveCompactor::OtherROAllocMark mark; - HeapShared::create_hashtables(); + HeapShared::write_subgraph_info_table(); } }