--- old/src/hotspot/share/classfile/symbolTable.cpp 2018-09-20 11:16:36.545023851 -0700 +++ new/src/hotspot/share/classfile/symbolTable.cpp 2018-09-20 11:16:36.285013918 -0700 @@ -627,43 +627,31 @@ } #if INCLUDE_CDS -class CompactSymbolTableWriter: public CompactHashtableWriter { -public: - CompactSymbolTableWriter(int num_buckets, CompactHashtableStats* stats) : - CompactHashtableWriter(num_buckets, stats) {} - void add(unsigned int hash, Symbol *symbol) { - uintx deltax = MetaspaceShared::object_delta(symbol); - // When the symbols are stored into the archive, we already check that - // they won't be more than MAX_SHARED_DELTA from the base address, or - // else the dumping would have been aborted. - assert(deltax <= MAX_SHARED_DELTA, "must not be"); - u4 delta = u4(deltax); - - CompactHashtableWriter::add(hash, delta); - } -}; - struct CopyToArchive : StackObj { - CompactSymbolTableWriter* _writer; - CopyToArchive(CompactSymbolTableWriter* writer) : _writer(writer) {} + CompactHashtableWriter* _writer; + CopyToArchive(CompactHashtableWriter* writer) : _writer(writer) {} bool operator()(Symbol** value) { 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()); - if (fixed_hash == 0) { - return true; - } + 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"); + uintx deltax = MetaspaceShared::object_delta(sym); + // When the symbols are stored into the archive, we already check that + // they won't be more than MAX_SHARED_DELTA from the base address, or + // else the dumping would have been aborted. + assert(deltax <= MAX_SHARED_DELTA, "must not be"); + u4 delta = u4(deltax); + // add to the compact table - _writer->add(fixed_hash, sym); + _writer->add(fixed_hash, delta); return true; } }; -void SymbolTable::copy_shared_symbol_table(CompactSymbolTableWriter* writer) { +void SymbolTable::copy_shared_symbol_table(CompactHashtableWriter* writer) { CopyToArchive copy(writer); SymbolTable::the_table()->_local_table->do_scan(Thread::current(), copy); } @@ -671,10 +659,10 @@ void SymbolTable::write_to_archive() { _shared_table.reset(); - int num_buckets = (int)(SymbolTable::the_table()->_items_count / SharedSymbolTableBucketSize); - // calculation of num_buckets can result in zero buckets, we need at least one - CompactSymbolTableWriter writer(num_buckets > 1 ? num_buckets : 1, - &MetaspaceShared::stats()->symbol); + int num_buckets = CompactHashtableWriter::default_num_buckets( + SymbolTable::the_table()->_items_count); + CompactHashtableWriter writer(num_buckets, + &MetaspaceShared::stats()->symbol); copy_shared_symbol_table(&writer); writer.dump(&_shared_table, "symbol");