< prev index next >

src/hotspot/share/cds/filemap.hpp

Print this page

208   // during dumping. At run time, we validate these entries according to their
209   // SharedClassPathEntry::_type. See:
210   //      check_nonempty_dir_in_shared_path_table()
211   //      validate_shared_path_table()
212   //      validate_non_existent_class_paths()
213   size_t _shared_path_table_offset;
214 
215   jshort _app_class_paths_start_index;  // Index of first app classpath entry
216   jshort _app_module_paths_start_index; // Index of first module path entry
217   jshort _max_used_path_index;          // max path index referenced during CDS dump
218   int    _num_module_paths;             // number of module path entries
219   bool   _verify_local;                 // BytecodeVerificationLocal setting
220   bool   _verify_remote;                // BytecodeVerificationRemote setting
221   bool   _has_platform_or_app_classes;  // Archive contains app classes
222   char*  _requested_base_address;       // Archive relocation is not necessary if we map with this base address.
223   char*  _mapped_base_address;          // Actual base address where archive is mapped.
224 
225   bool   _allow_archiving_with_java_agent; // setting of the AllowArchivingWithJavaAgent option
226   bool   _use_optimized_module_handling;// No module-relation VM options were specified, so we can skip
227                                         // some expensive operations.

228   bool   _has_full_module_graph;        // Does this CDS archive contain the full archived module graph?






229   HeapRootSegments _heap_root_segments; // Heap root segments info
230   size_t _heap_oopmap_start_pos;        // The first bit in the oopmap corresponds to this position in the heap.
231   size_t _heap_ptrmap_start_pos;        // The first bit in the ptrmap corresponds to this position in the heap.
232   size_t _rw_ptrmap_start_pos;          // The first bit in the ptrmap corresponds to this position in the rw region
233   size_t _ro_ptrmap_start_pos;          // The first bit in the ptrmap corresponds to this position in the ro region
234   char* from_mapped_offset(size_t offset) const {
235     return mapped_base_address() + offset;
236   }
237   void set_as_offset(char* p, size_t *offset);
238 public:
239   // Accessors -- fields declared in GenericCDSFileMapHeader
240   unsigned int magic()                            const { return _generic_header._magic;                    }
241   int crc()                                       const { return _generic_header._crc;                      }
242   int version()                                   const { return _generic_header._version;                  }
243   unsigned int header_size()                      const { return _generic_header._header_size;              }
244   unsigned int base_archive_name_offset()         const { return _generic_header._base_archive_name_offset; }
245   unsigned int base_archive_name_size()           const { return _generic_header._base_archive_name_size;   }
246   unsigned int common_app_classpath_prefix_size() const { return _common_app_classpath_prefix_size;         }
247 
248   void set_magic(unsigned int m)                            { _generic_header._magic = m;                    }

251   void set_header_size(unsigned int s)                      { _generic_header._header_size = s;              }
252   void set_base_archive_name_offset(unsigned int s)         { _generic_header._base_archive_name_offset = s; }
253   void set_base_archive_name_size(unsigned int s)           { _generic_header._base_archive_name_size = s;   }
254   void set_common_app_classpath_prefix_size(unsigned int s) { _common_app_classpath_prefix_size = s;         }
255 
256   bool is_static()                         const { return magic() == CDS_ARCHIVE_MAGIC; }
257   size_t core_region_alignment()           const { return _core_region_alignment; }
258   int obj_alignment()                      const { return _obj_alignment; }
259   address narrow_oop_base()                const { return _narrow_oop_base; }
260   int narrow_oop_shift()                   const { return _narrow_oop_shift; }
261   bool compact_strings()                   const { return _compact_strings; }
262   uintx max_heap_size()                    const { return _max_heap_size; }
263   CompressedOops::Mode narrow_oop_mode()   const { return _narrow_oop_mode; }
264   char* cloned_vtables()                   const { return from_mapped_offset(_cloned_vtables_offset); }
265   char* serialized_data()                  const { return from_mapped_offset(_serialized_data_offset); }
266   const char* jvm_ident()                  const { return _jvm_ident; }
267   char* requested_base_address()           const { return _requested_base_address; }
268   char* mapped_base_address()              const { return _mapped_base_address; }
269   bool has_platform_or_app_classes()       const { return _has_platform_or_app_classes; }
270   bool has_non_jar_in_classpath()          const { return _has_non_jar_in_classpath; }




