< 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));

2391   // while AllowArchivingWithJavaAgent is set during the current run.
2392   if (_allow_archiving_with_java_agent && !AllowArchivingWithJavaAgent) {
2393     log_warning(cds)("The setting of the AllowArchivingWithJavaAgent is different "
2394                                "from the setting in the shared archive.");
2395     return false;
2396   }
2397 
2398   if (_allow_archiving_with_java_agent) {
2399     log_warning(cds)("This archive was created with AllowArchivingWithJavaAgent. It should be used "
2400             "for testing purposes only and should not be used in a production environment");
2401   }
2402 
2403   log_info(cds)("Archive was created with UseCompressedOops = %d, UseCompressedClassPointers = %d",
2404                           compressed_oops(), compressed_class_pointers());
2405   if (compressed_oops() != UseCompressedOops || compressed_class_pointers() != UseCompressedClassPointers) {
2406     log_info(cds)("Unable to use shared archive.\nThe saved state of UseCompressedOops and UseCompressedClassPointers is "
2407                                "different from runtime, CDS will be disabled.");
2408     return false;
2409   }
2410 








2411   if (!_use_optimized_module_handling) {
2412     MetaspaceShared::disable_optimized_module_handling();
2413     log_info(cds)("optimized module handling: disabled because archive was created without optimized module handling");
2414   }
2415 
2416   if (!_use_full_module_graph) {
2417     MetaspaceShared::disable_full_module_graph();
2418     log_info(cds)("full module graph: disabled because archive was created without full module graph");
2419   }
2420 
2421   return true;
2422 }
2423 
2424 bool FileMapInfo::validate_header() {
2425   if (!header()->validate()) {
2426     return false;
2427   }
2428   if (_is_static) {
2429     return true;
2430   } 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));

2393   // while AllowArchivingWithJavaAgent is set during the current run.
2394   if (_allow_archiving_with_java_agent && !AllowArchivingWithJavaAgent) {
2395     log_warning(cds)("The setting of the AllowArchivingWithJavaAgent is different "
2396                                "from the setting in the shared archive.");
2397     return false;
2398   }
2399 
2400   if (_allow_archiving_with_java_agent) {
2401     log_warning(cds)("This archive was created with AllowArchivingWithJavaAgent. It should be used "
2402             "for testing purposes only and should not be used in a production environment");
2403   }
2404 
2405   log_info(cds)("Archive was created with UseCompressedOops = %d, UseCompressedClassPointers = %d",
2406                           compressed_oops(), compressed_class_pointers());
2407   if (compressed_oops() != UseCompressedOops || compressed_class_pointers() != UseCompressedClassPointers) {
2408     log_info(cds)("Unable to use shared archive.\nThe saved state of UseCompressedOops and UseCompressedClassPointers is "
2409                                "different from runtime, CDS will be disabled.");
2410     return false;
2411   }
2412 
2413   if (compact_headers() != UseCompactObjectHeaders) {
2414     log_info(cds)("The shared archive file's UseCompactObjectHeaders setting (%s)"
2415                   " does not equal the current UseCompactObjectHeaders setting (%s).",
2416                   _compact_headers          ? "enabled" : "disabled",
2417                   UseCompactObjectHeaders   ? "enabled" : "disabled");
2418     return false;
2419   }
2420 
2421   if (!_use_optimized_module_handling) {
2422     MetaspaceShared::disable_optimized_module_handling();
2423     log_info(cds)("optimized module handling: disabled because archive was created without optimized module handling");
2424   }
2425 
2426   if (!_use_full_module_graph) {
2427     MetaspaceShared::disable_full_module_graph();
2428     log_info(cds)("full module graph: disabled because archive was created without full module graph");
2429   }
2430 
2431   return true;
2432 }
2433 
2434 bool FileMapInfo::validate_header() {
2435   if (!header()->validate()) {
2436     return false;
2437   }
2438   if (_is_static) {
2439     return true;
2440   } else {
< prev index next >