< prev index next >

src/share/vm/classfile/stringTable.cpp

Print this page


 726       // 'hash' field. That avoids "write" to the shared strings at runtime by the deduplication process.
 727       java_lang_String::set_value_raw(new_s, new_v);
 728       if (java_lang_String::hash(new_s) == 0) {
 729         java_lang_String::set_hash(new_s, hash);
 730       }
 731 
 732       // add to the compact table
 733       writer->add(hash, new_s);
 734 
 735       MetaspaceShared::relocate_klass_ptr(new_s);
 736       MetaspaceShared::relocate_klass_ptr(new_v);
 737     }
 738   }
 739 
 740   G1CollectedHeap::heap()->end_archive_alloc_range(string_space, os::vm_allocation_granularity());
 741   assert(string_space->length() <= 2, "sanity");
 742 #endif
 743   return true;
 744 }
 745 
 746 void StringTable::write_to_archive(GrowableArray<MemRegion> *string_space,
 747                                    size_t* space_size) {
 748 #if INCLUDE_CDS
 749   _shared_table.reset();
 750   if (!(UseG1GC && UseCompressedOops && UseCompressedClassPointers)) {
 751       log_info(cds)(
 752         "Shared strings are excluded from the archive as UseG1GC, "
 753         "UseCompressedOops and UseCompressedClassPointers are required."
 754         "Current settings: UseG1GC=%s, UseCompressedOops=%s, UseCompressedClassPointers=%s.",
 755         BOOL_TO_STR(UseG1GC), BOOL_TO_STR(UseCompressedOops),
 756         BOOL_TO_STR(UseCompressedClassPointers));
 757   } else {
 758     int num_buckets = the_table()->number_of_entries() /
 759                            SharedSymbolTableBucketSize;
 760     // calculation of num_buckets can result in zero buckets, we need at least one
 761     CompactStringTableWriter writer(num_buckets > 1 ? num_buckets : 1,
 762                                     &MetaspaceShared::stats()->string);
 763 
 764     // Copy the interned strings into the "string space" within the java heap
 765     if (copy_shared_string(string_space, &writer)) {
 766       for (int i = 0; i < string_space->length(); i++) {
 767         *space_size += string_space->at(i).byte_size();
 768       }
 769       writer.dump(&_shared_table);
 770     }
 771   }
 772 #endif
 773 }
 774 
 775 void StringTable::serialize(SerializeClosure* soc) {
 776 #if INCLUDE_CDS && defined(_LP64) && !defined(_WINDOWS)
 777   _shared_table.set_type(CompactHashtable<oop, char>::_string_table);
 778   _shared_table.serialize(soc);
 779 
 780   if (soc->writing()) {
 781     _shared_table.reset(); // Sanity. Make sure we don't use the shared table at dump time
 782   } else if (_ignore_shared_strings) {
 783     _shared_table.reset();
 784   }
 785 #endif
 786 }
 787 
 788 void StringTable::shared_oops_do(OopClosure* f) {


 726       // 'hash' field. That avoids "write" to the shared strings at runtime by the deduplication process.
 727       java_lang_String::set_value_raw(new_s, new_v);
 728       if (java_lang_String::hash(new_s) == 0) {
 729         java_lang_String::set_hash(new_s, hash);
 730       }
 731 
 732       // add to the compact table
 733       writer->add(hash, new_s);
 734 
 735       MetaspaceShared::relocate_klass_ptr(new_s);
 736       MetaspaceShared::relocate_klass_ptr(new_v);
 737     }
 738   }
 739 
 740   G1CollectedHeap::heap()->end_archive_alloc_range(string_space, os::vm_allocation_granularity());
 741   assert(string_space->length() <= 2, "sanity");
 742 #endif
 743   return true;
 744 }
 745 
 746 void StringTable::write_to_archive(GrowableArray<MemRegion> *string_space) {

 747 #if INCLUDE_CDS
 748   _shared_table.reset();
 749   if (!(UseG1GC && UseCompressedOops && UseCompressedClassPointers)) {
 750       log_info(cds)(
 751         "Shared strings are excluded from the archive as UseG1GC, "
 752         "UseCompressedOops and UseCompressedClassPointers are required."
 753         "Current settings: UseG1GC=%s, UseCompressedOops=%s, UseCompressedClassPointers=%s.",
 754         BOOL_TO_STR(UseG1GC), BOOL_TO_STR(UseCompressedOops),
 755         BOOL_TO_STR(UseCompressedClassPointers));
 756   } else {
 757     int num_buckets = the_table()->number_of_entries() /
 758                            SharedSymbolTableBucketSize;
 759     // calculation of num_buckets can result in zero buckets, we need at least one
 760     CompactStringTableWriter writer(num_buckets > 1 ? num_buckets : 1,
 761                                     &MetaspaceShared::stats()->string);
 762 
 763     // Copy the interned strings into the "string space" within the java heap
 764     if (copy_shared_string(string_space, &writer)) {



 765       writer.dump(&_shared_table);
 766     }
 767   }
 768 #endif
 769 }
 770 
 771 void StringTable::serialize(SerializeClosure* soc) {
 772 #if INCLUDE_CDS && defined(_LP64) && !defined(_WINDOWS)
 773   _shared_table.set_type(CompactHashtable<oop, char>::_string_table);
 774   _shared_table.serialize(soc);
 775 
 776   if (soc->writing()) {
 777     _shared_table.reset(); // Sanity. Make sure we don't use the shared table at dump time
 778   } else if (_ignore_shared_strings) {
 779     _shared_table.reset();
 780   }
 781 #endif
 782 }
 783 
 784 void StringTable::shared_oops_do(OopClosure* f) {
< prev index next >