271   bool compressed_oops()                   const { return _compressed_oops; }
272   bool compressed_class_pointers()         const { return _compressed_class_ptrs; }
273   HeapRootSegments heap_root_segments()    const { return _heap_root_segments; }
274   size_t heap_oopmap_start_pos()           const { return _heap_oopmap_start_pos; }
275   size_t heap_ptrmap_start_pos()           const { return _heap_ptrmap_start_pos; }
276   size_t rw_ptrmap_start_pos()             const { return _rw_ptrmap_start_pos; }
277   size_t ro_ptrmap_start_pos()             const { return _ro_ptrmap_start_pos; }
278   // FIXME: These should really return int
279   jshort max_used_path_index()             const { return _max_used_path_index; }
280   jshort app_module_paths_start_index()    const { return _app_module_paths_start_index; }
281   jshort app_class_paths_start_index()     const { return _app_class_paths_start_index; }
282   int    num_module_paths()                const { return _num_module_paths; }
283 
284   void set_has_platform_or_app_classes(bool v)   { _has_platform_or_app_classes = v; }
285   void set_cloned_vtables(char* p)               { set_as_offset(p, &_cloned_vtables_offset); }
286   void set_serialized_data(char* p)              { set_as_offset(p, &_serialized_data_offset); }
287   void set_mapped_base_address(char* p)          { _mapped_base_address = p; }
288   void set_heap_root_segments(HeapRootSegments segments) { _heap_root_segments = segments; }
289   void set_heap_oopmap_start_pos(size_t n)       { _heap_oopmap_start_pos = n; }
290   void set_heap_ptrmap_start_pos(size_t n)       { _heap_ptrmap_start_pos = n; }

429 
430   static void set_current_info(FileMapInfo* info) {
431     CDS_ONLY(_current_info = info;)
432   }
433 
434   static FileMapInfo* dynamic_info() {
435     CDS_ONLY(return _dynamic_archive_info;)
436     NOT_CDS(return nullptr;)
437   }
438 
439   static void assert_mark(bool check);
440 
441   // File manipulation.
442   bool  initialize() NOT_CDS_RETURN_(false);
443   bool  open_for_read();
444   void  open_for_write();
445   void  write_header();
446   void  write_region(int region, char* base, size_t size,
447                      bool read_only, bool allow_exec);
448   size_t remove_bitmap_zeros(CHeapBitMap* map);
449   char* write_bitmap_region(CHeapBitMap* rw_ptrmap, CHeapBitMap* ro_ptrmap, ArchiveHeapInfo* heap_info,

450                             size_t &size_in_bytes);
451   size_t write_heap_region(ArchiveHeapInfo* heap_info);
452   void  write_bytes(const void* buffer, size_t count);
453   void  write_bytes_aligned(const void* buffer, size_t count);
454   size_t  read_bytes(void* buffer, size_t count);
455   static size_t readonly_total();
456   MapArchiveResult map_regions(int regions[], int num_regions, char* mapped_base_address, ReservedSpace rs);
457   void  unmap_regions(int regions[], int num_regions);
458   void  map_or_load_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
459   void  fixup_mapped_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
460   void  patch_heap_embedded_pointers() NOT_CDS_JAVA_HEAP_RETURN;
461   bool  has_heap_region()  NOT_CDS_JAVA_HEAP_RETURN_(false);
462   MemRegion get_heap_region_requested_range() NOT_CDS_JAVA_HEAP_RETURN_(MemRegion());
463   bool  read_region(int i, char* base, size_t size, bool do_commit);
464   char* map_bitmap_region();

