< 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   bool has_full_module_graph()             const { return _has_full_module_graph; }
275   size_t heap_oopmap_start_pos()           const { return _heap_oopmap_start_pos; }
276   size_t heap_ptrmap_start_pos()           const { return _heap_ptrmap_start_pos; }
277   size_t rw_ptrmap_start_pos()             const { return _rw_ptrmap_start_pos; }
278   size_t ro_ptrmap_start_pos()             const { return _ro_ptrmap_start_pos; }
279   // FIXME: These should really return int
280   jshort max_used_path_index()             const { return _max_used_path_index; }
281   jshort app_module_paths_start_index()    const { return _app_module_paths_start_index; }
282   jshort app_class_paths_start_index()     const { return _app_class_paths_start_index; }
283   int    num_module_paths()                const { return _num_module_paths; }
284 
285   void set_has_platform_or_app_classes(bool v)   { _has_platform_or_app_classes = v; }
286   void set_cloned_vtables(char* p)               { set_as_offset(p, &_cloned_vtables_offset); }
287   void set_serialized_data(char* p)              { set_as_offset(p, &_serialized_data_offset); }
288   void set_mapped_base_address(char* p)          { _mapped_base_address = p; }
289   void set_heap_root_segments(HeapRootSegments segments) { _heap_root_segments = segments; }
290   void set_heap_oopmap_start_pos(size_t n)       { _heap_oopmap_start_pos = n; }

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

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

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

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

549   GrowableArray<const char*>* create_path_array(const char* path) NOT_CDS_RETURN_(nullptr);
550   bool  classpath_failure(const char* msg, const char* name) NOT_CDS_RETURN_(false);
551   unsigned int longest_common_app_classpath_prefix_len(int num_paths,
552                                                        GrowableArray<const char*>* rp_array)
553                                                        NOT_CDS_RETURN_(0);
554   bool  check_paths(int shared_path_start_idx, int num_paths,
555                     GrowableArray<const char*>* rp_array,
556                     unsigned int dumptime_prefix_len,
557                     unsigned int runtime_prefix_len) NOT_CDS_RETURN_(false);
558   void  extract_module_paths(const char* runtime_path, GrowableArray<const char*>* module_paths);
559   bool  validate_boot_class_paths() NOT_CDS_RETURN_(false);
560   bool  validate_app_class_paths(int shared_app_paths_len) NOT_CDS_RETURN_(false);
561   bool  map_heap_region_impl() NOT_CDS_JAVA_HEAP_RETURN_(false);
562   void  dealloc_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
563   bool  can_use_heap_region();
564   bool  load_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
565   bool  map_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
566   void  init_heap_region_relocation();
567   MapArchiveResult map_region(int i, intx addr_delta, char* mapped_base_address, ReservedSpace rs);
568   bool  relocate_pointers_in_core_regions(intx addr_delta);
569 
570   static MemRegion _mapped_heap_memregion;
571 
572 public:
573   address heap_region_dumptime_address() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
574   address heap_region_requested_address() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
575   narrowOop encoded_heap_region_dumptime_address();
576 
577 private:
578 
579 #if INCLUDE_JVMTI
580   static ClassPathEntry** _classpath_entries_for_jvmti;
581   static ClassPathEntry* get_classpath_entry_for_jvmti(int i, TRAPS);
582 #endif
583 };
584 
585 #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   bool has_full_module_graph()             const { return _has_full_module_graph; }
286   size_t heap_oopmap_start_pos()           const { return _heap_oopmap_start_pos; }
287   size_t heap_ptrmap_start_pos()           const { return _heap_ptrmap_start_pos; }
288   size_t rw_ptrmap_start_pos()             const { return _rw_ptrmap_start_pos; }
289   size_t ro_ptrmap_start_pos()             const { return _ro_ptrmap_start_pos; }
290   // FIXME: These should really return int
291   jshort max_used_path_index()             const { return _max_used_path_index; }
292   jshort app_module_paths_start_index()    const { return _app_module_paths_start_index; }
293   jshort app_class_paths_start_index()     const { return _app_class_paths_start_index; }
294   int    num_module_paths()                const { return _num_module_paths; }
295 
296   void set_has_platform_or_app_classes(bool v)   { _has_platform_or_app_classes = v; }
297   void set_cloned_vtables(char* p)               { set_as_offset(p, &_cloned_vtables_offset); }
298   void set_serialized_data(char* p)              { set_as_offset(p, &_serialized_data_offset); }
299   void set_mapped_base_address(char* p)          { _mapped_base_address = p; }
300   void set_heap_root_segments(HeapRootSegments segments) { _heap_root_segments = segments; }
301   void set_heap_oopmap_start_pos(size_t n)       { _heap_oopmap_start_pos = n; }

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

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