< prev index next >

src/hotspot/share/classfile/symbolTable.cpp

Print this page

*** 625,681 **** } } } #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) {} 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; - } assert(fixed_hash == hash_symbol((const char*)sym->bytes(), sym->utf8_length(), false), "must not rehash during dumping"); // add to the compact table ! _writer->add(fixed_hash, sym); return true; } }; ! void SymbolTable::copy_shared_symbol_table(CompactSymbolTableWriter* writer) { CopyToArchive copy(writer); SymbolTable::the_table()->_local_table->do_scan(Thread::current(), copy); } 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); copy_shared_symbol_table(&writer); writer.dump(&_shared_table, "symbol"); // Verify table is correct --- 625,669 ---- } } } #if INCLUDE_CDS struct CopyToArchive : StackObj { ! 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()); 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, delta); return true; } }; ! void SymbolTable::copy_shared_symbol_table(CompactHashtableWriter* writer) { CopyToArchive copy(writer); SymbolTable::the_table()->_local_table->do_scan(Thread::current(), copy); } void SymbolTable::write_to_archive() { _shared_table.reset(); ! 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"); // Verify table is correct
< prev index next >