465   void  unmap_region(int i);
466   void  close();
467   bool  is_open() { return _file_open; }
468   ReservedSpace reserve_shared_memory();
469 
470   // JVM/TI RedefineClasses() support:
471   // Remap the shared readonly space to shared readwrite, private.
472   bool  remap_shared_readonly_as_readwrite();
473 
474   static bool memory_mapping_failed() {
475     CDS_ONLY(return _memory_mapping_failed;)
476     NOT_CDS(return false;)
477   }
478 
479   static void allocate_shared_path_table(TRAPS);
480   static int add_shared_classpaths(int i, const char* which, ClassPathEntry *cpe, TRAPS);
481   static void check_nonempty_dir_in_shared_path_table();
482   bool check_module_paths();
483   bool validate_shared_path_table();
484   void validate_non_existent_class_paths();

485   static void set_shared_path_table(FileMapInfo* info) {
486     _shared_path_table = info->header()->shared_path_table();
487   }
488   static void update_jar_manifest(ClassPathEntry *cpe, SharedClassPathEntry* ent, TRAPS);
489   static int num_non_existent_class_paths();
490   static void record_non_existent_class_path_entry(const char* path);
491 
492 #if INCLUDE_JVMTI
493   // Caller needs a ResourceMark because parts of the returned cfs are resource-allocated.
494   static ClassFileStream* open_stream_for_jvmti(InstanceKlass* ik, Handle class_loader, TRAPS);
495 #endif
496 
497   static SharedClassPathEntry* shared_path(int index) {
498     return _shared_path_table.path_at(index);
499   }
500 
501   static const char* shared_path_name(int index) {
502     assert(index >= 0, "Sanity");
503     return shared_path(index)->name();
504   }

547   GrowableArray<const char*>* create_dumptime_app_classpath_array() NOT_CDS_RETURN_(nullptr);
548   GrowableArray<const char*>* create_path_array(const char* path) NOT_CDS_RETURN_(nullptr);
549   bool  classpath_failure(const char* msg, const char* name) NOT_CDS_RETURN_(false);
550   unsigned int longest_common_app_classpath_prefix_len(int num_paths,
551                                                        GrowableArray<const char*>* rp_array)
552                                                        NOT_CDS_RETURN_(0);
553   bool  check_paths(int shared_path_start_idx, int num_paths,
554                     GrowableArray<const char*>* rp_array,
555                     unsigned int dumptime_prefix_len,
556                     unsigned int runtime_prefix_len) NOT_CDS_RETURN_(false);
557   bool  validate_boot_class_paths() NOT_CDS_RETURN_(false);
558   bool  validate_app_class_paths(int shared_app_paths_len) NOT_CDS_RETURN_(false);
559   bool  map_heap_region_impl() NOT_CDS_JAVA_HEAP_RETURN_(false);
560   void  dealloc_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
561   bool  can_use_heap_region();
562   bool  load_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
563   bool  map_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
564   void  init_heap_region_relocation();
565   MapArchiveResult map_region(int i, intx addr_delta, char* mapped_base_address, ReservedSpace rs);
566   bool  relocate_pointers_in_core_regions(intx addr_delta);
567 
568   static MemRegion _mapped_heap_memregion;
569 
570 public:
571   address heap_region_dumptime_address() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
572   address heap_region_requested_address() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
573   narrowOop encoded_heap_region_dumptime_address();
574 
575 private:
576 
577 #if INCLUDE_JVMTI
578   static ClassPathEntry** _classpath_entries_for_jvmti;
579   static ClassPathEntry* get_classpath_entry_for_jvmti(int i, TRAPS);
580 #endif
581 };
582 
583 #endif // SHARE_CDS_FILEMAP_HPP

