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; }
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 void unmap_region(int i);
372 void close();
373 bool is_open() { return _file_open; }
374
375 // JVM/TI RedefineClasses() support:
376 // Remap the shared readonly space to shared readwrite, private.
377 bool remap_shared_readonly_as_readwrite();
378
379 static bool memory_mapping_failed() {
380 CDS_ONLY(return _memory_mapping_failed;)
381 NOT_CDS(return false;)
382 }
383
384 bool validate_class_location();
385 bool validate_aot_class_linking();
386
387 #if INCLUDE_JVMTI
388 // Caller needs a ResourceMark because parts of the returned cfs are resource-allocated.
389 static ClassFileStream* open_stream_for_jvmti(InstanceKlass* ik, Handle class_loader, TRAPS);
390 static ClassFileStream* get_stream_from_class_loader(Handle class_loader,
417 BitMapView oopmap_view(int region_index);
418 BitMapView ptrmap_view(int region_index);
419
420 void print(outputStream* st) const;
421
422 const char* vm_version() {
423 return header()->jvm_ident();
424 }
425
426 private:
427 bool open_for_read();
428 void seek_to_position(size_t pos);
429 bool map_heap_region_impl() NOT_CDS_JAVA_HEAP_RETURN_(false);
430 void dealloc_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
431 bool can_use_heap_region();
432 bool load_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
433 bool map_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
434 void init_heap_region_relocation();
435 MapArchiveResult map_region(int i, intx addr_delta, char* mapped_base_address, ReservedSpace rs);
436 bool relocate_pointers_in_core_regions(intx addr_delta);
437
438 static MemRegion _mapped_heap_memregion;
439
440 public:
441 address heap_region_dumptime_address() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
442 address heap_region_requested_address() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
443 narrowOop encoded_heap_region_dumptime_address();
444
445 private:
446
447 #if INCLUDE_JVMTI
448 static ClassPathEntry** _classpath_entries_for_jvmti;
449 static ClassPathEntry* get_classpath_entry_for_jvmti(int i, TRAPS);
450 #endif
451 };
452
453 #endif // SHARE_CDS_FILEMAP_HPP
|
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 template <typename T> T from_mapped_offset(size_t offset) const {
154 return (T)(mapped_base_address() + offset);
155 }
156 void set_as_offset(char* p, size_t *offset);
157 template <typename T> void set_as_offset(T p, size_t *offset) {
158 set_as_offset((char*)p, offset);
159 }
160
161 public:
162 // Accessors -- fields declared in GenericCDSFileMapHeader
163 unsigned int magic() const { return _generic_header._magic; }
164 int crc() const { return _generic_header._crc; }
165 int version() const { return _generic_header._version; }
166 unsigned int header_size() const { return _generic_header._header_size; }
167 unsigned int base_archive_name_offset() const { return _generic_header._base_archive_name_offset; }
174 void set_base_archive_name_offset(unsigned int s) { _generic_header._base_archive_name_offset = s; }
175 void set_base_archive_name_size(unsigned int s) { _generic_header._base_archive_name_size = s; }
176
177 bool is_static() const { return magic() == CDS_ARCHIVE_MAGIC; }
178 size_t core_region_alignment() const { return _core_region_alignment; }
179 int obj_alignment() const { return _obj_alignment; }
180 address narrow_oop_base() const { return _narrow_oop_base; }
181 int narrow_oop_shift() const { return _narrow_oop_shift; }
182 bool compact_strings() const { return _compact_strings; }
183 bool compact_headers() const { return _compact_headers; }
184 uintx max_heap_size() const { return _max_heap_size; }
185 CompressedOops::Mode narrow_oop_mode() const { return _narrow_oop_mode; }
186 char* cloned_vtables() const { return from_mapped_offset<char*>(_cloned_vtables_offset); }
187 char* early_serialized_data() const { return from_mapped_offset<char*>(_early_serialized_data_offset); }
188 char* serialized_data() const { return from_mapped_offset<char*>(_serialized_data_offset); }
189 const char* jvm_ident() const { return _jvm_ident; }
190 char* requested_base_address() const { return _requested_base_address; }
191 char* mapped_base_address() const { return _mapped_base_address; }
192 bool has_platform_or_app_classes() const { return _has_platform_or_app_classes; }
193 bool has_aot_linked_classes() const { return _has_aot_linked_classes; }
194 int gc_kind() const { return _gc_kind; }
195 const char* gc_name() const { return _gc_name; }
196 size_t ptrmap_size_in_bits() const { return _ptrmap_size_in_bits; }
197 bool compressed_oops() const { return _compressed_oops; }
198 bool compressed_class_pointers() const { return _compressed_class_ptrs; }
199 int narrow_klass_pointer_bits() const { return _narrow_klass_pointer_bits; }
200 int narrow_klass_shift() const { return _narrow_klass_shift; }
201 HeapRootSegments heap_root_segments() const { return _heap_root_segments; }
202 bool has_full_module_graph() const { return _has_full_module_graph; }
203 size_t heap_oopmap_start_pos() const { return _heap_oopmap_start_pos; }
204 size_t heap_ptrmap_start_pos() const { return _heap_ptrmap_start_pos; }
205 size_t rw_ptrmap_start_pos() const { return _rw_ptrmap_start_pos; }
206 size_t ro_ptrmap_start_pos() const { return _ro_ptrmap_start_pos; }
207
208 void set_has_platform_or_app_classes(bool v) { _has_platform_or_app_classes = v; }
209 void set_cloned_vtables(char* p) { set_as_offset(p, &_cloned_vtables_offset); }
210 void set_early_serialized_data(char* p) { set_as_offset(p, &_early_serialized_data_offset); }
211 void set_serialized_data(char* p) { set_as_offset(p, &_serialized_data_offset); }
212 void set_mapped_base_address(char* p) { _mapped_base_address = p; }
213 void set_heap_root_segments(HeapRootSegments segments) { _heap_root_segments = segments; }
214 void set_heap_oopmap_start_pos(size_t n) { _heap_oopmap_start_pos = n; }
215 void set_heap_ptrmap_start_pos(size_t n) { _heap_ptrmap_start_pos = n; }
216 void set_rw_ptrmap_start_pos(size_t n) { _rw_ptrmap_start_pos = n; }
343 }
344
345 static void set_current_info(FileMapInfo* info) {
346 CDS_ONLY(_current_info = info;)
347 }
348
349 static FileMapInfo* dynamic_info() {
350 CDS_ONLY(return _dynamic_archive_info;)
351 NOT_CDS(return nullptr;)
352 }
353
354 static void assert_mark(bool check);
355
356 // File manipulation.
357 bool open_as_input() NOT_CDS_RETURN_(false);
358 void open_as_output();
359 void write_header();
360 void write_region(int region, char* base, size_t size,
361 bool read_only, bool allow_exec);
362 size_t remove_bitmap_zeros(CHeapBitMap* map);
363 char* write_bitmap_region(CHeapBitMap* rw_ptrmap, CHeapBitMap* ro_ptrmap,
364 CHeapBitMap* cc_ptrmap, ArchiveHeapInfo* heap_info,
365 size_t &size_in_bytes);
366 size_t write_heap_region(ArchiveHeapInfo* heap_info);
367 void write_bytes(const void* buffer, size_t count);
368 void write_bytes_aligned(const void* buffer, size_t count);
369 size_t read_bytes(void* buffer, size_t count);
370 static size_t readonly_total();
371 MapArchiveResult map_regions(int regions[], int num_regions, char* mapped_base_address, ReservedSpace rs);
372 void unmap_regions(int regions[], int num_regions);
373 void map_or_load_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
374 void fixup_mapped_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
375 void patch_heap_embedded_pointers() NOT_CDS_JAVA_HEAP_RETURN;
376 bool has_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
377 MemRegion get_heap_region_requested_range() NOT_CDS_JAVA_HEAP_RETURN_(MemRegion());
378 bool read_region(int i, char* base, size_t size, bool do_commit);
379 char* map_bitmap_region();
380 bool map_cached_code_region(ReservedSpace rs);
381 void unmap_region(int i);
382 void close();
383 bool is_open() { return _file_open; }
384
385 // JVM/TI RedefineClasses() support:
386 // Remap the shared readonly space to shared readwrite, private.
387 bool remap_shared_readonly_as_readwrite();
388
389 static bool memory_mapping_failed() {
390 CDS_ONLY(return _memory_mapping_failed;)
391 NOT_CDS(return false;)
392 }
393
394 bool validate_class_location();
395 bool validate_aot_class_linking();
396
397 #if INCLUDE_JVMTI
398 // Caller needs a ResourceMark because parts of the returned cfs are resource-allocated.
399 static ClassFileStream* open_stream_for_jvmti(InstanceKlass* ik, Handle class_loader, TRAPS);
400 static ClassFileStream* get_stream_from_class_loader(Handle class_loader,
427 BitMapView oopmap_view(int region_index);
428 BitMapView ptrmap_view(int region_index);
429
430 void print(outputStream* st) const;
431
432 const char* vm_version() {
433 return header()->jvm_ident();
434 }
435
436 private:
437 bool open_for_read();
438 void seek_to_position(size_t pos);
439 bool map_heap_region_impl() NOT_CDS_JAVA_HEAP_RETURN_(false);
440 void dealloc_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
441 bool can_use_heap_region();
442 bool load_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
443 bool map_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
444 void init_heap_region_relocation();
445 MapArchiveResult map_region(int i, intx addr_delta, char* mapped_base_address, ReservedSpace rs);
446 bool relocate_pointers_in_core_regions(intx addr_delta);
447 void relocate_pointers_in_cached_code_region();
448 static MemRegion _mapped_heap_memregion;
449
450 public:
451 address heap_region_dumptime_address() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
452 address heap_region_requested_address() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
453 narrowOop encoded_heap_region_dumptime_address();
454
455 private:
456
457 #if INCLUDE_JVMTI
458 static ClassPathEntry** _classpath_entries_for_jvmti;
459 static ClassPathEntry* get_classpath_entry_for_jvmti(int i, TRAPS);
460 #endif
461 };
462
463 #endif // SHARE_CDS_FILEMAP_HPP
|