124
125 // The following fields are all sanity checks for whether this archive
126 // will function correctly with this JVM and the bootclasspath it's
127 // invoked with.
128 char _jvm_ident[JVM_IDENT_MAX]; // identifier string of the jvm that created this dump
129
130 size_t _class_location_config_offset;
131
132 bool _verify_local; // BytecodeVerificationLocal setting
133 bool _verify_remote; // BytecodeVerificationRemote setting
134 bool _has_platform_or_app_classes; // Archive contains app or platform classes
135 char* _requested_base_address; // Archive relocation is not necessary if we map with this base address.
136 char* _mapped_base_address; // Actual base address where archive is mapped.
137
138 bool _allow_archiving_with_java_agent; // setting of the AllowArchivingWithJavaAgent option
139 bool _use_optimized_module_handling;// No module-relation VM options were specified, so we can skip
140 // some expensive operations.
141 bool _has_aot_linked_classes; // Was the CDS archive created with -XX:+AOTClassLinking
142 bool _has_full_module_graph; // Does this CDS archive contain the full archived module graph?
143 bool _has_archived_invokedynamic; // Does the archive have aot-linked invokedynamic CP entries?
144 HeapRootSegments _heap_root_segments; // Heap root segments info
145 size_t _heap_oopmap_start_pos; // The first bit in the oopmap corresponds to this position in the heap.
146 size_t _heap_ptrmap_start_pos; // The first bit in the ptrmap corresponds to this position in the heap.
147 size_t _rw_ptrmap_start_pos; // The first bit in the ptrmap corresponds to this position in the rw region
148 size_t _ro_ptrmap_start_pos; // The first bit in the ptrmap corresponds to this position in the ro region
149 template <typename T> T from_mapped_offset(size_t offset) const {
150 return (T)(mapped_base_address() + offset);
151 }
152 void set_as_offset(char* p, size_t *offset);
153 template <typename T> void set_as_offset(T p, size_t *offset) {
154 set_as_offset((char*)p, offset);
155 }
156
157 public:
158 // Accessors -- fields declared in GenericCDSFileMapHeader
159 unsigned int magic() const { return _generic_header._magic; }
160 int crc() const { return _generic_header._crc; }
161 int version() const { return _generic_header._version; }
162 unsigned int header_size() const { return _generic_header._header_size; }
163 unsigned int base_archive_name_offset() const { return _generic_header._base_archive_name_offset; }
170 void set_base_archive_name_offset(unsigned int s) { _generic_header._base_archive_name_offset = s; }
171 void set_base_archive_name_size(unsigned int s) { _generic_header._base_archive_name_size = s; }
172
173 bool is_static() const { return magic() == CDS_ARCHIVE_MAGIC; }
174 size_t core_region_alignment() const { return _core_region_alignment; }
175 int obj_alignment() const { return _obj_alignment; }
176 address narrow_oop_base() const { return _narrow_oop_base; }
177 int narrow_oop_shift() const { return _narrow_oop_shift; }
178 bool compact_strings() const { return _compact_strings; }
179 bool compact_headers() const { return _compact_headers; }
180 uintx max_heap_size() const { return _max_heap_size; }
181 CompressedOops::Mode narrow_oop_mode() const { return _narrow_oop_mode; }
182 char* cloned_vtables() const { return from_mapped_offset<char*>(_cloned_vtables_offset); }
183 char* early_serialized_data() const { return from_mapped_offset<char*>(_early_serialized_data_offset); }
184 char* serialized_data() const { return from_mapped_offset<char*>(_serialized_data_offset); }
185 const char* jvm_ident() const { return _jvm_ident; }
186 char* requested_base_address() const { return _requested_base_address; }
187 char* mapped_base_address() const { return _mapped_base_address; }
188 bool has_platform_or_app_classes() const { return _has_platform_or_app_classes; }
189 bool has_aot_linked_classes() const { return _has_aot_linked_classes; }
190 bool compressed_oops() const { return _compressed_oops; }
191 bool compressed_class_pointers() const { return _compressed_class_ptrs; }
192 int narrow_klass_pointer_bits() const { return _narrow_klass_pointer_bits; }
193 int narrow_klass_shift() const { return _narrow_klass_shift; }
194 HeapRootSegments heap_root_segments() const { return _heap_root_segments; }
195 bool has_full_module_graph() const { return _has_full_module_graph; }
196 size_t heap_oopmap_start_pos() const { return _heap_oopmap_start_pos; }
197 size_t heap_ptrmap_start_pos() const { return _heap_ptrmap_start_pos; }
198 size_t rw_ptrmap_start_pos() const { return _rw_ptrmap_start_pos; }
199 size_t ro_ptrmap_start_pos() const { return _ro_ptrmap_start_pos; }
200
201 void set_has_platform_or_app_classes(bool v) { _has_platform_or_app_classes = v; }
202 void set_cloned_vtables(char* p) { set_as_offset(p, &_cloned_vtables_offset); }
203 void set_early_serialized_data(char* p) { set_as_offset(p, &_early_serialized_data_offset); }
204 void set_serialized_data(char* p) { set_as_offset(p, &_serialized_data_offset); }
205 void set_mapped_base_address(char* p) { _mapped_base_address = p; }
206 void set_heap_root_segments(HeapRootSegments segments) { _heap_root_segments = segments; }
207 void set_heap_oopmap_start_pos(size_t n) { _heap_oopmap_start_pos = n; }
208 void set_heap_ptrmap_start_pos(size_t n) { _heap_ptrmap_start_pos = n; }
209 void set_rw_ptrmap_start_pos(size_t n) { _rw_ptrmap_start_pos = n; }
337
338 static void set_current_info(FileMapInfo* info) {
339 CDS_ONLY(_current_info = info;)
340 }
341
342 static FileMapInfo* dynamic_info() {
343 CDS_ONLY(return _dynamic_archive_info;)
344 NOT_CDS(return nullptr;)
345 }
346
347 static void assert_mark(bool check);
348
349 // File manipulation.
350 bool initialize() NOT_CDS_RETURN_(false);
351 bool open_for_read();
352 void open_for_write();
353 void write_header();
354 void write_region(int region, char* base, size_t size,
355 bool read_only, bool allow_exec);
356 size_t remove_bitmap_zeros(CHeapBitMap* map);
357 char* write_bitmap_region(CHeapBitMap* rw_ptrmap, CHeapBitMap* ro_ptrmap, ArchiveHeapInfo* heap_info,
358 size_t &size_in_bytes);
359 size_t write_heap_region(ArchiveHeapInfo* heap_info);
360 void write_bytes(const void* buffer, size_t count);
361 void write_bytes_aligned(const void* buffer, size_t count);
362 size_t read_bytes(void* buffer, size_t count);
363 static size_t readonly_total();
364 MapArchiveResult map_regions(int regions[], int num_regions, char* mapped_base_address, ReservedSpace rs);
365 void unmap_regions(int regions[], int num_regions);
366 void map_or_load_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
367 void fixup_mapped_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
368 void patch_heap_embedded_pointers() NOT_CDS_JAVA_HEAP_RETURN;
369 bool has_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
370 MemRegion get_heap_region_requested_range() NOT_CDS_JAVA_HEAP_RETURN_(MemRegion());
371 bool read_region(int i, char* base, size_t size, bool do_commit);
372 char* map_bitmap_region();
373 void unmap_region(int i);
374 void close();
375 bool is_open() { return _file_open; }
376
377 // JVM/TI RedefineClasses() support:
378 // Remap the shared readonly space to shared readwrite, private.
379 bool remap_shared_readonly_as_readwrite();
380
381 static bool memory_mapping_failed() {
382 CDS_ONLY(return _memory_mapping_failed;)
383 NOT_CDS(return false;)
384 }
385
386 bool validate_class_location();
387 bool validate_aot_class_linking();
388
389 #if INCLUDE_JVMTI
390 // Caller needs a ResourceMark because parts of the returned cfs are resource-allocated.
391 static ClassFileStream* open_stream_for_jvmti(InstanceKlass* ik, Handle class_loader, TRAPS);
392 static ClassFileStream* get_stream_from_class_loader(Handle class_loader,
418 BitMapView bitmap_view(int region_index, bool is_oopmap);
419 BitMapView oopmap_view(int region_index);
420 BitMapView ptrmap_view(int region_index);
421
422 void print(outputStream* st) const;
423
424 const char* vm_version() {
425 return header()->jvm_ident();
426 }
427
428 private:
429 void seek_to_position(size_t pos);
430 bool map_heap_region_impl() NOT_CDS_JAVA_HEAP_RETURN_(false);
431 void dealloc_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
432 bool can_use_heap_region();
433 bool load_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
434 bool map_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
435 void init_heap_region_relocation();
436 MapArchiveResult map_region(int i, intx addr_delta, char* mapped_base_address, ReservedSpace rs);
437 bool relocate_pointers_in_core_regions(intx addr_delta);
438
439 static MemRegion _mapped_heap_memregion;
440
441 public:
442 address heap_region_dumptime_address() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
443 address heap_region_requested_address() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
444 narrowOop encoded_heap_region_dumptime_address();
445
446 private:
447
448 #if INCLUDE_JVMTI
449 static ClassPathEntry** _classpath_entries_for_jvmti;
450 static ClassPathEntry* get_classpath_entry_for_jvmti(int i, TRAPS);
451 #endif
452 };
453
454 #endif // SHARE_CDS_FILEMAP_HPP
|
124
125 // The following fields are all sanity checks for whether this archive
126 // will function correctly with this JVM and the bootclasspath it's
127 // invoked with.
128 char _jvm_ident[JVM_IDENT_MAX]; // identifier string of the jvm that created this dump
129
130 size_t _class_location_config_offset;
131
132 bool _verify_local; // BytecodeVerificationLocal setting
133 bool _verify_remote; // BytecodeVerificationRemote setting
134 bool _has_platform_or_app_classes; // Archive contains app or platform classes
135 char* _requested_base_address; // Archive relocation is not necessary if we map with this base address.
136 char* _mapped_base_address; // Actual base address where archive is mapped.
137
138 bool _allow_archiving_with_java_agent; // setting of the AllowArchivingWithJavaAgent option
139 bool _use_optimized_module_handling;// No module-relation VM options were specified, so we can skip
140 // some expensive operations.
141 bool _has_aot_linked_classes; // Was the CDS archive created with -XX:+AOTClassLinking
142 bool _has_full_module_graph; // Does this CDS archive contain the full archived module graph?
143 bool _has_archived_invokedynamic; // Does the archive have aot-linked invokedynamic CP entries?
144 bool _has_archived_packages;
145 bool _has_archived_protection_domains;
146 int _gc_kind; // Universe::heap()->kind();
147 char _gc_name[32]; // Universe::heap()->name();
148 size_t _ptrmap_size_in_bits; // Size of pointer relocation bitmap
149 HeapRootSegments _heap_root_segments; // Heap root segments info
150 size_t _heap_oopmap_start_pos; // The first bit in the oopmap corresponds to this position in the heap.
151 size_t _heap_ptrmap_start_pos; // The first bit in the ptrmap corresponds to this position in the heap.
152 size_t _rw_ptrmap_start_pos; // The first bit in the ptrmap corresponds to this position in the rw region
153 size_t _ro_ptrmap_start_pos; // The first bit in the ptrmap corresponds to this position in the ro region
154 template <typename T> T from_mapped_offset(size_t offset) const {
155 return (T)(mapped_base_address() + offset);
156 }
157 void set_as_offset(char* p, size_t *offset);
158 template <typename T> void set_as_offset(T p, size_t *offset) {
159 set_as_offset((char*)p, offset);
160 }
161
162 public:
163 // Accessors -- fields declared in GenericCDSFileMapHeader
164 unsigned int magic() const { return _generic_header._magic; }
165 int crc() const { return _generic_header._crc; }
166 int version() const { return _generic_header._version; }
167 unsigned int header_size() const { return _generic_header._header_size; }
168 unsigned int base_archive_name_offset() const { return _generic_header._base_archive_name_offset; }
175 void set_base_archive_name_offset(unsigned int s) { _generic_header._base_archive_name_offset = s; }
176 void set_base_archive_name_size(unsigned int s) { _generic_header._base_archive_name_size = s; }
177
178 bool is_static() const { return magic() == CDS_ARCHIVE_MAGIC; }
179 size_t core_region_alignment() const { return _core_region_alignment; }
180 int obj_alignment() const { return _obj_alignment; }
181 address narrow_oop_base() const { return _narrow_oop_base; }
182 int narrow_oop_shift() const { return _narrow_oop_shift; }
183 bool compact_strings() const { return _compact_strings; }
184 bool compact_headers() const { return _compact_headers; }
185 uintx max_heap_size() const { return _max_heap_size; }
186 CompressedOops::Mode narrow_oop_mode() const { return _narrow_oop_mode; }
187 char* cloned_vtables() const { return from_mapped_offset<char*>(_cloned_vtables_offset); }
188 char* early_serialized_data() const { return from_mapped_offset<char*>(_early_serialized_data_offset); }
189 char* serialized_data() const { return from_mapped_offset<char*>(_serialized_data_offset); }
190 const char* jvm_ident() const { return _jvm_ident; }
191 char* requested_base_address() const { return _requested_base_address; }
192 char* mapped_base_address() const { return _mapped_base_address; }
193 bool has_platform_or_app_classes() const { return _has_platform_or_app_classes; }
194 bool has_aot_linked_classes() const { return _has_aot_linked_classes; }
195 int gc_kind() const { return _gc_kind; }
196 const char* gc_name() const { return _gc_name; }
197 size_t ptrmap_size_in_bits() const { return _ptrmap_size_in_bits; }
198 bool compressed_oops() const { return _compressed_oops; }
199 bool compressed_class_pointers() const { return _compressed_class_ptrs; }
200 int narrow_klass_pointer_bits() const { return _narrow_klass_pointer_bits; }
201 int narrow_klass_shift() const { return _narrow_klass_shift; }
202 HeapRootSegments heap_root_segments() const { return _heap_root_segments; }
203 bool has_full_module_graph() const { return _has_full_module_graph; }
204 size_t heap_oopmap_start_pos() const { return _heap_oopmap_start_pos; }
205 size_t heap_ptrmap_start_pos() const { return _heap_ptrmap_start_pos; }
206 size_t rw_ptrmap_start_pos() const { return _rw_ptrmap_start_pos; }
207 size_t ro_ptrmap_start_pos() const { return _ro_ptrmap_start_pos; }
208
209 void set_has_platform_or_app_classes(bool v) { _has_platform_or_app_classes = v; }
210 void set_cloned_vtables(char* p) { set_as_offset(p, &_cloned_vtables_offset); }
211 void set_early_serialized_data(char* p) { set_as_offset(p, &_early_serialized_data_offset); }
212 void set_serialized_data(char* p) { set_as_offset(p, &_serialized_data_offset); }
213 void set_mapped_base_address(char* p) { _mapped_base_address = p; }
214 void set_heap_root_segments(HeapRootSegments segments) { _heap_root_segments = segments; }
215 void set_heap_oopmap_start_pos(size_t n) { _heap_oopmap_start_pos = n; }
216 void set_heap_ptrmap_start_pos(size_t n) { _heap_ptrmap_start_pos = n; }
217 void set_rw_ptrmap_start_pos(size_t n) { _rw_ptrmap_start_pos = n; }
345
346 static void set_current_info(FileMapInfo* info) {
347 CDS_ONLY(_current_info = info;)
348 }
349
350 static FileMapInfo* dynamic_info() {
351 CDS_ONLY(return _dynamic_archive_info;)
352 NOT_CDS(return nullptr;)
353 }
354
355 static void assert_mark(bool check);
356
357 // File manipulation.
358 bool initialize() NOT_CDS_RETURN_(false);
359 bool open_for_read();
360 void open_for_write();
361 void write_header();
362 void write_region(int region, char* base, size_t size,
363 bool read_only, bool allow_exec);
364 size_t remove_bitmap_zeros(CHeapBitMap* map);
365 char* write_bitmap_region(CHeapBitMap* rw_ptrmap, CHeapBitMap* ro_ptrmap,
366 CHeapBitMap* cc_ptrmap, ArchiveHeapInfo* heap_info,
367 size_t &size_in_bytes);
368 size_t write_heap_region(ArchiveHeapInfo* heap_info);
369 void write_bytes(const void* buffer, size_t count);
370 void write_bytes_aligned(const void* buffer, size_t count);
371 size_t read_bytes(void* buffer, size_t count);
372 static size_t readonly_total();
373 MapArchiveResult map_regions(int regions[], int num_regions, char* mapped_base_address, ReservedSpace rs);
374 void unmap_regions(int regions[], int num_regions);
375 void map_or_load_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
376 void fixup_mapped_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
377 void patch_heap_embedded_pointers() NOT_CDS_JAVA_HEAP_RETURN;
378 bool has_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
379 MemRegion get_heap_region_requested_range() NOT_CDS_JAVA_HEAP_RETURN_(MemRegion());
380 bool read_region(int i, char* base, size_t size, bool do_commit);
381 char* map_bitmap_region();
382 bool map_cached_code_region(ReservedSpace rs);
383 void unmap_region(int i);
384 void close();
385 bool is_open() { return _file_open; }
386
387 // JVM/TI RedefineClasses() support:
388 // Remap the shared readonly space to shared readwrite, private.
389 bool remap_shared_readonly_as_readwrite();
390
391 static bool memory_mapping_failed() {
392 CDS_ONLY(return _memory_mapping_failed;)
393 NOT_CDS(return false;)
394 }
395
396 bool validate_class_location();
397 bool validate_aot_class_linking();
398
399 #if INCLUDE_JVMTI
400 // Caller needs a ResourceMark because parts of the returned cfs are resource-allocated.
401 static ClassFileStream* open_stream_for_jvmti(InstanceKlass* ik, Handle class_loader, TRAPS);
402 static ClassFileStream* get_stream_from_class_loader(Handle class_loader,
428 BitMapView bitmap_view(int region_index, bool is_oopmap);
429 BitMapView oopmap_view(int region_index);
430 BitMapView ptrmap_view(int region_index);
431
432 void print(outputStream* st) const;
433
434 const char* vm_version() {
435 return header()->jvm_ident();
436 }
437
438 private:
439 void seek_to_position(size_t pos);
440 bool map_heap_region_impl() NOT_CDS_JAVA_HEAP_RETURN_(false);
441 void dealloc_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
442 bool can_use_heap_region();
443 bool load_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
444 bool map_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
445 void init_heap_region_relocation();
446 MapArchiveResult map_region(int i, intx addr_delta, char* mapped_base_address, ReservedSpace rs);
447 bool relocate_pointers_in_core_regions(intx addr_delta);
448 void relocate_pointers_in_cached_code_region();
449 static MemRegion _mapped_heap_memregion;
450
451 public:
452 address heap_region_dumptime_address() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
453 address heap_region_requested_address() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
454 narrowOop encoded_heap_region_dumptime_address();
455
456 private:
457
458 #if INCLUDE_JVMTI
459 static ClassPathEntry** _classpath_entries_for_jvmti;
460 static ClassPathEntry* get_classpath_entry_for_jvmti(int i, TRAPS);
461 #endif
462 };
463
464 #endif // SHARE_CDS_FILEMAP_HPP
|