< prev index next >

src/hotspot/share/classfile/stringTable.cpp

Print this page

 956   }
 957 
 958   CompileBroker::wait_for_no_active_tasks();
 959 
 960   precond(CDSConfig::allow_only_single_java_thread());
 961 
 962   // At this point, no more strings will be added:
 963   // - There's only a single Java thread (this thread). It no longer executes Java bytecodes
 964   //   so JIT compilation will eventually stop.
 965   // - CompileBroker has no more active tasks, so all JIT requests have been processed.
 966 
 967   // This flag will be cleared after intern table dumping has completed, so we can run the
 968   // compiler again (for future AOT method compilation, etc).
 969   DEBUG_ONLY(Atomic::release_store(&_disable_interning_during_cds_dump, true));
 970 
 971   if (items_count_acquire() > (size_t)max_jint) {
 972     fatal("Too many strings to be archived: %zu", items_count_acquire());
 973   }
 974 
 975   int total = (int)items_count_acquire();
 976   size_t single_array_size = objArrayOopDesc::object_size(total);
 977 
 978   log_info(aot)("allocated string table for %d strings", total);
 979 
 980   if (!ArchiveHeapWriter::is_too_large_to_archive(single_array_size)) {
 981     // The entire table can fit in a single array
 982     objArrayOop array = oopFactory::new_objArray(vmClasses::Object_klass(), total, CHECK);
 983     _shared_strings_array = OopHandle(Universe::vm_global(), array);
 984     log_info(aot)("string table array (single level) length = %d", total);
 985   } else {
 986     // Split the table in two levels of arrays.
 987     int primary_array_length = (total + _secondary_array_max_length - 1) / _secondary_array_max_length;
 988     size_t primary_array_size = objArrayOopDesc::object_size(primary_array_length);
 989     size_t secondary_array_size = objArrayOopDesc::object_size(_secondary_array_max_length);
 990 
 991     if (ArchiveHeapWriter::is_too_large_to_archive(secondary_array_size)) {
 992       // This can only happen if you have an extremely large number of classes that
 993       // refer to more than 16384 * 16384 = 26M interned strings! Not a practical concern
 994       // but bail out for safety.
 995       log_error(aot)("Too many strings to be archived: %zu", items_count_acquire());
 996       MetaspaceShared::unrecoverable_writing_error();
 997     }
 998 
 999     objArrayOop primary = oopFactory::new_objArray(vmClasses::Object_klass(), primary_array_length, CHECK);
1000     objArrayHandle primaryHandle(THREAD, primary);
1001     _shared_strings_array = OopHandle(Universe::vm_global(), primary);
1002 
1003     log_info(aot)("string table array (primary) length = %d", primary_array_length);
1004     for (int i = 0; i < primary_array_length; i++) {
1005       int len;
1006       if (total > _secondary_array_max_length) {
1007         len = _secondary_array_max_length;
1008       } else {
1009         len = total;
1010       }
1011       total -= len;
1012 
1013       objArrayOop secondary = oopFactory::new_objArray(vmClasses::Object_klass(), len, CHECK);
1014       primaryHandle()->obj_at_put(i, secondary);
1015 
1016       log_info(aot)("string table array (secondary)[%d] length = %d", i, len);
1017       assert(!ArchiveHeapWriter::is_too_large_to_archive(secondary), "sanity");
1018     }
1019 
1020     assert(total == 0, "must be");
1021     _is_two_dimensional_shared_strings_array = true;
1022   }
1023 }
1024 
1025 #ifndef PRODUCT
1026 void StringTable::verify_secondary_array_index_bits() {
1027   int max;
1028   for (max = 1; ; max++) {
1029     size_t next_size = objArrayOopDesc::object_size(1 << (max + 1));
1030     if (ArchiveHeapWriter::is_too_large_to_archive(next_size)) {
1031       break;
1032     }
1033   }
1034   // Currently max is 17 for +UseCompressedOops, 16 for -UseCompressedOops.
1035   // When we add support for Shenandoah (which has a smaller mininum region size than G1),
1036   // max will become 15/14.
1037   //
1038   // We use _secondary_array_index_bits==14 as that will be the eventual value, and will
1039   // make testing easier.
1040   assert(_secondary_array_index_bits <= max,
1041          "_secondary_array_index_bits (%d) must be smaller than max possible value (%d)",
1042          _secondary_array_index_bits, max);
1043 }
1044 #endif // PRODUCT
1045 
1046 // This is called AFTER we enter the CDS safepoint.
1047 //
1048 // For each shared string:
1049 // [1] Store it into _shared_strings_array. Encode its position as a 32-bit index.

 956   }
 957 
 958   CompileBroker::wait_for_no_active_tasks();
 959 
 960   precond(CDSConfig::allow_only_single_java_thread());
 961 
 962   // At this point, no more strings will be added:
 963   // - There's only a single Java thread (this thread). It no longer executes Java bytecodes
 964   //   so JIT compilation will eventually stop.
 965   // - CompileBroker has no more active tasks, so all JIT requests have been processed.
 966 
 967   // This flag will be cleared after intern table dumping has completed, so we can run the
 968   // compiler again (for future AOT method compilation, etc).
 969   DEBUG_ONLY(Atomic::release_store(&_disable_interning_during_cds_dump, true));
 970 
 971   if (items_count_acquire() > (size_t)max_jint) {
 972     fatal("Too many strings to be archived: %zu", items_count_acquire());
 973   }
 974 
 975   int total = (int)items_count_acquire();
 976   size_t single_array_size = refArrayOopDesc::object_size(total);
 977 
 978   log_info(aot)("allocated string table for %d strings", total);
 979 
 980   if (!ArchiveHeapWriter::is_too_large_to_archive(single_array_size)) {
 981     // The entire table can fit in a single array
 982     objArrayOop array = oopFactory::new_objArray(vmClasses::Object_klass(), total, CHECK);
 983     _shared_strings_array = OopHandle(Universe::vm_global(), array);
 984     log_info(aot)("string table array (single level) length = %d", total);
 985   } else {
 986     // Split the table in two levels of arrays.
 987     int primary_array_length = (total + _secondary_array_max_length - 1) / _secondary_array_max_length;
 988     size_t primary_array_size = refArrayOopDesc::object_size(primary_array_length);
 989     size_t secondary_array_size = refArrayOopDesc::object_size(_secondary_array_max_length);
 990 
 991     if (ArchiveHeapWriter::is_too_large_to_archive(secondary_array_size)) {
 992       // This can only happen if you have an extremely large number of classes that
 993       // refer to more than 16384 * 16384 = 26M interned strings! Not a practical concern
 994       // but bail out for safety.
 995       log_error(aot)("Too many strings to be archived: %zu", items_count_acquire());
 996       MetaspaceShared::unrecoverable_writing_error();
 997     }
 998 
 999     objArrayOop primary = oopFactory::new_objArray(vmClasses::Object_klass(), primary_array_length, CHECK);
1000     objArrayHandle primaryHandle(THREAD, primary);
1001     _shared_strings_array = OopHandle(Universe::vm_global(), primary);
1002 
1003     log_info(aot)("string table array (primary) length = %d", primary_array_length);
1004     for (int i = 0; i < primary_array_length; i++) {
1005       int len;
1006       if (total > _secondary_array_max_length) {
1007         len = _secondary_array_max_length;
1008       } else {
1009         len = total;
1010       }
1011       total -= len;
1012 
1013       objArrayOop secondary = oopFactory::new_objArray(vmClasses::Object_klass(), len, CHECK);
1014       primaryHandle()->obj_at_put(i, secondary);
1015 
1016       log_info(aot)("string table array (secondary)[%d] length = %d", i, len);
1017       assert(!ArchiveHeapWriter::is_too_large_to_archive(secondary), "sanity");
1018     }
1019 
1020     assert(total == 0, "must be");
1021     _is_two_dimensional_shared_strings_array = true;
1022   }
1023 }
1024 
1025 #ifndef PRODUCT
1026 void StringTable::verify_secondary_array_index_bits() {
1027   int max;
1028   for (max = 1; ; max++) {
1029     size_t next_size = refArrayOopDesc::object_size(1 << (max + 1));
1030     if (ArchiveHeapWriter::is_too_large_to_archive(next_size)) {
1031       break;
1032     }
1033   }
1034   // Currently max is 17 for +UseCompressedOops, 16 for -UseCompressedOops.
1035   // When we add support for Shenandoah (which has a smaller mininum region size than G1),
1036   // max will become 15/14.
1037   //
1038   // We use _secondary_array_index_bits==14 as that will be the eventual value, and will
1039   // make testing easier.
1040   assert(_secondary_array_index_bits <= max,
1041          "_secondary_array_index_bits (%d) must be smaller than max possible value (%d)",
1042          _secondary_array_index_bits, max);
1043 }
1044 #endif // PRODUCT
1045 
1046 // This is called AFTER we enter the CDS safepoint.
1047 //
1048 // For each shared string:
1049 // [1] Store it into _shared_strings_array. Encode its position as a 32-bit index.
< prev index next >