< prev index next >

src/hotspot/share/memory/metaspaceShared.cpp

Print this page


1059   // Ensure the ConstMethods won't be modified at run-time
1060   log_info(cds)("Updating ConstMethods ... ");
1061   rewrite_nofast_bytecodes_and_calculate_fingerprints(THREAD);
1062   log_info(cds)("done. ");
1063 
1064   // Remove all references outside the metadata
1065   log_info(cds)("Removing unshareable information ... ");
1066   remove_unshareable_in_classes();
1067   log_info(cds)("done. ");
1068 
1069   builder.gather_source_objs();
1070 
1071   MetaspaceShared::allocate_cloned_cpp_vtptrs();
1072   char* cloned_vtables = _mc_region.top();
1073   MetaspaceShared::allocate_cpp_vtable_clones();
1074 
1075   {
1076     _mc_region.pack(&_rw_region);
1077     builder.dump_rw_region();
1078 #if INCLUDE_CDS_JAVA_HEAP

1079     // Archive the ModuleEntry's and PackageEntry's of the 3 built-in loaders
1080     char* start = _rw_region.top();
1081     ClassLoaderDataShared::allocate_archived_tables();
1082     ArchiveBuilder::alloc_stats()->record_modules(_rw_region.top() - start, /*read_only*/false);

1083 #endif
1084   }
1085   {
1086     _rw_region.pack(&_ro_region);
1087     builder.dump_ro_region();
1088 #if INCLUDE_CDS_JAVA_HEAP

1089     char* start = _ro_region.top();
1090     ClassLoaderDataShared::init_archived_tables();
1091     ArchiveBuilder::alloc_stats()->record_modules(_ro_region.top() - start, /*read_only*/true);

1092 #endif
1093   }
1094   builder.relocate_pointers();
1095 
1096   dump_symbols();
1097 
1098   // Dump supported java heap objects
1099   _closed_archive_heap_regions = NULL;
1100   _open_archive_heap_regions = NULL;
1101   dump_java_heap_objects();
1102 
1103   builder.relocate_well_known_klasses();
1104 
1105   char* serialized_data = dump_read_only_tables();
1106   _ro_region.pack();
1107 
1108   // The vtable clones contain addresses of the current process.
1109   // We don't want to write these addresses into the archive. Same for i2i buffer.
1110   MetaspaceShared::zero_cpp_vtable_clones_for_writing();
1111   memset(MetaspaceShared::i2i_entry_code_buffers(), 0,


2043 void MetaspaceShared::report_out_of_space(const char* name, size_t needed_bytes) {
2044   // This is highly unlikely to happen on 64-bits because we have reserved a 4GB space.
2045   // On 32-bit we reserve only 256MB so you could run out of space with 100,000 classes
2046   // or so.
2047   _mc_region.print_out_of_space_msg(name, needed_bytes);
2048   _rw_region.print_out_of_space_msg(name, needed_bytes);
2049   _ro_region.print_out_of_space_msg(name, needed_bytes);
2050 
2051   vm_exit_during_initialization(err_msg("Unable to allocate from '%s' region", name),
2052                                 "Please reduce the number of shared classes.");
2053 }
2054 
2055 // This is used to relocate the pointers so that the base archive can be mapped at
2056 // MetaspaceShared::requested_base_address() without runtime relocation.
2057 intx MetaspaceShared::final_delta() {
2058   return intx(MetaspaceShared::requested_base_address())  // We want the base archive to be mapped to here at runtime
2059        - intx(SharedBaseAddress);                         // .. but the base archive is mapped at here at dump time
2060 }
2061 
2062 bool MetaspaceShared::use_full_module_graph() {
2063   return _use_optimized_module_handling && _use_full_module_graph &&
2064     (UseSharedSpaces || DumpSharedSpaces) && HeapShared::is_heap_object_archiving_allowed();






2065 }
2066 
2067 void MetaspaceShared::print_on(outputStream* st) {
2068   if (UseSharedSpaces || DumpSharedSpaces) {
2069     st->print("CDS archive(s) mapped at: ");
2070     address base;
2071     address top;
2072     if (UseSharedSpaces) { // Runtime
2073       base = (address)MetaspaceObj::shared_metaspace_base();
2074       address static_top = (address)_shared_metaspace_static_top;
2075       top = (address)MetaspaceObj::shared_metaspace_top();
2076       st->print("[" PTR_FORMAT "-" PTR_FORMAT "-" PTR_FORMAT "), ", p2i(base), p2i(static_top), p2i(top));
2077     } else if (DumpSharedSpaces) { // Dump Time
2078       base = (address)_shared_rs.base();
2079       top = (address)_shared_rs.end();
2080       st->print("[" PTR_FORMAT "-" PTR_FORMAT "), ", p2i(base), p2i(top));
2081     }
2082     st->print("size " SIZE_FORMAT ", ", top - base);
2083     st->print("SharedBaseAddress: " PTR_FORMAT ", ArchiveRelocationMode: %d.", SharedBaseAddress, (int)ArchiveRelocationMode);
2084   } else {


1059   // Ensure the ConstMethods won't be modified at run-time
1060   log_info(cds)("Updating ConstMethods ... ");
1061   rewrite_nofast_bytecodes_and_calculate_fingerprints(THREAD);
1062   log_info(cds)("done. ");
1063 
1064   // Remove all references outside the metadata
1065   log_info(cds)("Removing unshareable information ... ");
1066   remove_unshareable_in_classes();
1067   log_info(cds)("done. ");
1068 
1069   builder.gather_source_objs();
1070 
1071   MetaspaceShared::allocate_cloned_cpp_vtptrs();
1072   char* cloned_vtables = _mc_region.top();
1073   MetaspaceShared::allocate_cpp_vtable_clones();
1074 
1075   {
1076     _mc_region.pack(&_rw_region);
1077     builder.dump_rw_region();
1078 #if INCLUDE_CDS_JAVA_HEAP
1079     if (MetaspaceShared::use_full_module_graph()) {    
1080       // Archive the ModuleEntry's and PackageEntry's of the 3 built-in loaders
1081       char* start = _rw_region.top();
1082       ClassLoaderDataShared::allocate_archived_tables();
1083       ArchiveBuilder::alloc_stats()->record_modules(_rw_region.top() - start, /*read_only*/false);
1084     }
1085 #endif
1086   }
1087   {
1088     _rw_region.pack(&_ro_region);
1089     builder.dump_ro_region();
1090 #if INCLUDE_CDS_JAVA_HEAP
1091     if (MetaspaceShared::use_full_module_graph()) {    
1092       char* start = _ro_region.top();
1093       ClassLoaderDataShared::init_archived_tables();
1094       ArchiveBuilder::alloc_stats()->record_modules(_ro_region.top() - start, /*read_only*/true);
1095     }
1096 #endif
1097   }
1098   builder.relocate_pointers();
1099 
1100   dump_symbols();
1101 
1102   // Dump supported java heap objects
1103   _closed_archive_heap_regions = NULL;
1104   _open_archive_heap_regions = NULL;
1105   dump_java_heap_objects();
1106 
1107   builder.relocate_well_known_klasses();
1108 
1109   char* serialized_data = dump_read_only_tables();
1110   _ro_region.pack();
1111 
1112   // The vtable clones contain addresses of the current process.
1113   // We don't want to write these addresses into the archive. Same for i2i buffer.
1114   MetaspaceShared::zero_cpp_vtable_clones_for_writing();
1115   memset(MetaspaceShared::i2i_entry_code_buffers(), 0,


2047 void MetaspaceShared::report_out_of_space(const char* name, size_t needed_bytes) {
2048   // This is highly unlikely to happen on 64-bits because we have reserved a 4GB space.
2049   // On 32-bit we reserve only 256MB so you could run out of space with 100,000 classes
2050   // or so.
2051   _mc_region.print_out_of_space_msg(name, needed_bytes);
2052   _rw_region.print_out_of_space_msg(name, needed_bytes);
2053   _ro_region.print_out_of_space_msg(name, needed_bytes);
2054 
2055   vm_exit_during_initialization(err_msg("Unable to allocate from '%s' region", name),
2056                                 "Please reduce the number of shared classes.");
2057 }
2058 
2059 // This is used to relocate the pointers so that the base archive can be mapped at
2060 // MetaspaceShared::requested_base_address() without runtime relocation.
2061 intx MetaspaceShared::final_delta() {
2062   return intx(MetaspaceShared::requested_base_address())  // We want the base archive to be mapped to here at runtime
2063        - intx(SharedBaseAddress);                         // .. but the base archive is mapped at here at dump time
2064 }
2065 
2066 bool MetaspaceShared::use_full_module_graph() {
2067   bool result = _use_optimized_module_handling && _use_full_module_graph &&
2068     (UseSharedSpaces || DumpSharedSpaces) && HeapShared::is_heap_object_archiving_allowed();
2069   if (result && UseSharedSpaces) {
2070     // Classes used by the archived full module graph are loaded in JVMTI early phase.
2071     assert(!(JvmtiExport::should_post_class_file_load_hook() && JvmtiExport::has_early_class_hook_env()),
2072            "CDS should be disabled if early class hooks are enabled");
2073   }
2074   return result;
2075 }
2076 
2077 void MetaspaceShared::print_on(outputStream* st) {
2078   if (UseSharedSpaces || DumpSharedSpaces) {
2079     st->print("CDS archive(s) mapped at: ");
2080     address base;
2081     address top;
2082     if (UseSharedSpaces) { // Runtime
2083       base = (address)MetaspaceObj::shared_metaspace_base();
2084       address static_top = (address)_shared_metaspace_static_top;
2085       top = (address)MetaspaceObj::shared_metaspace_top();
2086       st->print("[" PTR_FORMAT "-" PTR_FORMAT "-" PTR_FORMAT "), ", p2i(base), p2i(static_top), p2i(top));
2087     } else if (DumpSharedSpaces) { // Dump Time
2088       base = (address)_shared_rs.base();
2089       top = (address)_shared_rs.end();
2090       st->print("[" PTR_FORMAT "-" PTR_FORMAT "), ", p2i(base), p2i(top));
2091     }
2092     st->print("size " SIZE_FORMAT ", ", top - base);
2093     st->print("SharedBaseAddress: " PTR_FORMAT ", ArchiveRelocationMode: %d.", SharedBaseAddress, (int)ArchiveRelocationMode);
2094   } else {
< prev index next >