< prev index next >

src/hotspot/share/cds/filemap.cpp

Print this page

 186 void FileMapHeader::populate(FileMapInfo *info, size_t core_region_alignment,
 187                              size_t header_size, size_t base_archive_name_size,
 188                              size_t base_archive_name_offset, size_t common_app_classpath_prefix_size) {
 189   // 1. We require _generic_header._magic to be at the beginning of the file
 190   // 2. FileMapHeader also assumes that _generic_header is at the beginning of the file
 191   assert(offset_of(FileMapHeader, _generic_header) == 0, "must be");
 192   set_header_size((unsigned int)header_size);
 193   set_base_archive_name_offset((unsigned int)base_archive_name_offset);
 194   set_base_archive_name_size((unsigned int)base_archive_name_size);
 195   set_common_app_classpath_prefix_size((unsigned int)common_app_classpath_prefix_size);
 196   set_magic(DynamicDumpSharedSpaces ? CDS_DYNAMIC_ARCHIVE_MAGIC : CDS_ARCHIVE_MAGIC);
 197   set_version(CURRENT_CDS_ARCHIVE_VERSION);
 198 
 199   if (!info->is_static() && base_archive_name_size != 0) {
 200     // copy base archive name
 201     copy_base_archive_name(Arguments::GetSharedArchivePath());
 202   }
 203   _core_region_alignment = core_region_alignment;
 204   _obj_alignment = ObjectAlignmentInBytes;
 205   _compact_strings = CompactStrings;

 206   if (DumpSharedSpaces && HeapShared::can_write()) {
 207     _narrow_oop_mode = CompressedOops::mode();
 208     _narrow_oop_base = CompressedOops::base();
 209     _narrow_oop_shift = CompressedOops::shift();
 210     if (UseCompressedOops) {
 211       _heap_begin = CompressedOops::begin();
 212       _heap_end = CompressedOops::end();
 213     } else {
 214 #if INCLUDE_G1GC
 215       address start = (address)G1CollectedHeap::heap()->reserved().start();
 216       address end = (address)G1CollectedHeap::heap()->reserved().end();
 217       _heap_begin = HeapShared::to_requested_address(start);
 218       _heap_end = HeapShared::to_requested_address(end);
 219 #endif
 220     }
 221   }
 222   _compressed_oops = UseCompressedOops;
 223   _compressed_class_ptrs = UseCompressedClassPointers;
 224   _max_heap_size = MaxHeapSize;
 225   _narrow_klass_shift = CompressedKlassPointers::shift();

 264   st->print_cr("- magic:                          0x%08x", magic());
 265   st->print_cr("- crc:                            0x%08x", crc());
 266   st->print_cr("- version:                        0x%x", version());
 267   st->print_cr("- header_size:                    " UINT32_FORMAT, header_size());
 268   st->print_cr("- common_app_classpath_size:      " UINT32_FORMAT, common_app_classpath_prefix_size());
 269   st->print_cr("- base_archive_name_offset:       " UINT32_FORMAT, base_archive_name_offset());
 270   st->print_cr("- base_archive_name_size:         " UINT32_FORMAT, base_archive_name_size());
 271 
 272   for (int i = 0; i < NUM_CDS_REGIONS; i++) {
 273     FileMapRegion* r = region_at(i);
 274     r->print(st, i);
 275   }
 276   st->print_cr("============ end regions ======== ");
 277 
 278   st->print_cr("- core_region_alignment:          " SIZE_FORMAT, _core_region_alignment);
 279   st->print_cr("- obj_alignment:                  %d", _obj_alignment);
 280   st->print_cr("- narrow_oop_base:                " INTPTR_FORMAT, p2i(_narrow_oop_base));
 281   st->print_cr("- narrow_oop_base:                " INTPTR_FORMAT, p2i(_narrow_oop_base));
 282   st->print_cr("- narrow_oop_shift                %d", _narrow_oop_shift);
 283   st->print_cr("- compact_strings:                %d", _compact_strings);

 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_X, _cloned_vtables_offset);
 290   st->print_cr("- serialized_data_offset:         " SIZE_FORMAT_X, _serialized_data_offset);
 291   st->print_cr("- heap_begin:                     " INTPTR_FORMAT, p2i(_heap_begin));
 292   st->print_cr("- heap_end:                       " INTPTR_FORMAT, p2i(_heap_end));
 293   st->print_cr("- jvm_ident:                      %s", _jvm_ident);
 294   st->print_cr("- shared_path_table_offset:       " SIZE_FORMAT_X, _shared_path_table_offset);
 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);
 302   st->print_cr("- has_non_jar_in_classpath:       %d", _has_non_jar_in_classpath);
 303   st->print_cr("- requested_base_address:         " INTPTR_FORMAT, p2i(_requested_base_address));

