100
101 class FileMapHeader: private CDSFileMapHeaderBase {
102 friend class CDSConstants;
103 friend class VMStructs;
104
105 private:
106 // The following fields record the states of the VM during dump time.
107 // They are compared with the runtime states to see if the archive
108 // can be used.
109 size_t _core_region_alignment; // how shared archive should be aligned
110 int _obj_alignment; // value of ObjectAlignmentInBytes
111 address _narrow_oop_base; // compressed oop encoding base
112 int _narrow_oop_shift; // compressed oop encoding shift
113 bool _compact_strings; // value of CompactStrings
114 bool _compact_headers; // value of UseCompactObjectHeaders
115 uintx _max_heap_size; // java max heap size during dumping
116 CompressedOops::Mode _narrow_oop_mode; // compressed oop encoding mode
117 bool _compressed_oops; // save the flag UseCompressedOops
118 bool _compressed_class_ptrs; // save the flag UseCompressedClassPointers
119 int _narrow_klass_pointer_bits; // save number of bits in narrowKlass
120 int _narrow_klass_shift; // save shift width used to pre-compute narrowKlass IDs in archived heap objects
121 size_t _cloned_vtables_offset; // The address of the first cloned vtable
122 size_t _early_serialized_data_offset; // Data accessed using {ReadClosure,WriteClosure}::serialize()
123 size_t _serialized_data_offset; // Data accessed using {ReadClosure,WriteClosure}::serialize()
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 HeapRootSegments _heap_root_segments; // Heap root segments info
144 size_t _heap_oopmap_start_pos; // The first bit in the oopmap corresponds to this position in the heap.
145 size_t _heap_ptrmap_start_pos; // The first bit in the ptrmap corresponds to this position in the heap.
146 size_t _rw_ptrmap_start_pos; // The first bit in the ptrmap corresponds to this position in the rw region
147 size_t _ro_ptrmap_start_pos; // The first bit in the ptrmap corresponds to this position in the ro region
148 template <typename T> T from_mapped_offset(size_t offset) const {
149 return (T)(mapped_base_address() + offset);
150 }
151 void set_as_offset(char* p, size_t *offset);
152 template <typename T> void set_as_offset(T p, size_t *offset) {
153 set_as_offset((char*)p, offset);
154 }
155
156 public:
157 // Accessors -- fields declared in GenericCDSFileMapHeader
158 unsigned int magic() const { return _generic_header._magic; }
159 int crc() const { return _generic_header._crc; }
160 int version() const { return _generic_header._version; }
161 unsigned int header_size() const { return _generic_header._header_size; }
162 unsigned int base_archive_name_offset() const { return _generic_header._base_archive_name_offset; }
163 unsigned int base_archive_name_size() const { return _generic_header._base_archive_name_size; }
164
165 void set_magic(unsigned int m) { _generic_header._magic = m; }
166 void set_crc(int crc_value) { _generic_header._crc = crc_value; }
167 void set_version(int v) { _generic_header._version = v; }
169 void set_base_archive_name_offset(unsigned int s) { _generic_header._base_archive_name_offset = s; }
170 void set_base_archive_name_size(unsigned int s) { _generic_header._base_archive_name_size = s; }
171
172 bool is_static() const { return magic() == CDS_ARCHIVE_MAGIC; }
173 size_t core_region_alignment() const { return _core_region_alignment; }
174 int obj_alignment() const { return _obj_alignment; }
175 address narrow_oop_base() const { return _narrow_oop_base; }
176 int narrow_oop_shift() const { return _narrow_oop_shift; }
177 bool compact_strings() const { return _compact_strings; }
178 bool compact_headers() const { return _compact_headers; }
179 uintx max_heap_size() const { return _max_heap_size; }
180 CompressedOops::Mode narrow_oop_mode() const { return _narrow_oop_mode; }
181 char* cloned_vtables() const { return from_mapped_offset<char*>(_cloned_vtables_offset); }
182 char* early_serialized_data() const { return from_mapped_offset<char*>(_early_serialized_data_offset); }
183 char* serialized_data() const { return from_mapped_offset<char*>(_serialized_data_offset); }
184 const char* jvm_ident() const { return _jvm_ident; }
185 char* requested_base_address() const { return _requested_base_address; }
186 char* mapped_base_address() const { return _mapped_base_address; }
187 bool has_platform_or_app_classes() const { return _has_platform_or_app_classes; }
188 bool has_aot_linked_classes() const { return _has_aot_linked_classes; }
189 bool compressed_oops() const { return _compressed_oops; }
190 bool compressed_class_pointers() const { return _compressed_class_ptrs; }
191 int narrow_klass_pointer_bits() const { return _narrow_klass_pointer_bits; }
192 int narrow_klass_shift() const { return _narrow_klass_shift; }
193 HeapRootSegments heap_root_segments() const { return _heap_root_segments; }
194 bool has_full_module_graph() const { return _has_full_module_graph; }
195 size_t heap_oopmap_start_pos() const { return _heap_oopmap_start_pos; }
196 size_t heap_ptrmap_start_pos() const { return _heap_ptrmap_start_pos; }
197 size_t rw_ptrmap_start_pos() const { return _rw_ptrmap_start_pos; }
198 size_t ro_ptrmap_start_pos() const { return _ro_ptrmap_start_pos; }
199
200 void set_has_platform_or_app_classes(bool v) { _has_platform_or_app_classes = v; }
201 void set_cloned_vtables(char* p) { set_as_offset(p, &_cloned_vtables_offset); }
202 void set_early_serialized_data(char* p) { set_as_offset(p, &_early_serialized_data_offset); }
203 void set_serialized_data(char* p) { set_as_offset(p, &_serialized_data_offset); }
204 void set_mapped_base_address(char* p) { _mapped_base_address = p; }
205 void set_heap_root_segments(HeapRootSegments segments) { _heap_root_segments = segments; }
206 void set_heap_oopmap_start_pos(size_t n) { _heap_oopmap_start_pos = n; }
207 void set_heap_ptrmap_start_pos(size_t n) { _heap_ptrmap_start_pos = n; }
208 void set_rw_ptrmap_start_pos(size_t n) { _rw_ptrmap_start_pos = n; }
335 }
336
337 static void set_current_info(FileMapInfo* info) {
338 CDS_ONLY(_current_info = info;)
339 }
340
341 static FileMapInfo* dynamic_info() {
342 CDS_ONLY(return _dynamic_archive_info;)
343 NOT_CDS(return nullptr;)
344 }
345
346 static void assert_mark(bool check);
347
348 // File manipulation.
349 bool open_as_input() NOT_CDS_RETURN_(false);
350 void open_as_output();
351 void write_header();
352 void write_region(int region, char* base, size_t size,
353 bool read_only, bool allow_exec);
354 size_t remove_bitmap_zeros(CHeapBitMap* map);
355 char* write_bitmap_region(CHeapBitMap* rw_ptrmap, CHeapBitMap* ro_ptrmap, ArchiveHeapInfo* heap_info,
356 size_t &size_in_bytes);
357 size_t write_heap_region(ArchiveHeapInfo* heap_info);
358 void write_bytes(const void* buffer, size_t count);
359 void write_bytes_aligned(const void* buffer, size_t count);
360 size_t read_bytes(void* buffer, size_t count);
361 static size_t readonly_total();
362 MapArchiveResult map_regions(int regions[], int num_regions, char* mapped_base_address, ReservedSpace rs);
363 void unmap_regions(int regions[], int num_regions);
364 void map_or_load_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
365 void fixup_mapped_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
366 void patch_heap_embedded_pointers() NOT_CDS_JAVA_HEAP_RETURN;
367 bool has_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
368 MemRegion get_heap_region_requested_range() NOT_CDS_JAVA_HEAP_RETURN_(MemRegion());
369 bool read_region(int i, char* base, size_t size, bool do_commit);
370 char* map_bitmap_region();
371 bool map_aot_code_region(ReservedSpace rs);
372 void unmap_region(int i);
373 void close();
374 bool is_open() { return _file_open; }
375
418 BitMapView oopmap_view(int region_index);
419 BitMapView ptrmap_view(int region_index);
420
421 void print(outputStream* st) const;
422
423 const char* vm_version() {
424 return header()->jvm_ident();
425 }
426
427 private:
428 bool open_for_read();
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
|
100
101 class FileMapHeader: private CDSFileMapHeaderBase {
102 friend class CDSConstants;
103 friend class VMStructs;
104
105 private:
106 // The following fields record the states of the VM during dump time.
107 // They are compared with the runtime states to see if the archive
108 // can be used.
109 size_t _core_region_alignment; // how shared archive should be aligned
110 int _obj_alignment; // value of ObjectAlignmentInBytes
111 address _narrow_oop_base; // compressed oop encoding base
112 int _narrow_oop_shift; // compressed oop encoding shift
113 bool _compact_strings; // value of CompactStrings
114 bool _compact_headers; // value of UseCompactObjectHeaders
115 uintx _max_heap_size; // java max heap size during dumping
116 CompressedOops::Mode _narrow_oop_mode; // compressed oop encoding mode
117 bool _compressed_oops; // save the flag UseCompressedOops
118 bool _compressed_class_ptrs; // save the flag UseCompressedClassPointers
119 int _narrow_klass_pointer_bits; // save number of bits in narrowKlass
120 int _narrow_klass_shift; // save shift width used to pre-compute narrowKlass IDs in archived heap objectsa
121 size_t _cloned_vtables_offset; // The address of the first cloned vtable
122 size_t _early_serialized_data_offset; // Data accessed using {ReadClosure,WriteClosure}::serialize()
123 size_t _serialized_data_offset; // Data accessed using {ReadClosure,WriteClosure}::serialize()
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_packages;
144 bool _has_archived_protection_domains;
145 int _gc_kind; // Universe::heap()->kind();
146 char _gc_name[32]; // Universe::heap()->name();
147 size_t _ptrmap_size_in_bits; // Size of pointer relocation bitmap
148 HeapRootSegments _heap_root_segments; // Heap root segments info
149 size_t _heap_oopmap_start_pos; // The first bit in the oopmap corresponds to this position in the heap.
150 size_t _heap_ptrmap_start_pos; // The first bit in the ptrmap corresponds to this position in the heap.
151 size_t _rw_ptrmap_start_pos; // The first bit in the ptrmap corresponds to this position in the rw region
152 size_t _ro_ptrmap_start_pos; // The first bit in the ptrmap corresponds to this position in the ro region
153
154 // The following are parameters that affect MethodData layout.
155 uint _type_profile_level;
156 intx _type_profile_width;
157 intx _bci_profile_width;
158 bool _profile_traps;
159 int _spec_trap_limit_extra_entries;
160
161 template <typename T> T from_mapped_offset(size_t offset) const {
162 return (T)(mapped_base_address() + offset);
163 }
164 void set_as_offset(char* p, size_t *offset);
165 template <typename T> void set_as_offset(T p, size_t *offset) {
166 set_as_offset((char*)p, offset);
167 }
168
169 public:
170 // Accessors -- fields declared in GenericCDSFileMapHeader
171 unsigned int magic() const { return _generic_header._magic; }
172 int crc() const { return _generic_header._crc; }
173 int version() const { return _generic_header._version; }
174 unsigned int header_size() const { return _generic_header._header_size; }
175 unsigned int base_archive_name_offset() const { return _generic_header._base_archive_name_offset; }
176 unsigned int base_archive_name_size() const { return _generic_header._base_archive_name_size; }
177
178 void set_magic(unsigned int m) { _generic_header._magic = m; }
179 void set_crc(int crc_value) { _generic_header._crc = crc_value; }
180 void set_version(int v) { _generic_header._version = v; }
182 void set_base_archive_name_offset(unsigned int s) { _generic_header._base_archive_name_offset = s; }
183 void set_base_archive_name_size(unsigned int s) { _generic_header._base_archive_name_size = s; }
184
185 bool is_static() const { return magic() == CDS_ARCHIVE_MAGIC; }
186 size_t core_region_alignment() const { return _core_region_alignment; }
187 int obj_alignment() const { return _obj_alignment; }
188 address narrow_oop_base() const { return _narrow_oop_base; }
189 int narrow_oop_shift() const { return _narrow_oop_shift; }
190 bool compact_strings() const { return _compact_strings; }
191 bool compact_headers() const { return _compact_headers; }
192 uintx max_heap_size() const { return _max_heap_size; }
193 CompressedOops::Mode narrow_oop_mode() const { return _narrow_oop_mode; }
194 char* cloned_vtables() const { return from_mapped_offset<char*>(_cloned_vtables_offset); }
195 char* early_serialized_data() const { return from_mapped_offset<char*>(_early_serialized_data_offset); }
196 char* serialized_data() const { return from_mapped_offset<char*>(_serialized_data_offset); }
197 const char* jvm_ident() const { return _jvm_ident; }
198 char* requested_base_address() const { return _requested_base_address; }
199 char* mapped_base_address() const { return _mapped_base_address; }
200 bool has_platform_or_app_classes() const { return _has_platform_or_app_classes; }
201 bool has_aot_linked_classes() const { return _has_aot_linked_classes; }
202 int gc_kind() const { return _gc_kind; }
203 const char* gc_name() const { return _gc_name; }
204 size_t ptrmap_size_in_bits() const { return _ptrmap_size_in_bits; }
205 bool compressed_oops() const { return _compressed_oops; }
206 bool compressed_class_pointers() const { return _compressed_class_ptrs; }
207 int narrow_klass_pointer_bits() const { return _narrow_klass_pointer_bits; }
208 int narrow_klass_shift() const { return _narrow_klass_shift; }
209 HeapRootSegments heap_root_segments() const { return _heap_root_segments; }
210 bool has_full_module_graph() const { return _has_full_module_graph; }
211 size_t heap_oopmap_start_pos() const { return _heap_oopmap_start_pos; }
212 size_t heap_ptrmap_start_pos() const { return _heap_ptrmap_start_pos; }
213 size_t rw_ptrmap_start_pos() const { return _rw_ptrmap_start_pos; }
214 size_t ro_ptrmap_start_pos() const { return _ro_ptrmap_start_pos; }
215
216 void set_has_platform_or_app_classes(bool v) { _has_platform_or_app_classes = v; }
217 void set_cloned_vtables(char* p) { set_as_offset(p, &_cloned_vtables_offset); }
218 void set_early_serialized_data(char* p) { set_as_offset(p, &_early_serialized_data_offset); }
219 void set_serialized_data(char* p) { set_as_offset(p, &_serialized_data_offset); }
220 void set_mapped_base_address(char* p) { _mapped_base_address = p; }
221 void set_heap_root_segments(HeapRootSegments segments) { _heap_root_segments = segments; }
222 void set_heap_oopmap_start_pos(size_t n) { _heap_oopmap_start_pos = n; }
223 void set_heap_ptrmap_start_pos(size_t n) { _heap_ptrmap_start_pos = n; }
224 void set_rw_ptrmap_start_pos(size_t n) { _rw_ptrmap_start_pos = n; }
351 }
352
353 static void set_current_info(FileMapInfo* info) {
354 CDS_ONLY(_current_info = info;)
355 }
356
357 static FileMapInfo* dynamic_info() {
358 CDS_ONLY(return _dynamic_archive_info;)
359 NOT_CDS(return nullptr;)
360 }
361
362 static void assert_mark(bool check);
363
364 // File manipulation.
365 bool open_as_input() NOT_CDS_RETURN_(false);
366 void open_as_output();
367 void write_header();
368 void write_region(int region, char* base, size_t size,
369 bool read_only, bool allow_exec);
370 size_t remove_bitmap_zeros(CHeapBitMap* map);
371 char* write_bitmap_region(CHeapBitMap* rw_ptrmap, CHeapBitMap* ro_ptrmap,
372 CHeapBitMap* cc_ptrmap, ArchiveHeapInfo* heap_info,
373 size_t &size_in_bytes);
374 size_t write_heap_region(ArchiveHeapInfo* heap_info);
375 void write_bytes(const void* buffer, size_t count);
376 void write_bytes_aligned(const void* buffer, size_t count);
377 size_t read_bytes(void* buffer, size_t count);
378 static size_t readonly_total();
379 MapArchiveResult map_regions(int regions[], int num_regions, char* mapped_base_address, ReservedSpace rs);
380 void unmap_regions(int regions[], int num_regions);
381 void map_or_load_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
382 void fixup_mapped_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
383 void patch_heap_embedded_pointers() NOT_CDS_JAVA_HEAP_RETURN;
384 bool has_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
385 MemRegion get_heap_region_requested_range() NOT_CDS_JAVA_HEAP_RETURN_(MemRegion());
386 bool read_region(int i, char* base, size_t size, bool do_commit);
387 char* map_bitmap_region();
388 bool map_aot_code_region(ReservedSpace rs);
389 void unmap_region(int i);
390 void close();
391 bool is_open() { return _file_open; }
392
435 BitMapView oopmap_view(int region_index);
436 BitMapView ptrmap_view(int region_index);
437
438 void print(outputStream* st) const;
439
440 const char* vm_version() {
441 return header()->jvm_ident();
442 }
443
444 private:
445 bool open_for_read();
446 void seek_to_position(size_t pos);
447 bool map_heap_region_impl() NOT_CDS_JAVA_HEAP_RETURN_(false);
448 void dealloc_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
449 bool can_use_heap_region();
450 bool load_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
451 bool map_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
452 void init_heap_region_relocation();
453 MapArchiveResult map_region(int i, intx addr_delta, char* mapped_base_address, ReservedSpace rs);
454 bool relocate_pointers_in_core_regions(intx addr_delta);
455 void relocate_pointers_in_aot_code_region();
456 static MemRegion _mapped_heap_memregion;
457
458 public:
459 address heap_region_dumptime_address() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
460 address heap_region_requested_address() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
461 narrowOop encoded_heap_region_dumptime_address();
462
463 private:
464
465 #if INCLUDE_JVMTI
466 static ClassPathEntry** _classpath_entries_for_jvmti;
467 static ClassPathEntry* get_classpath_entry_for_jvmti(int i, TRAPS);
468 #endif
469 };
470
471 #endif // SHARE_CDS_FILEMAP_HPP
|