--- old/src/hotspot/share/memory/metaspaceShared.cpp 2018-09-20 11:16:39.281128374 -0700 +++ new/src/hotspot/share/memory/metaspaceShared.cpp 2018-09-20 11:16:39.021118441 -0700 @@ -422,6 +422,9 @@ // 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); JavaClasses::serialize_offsets(soc); @@ -1097,6 +1100,21 @@ return _alloc_stats; } + // Use this when you allocate space with MetaspaceShare::read_only_space_alloc() + // outside of ArchiveCompactor::allocate(). These are usually for misc tables + // that are allocated in the RO space. + class OtherROAllocMark { + char* _oldtop; + public: + OtherROAllocMark() { + _oldtop = _ro_region.top(); + } + ~OtherROAllocMark() { + char* newtop = _ro_region.top(); + ArchiveCompactor::alloc_stats()->record_other_type(int(newtop - _oldtop), true); + } + }; + static void allocate(MetaspaceClosure::Ref* ref, bool read_only) { address obj = ref->obj(); int bytes = ref->size() * BytesPerWord; @@ -1307,7 +1325,7 @@ } char* VM_PopulateDumpSharedSpace::dump_read_only_tables() { - char* oldtop = _ro_region.top(); + ArchiveCompactor::OtherROAllocMark mark; // Reorder the system dictionary. Moving the symbols affects // how the hash table indices are calculated. SystemDictionary::reorder_dictionary_for_sharing(); @@ -1328,11 +1346,6 @@ char* table_top = _ro_region.allocate(table_bytes, sizeof(intptr_t)); SystemDictionary::copy_table(table_top, _ro_region.top()); - // Write the archived object sub-graph infos. For each klass with sub-graphs, - // the info includes the static fields (sub-graph entry points) and Klasses - // of objects included in the sub-graph. - HeapShared::write_archived_subgraph_infos(); - // Write the other data to the output array. WriteClosure wc(&_ro_region); MetaspaceShared::serialize(&wc); @@ -1340,8 +1353,6 @@ // Write the bitmaps for patching the archive heap regions dump_archive_heap_oopmaps(); - char* newtop = _ro_region.top(); - ArchiveCompactor::alloc_stats()->record_other_type(int(newtop - oldtop), true); return buckets_top; } @@ -1821,6 +1832,11 @@ } G1HeapVerifier::verify_archive_regions(); + + { + ArchiveCompactor::OtherROAllocMark mark; + HeapShared::create_hashtables(); + } } void VM_PopulateDumpSharedSpace::dump_archive_heap_oopmaps() { @@ -1888,7 +1904,7 @@ unsigned MetaspaceShared::obj_hash(oop const& p) { assert(!p->mark()->has_bias_pattern(), - "this object should never have been locked"); // so identity_hash won't safepoin + "this object should never have been locked"); // so identity_hash won't safepoint unsigned hash = (unsigned)p->identity_hash(); return hash; } @@ -2144,9 +2160,6 @@ buffer += sizeof(intptr_t); buffer += len; - // The table of archived java heap object sub-graph infos - buffer = HeapShared::read_archived_subgraph_infos(buffer); - // Verify various attributes of the archive, plus initialize the // shared string/symbol tables intptr_t* array = (intptr_t*)buffer;