208   // during dumping. At run time, we validate these entries according to their
209   // SharedClassPathEntry::_type. See:
210   //      check_nonempty_dir_in_shared_path_table()
211   //      validate_shared_path_table()
212   //      validate_non_existent_class_paths()
213   size_t _shared_path_table_offset;
214 
215   jshort _app_class_paths_start_index;  // Index of first app classpath entry
216   jshort _app_module_paths_start_index; // Index of first module path entry
217   jshort _max_used_path_index;          // max path index referenced during CDS dump
218   int    _num_module_paths;             // number of module path entries
219   bool   _verify_local;                 // BytecodeVerificationLocal setting
220   bool   _verify_remote;                // BytecodeVerificationRemote setting
221   bool   _has_platform_or_app_classes;  // Archive contains app classes
222   char*  _requested_base_address;       // Archive relocation is not necessary if we map with this base address.
223   char*  _mapped_base_address;          // Actual base address where archive is mapped.
224 
225   bool   _allow_archiving_with_java_agent; // setting of the AllowArchivingWithJavaAgent option
226   bool   _use_optimized_module_handling;// No module-relation VM options were specified, so we can skip
227                                         // some expensive operations.
228   bool   _has_aot_linked_classes;       // Was the CDS archive created with -XX:+AOTClassLinking
229   bool   _has_full_module_graph;        // Does this CDS archive contain the full archived module graph?
230   bool   _has_archived_invokedynamic;   // Does the archive have aot-linked invokedynamic CP entries?
231   bool   _has_archived_packages;
232   bool   _has_archived_protection_domains;
233   int    _gc_kind;                      // Universe::heap()->kind();
234   char   _gc_name[32];                  // Universe::heap()->name();
235   size_t _ptrmap_size_in_bits;          // Size of pointer relocation bitmap
236   HeapRootSegments _heap_root_segments; // Heap root segments info
237   size_t _heap_oopmap_start_pos;        // The first bit in the oopmap corresponds to this position in the heap.
238   size_t _heap_ptrmap_start_pos;        // The first bit in the ptrmap corresponds to this position in the heap.
239   size_t _rw_ptrmap_start_pos;          // The first bit in the ptrmap corresponds to this position in the rw region
240   size_t _ro_ptrmap_start_pos;          // The first bit in the ptrmap corresponds to this position in the ro region
241   char* from_mapped_offset(size_t offset) const {
242     return mapped_base_address() + offset;
243   }
244   void set_as_offset(char* p, size_t *offset);
245 public:
246   // Accessors -- fields declared in GenericCDSFileMapHeader
247   unsigned int magic()                            const { return _generic_header._magic;                    }
248   int crc()                                       const { return _generic_header._crc;                      }
249   int version()                                   const { return _generic_header._version;                  }
250   unsigned int header_size()                      const { return _generic_header._header_size;              }
251   unsigned int base_archive_name_offset()         const { return _generic_header._base_archive_name_offset; }
252   unsigned int base_archive_name_size()           const { return _generic_header._base_archive_name_size;   }
253   unsigned int common_app_classpath_prefix_size() const { return _common_app_classpath_prefix_size;         }
254 
255   void set_magic(unsigned int m)                            { _generic_header._magic = m;                    }