2418   // while AllowArchivingWithJavaAgent is set during the current run.
2419   if (_allow_archiving_with_java_agent && !AllowArchivingWithJavaAgent) {
2420     log_warning(cds)("The setting of the AllowArchivingWithJavaAgent is different "
2421                                "from the setting in the shared archive.");
2422     return false;
2423   }
2424 
2425   if (_allow_archiving_with_java_agent) {
2426     log_warning(cds)("This archive was created with AllowArchivingWithJavaAgent. It should be used "
2427             "for testing purposes only and should not be used in a production environment");
2428   }
2429 
2430   log_info(cds)("Archive was created with UseCompressedOops = %d, UseCompressedClassPointers = %d",
2431                           compressed_oops(), compressed_class_pointers());
2432   if (compressed_oops() != UseCompressedOops || compressed_class_pointers() != UseCompressedClassPointers) {
2433     log_info(cds)("Unable to use shared archive.\nThe saved state of UseCompressedOops and UseCompressedClassPointers is "
2434                                "different from runtime, CDS will be disabled.");
2435     return false;
2436   }
2437 








2438   if (!_use_optimized_module_handling) {
2439     MetaspaceShared::disable_optimized_module_handling();
2440     log_info(cds)("optimized module handling: disabled because archive was created without optimized module handling");
2441   }
2442 
2443   if (!_use_full_module_graph) {
2444     MetaspaceShared::disable_full_module_graph();
2445     log_info(cds)("full module graph: disabled because archive was created without full module graph");
2446   }
2447 
2448   return true;
2449 }
2450 
2451 bool FileMapInfo::validate_header() {
2452   if (!header()->validate()) {
2453     return false;
2454   }
2455   if (_is_static) {
2456     return true;
2457   } else {

 186 void FileMapHeader::populate(FileMapInfo *info, size_t core_region_alignment,
 187                              size_t header_size, size_t base_archive_name_size,
 188                              size_t base_archive_name_offset, size_t common_app_classpath_prefix_size) {
 189   // 1. We require _generic_header._magic to be at the beginning of the file
 190   // 2. FileMapHeader also assumes that _generic_header is at the beginning of the file
 191   assert(offset_of(FileMapHeader, _generic_header) == 0, "must be");
 192   set_header_size((unsigned int)header_size);
 193   set_base_archive_name_offset((unsigned int)base_archive_name_offset);
 194   set_base_archive_name_size((unsigned int)base_archive_name_size);
 195   set_common_app_classpath_prefix_size((unsigned int)common_app_classpath_prefix_size);
 196   set_magic(DynamicDumpSharedSpaces ? CDS_DYNAMIC_ARCHIVE_MAGIC : CDS_ARCHIVE_MAGIC);
 197   set_version(CURRENT_CDS_ARCHIVE_VERSION);
 198 
 199   if (!info->is_static() && base_archive_name_size != 0) {
 200     // copy base archive name
 201     copy_base_archive_name(Arguments::GetSharedArchivePath());
 202   }
 203   _core_region_alignment = core_region_alignment;
 204   _obj_alignment = ObjectAlignmentInBytes;
 205   _compact_strings = CompactStrings;
 206   _compact_headers = UseCompactObjectHeaders;
 207   if (DumpSharedSpaces && HeapShared::can_write()) {
 208     _narrow_oop_mode = CompressedOops::mode();
 209     _narrow_oop_base = CompressedOops::base();
 210     _narrow_oop_shift = CompressedOops::shift();
 211     if (UseCompressedOops) {
 212       _heap_begin = CompressedOops::begin();
 213       _heap_end = CompressedOops::end();
 214     } else {
 215 #if INCLUDE_G1GC
 216       address start = (address)G1CollectedHeap::heap()->reserved().start();
 217       address end = (address)G1CollectedHeap::heap()->reserved().end();
 218       _heap_begin = HeapShared::to_requested_address(start);
 219       _heap_end = HeapShared::to_requested_address(end);
 220 #endif
 221     }
 222   }
 223   _compressed_oops = UseCompressedOops;
 224   _compressed_class_ptrs = UseCompressedClassPointers;
 225   _max_heap_size = MaxHeapSize;
 226   _narrow_klass_shift = CompressedKlassPointers::shift();

 265   st->print_cr("- magic:                          0x%08x", magic());
 266   st->print_cr("- crc:                            0x%08x", crc());
 267   st->print_cr("- version:                        0x%x", version());
 268   st->print_cr("- header_size:                    " UINT32_FORMAT, header_size());
 269   st->print_cr("- common_app_classpath_size:      " UINT32_FORMAT, common_app_classpath_prefix_size());
 270   st->print_cr("- base_archive_name_offset:       " UINT32_FORMAT, base_archive_name_offset());
 271   st->print_cr("- base_archive_name_size:         " UINT32_FORMAT, base_archive_name_size());
 272 
 273   for (int i = 0; i < NUM_CDS_REGIONS; i++) {
 274     FileMapRegion* r = region_at(i);
 275     r->print(st, i);
 276   }
 277   st->print_cr("============ end regions ======== ");
 278 
 279   st->print_cr("- core_region_alignment:          " SIZE_FORMAT, _core_region_alignment);
 280   st->print_cr("- obj_alignment:                  %d", _obj_alignment);
 281   st->print_cr("- narrow_oop_base:                " INTPTR_FORMAT, p2i(_narrow_oop_base));
 282   st->print_cr("- narrow_oop_base:                " INTPTR_FORMAT, p2i(_narrow_oop_base));
 283   st->print_cr("- narrow_oop_shift                %d", _narrow_oop_shift);
 284   st->print_cr("- compact_strings:                %d", _compact_strings);
 285   st->print_cr("- compact_headers:                %d", _compact_headers);
 286   st->print_cr("- max_heap_size:                  " UINTX_FORMAT, _max_heap_size);
 287   st->print_cr("- narrow_oop_mode:                %d", _narrow_oop_mode);
 288   st->print_cr("- narrow_klass_shift:             %d", _narrow_klass_shift);
 289   st->print_cr("- compressed_oops:                %d", _compressed_oops);
 290   st->print_cr("- compressed_class_ptrs:          %d", _compressed_class_ptrs);
 291   st->print_cr("- cloned_vtables_offset:          " SIZE_FORMAT_X, _cloned_vtables_offset);
 292   st->print_cr("- serialized_data_offset:         " SIZE_FORMAT_X, _serialized_data_offset);
 293   st->print_cr("- heap_begin:                     " INTPTR_FORMAT, p2i(_heap_begin));
 294   st->print_cr("- heap_end:                       " INTPTR_FORMAT, p2i(_heap_end));
 295   st->print_cr("- jvm_ident:                      %s", _jvm_ident);
 296   st->print_cr("- shared_path_table_offset:       " SIZE_FORMAT_X, _shared_path_table_offset);
 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);
 304   st->print_cr("- has_non_jar_in_classpath:       %d", _has_non_jar_in_classpath);
 305   st->print_cr("- requested_base_address:         " INTPTR_FORMAT, p2i(_requested_base_address));

2420   // while AllowArchivingWithJavaAgent is set during the current run.
2421   if (_allow_archiving_with_java_agent && !AllowArchivingWithJavaAgent) {
2422     log_warning(cds)("The setting of the AllowArchivingWithJavaAgent is different "
2423                                "from the setting in the shared archive.");
2424     return false;
2425   }
2426 
2427   if (_allow_archiving_with_java_agent) {
2428     log_warning(cds)("This archive was created with AllowArchivingWithJavaAgent. It should be used "
2429             "for testing purposes only and should not be used in a production environment");
2430   }
2431 
2432   log_info(cds)("Archive was created with UseCompressedOops = %d, UseCompressedClassPointers = %d",
2433                           compressed_oops(), compressed_class_pointers());
2434   if (compressed_oops() != UseCompressedOops || compressed_class_pointers() != UseCompressedClassPointers) {
2435     log_info(cds)("Unable to use shared archive.\nThe saved state of UseCompressedOops and UseCompressedClassPointers is "
2436                                "different from runtime, CDS will be disabled.");
2437     return false;
2438   }
2439 
2440   if (compact_headers() != UseCompactObjectHeaders) {
2441     log_info(cds)("The shared archive file's UseCompactObjectHeaders setting (%s)"
2442                   " does not equal the current UseCompactObjectHeaders setting (%s).",
2443                   _compact_headers          ? "enabled" : "disabled",
2444                   UseCompactObjectHeaders   ? "enabled" : "disabled");
2445     return false;
2446   }
2447 
2448   if (!_use_optimized_module_handling) {
2449     MetaspaceShared::disable_optimized_module_handling();
2450     log_info(cds)("optimized module handling: disabled because archive was created without optimized module handling");
2451   }
2452 
2453   if (!_use_full_module_graph) {
2454     MetaspaceShared::disable_full_module_graph();
2455     log_info(cds)("full module graph: disabled because archive was created without full module graph");
2456   }
2457 
2458   return true;
2459 }
2460 
2461 bool FileMapInfo::validate_header() {
2462   if (!header()->validate()) {
2463     return false;
2464   }
2465   if (_is_static) {
2466     return true;
2467   } else {
< prev index next >