< prev index next >

src/hotspot/share/classfile/stringTable.cpp

Print this page

*** 817,845 **** // adjust the pointer to the 'value' field in the new String oop java_lang_String::set_value_raw(new_s, new_v); return new_s; } - class CompactStringTableWriter: public CompactHashtableWriter { - public: - CompactStringTableWriter(int num_entries, CompactHashtableStats* stats) : - CompactHashtableWriter(num_entries, stats) {} - void add(unsigned int hash, oop string) { - CompactHashtableWriter::add(hash, CompressedOops::encode(string)); - } - }; - struct CopyToArchive : StackObj { ! CompactStringTableWriter* _writer; ! CopyToArchive(CompactStringTableWriter* writer) : _writer(writer) {} bool operator()(WeakHandle<vm_string_table_data>* val) { oop s = val->peek(); if (s == NULL) { return true; } unsigned int hash = java_lang_String::hash_code(s); if (hash == 0) { return true; } java_lang_String::set_hash(s, hash); oop new_s = StringTable::create_archived_string(s, Thread::current()); --- 817,837 ---- // adjust the pointer to the 'value' field in the new String oop java_lang_String::set_value_raw(new_s, new_v); return new_s; } struct CopyToArchive : StackObj { ! CompactHashtableWriter* _writer; ! CopyToArchive(CompactHashtableWriter* writer) : _writer(writer) {} bool operator()(WeakHandle<vm_string_table_data>* val) { oop s = val->peek(); if (s == NULL) { return true; } unsigned int hash = java_lang_String::hash_code(s); if (hash == 0) { + // We do not archive Strings with a 0 hashcode because ...... return true; } java_lang_String::set_hash(s, hash); oop new_s = StringTable::create_archived_string(s, Thread::current());
*** 847,875 **** return true; } val->replace(new_s); // add to the compact table ! _writer->add(hash, new_s); return true; } }; ! void StringTable::copy_shared_string_table(CompactStringTableWriter* writer) { assert(MetaspaceShared::is_heap_object_archiving_allowed(), "must be"); CopyToArchive copy(writer); StringTable::the_table()->_local_table->do_scan(Thread::current(), copy); } void StringTable::write_to_archive() { assert(MetaspaceShared::is_heap_object_archiving_allowed(), "must be"); _shared_table.reset(); ! int num_buckets = the_table()->_items_count / SharedSymbolTableBucketSize; ! // calculation of num_buckets can result in zero buckets, we need at least one ! CompactStringTableWriter writer(num_buckets > 1 ? num_buckets : 1, &MetaspaceShared::stats()->string); // Copy the interned strings into the "string space" within the java heap copy_shared_string_table(&writer); writer.dump(&_shared_table, "string"); --- 839,867 ---- return true; } val->replace(new_s); // add to the compact table ! _writer->add(hash, CompressedOops::encode(new_s)); return true; } }; ! void StringTable::copy_shared_string_table(CompactHashtableWriter* writer) { assert(MetaspaceShared::is_heap_object_archiving_allowed(), "must be"); CopyToArchive copy(writer); StringTable::the_table()->_local_table->do_scan(Thread::current(), copy); } void StringTable::write_to_archive() { assert(MetaspaceShared::is_heap_object_archiving_allowed(), "must be"); _shared_table.reset(); ! int num_buckets = CompactHashtableWriter::default_num_buckets( ! StringTable::the_table()->_items_count); ! CompactHashtableWriter writer(num_buckets, &MetaspaceShared::stats()->string); // Copy the interned strings into the "string space" within the java heap copy_shared_string_table(&writer); writer.dump(&_shared_table, "string");
< prev index next >