258   void set_header_size(unsigned int s)                      { _generic_header._header_size = s;              }
259   void set_base_archive_name_offset(unsigned int s)         { _generic_header._base_archive_name_offset = s; }
260   void set_base_archive_name_size(unsigned int s)           { _generic_header._base_archive_name_size = s;   }
261   void set_common_app_classpath_prefix_size(unsigned int s) { _common_app_classpath_prefix_size = s;         }
262 
263   bool is_static()                         const { return magic() == CDS_ARCHIVE_MAGIC; }
264   size_t core_region_alignment()           const { return _core_region_alignment; }
265   int obj_alignment()                      const { return _obj_alignment; }
266   address narrow_oop_base()                const { return _narrow_oop_base; }
267   int narrow_oop_shift()                   const { return _narrow_oop_shift; }
268   bool compact_strings()                   const { return _compact_strings; }
269   uintx max_heap_size()                    const { return _max_heap_size; }
270   CompressedOops::Mode narrow_oop_mode()   const { return _narrow_oop_mode; }
271   char* cloned_vtables()                   const { return from_mapped_offset(_cloned_vtables_offset); }
272   char* serialized_data()                  const { return from_mapped_offset(_serialized_data_offset); }
273   const char* jvm_ident()                  const { return _jvm_ident; }
274   char* requested_base_address()           const { return _requested_base_address; }
275   char* mapped_base_address()              const { return _mapped_base_address; }
276   bool has_platform_or_app_classes()       const { return _has_platform_or_app_classes; }
277   bool has_non_jar_in_classpath()          const { return _has_non_jar_in_classpath; }
278   bool has_aot_linked_classes()            const { return _has_aot_linked_classes; }
279   int gc_kind()                            const { return _gc_kind; }
280   const char* gc_name()                    const { return _gc_name; }
281   size_t ptrmap_size_in_bits()             const { return _ptrmap_size_in_bits; }
282   bool compressed_oops()                   const { return _compressed_oops; }
283   bool compressed_class_pointers()         const { return _compressed_class_ptrs; }
284   HeapRootSegments heap_root_segments()    const { return _heap_root_segments; }
285   size_t heap_oopmap_start_pos()           const { return _heap_oopmap_start_pos; }
286   size_t heap_ptrmap_start_pos()           const { return _heap_ptrmap_start_pos; }
287   size_t rw_ptrmap_start_pos()             const { return _rw_ptrmap_start_pos; }
288   size_t ro_ptrmap_start_pos()             const { return _ro_ptrmap_start_pos; }
289   // FIXME: These should really return int
290   jshort max_used_path_index()             const { return _max_used_path_index; }
291   jshort app_module_paths_start_index()    const { return _app_module_paths_start_index; }
292   jshort app_class_paths_start_index()     const { return _app_class_paths_start_index; }
293   int    num_module_paths()                const { return _num_module_paths; }
294 
295   void set_has_platform_or_app_classes(bool v)   { _has_platform_or_app_classes = v; }
296   void set_cloned_vtables(char* p)               { set_as_offset(p, &_cloned_vtables_offset); }
297   void set_serialized_data(char* p)              { set_as_offset(p, &_serialized_data_offset); }
298   void set_mapped_base_address(char* p)          { _mapped_base_address = p; }
299   void set_heap_root_segments(HeapRootSegments segments) { _heap_root_segments = segments; }
300   void set_heap_oopmap_start_pos(size_t n)       { _heap_oopmap_start_pos = n; }
301   void set_heap_ptrmap_start_pos(size_t n)       { _heap_ptrmap_start_pos = n; }

