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 }
211 _compressed_oops = UseCompressedOops;
212 _compressed_class_ptrs = UseCompressedClassPointers;
213 _max_heap_size = MaxHeapSize;
214 _use_optimized_module_handling = MetaspaceShared::use_optimized_module_handling();
215 _use_full_module_graph = MetaspaceShared::use_full_module_graph();
216
217 // The following fields are for sanity checks for whether this archive
218 // will function correctly with this JVM and the bootclasspath it's
219 // invoked with.
220
221 // JVM version string ... changes on each build.
222 get_header_version(_jvm_ident);
223
224 _app_class_paths_start_index = ClassLoaderExt::app_class_paths_start_index();
225 _app_module_paths_start_index = ClassLoaderExt::app_module_paths_start_index();
252 st->print_cr("- magic: 0x%08x", magic());
253 st->print_cr("- crc: 0x%08x", crc());
254 st->print_cr("- version: 0x%x", version());
255 st->print_cr("- header_size: " UINT32_FORMAT, header_size());
256 st->print_cr("- common_app_classpath_size: " UINT32_FORMAT, common_app_classpath_prefix_size());
257 st->print_cr("- base_archive_name_offset: " UINT32_FORMAT, base_archive_name_offset());
258 st->print_cr("- base_archive_name_size: " UINT32_FORMAT, base_archive_name_size());
259
260 for (int i = 0; i < NUM_CDS_REGIONS; i++) {
261 FileMapRegion* r = region_at(i);
262 r->print(st, i);
263 }
264 st->print_cr("============ end regions ======== ");
265
266 st->print_cr("- core_region_alignment: " SIZE_FORMAT, _core_region_alignment);
267 st->print_cr("- obj_alignment: %d", _obj_alignment);
268 st->print_cr("- narrow_oop_base: " INTPTR_FORMAT, p2i(_narrow_oop_base));
269 st->print_cr("- narrow_oop_base: " INTPTR_FORMAT, p2i(_narrow_oop_base));
270 st->print_cr("- narrow_oop_shift %d", _narrow_oop_shift);
271 st->print_cr("- compact_strings: %d", _compact_strings);
272 st->print_cr("- max_heap_size: " UINTX_FORMAT, _max_heap_size);
273 st->print_cr("- narrow_oop_mode: %d", _narrow_oop_mode);
274 st->print_cr("- compressed_oops: %d", _compressed_oops);
275 st->print_cr("- compressed_class_ptrs: %d", _compressed_class_ptrs);
276 st->print_cr("- cloned_vtables_offset: " SIZE_FORMAT_X, _cloned_vtables_offset);
277 st->print_cr("- serialized_data_offset: " SIZE_FORMAT_X, _serialized_data_offset);
278 st->print_cr("- jvm_ident: %s", _jvm_ident);
279 st->print_cr("- shared_path_table_offset: " SIZE_FORMAT_X, _shared_path_table_offset);
280 st->print_cr("- app_class_paths_start_index: %d", _app_class_paths_start_index);
281 st->print_cr("- app_module_paths_start_index: %d", _app_module_paths_start_index);
282 st->print_cr("- num_module_paths: %d", _num_module_paths);
283 st->print_cr("- max_used_path_index: %d", _max_used_path_index);
284 st->print_cr("- verify_local: %d", _verify_local);
285 st->print_cr("- verify_remote: %d", _verify_remote);
286 st->print_cr("- has_platform_or_app_classes: %d", _has_platform_or_app_classes);
287 st->print_cr("- has_non_jar_in_classpath: %d", _has_non_jar_in_classpath);
288 st->print_cr("- requested_base_address: " INTPTR_FORMAT, p2i(_requested_base_address));
289 st->print_cr("- mapped_base_address: " INTPTR_FORMAT, p2i(_mapped_base_address));
290 st->print_cr("- heap_roots_offset: " SIZE_FORMAT, _heap_roots_offset);
291 st->print_cr("- allow_archiving_with_java_agent:%d", _allow_archiving_with_java_agent);
2377 // while AllowArchivingWithJavaAgent is set during the current run.
2378 if (_allow_archiving_with_java_agent && !AllowArchivingWithJavaAgent) {
2379 log_warning(cds)("The setting of the AllowArchivingWithJavaAgent is different "
2380 "from the setting in the shared archive.");
2381 return false;
2382 }
2383
2384 if (_allow_archiving_with_java_agent) {
2385 log_warning(cds)("This archive was created with AllowArchivingWithJavaAgent. It should be used "
2386 "for testing purposes only and should not be used in a production environment");
2387 }
2388
2389 log_info(cds)("Archive was created with UseCompressedOops = %d, UseCompressedClassPointers = %d",
2390 compressed_oops(), compressed_class_pointers());
2391 if (compressed_oops() != UseCompressedOops || compressed_class_pointers() != UseCompressedClassPointers) {
2392 log_info(cds)("Unable to use shared archive.\nThe saved state of UseCompressedOops and UseCompressedClassPointers is "
2393 "different from runtime, CDS will be disabled.");
2394 return false;
2395 }
2396
2397 if (!_use_optimized_module_handling) {
2398 MetaspaceShared::disable_optimized_module_handling();
2399 log_info(cds)("optimized module handling: disabled because archive was created without optimized module handling");
2400 }
2401
2402 if (!_use_full_module_graph) {
2403 MetaspaceShared::disable_full_module_graph();
2404 log_info(cds)("full module graph: disabled because archive was created without full module graph");
2405 }
2406
2407 return true;
2408 }
2409
2410 bool FileMapInfo::validate_header() {
2411 if (!header()->validate()) {
2412 return false;
2413 }
2414 if (_is_static) {
2415 return true;
2416 } 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 }
212 _compressed_oops = UseCompressedOops;
213 _compressed_class_ptrs = UseCompressedClassPointers;
214 _max_heap_size = MaxHeapSize;
215 _use_optimized_module_handling = MetaspaceShared::use_optimized_module_handling();
216 _use_full_module_graph = MetaspaceShared::use_full_module_graph();
217
218 // The following fields are for sanity checks for whether this archive
219 // will function correctly with this JVM and the bootclasspath it's
220 // invoked with.
221
222 // JVM version string ... changes on each build.
223 get_header_version(_jvm_ident);
224
225 _app_class_paths_start_index = ClassLoaderExt::app_class_paths_start_index();
226 _app_module_paths_start_index = ClassLoaderExt::app_module_paths_start_index();
253 st->print_cr("- magic: 0x%08x", magic());
254 st->print_cr("- crc: 0x%08x", crc());
255 st->print_cr("- version: 0x%x", version());
256 st->print_cr("- header_size: " UINT32_FORMAT, header_size());
257 st->print_cr("- common_app_classpath_size: " UINT32_FORMAT, common_app_classpath_prefix_size());
258 st->print_cr("- base_archive_name_offset: " UINT32_FORMAT, base_archive_name_offset());
259 st->print_cr("- base_archive_name_size: " UINT32_FORMAT, base_archive_name_size());
260
261 for (int i = 0; i < NUM_CDS_REGIONS; i++) {
262 FileMapRegion* r = region_at(i);
263 r->print(st, i);
264 }
265 st->print_cr("============ end regions ======== ");
266
267 st->print_cr("- core_region_alignment: " SIZE_FORMAT, _core_region_alignment);
268 st->print_cr("- obj_alignment: %d", _obj_alignment);
269 st->print_cr("- narrow_oop_base: " INTPTR_FORMAT, p2i(_narrow_oop_base));
270 st->print_cr("- narrow_oop_base: " INTPTR_FORMAT, p2i(_narrow_oop_base));
271 st->print_cr("- narrow_oop_shift %d", _narrow_oop_shift);
272 st->print_cr("- compact_strings: %d", _compact_strings);
273 st->print_cr("- compact_headers: %d", _compact_headers);
274 st->print_cr("- max_heap_size: " UINTX_FORMAT, _max_heap_size);
275 st->print_cr("- narrow_oop_mode: %d", _narrow_oop_mode);
276 st->print_cr("- compressed_oops: %d", _compressed_oops);
277 st->print_cr("- compressed_class_ptrs: %d", _compressed_class_ptrs);
278 st->print_cr("- cloned_vtables_offset: " SIZE_FORMAT_X, _cloned_vtables_offset);
279 st->print_cr("- serialized_data_offset: " SIZE_FORMAT_X, _serialized_data_offset);
280 st->print_cr("- jvm_ident: %s", _jvm_ident);
281 st->print_cr("- shared_path_table_offset: " SIZE_FORMAT_X, _shared_path_table_offset);
282 st->print_cr("- app_class_paths_start_index: %d", _app_class_paths_start_index);
283 st->print_cr("- app_module_paths_start_index: %d", _app_module_paths_start_index);
284 st->print_cr("- num_module_paths: %d", _num_module_paths);
285 st->print_cr("- max_used_path_index: %d", _max_used_path_index);
286 st->print_cr("- verify_local: %d", _verify_local);
287 st->print_cr("- verify_remote: %d", _verify_remote);
288 st->print_cr("- has_platform_or_app_classes: %d", _has_platform_or_app_classes);
289 st->print_cr("- has_non_jar_in_classpath: %d", _has_non_jar_in_classpath);
290 st->print_cr("- requested_base_address: " INTPTR_FORMAT, p2i(_requested_base_address));
291 st->print_cr("- mapped_base_address: " INTPTR_FORMAT, p2i(_mapped_base_address));
292 st->print_cr("- heap_roots_offset: " SIZE_FORMAT, _heap_roots_offset);
293 st->print_cr("- allow_archiving_with_java_agent:%d", _allow_archiving_with_java_agent);
2379 // while AllowArchivingWithJavaAgent is set during the current run.
2380 if (_allow_archiving_with_java_agent && !AllowArchivingWithJavaAgent) {
2381 log_warning(cds)("The setting of the AllowArchivingWithJavaAgent is different "
2382 "from the setting in the shared archive.");
2383 return false;
2384 }
2385
2386 if (_allow_archiving_with_java_agent) {
2387 log_warning(cds)("This archive was created with AllowArchivingWithJavaAgent. It should be used "
2388 "for testing purposes only and should not be used in a production environment");
2389 }
2390
2391 log_info(cds)("Archive was created with UseCompressedOops = %d, UseCompressedClassPointers = %d",
2392 compressed_oops(), compressed_class_pointers());
2393 if (compressed_oops() != UseCompressedOops || compressed_class_pointers() != UseCompressedClassPointers) {
2394 log_info(cds)("Unable to use shared archive.\nThe saved state of UseCompressedOops and UseCompressedClassPointers is "
2395 "different from runtime, CDS will be disabled.");
2396 return false;
2397 }
2398
2399 if (compact_headers() != UseCompactObjectHeaders) {
2400 log_info(cds)("The shared archive file's UseCompactObjectHeaders setting (%s)"
2401 " does not equal the current UseCompactObjectHeaders setting (%s).",
2402 _compact_headers ? "enabled" : "disabled",
2403 UseCompactObjectHeaders ? "enabled" : "disabled");
2404 return false;
2405 }
2406
2407 if (!_use_optimized_module_handling) {
2408 MetaspaceShared::disable_optimized_module_handling();
2409 log_info(cds)("optimized module handling: disabled because archive was created without optimized module handling");
2410 }
2411
2412 if (!_use_full_module_graph) {
2413 MetaspaceShared::disable_full_module_graph();
2414 log_info(cds)("full module graph: disabled because archive was created without full module graph");
2415 }
2416
2417 return true;
2418 }
2419
2420 bool FileMapInfo::validate_header() {
2421 if (!header()->validate()) {
2422 return false;
2423 }
2424 if (_is_static) {
2425 return true;
2426 } else {
|