< prev index next >

src/hotspot/share/classfile/stringTable.cpp

Print this page




 744   }
 745   new_s = HeapShared::archive_heap_object(s, THREAD);
 746   if (new_s == NULL) {
 747     return NULL;
 748   }
 749 
 750   // adjust the pointer to the 'value' field in the new String oop
 751   java_lang_String::set_value_raw(new_s, new_v);
 752   return new_s;
 753 }
 754 
 755 struct CopyToArchive : StackObj {
 756   CompactHashtableWriter* _writer;
 757   CopyToArchive(CompactHashtableWriter* writer) : _writer(writer) {}
 758   bool operator()(WeakHandle<vm_string_table_data>* val) {
 759     oop s = val->peek();
 760     if (s == NULL) {
 761       return true;
 762     }
 763     unsigned int hash = java_lang_String::hash_code(s);


 764     oop new_s = StringTable::create_archived_string(s, Thread::current());
 765     if (new_s == NULL) {
 766       return true;
 767     }
 768 
 769     val->replace(new_s);
 770     // add to the compact table
 771     _writer->add(hash, CompressedOops::encode(new_s));
 772     return true;
 773   }
 774 };
 775 
 776 void StringTable::copy_shared_string_table(CompactHashtableWriter* writer) {
 777   assert(HeapShared::is_heap_object_archiving_allowed(), "must be");
 778 
 779   CopyToArchive copy(writer);
 780   StringTable::the_table()->_local_table->do_safepoint_scan(copy);
 781 }
 782 
 783 void StringTable::write_to_archive() {




 744   }
 745   new_s = HeapShared::archive_heap_object(s, THREAD);
 746   if (new_s == NULL) {
 747     return NULL;
 748   }
 749 
 750   // adjust the pointer to the 'value' field in the new String oop
 751   java_lang_String::set_value_raw(new_s, new_v);
 752   return new_s;
 753 }
 754 
 755 struct CopyToArchive : StackObj {
 756   CompactHashtableWriter* _writer;
 757   CopyToArchive(CompactHashtableWriter* writer) : _writer(writer) {}
 758   bool operator()(WeakHandle<vm_string_table_data>* val) {
 759     oop s = val->peek();
 760     if (s == NULL) {
 761       return true;
 762     }
 763     unsigned int hash = java_lang_String::hash_code(s);
 764 
 765     java_lang_String::set_hash(s, hash);
 766     oop new_s = StringTable::create_archived_string(s, Thread::current());
 767     if (new_s == NULL) {
 768       return true;
 769     }
 770 
 771     val->replace(new_s);
 772     // add to the compact table
 773     _writer->add(hash, CompressedOops::encode(new_s));
 774     return true;
 775   }
 776 };
 777 
 778 void StringTable::copy_shared_string_table(CompactHashtableWriter* writer) {
 779   assert(HeapShared::is_heap_object_archiving_allowed(), "must be");
 780 
 781   CopyToArchive copy(writer);
 782   StringTable::the_table()->_local_table->do_safepoint_scan(copy);
 783 }
 784 
 785 void StringTable::write_to_archive() {


< prev index next >