440 
441   static void set_current_info(FileMapInfo* info) {
442     CDS_ONLY(_current_info = info;)
443   }
444 
445   static FileMapInfo* dynamic_info() {
446     CDS_ONLY(return _dynamic_archive_info;)
447     NOT_CDS(return nullptr;)
448   }
449 
450   static void assert_mark(bool check);
451 
452   // File manipulation.
453   bool  initialize() NOT_CDS_RETURN_(false);
454   bool  open_for_read();
455   void  open_for_write();
456   void  write_header();
457   void  write_region(int region, char* base, size_t size,
458                      bool read_only, bool allow_exec);
459   size_t remove_bitmap_zeros(CHeapBitMap* map);
460   char* write_bitmap_region(CHeapBitMap* rw_ptrmap, CHeapBitMap* ro_ptrmap,
461                             CHeapBitMap* cc_ptrmap, ArchiveHeapInfo* heap_info,
462                             size_t &size_in_bytes);
463   size_t write_heap_region(ArchiveHeapInfo* heap_info);
464   void  write_bytes(const void* buffer, size_t count);
465   void  write_bytes_aligned(const void* buffer, size_t count);
466   size_t  read_bytes(void* buffer, size_t count);
467   static size_t readonly_total();
468   MapArchiveResult map_regions(int regions[], int num_regions, char* mapped_base_address, ReservedSpace rs);
469   void  unmap_regions(int regions[], int num_regions);
470   void  map_or_load_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
471   void  fixup_mapped_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
472   void  patch_heap_embedded_pointers() NOT_CDS_JAVA_HEAP_RETURN;
473   bool  has_heap_region()  NOT_CDS_JAVA_HEAP_RETURN_(false);
474   MemRegion get_heap_region_requested_range() NOT_CDS_JAVA_HEAP_RETURN_(MemRegion());
475   bool  read_region(int i, char* base, size_t size, bool do_commit);
476   char* map_bitmap_region();
477   bool map_cached_code_region(ReservedSpace rs);
478   void  unmap_region(int i);
479   void  close();
480   bool  is_open() { return _file_open; }
481   ReservedSpace reserve_shared_memory();
482 
483   // JVM/TI RedefineClasses() support:
484   // Remap the shared readonly space to shared readwrite, private.
485   bool  remap_shared_readonly_as_readwrite();
486 
487   static bool memory_mapping_failed() {
488     CDS_ONLY(return _memory_mapping_failed;)
489     NOT_CDS(return false;)
490   }
491 
492   static void allocate_shared_path_table(TRAPS);
493   static int add_shared_classpaths(int i, const char* which, ClassPathEntry *cpe, TRAPS);
494   static void check_nonempty_dir_in_shared_path_table();
495   bool check_module_paths();
496   bool validate_shared_path_table();
497   bool validate_non_existent_class_paths();
498   bool validate_aot_class_linking();
499   static void set_shared_path_table(FileMapInfo* info) {
500     _shared_path_table = info->header()->shared_path_table();
501   }
502   static void update_jar_manifest(ClassPathEntry *cpe, SharedClassPathEntry* ent, TRAPS);
503   static int num_non_existent_class_paths();
504   static void record_non_existent_class_path_entry(const char* path);
505 
506 #if INCLUDE_JVMTI
507   // Caller needs a ResourceMark because parts of the returned cfs are resource-allocated.
508   static ClassFileStream* open_stream_for_jvmti(InstanceKlass* ik, Handle class_loader, TRAPS);
509 #endif
510 
511   static SharedClassPathEntry* shared_path(int index) {
512     return _shared_path_table.path_at(index);
513   }
514 
515   static const char* shared_path_name(int index) {
516     assert(index >= 0, "Sanity");
517     return shared_path(index)->name();
518   }

561   GrowableArray<const char*>* create_dumptime_app_classpath_array() NOT_CDS_RETURN_(nullptr);
562   GrowableArray<const char*>* create_path_array(const char* path) NOT_CDS_RETURN_(nullptr);
563   bool  classpath_failure(const char* msg, const char* name) NOT_CDS_RETURN_(false);
564   unsigned int longest_common_app_classpath_prefix_len(int num_paths,
565                                                        GrowableArray<const char*>* rp_array)
566                                                        NOT_CDS_RETURN_(0);
567   bool  check_paths(int shared_path_start_idx, int num_paths,
568                     GrowableArray<const char*>* rp_array,
569                     unsigned int dumptime_prefix_len,
570                     unsigned int runtime_prefix_len) NOT_CDS_RETURN_(false);
571   bool  validate_boot_class_paths() NOT_CDS_RETURN_(false);
572   bool  validate_app_class_paths(int shared_app_paths_len) NOT_CDS_RETURN_(false);
573   bool  map_heap_region_impl() NOT_CDS_JAVA_HEAP_RETURN_(false);
574   void  dealloc_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
575   bool  can_use_heap_region();
576   bool  load_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
577   bool  map_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
578   void  init_heap_region_relocation();
579   MapArchiveResult map_region(int i, intx addr_delta, char* mapped_base_address, ReservedSpace rs);
580   bool  relocate_pointers_in_core_regions(intx addr_delta);
581   void  relocate_pointers_in_cached_code_region();
582   static MemRegion _mapped_heap_memregion;
583 
584 public:
585   address heap_region_dumptime_address() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
586   address heap_region_requested_address() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
587   narrowOop encoded_heap_region_dumptime_address();
588 
589 private:
590 
591 #if INCLUDE_JVMTI
592   static ClassPathEntry** _classpath_entries_for_jvmti;
593   static ClassPathEntry* get_classpath_entry_for_jvmti(int i, TRAPS);
594 #endif
595 };
596 
597 #endif // SHARE_CDS_FILEMAP_HPP
< prev index next >