--- old/src/share/vm/classfile/symbolTable.cpp 2017-06-29 15:57:17.655663847 -0700 +++ new/src/share/vm/classfile/symbolTable.cpp 2017-06-29 15:57:17.475656927 -0700 @@ -32,6 +32,7 @@ #include "gc/shared/gcLocker.inline.hpp" #include "memory/allocation.inline.hpp" #include "memory/filemap.hpp" +#include "memory/metaspaceClosure.hpp" #include "memory/resourceArea.hpp" #include "oops/oop.inline.hpp" #include "runtime/atomic.hpp" @@ -56,9 +57,9 @@ Symbol* sym; if (DumpSharedSpaces) { - // Allocate all symbols to CLD shared metaspace - sym = new (len, ClassLoaderData::the_null_class_loader_data(), THREAD) Symbol(name, len, PERM_REFCOUNT); - } else if (c_heap) { + c_heap = false; + } + if (c_heap) { // refcount starts as 1 sym = new (len, THREAD) Symbol(name, len, 1); assert(sym != NULL, "new should call vm_exit_out_of_memory if C_HEAP is exhausted"); @@ -80,8 +81,10 @@ // Call function for all symbols in the symbol table. void SymbolTable::symbols_do(SymbolClosure *cl) { - // all symbols from shared table - _shared_table.symbols_do(cl); + if (!DumpSharedSpaces) { + // all symbols from shared table + _shared_table.symbols_do(cl); + } // all symbols from the dynamic table const int n = the_table()->table_size(); @@ -94,6 +97,18 @@ } } +void SymbolTable::metaspace_pointers_do(MetaspaceClosure* it) { + assert(DumpSharedSpaces, "called only during dump time"); + const int n = the_table()->table_size(); + for (int i = 0; i < n; i++) { + for (HashtableEntry* p = the_table()->bucket(i); + p != NULL; + p = p->next()) { + it->push(p->literal_addr()); + } + } +} + int SymbolTable::_symbols_removed = 0; int SymbolTable::_symbols_counted = 0; volatile int SymbolTable::_parallel_claimed_idx = 0; @@ -567,10 +582,10 @@ } } -void SymbolTable::serialize(SerializeClosure* soc) { +void SymbolTable::write_to_archive() { #if INCLUDE_CDS - _shared_table.reset(); - if (soc->writing()) { + _shared_table.reset(); + int num_buckets = the_table()->number_of_entries() / SharedSymbolTableBucketSize; CompactSymbolTableWriter writer(num_buckets, @@ -586,19 +601,22 @@ } writer.dump(&_shared_table); - } - _shared_table.set_type(CompactHashtable::_symbol_table); - _shared_table.serialize(soc); - - if (soc->writing()) { // Verify table is correct Symbol* sym = vmSymbols::java_lang_Object(); const char* name = (const char*)sym->bytes(); int len = sym->utf8_length(); unsigned int hash = hash_symbol(name, len); assert(sym == _shared_table.lookup(name, hash, len), "sanity"); +#endif +} +void SymbolTable::serialize(SerializeClosure* soc) { +#if INCLUDE_CDS + _shared_table.set_type(CompactHashtable::_symbol_table); + _shared_table.serialize(soc); + + if (soc->writing()) { // Sanity. Make sure we don't use the shared table at dump time _shared_table.reset(); }