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);
2268 // while AllowArchivingWithJavaAgent is set during the current run.
2269 if (_allow_archiving_with_java_agent && !AllowArchivingWithJavaAgent) {
2270 FileMapInfo::fail_continue("The setting of the AllowArchivingWithJavaAgent is different "
2271 "from the setting in the shared archive.");
2272 return false;
2273 }
2274
2275 if (_allow_archiving_with_java_agent) {
2276 warning("This archive was created with AllowArchivingWithJavaAgent. It should be used "
2277 "for testing purposes only and should not be used in a production environment");
2278 }
2279
2280 log_info(cds)("Archive was created with UseCompressedOops = %d, UseCompressedClassPointers = %d",
2281 compressed_oops(), compressed_class_pointers());
2282 if (compressed_oops() != UseCompressedOops || compressed_class_pointers() != UseCompressedClassPointers) {
2283 FileMapInfo::fail_continue("Unable to use shared archive.\nThe saved state of UseCompressedOops and UseCompressedClassPointers is "
2284 "different from runtime, CDS will be disabled.");
2285 return false;
2286 }
2287
2288 if (!_use_optimized_module_handling) {
2289 MetaspaceShared::disable_optimized_module_handling();
2290 log_info(cds)("optimized module handling: disabled because archive was created without optimized module handling");
2291 }
2292
2293 if (!_use_full_module_graph) {
2294 MetaspaceShared::disable_full_module_graph();
2295 log_info(cds)("full module graph: disabled because archive was created without full module graph");
2296 }
2297
2298 return true;
2299 }
2300
2301 bool FileMapInfo::validate_header() {
2302 if (!header()->validate()) {
2303 return false;
2304 }
2305 if (_is_static) {
2306 return true;
2307 } 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);
2270 // while AllowArchivingWithJavaAgent is set during the current run.
2271 if (_allow_archiving_with_java_agent && !AllowArchivingWithJavaAgent) {
2272 FileMapInfo::fail_continue("The setting of the AllowArchivingWithJavaAgent is different "
2273 "from the setting in the shared archive.");
2274 return false;
2275 }
2276
2277 if (_allow_archiving_with_java_agent) {
2278 warning("This archive was created with AllowArchivingWithJavaAgent. It should be used "
2279 "for testing purposes only and should not be used in a production environment");
2280 }
2281
2282 log_info(cds)("Archive was created with UseCompressedOops = %d, UseCompressedClassPointers = %d",
2283 compressed_oops(), compressed_class_pointers());
2284 if (compressed_oops() != UseCompressedOops || compressed_class_pointers() != UseCompressedClassPointers) {
2285 FileMapInfo::fail_continue("Unable to use shared archive.\nThe saved state of UseCompressedOops and UseCompressedClassPointers is "
2286 "different from runtime, CDS will be disabled.");
2287 return false;
2288 }
2289
2290 if (compact_headers() != UseCompactObjectHeaders) {
2291 log_info(cds)("The shared archive file's UseCompactObjectHeaders setting (%s)"
2292 " does not equal the current UseCompactObjectHeaders setting (%s).",
2293 _compact_headers ? "enabled" : "disabled",
2294 UseCompactObjectHeaders ? "enabled" : "disabled");
2295 return false;
2296 }
2297
2298 if (!_use_optimized_module_handling) {
2299 MetaspaceShared::disable_optimized_module_handling();
2300 log_info(cds)("optimized module handling: disabled because archive was created without optimized module handling");
2301 }
2302
2303 if (!_use_full_module_graph) {
2304 MetaspaceShared::disable_full_module_graph();
2305 log_info(cds)("full module graph: disabled because archive was created without full module graph");
2306 }
2307
2308 return true;
2309 }
2310
2311 bool FileMapInfo::validate_header() {
2312 if (!header()->validate()) {
2313 return false;
2314 }
2315 if (_is_static) {
2316 return true;
2317 } else {
|