< prev index next >

src/hotspot/share/cds/filemap.cpp

Print this page

  70 #include "runtime/mutexLocker.hpp"
  71 #include "runtime/os.hpp"
  72 #include "runtime/vm_version.hpp"
  73 #include "utilities/align.hpp"
  74 #include "utilities/bitMap.inline.hpp"
  75 #include "utilities/classpathStream.hpp"
  76 #include "utilities/defaultStream.hpp"
  77 #include "utilities/ostream.hpp"
  78 #if INCLUDE_G1GC
  79 #include "gc/g1/g1CollectedHeap.hpp"
  80 #include "gc/g1/g1HeapRegion.hpp"
  81 #endif
  82 
  83 #include <errno.h>
  84 #include <sys/stat.h>
  85 
  86 #ifndef O_BINARY       // if defined (Win32) use binary files.
  87 #define O_BINARY 0     // otherwise do nothing.
  88 #endif
  89 

































































  90 // Fill in the fileMapInfo structure with data about this VM instance.
  91 
  92 // This method copies the vm version info into header_version.  If the version is too
  93 // long then a truncated version, which has a hash code appended to it, is copied.
  94 //
  95 // Using a template enables this method to verify that header_version is an array of
  96 // length JVM_IDENT_MAX.  This ensures that the code that writes to the CDS file and
  97 // the code that reads the CDS file will both use the same size buffer.  Hence, will
  98 // use identical truncation.  This is necessary for matching of truncated versions.
  99 template <int N> static void get_header_version(char (&header_version) [N]) {
 100   assert(N == JVM_IDENT_MAX, "Bad header_version size");
 101 
 102   const char *vm_version = VM_Version::internal_vm_info_string();
 103   const int version_len = (int)strlen(vm_version);
 104 
 105   memset(header_version, 0, JVM_IDENT_MAX);
 106 
 107   if (version_len < (JVM_IDENT_MAX-1)) {
 108     strcpy(header_version, vm_version);
 109 

 229     _narrow_klass_pointer_bits = CompressedKlassPointers::narrow_klass_pointer_bits();
 230     _narrow_klass_shift = ArchiveBuilder::precomputed_narrow_klass_shift();
 231 #endif
 232   } else {
 233     _narrow_klass_pointer_bits = _narrow_klass_shift = -1;
 234   }
 235   // Which JIT compier is used
 236   _compiler_type = (u1)CompilerConfig::compiler_type();
 237   _type_profile_level = TypeProfileLevel;
 238   _type_profile_args_limit = TypeProfileArgsLimit;
 239   _type_profile_parms_limit = TypeProfileParmsLimit;
 240   _type_profile_width = TypeProfileWidth;
 241   _bci_profile_width = BciProfileWidth;
 242   _profile_traps = ProfileTraps;
 243   _type_profile_casts = TypeProfileCasts;
 244   _spec_trap_limit_extra_entries = SpecTrapLimitExtraEntries;
 245   _max_heap_size = MaxHeapSize;
 246   _use_optimized_module_handling = CDSConfig::is_using_optimized_module_handling();
 247   _has_aot_linked_classes = CDSConfig::is_dumping_aot_linked_classes();
 248   _has_full_module_graph = CDSConfig::is_dumping_full_module_graph();

 249 
 250   // The following fields are for sanity checks for whether this archive
 251   // will function correctly with this JVM and the bootclasspath it's
 252   // invoked with.
 253 
 254   // JVM version string ... changes on each build.
 255   get_header_version(_jvm_ident);
 256 
 257   _verify_local = BytecodeVerificationLocal;
 258   _verify_remote = BytecodeVerificationRemote;
 259   _has_platform_or_app_classes = AOTClassLocationConfig::dumptime()->has_platform_or_app_classes();
 260   _requested_base_address = (char*)SharedBaseAddress;
 261   _mapped_base_address = (char*)SharedBaseAddress;
 262   _allow_archiving_with_java_agent = AllowArchivingWithJavaAgent;

 263 }
 264 
 265 void FileMapHeader::copy_base_archive_name(const char* archive) {
 266   assert(base_archive_name_size() != 0, "_base_archive_name_size not set");
 267   assert(base_archive_name_offset() != 0, "_base_archive_name_offset not set");
 268   assert(header_size() > sizeof(*this), "_base_archive_name_size not included in header size?");
 269   memcpy((char*)this + base_archive_name_offset(), archive, base_archive_name_size());
 270 }
 271 
 272 void FileMapHeader::print(outputStream* st) {
 273   ResourceMark rm;
 274 
 275   st->print_cr("- magic:                          0x%08x", magic());
 276   st->print_cr("- crc:                            0x%08x", crc());
 277   st->print_cr("- version:                        0x%x", version());
 278   st->print_cr("- header_size:                    " UINT32_FORMAT, header_size());
 279   st->print_cr("- base_archive_name_offset:       " UINT32_FORMAT, base_archive_name_offset());
 280   st->print_cr("- base_archive_name_size:         " UINT32_FORMAT, base_archive_name_size());
 281 
 282   for (int i = 0; i < NUM_CDS_REGIONS; i++) {

 302   st->print_cr("- serialized_data_offset:         0x%zx", _serialized_data_offset);
 303   st->print_cr("- jvm_ident:                      %s", _jvm_ident);
 304   st->print_cr("- class_location_config_offset:   0x%zx", _class_location_config_offset);
 305   st->print_cr("- verify_local:                   %d", _verify_local);
 306   st->print_cr("- verify_remote:                  %d", _verify_remote);
 307   st->print_cr("- has_platform_or_app_classes:    %d", _has_platform_or_app_classes);
 308   st->print_cr("- requested_base_address:         " INTPTR_FORMAT, p2i(_requested_base_address));
 309   st->print_cr("- mapped_base_address:            " INTPTR_FORMAT, p2i(_mapped_base_address));
 310   st->print_cr("- heap_root_segments.roots_count: %d" , _heap_root_segments.roots_count());
 311   st->print_cr("- heap_root_segments.base_offset: 0x%zx", _heap_root_segments.base_offset());
 312   st->print_cr("- heap_root_segments.count:       %zu", _heap_root_segments.count());
 313   st->print_cr("- heap_root_segments.max_size_elems: %d", _heap_root_segments.max_size_in_elems());
 314   st->print_cr("- heap_root_segments.max_size_bytes: %d", _heap_root_segments.max_size_in_bytes());
 315   st->print_cr("- _heap_oopmap_start_pos:         %zu", _heap_oopmap_start_pos);
 316   st->print_cr("- _heap_ptrmap_start_pos:         %zu", _heap_ptrmap_start_pos);
 317   st->print_cr("- _rw_ptrmap_start_pos:           %zu", _rw_ptrmap_start_pos);
 318   st->print_cr("- _ro_ptrmap_start_pos:           %zu", _ro_ptrmap_start_pos);
 319   st->print_cr("- allow_archiving_with_java_agent:%d", _allow_archiving_with_java_agent);
 320   st->print_cr("- use_optimized_module_handling:  %d", _use_optimized_module_handling);
 321   st->print_cr("- has_full_module_graph           %d", _has_full_module_graph);


 322   st->print_cr("- has_aot_linked_classes          %d", _has_aot_linked_classes);
 323 }
 324 
 325 bool FileMapInfo::validate_class_location() {
 326   assert(CDSConfig::is_using_archive(), "runtime only");
 327 
 328   AOTClassLocationConfig* config = header()->class_location_config();
 329   bool has_extra_module_paths = false;
 330   if (!config->validate(full_path(), header()->has_aot_linked_classes(), &has_extra_module_paths)) {
 331     if (PrintSharedArchiveAndExit) {
 332       MetaspaceShared::set_archive_loading_failed();
 333       return true;
 334     } else {
 335       return false;
 336     }
 337   }
 338 
 339   if (header()->has_full_module_graph() && has_extra_module_paths) {
 340     CDSConfig::stop_using_optimized_module_handling();
 341     MetaspaceShared::report_loading_error("optimized module handling: disabled because extra module path(s) are specified");

 685   if (strncmp(actual_ident, expected_ident, JVM_IDENT_MAX-1) != 0) {
 686     aot_log_info(aot)("_jvm_ident expected: %s", expected_ident);
 687     aot_log_info(aot)("             actual: %s", actual_ident);
 688     aot_log_warning(aot)("The %s was created by a different"
 689                   " version or build of HotSpot", file_type);
 690     return false;
 691   }
 692 
 693   _file_offset = header()->header_size(); // accounts for the size of _base_archive_name
 694 
 695   size_t len = os::lseek(fd, 0, SEEK_END);
 696 
 697   for (int i = 0; i < MetaspaceShared::n_regions; i++) {
 698     FileMapRegion* r = region_at(i);
 699     if (r->file_offset() > len || len - r->file_offset() < r->used()) {
 700       aot_log_warning(aot)("The %s has been truncated.", file_type);
 701       return false;
 702     }
 703   }
 704 




 705   return true;
 706 }
 707 
 708 void FileMapInfo::seek_to_position(size_t pos) {
 709   if (os::lseek(_fd, (long)pos, SEEK_SET) < 0) {
 710     aot_log_error(aot)("Unable to seek to position %zu", pos);
 711     MetaspaceShared::unrecoverable_loading_error();
 712   }
 713 }
 714 
 715 // Read the FileMapInfo information from the file.
 716 bool FileMapInfo::open_for_read() {
 717   if (_file_open) {
 718     return true;
 719   }
 720   const char* file_type = CDSConfig::type_of_archive_being_loaded();
 721   const char* info = CDSConfig::is_dumping_final_static_archive() ?
 722     "AOTConfiguration file " : "";
 723   aot_log_info(aot)("trying to map %s%s", info, _full_path);
 724   int fd = os::open(_full_path, O_RDONLY | O_BINARY, 0);

2057   // while AllowArchivingWithJavaAgent is set during the current run.
2058   if (_allow_archiving_with_java_agent && !AllowArchivingWithJavaAgent) {
2059     MetaspaceShared::report_loading_error("The setting of the AllowArchivingWithJavaAgent is different "
2060                                           "from the setting in the %s.", file_type);
2061     return false;
2062   }
2063 
2064   if (_allow_archiving_with_java_agent) {
2065     aot_log_warning(aot)("This %s was created with AllowArchivingWithJavaAgent. It should be used "
2066             "for testing purposes only and should not be used in a production environment", file_type);
2067   }
2068 
2069   aot_log_info(aot)("The %s was created with UseCompressedOops = %d, UseCompressedClassPointers = %d, UseCompactObjectHeaders = %d",
2070                           file_type, compressed_oops(), compressed_class_pointers(), compact_headers());
2071   if (compressed_oops() != UseCompressedOops || compressed_class_pointers() != UseCompressedClassPointers) {
2072     aot_log_warning(aot)("Unable to use %s.\nThe saved state of UseCompressedOops and UseCompressedClassPointers is "
2073                                "different from runtime, CDS will be disabled.", file_type);
2074     return false;
2075   }
2076 


















2077   if (compact_headers() != UseCompactObjectHeaders) {
2078     aot_log_warning(aot)("Unable to use %s.\nThe %s's UseCompactObjectHeaders setting (%s)"
2079                      " does not equal the current UseCompactObjectHeaders setting (%s).", file_type, file_type,
2080                      _compact_headers          ? "enabled" : "disabled",
2081                      UseCompactObjectHeaders   ? "enabled" : "disabled");
2082     return false;
2083   }
2084 
2085   if (!_use_optimized_module_handling && !CDSConfig::is_dumping_final_static_archive()) {
2086     CDSConfig::stop_using_optimized_module_handling();
2087     aot_log_info(aot)("optimized module handling: disabled because archive was created without optimized module handling");
2088   }
2089 
2090   if (is_static()) {
2091     // Only the static archive can contain the full module graph.
2092     if (!_has_full_module_graph) {
2093       CDSConfig::stop_using_full_module_graph("archive was created without full module graph");
2094     }
2095   }
2096 

  70 #include "runtime/mutexLocker.hpp"
  71 #include "runtime/os.hpp"
  72 #include "runtime/vm_version.hpp"
  73 #include "utilities/align.hpp"
  74 #include "utilities/bitMap.inline.hpp"
  75 #include "utilities/classpathStream.hpp"
  76 #include "utilities/defaultStream.hpp"
  77 #include "utilities/ostream.hpp"
  78 #if INCLUDE_G1GC
  79 #include "gc/g1/g1CollectedHeap.hpp"
  80 #include "gc/g1/g1HeapRegion.hpp"
  81 #endif
  82 
  83 #include <errno.h>
  84 #include <sys/stat.h>
  85 
  86 #ifndef O_BINARY       // if defined (Win32) use binary files.
  87 #define O_BINARY 0     // otherwise do nothing.
  88 #endif
  89 
  90 inline void CDSMustMatchFlags::do_print(outputStream* st, bool v) {
  91   st->print("%s", v ? "true" : "false");
  92 }
  93 
  94 inline void CDSMustMatchFlags::do_print(outputStream* st, intx v) {
  95   st->print("%zd", v);
  96 }
  97 
  98 inline void CDSMustMatchFlags::do_print(outputStream* st, uintx v) {
  99   st->print("%zu", v);
 100 }
 101 
 102 inline void CDSMustMatchFlags::do_print(outputStream* st, double v) {
 103   st->print("%f", v);
 104 }
 105 
 106 void CDSMustMatchFlags::init() {
 107   assert(CDSConfig::is_dumping_archive(), "sanity");
 108   _max_name_width = 0;
 109 
 110 #define INIT_CDS_MUST_MATCH_FLAG(n) \
 111   _v_##n = n; \
 112   _max_name_width = MAX2(_max_name_width,strlen(#n));
 113   CDS_MUST_MATCH_FLAGS_DO(INIT_CDS_MUST_MATCH_FLAG);
 114 #undef INIT_CDS_MUST_MATCH_FLAG
 115 }
 116 
 117 bool CDSMustMatchFlags::runtime_check() const {
 118 #define CHECK_CDS_MUST_MATCH_FLAG(n) \
 119   if (_v_##n != n) { \
 120     ResourceMark rm; \
 121     stringStream ss; \
 122     ss.print("VM option %s is different between dumptime (", #n);  \
 123     do_print(&ss, _v_ ## n); \
 124     ss.print(") and runtime ("); \
 125     do_print(&ss, n); \
 126     ss.print(")"); \
 127     log_info(cds)("%s", ss.as_string()); \
 128     return false; \
 129   }
 130   CDS_MUST_MATCH_FLAGS_DO(CHECK_CDS_MUST_MATCH_FLAG);
 131 #undef CHECK_CDS_MUST_MATCH_FLAG
 132 
 133   return true;
 134 }
 135 
 136 void CDSMustMatchFlags::print_info() const {
 137   LogTarget(Info, cds) lt;
 138   if (lt.is_enabled()) {
 139     LogStream ls(lt);
 140     ls.print_cr("Recorded VM flags during dumptime:");
 141     print(&ls);
 142   }
 143 }
 144 
 145 void CDSMustMatchFlags::print(outputStream* st) const {
 146 #define PRINT_CDS_MUST_MATCH_FLAG(n) \
 147   st->print("- %-s ", #n);                   \
 148   st->sp(int(_max_name_width - strlen(#n))); \
 149   do_print(st, _v_##n);                      \
 150   st->cr();
 151   CDS_MUST_MATCH_FLAGS_DO(PRINT_CDS_MUST_MATCH_FLAG);
 152 #undef PRINT_CDS_MUST_MATCH_FLAG
 153 }
 154 
 155 // Fill in the fileMapInfo structure with data about this VM instance.
 156 
 157 // This method copies the vm version info into header_version.  If the version is too
 158 // long then a truncated version, which has a hash code appended to it, is copied.
 159 //
 160 // Using a template enables this method to verify that header_version is an array of
 161 // length JVM_IDENT_MAX.  This ensures that the code that writes to the CDS file and
 162 // the code that reads the CDS file will both use the same size buffer.  Hence, will
 163 // use identical truncation.  This is necessary for matching of truncated versions.
 164 template <int N> static void get_header_version(char (&header_version) [N]) {
 165   assert(N == JVM_IDENT_MAX, "Bad header_version size");
 166 
 167   const char *vm_version = VM_Version::internal_vm_info_string();
 168   const int version_len = (int)strlen(vm_version);
 169 
 170   memset(header_version, 0, JVM_IDENT_MAX);
 171 
 172   if (version_len < (JVM_IDENT_MAX-1)) {
 173     strcpy(header_version, vm_version);
 174 

 294     _narrow_klass_pointer_bits = CompressedKlassPointers::narrow_klass_pointer_bits();
 295     _narrow_klass_shift = ArchiveBuilder::precomputed_narrow_klass_shift();
 296 #endif
 297   } else {
 298     _narrow_klass_pointer_bits = _narrow_klass_shift = -1;
 299   }
 300   // Which JIT compier is used
 301   _compiler_type = (u1)CompilerConfig::compiler_type();
 302   _type_profile_level = TypeProfileLevel;
 303   _type_profile_args_limit = TypeProfileArgsLimit;
 304   _type_profile_parms_limit = TypeProfileParmsLimit;
 305   _type_profile_width = TypeProfileWidth;
 306   _bci_profile_width = BciProfileWidth;
 307   _profile_traps = ProfileTraps;
 308   _type_profile_casts = TypeProfileCasts;
 309   _spec_trap_limit_extra_entries = SpecTrapLimitExtraEntries;
 310   _max_heap_size = MaxHeapSize;
 311   _use_optimized_module_handling = CDSConfig::is_using_optimized_module_handling();
 312   _has_aot_linked_classes = CDSConfig::is_dumping_aot_linked_classes();
 313   _has_full_module_graph = CDSConfig::is_dumping_full_module_graph();
 314   _has_valhalla_patched_classes = CDSConfig::is_valhalla_preview();
 315 
 316   // The following fields are for sanity checks for whether this archive
 317   // will function correctly with this JVM and the bootclasspath it's
 318   // invoked with.
 319 
 320   // JVM version string ... changes on each build.
 321   get_header_version(_jvm_ident);
 322 
 323   _verify_local = BytecodeVerificationLocal;
 324   _verify_remote = BytecodeVerificationRemote;
 325   _has_platform_or_app_classes = AOTClassLocationConfig::dumptime()->has_platform_or_app_classes();
 326   _requested_base_address = (char*)SharedBaseAddress;
 327   _mapped_base_address = (char*)SharedBaseAddress;
 328   _allow_archiving_with_java_agent = AllowArchivingWithJavaAgent;
 329   _must_match.init();
 330 }
 331 
 332 void FileMapHeader::copy_base_archive_name(const char* archive) {
 333   assert(base_archive_name_size() != 0, "_base_archive_name_size not set");
 334   assert(base_archive_name_offset() != 0, "_base_archive_name_offset not set");
 335   assert(header_size() > sizeof(*this), "_base_archive_name_size not included in header size?");
 336   memcpy((char*)this + base_archive_name_offset(), archive, base_archive_name_size());
 337 }
 338 
 339 void FileMapHeader::print(outputStream* st) {
 340   ResourceMark rm;
 341 
 342   st->print_cr("- magic:                          0x%08x", magic());
 343   st->print_cr("- crc:                            0x%08x", crc());
 344   st->print_cr("- version:                        0x%x", version());
 345   st->print_cr("- header_size:                    " UINT32_FORMAT, header_size());
 346   st->print_cr("- base_archive_name_offset:       " UINT32_FORMAT, base_archive_name_offset());
 347   st->print_cr("- base_archive_name_size:         " UINT32_FORMAT, base_archive_name_size());
 348 
 349   for (int i = 0; i < NUM_CDS_REGIONS; i++) {

 369   st->print_cr("- serialized_data_offset:         0x%zx", _serialized_data_offset);
 370   st->print_cr("- jvm_ident:                      %s", _jvm_ident);
 371   st->print_cr("- class_location_config_offset:   0x%zx", _class_location_config_offset);
 372   st->print_cr("- verify_local:                   %d", _verify_local);
 373   st->print_cr("- verify_remote:                  %d", _verify_remote);
 374   st->print_cr("- has_platform_or_app_classes:    %d", _has_platform_or_app_classes);
 375   st->print_cr("- requested_base_address:         " INTPTR_FORMAT, p2i(_requested_base_address));
 376   st->print_cr("- mapped_base_address:            " INTPTR_FORMAT, p2i(_mapped_base_address));
 377   st->print_cr("- heap_root_segments.roots_count: %d" , _heap_root_segments.roots_count());
 378   st->print_cr("- heap_root_segments.base_offset: 0x%zx", _heap_root_segments.base_offset());
 379   st->print_cr("- heap_root_segments.count:       %zu", _heap_root_segments.count());
 380   st->print_cr("- heap_root_segments.max_size_elems: %d", _heap_root_segments.max_size_in_elems());
 381   st->print_cr("- heap_root_segments.max_size_bytes: %d", _heap_root_segments.max_size_in_bytes());
 382   st->print_cr("- _heap_oopmap_start_pos:         %zu", _heap_oopmap_start_pos);
 383   st->print_cr("- _heap_ptrmap_start_pos:         %zu", _heap_ptrmap_start_pos);
 384   st->print_cr("- _rw_ptrmap_start_pos:           %zu", _rw_ptrmap_start_pos);
 385   st->print_cr("- _ro_ptrmap_start_pos:           %zu", _ro_ptrmap_start_pos);
 386   st->print_cr("- allow_archiving_with_java_agent:%d", _allow_archiving_with_java_agent);
 387   st->print_cr("- use_optimized_module_handling:  %d", _use_optimized_module_handling);
 388   st->print_cr("- has_full_module_graph           %d", _has_full_module_graph);
 389   st->print_cr("- has_valhalla_patched_classes    %d", _has_valhalla_patched_classes);
 390   _must_match.print(st);
 391   st->print_cr("- has_aot_linked_classes          %d", _has_aot_linked_classes);
 392 }
 393 
 394 bool FileMapInfo::validate_class_location() {
 395   assert(CDSConfig::is_using_archive(), "runtime only");
 396 
 397   AOTClassLocationConfig* config = header()->class_location_config();
 398   bool has_extra_module_paths = false;
 399   if (!config->validate(full_path(), header()->has_aot_linked_classes(), &has_extra_module_paths)) {
 400     if (PrintSharedArchiveAndExit) {
 401       MetaspaceShared::set_archive_loading_failed();
 402       return true;
 403     } else {
 404       return false;
 405     }
 406   }
 407 
 408   if (header()->has_full_module_graph() && has_extra_module_paths) {
 409     CDSConfig::stop_using_optimized_module_handling();
 410     MetaspaceShared::report_loading_error("optimized module handling: disabled because extra module path(s) are specified");

 754   if (strncmp(actual_ident, expected_ident, JVM_IDENT_MAX-1) != 0) {
 755     aot_log_info(aot)("_jvm_ident expected: %s", expected_ident);
 756     aot_log_info(aot)("             actual: %s", actual_ident);
 757     aot_log_warning(aot)("The %s was created by a different"
 758                   " version or build of HotSpot", file_type);
 759     return false;
 760   }
 761 
 762   _file_offset = header()->header_size(); // accounts for the size of _base_archive_name
 763 
 764   size_t len = os::lseek(fd, 0, SEEK_END);
 765 
 766   for (int i = 0; i < MetaspaceShared::n_regions; i++) {
 767     FileMapRegion* r = region_at(i);
 768     if (r->file_offset() > len || len - r->file_offset() < r->used()) {
 769       aot_log_warning(aot)("The %s has been truncated.", file_type);
 770       return false;
 771     }
 772   }
 773 
 774   if (!header()->check_must_match_flags()) {
 775     return false;
 776   }
 777 
 778   return true;
 779 }
 780 
 781 void FileMapInfo::seek_to_position(size_t pos) {
 782   if (os::lseek(_fd, (long)pos, SEEK_SET) < 0) {
 783     aot_log_error(aot)("Unable to seek to position %zu", pos);
 784     MetaspaceShared::unrecoverable_loading_error();
 785   }
 786 }
 787 
 788 // Read the FileMapInfo information from the file.
 789 bool FileMapInfo::open_for_read() {
 790   if (_file_open) {
 791     return true;
 792   }
 793   const char* file_type = CDSConfig::type_of_archive_being_loaded();
 794   const char* info = CDSConfig::is_dumping_final_static_archive() ?
 795     "AOTConfiguration file " : "";
 796   aot_log_info(aot)("trying to map %s%s", info, _full_path);
 797   int fd = os::open(_full_path, O_RDONLY | O_BINARY, 0);

2130   // while AllowArchivingWithJavaAgent is set during the current run.
2131   if (_allow_archiving_with_java_agent && !AllowArchivingWithJavaAgent) {
2132     MetaspaceShared::report_loading_error("The setting of the AllowArchivingWithJavaAgent is different "
2133                                           "from the setting in the %s.", file_type);
2134     return false;
2135   }
2136 
2137   if (_allow_archiving_with_java_agent) {
2138     aot_log_warning(aot)("This %s was created with AllowArchivingWithJavaAgent. It should be used "
2139             "for testing purposes only and should not be used in a production environment", file_type);
2140   }
2141 
2142   aot_log_info(aot)("The %s was created with UseCompressedOops = %d, UseCompressedClassPointers = %d, UseCompactObjectHeaders = %d",
2143                           file_type, compressed_oops(), compressed_class_pointers(), compact_headers());
2144   if (compressed_oops() != UseCompressedOops || compressed_class_pointers() != UseCompressedClassPointers) {
2145     aot_log_warning(aot)("Unable to use %s.\nThe saved state of UseCompressedOops and UseCompressedClassPointers is "
2146                                "different from runtime, CDS will be disabled.", file_type);
2147     return false;
2148   }
2149 
2150   if (is_static()) {
2151     const char* err = nullptr;
2152     if (CDSConfig::is_valhalla_preview()) {
2153       if (!_has_valhalla_patched_classes) {
2154         err = "not created";
2155       }
2156     } else {
2157       if (_has_valhalla_patched_classes) {
2158         err = "created";
2159       }
2160     }
2161     if (err != nullptr) {
2162       log_warning(cds)("This archive was %s with --enable-preview -XX:+EnableValhalla. It is "
2163                          "incompatible with the current JVM setting", err);
2164       return false;
2165     }
2166   }
2167 
2168   if (compact_headers() != UseCompactObjectHeaders) {
2169     aot_log_warning(aot)("Unable to use %s.\nThe %s's UseCompactObjectHeaders setting (%s)"
2170                      " does not equal the current UseCompactObjectHeaders setting (%s).", file_type, file_type,
2171                      _compact_headers          ? "enabled" : "disabled",
2172                      UseCompactObjectHeaders   ? "enabled" : "disabled");
2173     return false;
2174   }
2175 
2176   if (!_use_optimized_module_handling && !CDSConfig::is_dumping_final_static_archive()) {
2177     CDSConfig::stop_using_optimized_module_handling();
2178     aot_log_info(aot)("optimized module handling: disabled because archive was created without optimized module handling");
2179   }
2180 
2181   if (is_static()) {
2182     // Only the static archive can contain the full module graph.
2183     if (!_has_full_module_graph) {
2184       CDSConfig::stop_using_full_module_graph("archive was created without full module graph");
2185     }
2186   }
2187 
< prev index next >