< prev index next >

src/hotspot/share/cds/filemap.cpp

Print this page

 200 
 201   if (_file_open) {
 202     ::close(_fd);
 203   }
 204 }
 205 
 206 void FileMapInfo::populate_header(size_t core_region_alignment) {
 207   header()->populate(this, core_region_alignment);
 208 }
 209 
 210 void FileMapHeader::populate(FileMapInfo* mapinfo, size_t core_region_alignment) {
 211   if (DynamicDumpSharedSpaces) {
 212     _magic = CDS_DYNAMIC_ARCHIVE_MAGIC;
 213   } else {
 214     _magic = CDS_ARCHIVE_MAGIC;
 215   }
 216   _version = CURRENT_CDS_ARCHIVE_VERSION;
 217   _core_region_alignment = core_region_alignment;
 218   _obj_alignment = ObjectAlignmentInBytes;
 219   _compact_strings = CompactStrings;

 220   if (HeapShared::is_heap_object_archiving_allowed()) {
 221     _narrow_oop_mode = CompressedOops::mode();
 222     _narrow_oop_base = CompressedOops::base();
 223     _narrow_oop_shift = CompressedOops::shift();
 224     _heap_begin = CompressedOops::begin();
 225     _heap_end = CompressedOops::end();
 226   }
 227   _compressed_oops = UseCompressedOops;
 228   _compressed_class_ptrs = UseCompressedClassPointers;
 229   _max_heap_size = MaxHeapSize;
 230   _narrow_klass_shift = CompressedKlassPointers::shift();
 231   _use_optimized_module_handling = MetaspaceShared::use_optimized_module_handling();
 232   _use_full_module_graph = MetaspaceShared::use_full_module_graph();
 233 
 234   // The following fields are for sanity checks for whether this archive
 235   // will function correctly with this JVM and the bootclasspath it's
 236   // invoked with.
 237 
 238   // JVM version string ... changes on each build.
 239   get_header_version(_jvm_ident);

 262 void FileMapHeader::print(outputStream* st) {
 263   ResourceMark rm;
 264 
 265   st->print_cr("- magic:                          0x%08x", _magic);
 266   st->print_cr("- crc:                            0x%08x", _crc);
 267   st->print_cr("- version:                        %d", _version);
 268 
 269   for (int i = 0; i < NUM_CDS_REGIONS; i++) {
 270     FileMapRegion* si = space_at(i);
 271     si->print(st, i);
 272   }
 273   st->print_cr("============ end regions ======== ");
 274 
 275   st->print_cr("- header_size:                    " SIZE_FORMAT, _header_size);
 276   st->print_cr("- core_region_alignment:          " SIZE_FORMAT, _core_region_alignment);
 277   st->print_cr("- obj_alignment:                  %d", _obj_alignment);
 278   st->print_cr("- narrow_oop_base:                " INTPTR_FORMAT, p2i(_narrow_oop_base));
 279   st->print_cr("- narrow_oop_base:                " INTPTR_FORMAT, p2i(_narrow_oop_base));
 280   st->print_cr("- narrow_oop_shift                %d", _narrow_oop_shift);
 281   st->print_cr("- compact_strings:                %d", _compact_strings);

 282   st->print_cr("- max_heap_size:                  " UINTX_FORMAT, _max_heap_size);
 283   st->print_cr("- narrow_oop_mode:                %d", _narrow_oop_mode);
 284   st->print_cr("- narrow_klass_shift:             %d", _narrow_klass_shift);
 285   st->print_cr("- compressed_oops:                %d", _compressed_oops);
 286   st->print_cr("- compressed_class_ptrs:          %d", _compressed_class_ptrs);
 287   st->print_cr("- cloned_vtables_offset:          " SIZE_FORMAT_HEX, _cloned_vtables_offset);
 288   st->print_cr("- serialized_data_offset:         " SIZE_FORMAT_HEX, _serialized_data_offset);
 289   st->print_cr("- heap_end:                       " INTPTR_FORMAT, p2i(_heap_end));
 290   st->print_cr("- base_archive_is_default:        %d", _base_archive_is_default);
 291   st->print_cr("- jvm_ident:                      %s", _jvm_ident);
 292   st->print_cr("- base_archive_name_size:         " SIZE_FORMAT, _base_archive_name_size);
 293   st->print_cr("- shared_path_table_offset:       " SIZE_FORMAT_HEX, _shared_path_table_offset);
 294   st->print_cr("- shared_path_table_size:         %d", _shared_path_table_size);
 295   st->print_cr("- app_class_paths_start_index:    %d", _app_class_paths_start_index);
 296   st->print_cr("- app_module_paths_start_index:   %d", _app_module_paths_start_index);
 297   st->print_cr("- num_module_paths:               %d", _num_module_paths);
 298   st->print_cr("- max_used_path_index:            %d", _max_used_path_index);
 299   st->print_cr("- verify_local:                   %d", _verify_local);
 300   st->print_cr("- verify_remote:                  %d", _verify_remote);
 301   st->print_cr("- has_platform_or_app_classes:    %d", _has_platform_or_app_classes);

2241   // while AllowArchivingWithJavaAgent is set during the current run.
2242   if (_allow_archiving_with_java_agent && !AllowArchivingWithJavaAgent) {
2243     FileMapInfo::fail_continue("The setting of the AllowArchivingWithJavaAgent is different "
2244                                "from the setting in the shared archive.");
2245     return false;
2246   }
2247 
2248   if (_allow_archiving_with_java_agent) {
2249     warning("This archive was created with AllowArchivingWithJavaAgent. It should be used "
2250             "for testing purposes only and should not be used in a production environment");
2251   }
2252 
2253   log_info(cds)("Archive was created with UseCompressedOops = %d, UseCompressedClassPointers = %d",
2254                           compressed_oops(), compressed_class_pointers());
2255   if (compressed_oops() != UseCompressedOops || compressed_class_pointers() != UseCompressedClassPointers) {
2256     FileMapInfo::fail_continue("Unable to use shared archive.\nThe saved state of UseCompressedOops and UseCompressedClassPointers is "
2257                                "different from runtime, CDS will be disabled.");
2258     return false;
2259   }
2260 








2261   if (!_use_optimized_module_handling) {
2262     MetaspaceShared::disable_optimized_module_handling();
2263     log_info(cds)("optimized module handling: disabled because archive was created without optimized module handling");
2264   }
2265 
2266   if (!_use_full_module_graph) {
2267     MetaspaceShared::disable_full_module_graph();
2268     log_info(cds)("full module graph: disabled because archive was created without full module graph");
2269   }
2270 
2271   return true;
2272 }
2273 
2274 bool FileMapInfo::validate_header() {
2275   if (!header()->validate()) {
2276     return false;
2277   }
2278   if (_is_static) {
2279     return true;
2280   } else {

 200 
 201   if (_file_open) {
 202     ::close(_fd);
 203   }
 204 }
 205 
 206 void FileMapInfo::populate_header(size_t core_region_alignment) {
 207   header()->populate(this, core_region_alignment);
 208 }
 209 
 210 void FileMapHeader::populate(FileMapInfo* mapinfo, size_t core_region_alignment) {
 211   if (DynamicDumpSharedSpaces) {
 212     _magic = CDS_DYNAMIC_ARCHIVE_MAGIC;
 213   } else {
 214     _magic = CDS_ARCHIVE_MAGIC;
 215   }
 216   _version = CURRENT_CDS_ARCHIVE_VERSION;
 217   _core_region_alignment = core_region_alignment;
 218   _obj_alignment = ObjectAlignmentInBytes;
 219   _compact_strings = CompactStrings;
 220   _compact_headers = UseCompactObjectHeaders;
 221   if (HeapShared::is_heap_object_archiving_allowed()) {
 222     _narrow_oop_mode = CompressedOops::mode();
 223     _narrow_oop_base = CompressedOops::base();
 224     _narrow_oop_shift = CompressedOops::shift();
 225     _heap_begin = CompressedOops::begin();
 226     _heap_end = CompressedOops::end();
 227   }
 228   _compressed_oops = UseCompressedOops;
 229   _compressed_class_ptrs = UseCompressedClassPointers;
 230   _max_heap_size = MaxHeapSize;
 231   _narrow_klass_shift = CompressedKlassPointers::shift();
 232   _use_optimized_module_handling = MetaspaceShared::use_optimized_module_handling();
 233   _use_full_module_graph = MetaspaceShared::use_full_module_graph();
 234 
 235   // The following fields are for sanity checks for whether this archive
 236   // will function correctly with this JVM and the bootclasspath it's
 237   // invoked with.
 238 
 239   // JVM version string ... changes on each build.
 240   get_header_version(_jvm_ident);

 263 void FileMapHeader::print(outputStream* st) {
 264   ResourceMark rm;
 265 
 266   st->print_cr("- magic:                          0x%08x", _magic);
 267   st->print_cr("- crc:                            0x%08x", _crc);
 268   st->print_cr("- version:                        %d", _version);
 269 
 270   for (int i = 0; i < NUM_CDS_REGIONS; i++) {
 271     FileMapRegion* si = space_at(i);
 272     si->print(st, i);
 273   }
 274   st->print_cr("============ end regions ======== ");
 275 
 276   st->print_cr("- header_size:                    " SIZE_FORMAT, _header_size);
 277   st->print_cr("- core_region_alignment:          " SIZE_FORMAT, _core_region_alignment);
 278   st->print_cr("- obj_alignment:                  %d", _obj_alignment);
 279   st->print_cr("- narrow_oop_base:                " INTPTR_FORMAT, p2i(_narrow_oop_base));
 280   st->print_cr("- narrow_oop_base:                " INTPTR_FORMAT, p2i(_narrow_oop_base));
 281   st->print_cr("- narrow_oop_shift                %d", _narrow_oop_shift);
 282   st->print_cr("- compact_strings:                %d", _compact_strings);
 283   st->print_cr("- compact_headers:                %d", _compact_headers);
 284   st->print_cr("- max_heap_size:                  " UINTX_FORMAT, _max_heap_size);
 285   st->print_cr("- narrow_oop_mode:                %d", _narrow_oop_mode);
 286   st->print_cr("- narrow_klass_shift:             %d", _narrow_klass_shift);
 287   st->print_cr("- compressed_oops:                %d", _compressed_oops);
 288   st->print_cr("- compressed_class_ptrs:          %d", _compressed_class_ptrs);
 289   st->print_cr("- cloned_vtables_offset:          " SIZE_FORMAT_HEX, _cloned_vtables_offset);
 290   st->print_cr("- serialized_data_offset:         " SIZE_FORMAT_HEX, _serialized_data_offset);
 291   st->print_cr("- heap_end:                       " INTPTR_FORMAT, p2i(_heap_end));
 292   st->print_cr("- base_archive_is_default:        %d", _base_archive_is_default);
 293   st->print_cr("- jvm_ident:                      %s", _jvm_ident);
 294   st->print_cr("- base_archive_name_size:         " SIZE_FORMAT, _base_archive_name_size);
 295   st->print_cr("- shared_path_table_offset:       " SIZE_FORMAT_HEX, _shared_path_table_offset);
 296   st->print_cr("- shared_path_table_size:         %d", _shared_path_table_size);
 297   st->print_cr("- app_class_paths_start_index:    %d", _app_class_paths_start_index);
 298   st->print_cr("- app_module_paths_start_index:   %d", _app_module_paths_start_index);
 299   st->print_cr("- num_module_paths:               %d", _num_module_paths);
 300   st->print_cr("- max_used_path_index:            %d", _max_used_path_index);
 301   st->print_cr("- verify_local:                   %d", _verify_local);
 302   st->print_cr("- verify_remote:                  %d", _verify_remote);
 303   st->print_cr("- has_platform_or_app_classes:    %d", _has_platform_or_app_classes);

2243   // while AllowArchivingWithJavaAgent is set during the current run.
2244   if (_allow_archiving_with_java_agent && !AllowArchivingWithJavaAgent) {
2245     FileMapInfo::fail_continue("The setting of the AllowArchivingWithJavaAgent is different "
2246                                "from the setting in the shared archive.");
2247     return false;
2248   }
2249 
2250   if (_allow_archiving_with_java_agent) {
2251     warning("This archive was created with AllowArchivingWithJavaAgent. It should be used "
2252             "for testing purposes only and should not be used in a production environment");
2253   }
2254 
2255   log_info(cds)("Archive was created with UseCompressedOops = %d, UseCompressedClassPointers = %d",
2256                           compressed_oops(), compressed_class_pointers());
2257   if (compressed_oops() != UseCompressedOops || compressed_class_pointers() != UseCompressedClassPointers) {
2258     FileMapInfo::fail_continue("Unable to use shared archive.\nThe saved state of UseCompressedOops and UseCompressedClassPointers is "
2259                                "different from runtime, CDS will be disabled.");
2260     return false;
2261   }
2262 
2263   if (compact_headers() != UseCompactObjectHeaders) {
2264     log_info(cds)("The shared archive file's UseCompactObjectHeaders setting (%s)"
2265                   " does not equal the current UseCompactObjectHeaders setting (%s).",
2266                   _compact_headers          ? "enabled" : "disabled",
2267                   UseCompactObjectHeaders   ? "enabled" : "disabled");
2268     return false;
2269   }
2270 
2271   if (!_use_optimized_module_handling) {
2272     MetaspaceShared::disable_optimized_module_handling();
2273     log_info(cds)("optimized module handling: disabled because archive was created without optimized module handling");
2274   }
2275 
2276   if (!_use_full_module_graph) {
2277     MetaspaceShared::disable_full_module_graph();
2278     log_info(cds)("full module graph: disabled because archive was created without full module graph");
2279   }
2280 
2281   return true;
2282 }
2283 
2284 bool FileMapInfo::validate_header() {
2285   if (!header()->validate()) {
2286     return false;
2287   }
2288   if (_is_static) {
2289     return true;
2290   } else {
< prev index next >