< prev index next >

src/hotspot/share/cds/filemap.hpp

Print this page

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

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

228   size_t _ptrmap_size_in_bits;          // Size of pointer relocation bitmap
229   size_t _heap_roots_offset;            // Offset of the HeapShared::roots() object, from the bottom
230                                         // of the archived heap objects, in bytes.
231   char* from_mapped_offset(size_t offset) const {
232     return mapped_base_address() + offset;
233   }
234   void set_as_offset(char* p, size_t *offset);
235 public:
236   // Accessors -- fields declared in GenericCDSFileMapHeader
237   unsigned int magic()                            const { return _generic_header._magic;                    }
238   int crc()                                       const { return _generic_header._crc;                      }
239   int version()                                   const { return _generic_header._version;                  }
240   unsigned int header_size()                      const { return _generic_header._header_size;              }
241   unsigned int base_archive_name_offset()         const { return _generic_header._base_archive_name_offset; }
242   unsigned int base_archive_name_size()           const { return _generic_header._base_archive_name_size;   }
243   unsigned int common_app_classpath_prefix_size() const { return _common_app_classpath_prefix_size;         }
244 
245   void set_magic(unsigned int m)                            { _generic_header._magic = m;                    }
246   void set_crc(int crc_value)                               { _generic_header._crc = crc_value;              }
247   void set_version(int v)                                   { _generic_header._version = v;                  }
248   void set_header_size(unsigned int s)                      { _generic_header._header_size = s;              }
249   void set_base_archive_name_offset(unsigned int s)         { _generic_header._base_archive_name_offset = s; }
250   void set_base_archive_name_size(unsigned int s)           { _generic_header._base_archive_name_size = s;   }
251   void set_common_app_classpath_prefix_size(unsigned int s) { _common_app_classpath_prefix_size = s;         }
252 
253   bool is_static()                         const { return magic() == CDS_ARCHIVE_MAGIC; }
254   size_t core_region_alignment()           const { return _core_region_alignment; }
255   int obj_alignment()                      const { return _obj_alignment; }
256   address narrow_oop_base()                const { return _narrow_oop_base; }
257   int narrow_oop_shift()                   const { return _narrow_oop_shift; }
258   bool compact_strings()                   const { return _compact_strings; }
259   uintx max_heap_size()                    const { return _max_heap_size; }
260   CompressedOops::Mode narrow_oop_mode()   const { return _narrow_oop_mode; }
261   char* cloned_vtables()                   const { return from_mapped_offset(_cloned_vtables_offset); }
262   char* serialized_data()                  const { return from_mapped_offset(_serialized_data_offset); }
263   const char* jvm_ident()                  const { return _jvm_ident; }
264   char* requested_base_address()           const { return _requested_base_address; }
265   char* mapped_base_address()              const { return _mapped_base_address; }
266   bool has_platform_or_app_classes()       const { return _has_platform_or_app_classes; }
267   bool has_non_jar_in_classpath()          const { return _has_non_jar_in_classpath; }

268   size_t ptrmap_size_in_bits()             const { return _ptrmap_size_in_bits; }
269   bool compressed_oops()                   const { return _compressed_oops; }
270   bool compressed_class_pointers()         const { return _compressed_class_ptrs; }
271   size_t heap_roots_offset()               const { return _heap_roots_offset; }
272   // FIXME: These should really return int
273   jshort max_used_path_index()             const { return _max_used_path_index; }
274   jshort app_module_paths_start_index()    const { return _app_module_paths_start_index; }
275   jshort app_class_paths_start_index()     const { return _app_class_paths_start_index; }
276   int    num_module_paths()                const { return _num_module_paths; }
277 
278   void set_has_platform_or_app_classes(bool v)   { _has_platform_or_app_classes = v; }
279   void set_cloned_vtables(char* p)               { set_as_offset(p, &_cloned_vtables_offset); }
280   void set_serialized_data(char* p)              { set_as_offset(p, &_serialized_data_offset); }
281   void set_ptrmap_size_in_bits(size_t s)         { _ptrmap_size_in_bits = s; }
282   void set_mapped_base_address(char* p)          { _mapped_base_address = p; }
283   void set_heap_roots_offset(size_t n)           { _heap_roots_offset = n; }
284   void copy_base_archive_name(const char* name);
285 
286   void set_shared_path_table(SharedPathTable table) {
287     set_as_offset((char*)table.table(), &_shared_path_table_offset);

433   void  open_for_write();
434   void  write_header();
435   void  write_region(int region, char* base, size_t size,
436                      bool read_only, bool allow_exec);
437   char* write_bitmap_region(const CHeapBitMap* ptrmap, ArchiveHeapInfo* heap_info,
438                             size_t &size_in_bytes);
439   size_t write_heap_region(ArchiveHeapInfo* heap_info);
440   void  write_bytes(const void* buffer, size_t count);
441   void  write_bytes_aligned(const void* buffer, size_t count);
442   size_t  read_bytes(void* buffer, size_t count);
443   static size_t readonly_total();
444   MapArchiveResult map_regions(int regions[], int num_regions, char* mapped_base_address, ReservedSpace rs);
445   void  unmap_regions(int regions[], int num_regions);
446   void  map_or_load_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
447   void  fixup_mapped_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
448   void  patch_heap_embedded_pointers() NOT_CDS_JAVA_HEAP_RETURN;
449   bool  has_heap_region()  NOT_CDS_JAVA_HEAP_RETURN_(false);
450   MemRegion get_heap_region_requested_range() NOT_CDS_JAVA_HEAP_RETURN_(MemRegion());
451   bool  read_region(int i, char* base, size_t size, bool do_commit);
452   char* map_bitmap_region();

453   void  unmap_region(int i);
454   void  close();
455   bool  is_open() { return _file_open; }
456   ReservedSpace reserve_shared_memory();
457 
458   // JVM/TI RedefineClasses() support:
459   // Remap the shared readonly space to shared readwrite, private.
460   bool  remap_shared_readonly_as_readwrite();
461 
462   static bool memory_mapping_failed() {
463     CDS_ONLY(return _memory_mapping_failed;)
464     NOT_CDS(return false;)
465   }
466 
467   static void allocate_shared_path_table(TRAPS);
468   static int add_shared_classpaths(int i, const char* which, ClassPathEntry *cpe, TRAPS);
469   static void check_nonempty_dir_in_shared_path_table();
470   bool check_module_paths();
471   bool validate_shared_path_table();
472   void validate_non_existent_class_paths();

531   GrowableArray<const char*>* create_dumptime_app_classpath_array() NOT_CDS_RETURN_(nullptr);
532   GrowableArray<const char*>* create_path_array(const char* path) NOT_CDS_RETURN_(nullptr);
533   bool  classpath_failure(const char* msg, const char* name) NOT_CDS_RETURN_(false);
534   unsigned int longest_common_app_classpath_prefix_len(int num_paths,
535                                                        GrowableArray<const char*>* rp_array)
536                                                        NOT_CDS_RETURN_(0);
537   bool  check_paths(int shared_path_start_idx, int num_paths,
538                     GrowableArray<const char*>* rp_array,
539                     unsigned int dumptime_prefix_len,
540                     unsigned int runtime_prefix_len) NOT_CDS_RETURN_(false);
541   bool  validate_boot_class_paths() NOT_CDS_RETURN_(false);
542   bool  validate_app_class_paths(int shared_app_paths_len) NOT_CDS_RETURN_(false);
543   bool  map_heap_region_impl() NOT_CDS_JAVA_HEAP_RETURN_(false);
544   void  dealloc_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
545   bool  can_use_heap_region();
546   bool  load_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
547   bool  map_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
548   void  init_heap_region_relocation();
549   MapArchiveResult map_region(int i, intx addr_delta, char* mapped_base_address, ReservedSpace rs);
550   bool  relocate_pointers_in_core_regions(intx addr_delta);
551 
552   static MemRegion _mapped_heap_memregion;
553 
554 public:
555   address heap_region_dumptime_address() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
556   address heap_region_requested_address() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
557   narrowOop encoded_heap_region_dumptime_address();
558 
559 private:
560 
561 #if INCLUDE_JVMTI
562   static ClassPathEntry** _classpath_entries_for_jvmti;
563   static ClassPathEntry* get_classpath_entry_for_jvmti(int i, TRAPS);
564 #endif
565 };
566 
567 #endif // SHARE_CDS_FILEMAP_HPP

207   // during dumping. At run time, we validate these entries according to their
208   // SharedClassPathEntry::_type. See:
209   //      check_nonempty_dir_in_shared_path_table()
210   //      validate_shared_path_table()
211   //      validate_non_existent_class_paths()
212   size_t _shared_path_table_offset;
213 
214   jshort _app_class_paths_start_index;  // Index of first app classpath entry
215   jshort _app_module_paths_start_index; // Index of first module path entry
216   jshort _max_used_path_index;          // max path index referenced during CDS dump
217   int    _num_module_paths;             // number of module path entries
218   bool   _verify_local;                 // BytecodeVerificationLocal setting
219   bool   _verify_remote;                // BytecodeVerificationRemote setting
220   bool   _has_platform_or_app_classes;  // Archive contains app classes
221   char*  _requested_base_address;       // Archive relocation is not necessary if we map with this base address.
222   char*  _mapped_base_address;          // Actual base address where archive is mapped.
223 
224   bool   _allow_archiving_with_java_agent; // setting of the AllowArchivingWithJavaAgent option
225   bool   _use_optimized_module_handling;// No module-relation VM options were specified, so we can skip
226                                         // some expensive operations.
227   bool   _has_preloaded_classes;        // Does the CDS archive have preloaded classes?
228   bool   _has_full_module_graph;        // Does this CDS archive contain the full archived module graph?
229   bool   _has_archived_invokedynamic;   // Does the archive have preresolved invokedynamic CP entries?
230   size_t _ptrmap_size_in_bits;          // Size of pointer relocation bitmap
231   size_t _heap_roots_offset;            // Offset of the HeapShared::roots() object, from the bottom
232                                         // of the archived heap objects, in bytes.
233   char* from_mapped_offset(size_t offset) const {
234     return mapped_base_address() + offset;
235   }
236   void set_as_offset(char* p, size_t *offset);
237 public:
238   // Accessors -- fields declared in GenericCDSFileMapHeader
239   unsigned int magic()                            const { return _generic_header._magic;                    }
240   int crc()                                       const { return _generic_header._crc;                      }
241   int version()                                   const { return _generic_header._version;                  }
242   unsigned int header_size()                      const { return _generic_header._header_size;              }
243   unsigned int base_archive_name_offset()         const { return _generic_header._base_archive_name_offset; }
244   unsigned int base_archive_name_size()           const { return _generic_header._base_archive_name_size;   }
245   unsigned int common_app_classpath_prefix_size() const { return _common_app_classpath_prefix_size;         }
246 
247   void set_magic(unsigned int m)                            { _generic_header._magic = m;                    }
248   void set_crc(int crc_value)                               { _generic_header._crc = crc_value;              }
249   void set_version(int v)                                   { _generic_header._version = v;                  }
250   void set_header_size(unsigned int s)                      { _generic_header._header_size = s;              }
251   void set_base_archive_name_offset(unsigned int s)         { _generic_header._base_archive_name_offset = s; }
252   void set_base_archive_name_size(unsigned int s)           { _generic_header._base_archive_name_size = s;   }
253   void set_common_app_classpath_prefix_size(unsigned int s) { _common_app_classpath_prefix_size = s;         }
254 
255   bool is_static()                         const { return magic() == CDS_ARCHIVE_MAGIC; }
256   size_t core_region_alignment()           const { return _core_region_alignment; }
257   int obj_alignment()                      const { return _obj_alignment; }
258   address narrow_oop_base()                const { return _narrow_oop_base; }
259   int narrow_oop_shift()                   const { return _narrow_oop_shift; }
260   bool compact_strings()                   const { return _compact_strings; }
261   uintx max_heap_size()                    const { return _max_heap_size; }
262   CompressedOops::Mode narrow_oop_mode()   const { return _narrow_oop_mode; }
263   char* cloned_vtables()                   const { return from_mapped_offset(_cloned_vtables_offset); }
264   char* serialized_data()                  const { return from_mapped_offset(_serialized_data_offset); }
265   const char* jvm_ident()                  const { return _jvm_ident; }
266   char* requested_base_address()           const { return _requested_base_address; }
267   char* mapped_base_address()              const { return _mapped_base_address; }
268   bool has_platform_or_app_classes()       const { return _has_platform_or_app_classes; }
269   bool has_non_jar_in_classpath()          const { return _has_non_jar_in_classpath; }
270   bool has_preloaded_classes()             const { return _has_preloaded_classes; }
271   size_t ptrmap_size_in_bits()             const { return _ptrmap_size_in_bits; }
272   bool compressed_oops()                   const { return _compressed_oops; }
273   bool compressed_class_pointers()         const { return _compressed_class_ptrs; }
274   size_t heap_roots_offset()               const { return _heap_roots_offset; }
275   // FIXME: These should really return int
276   jshort max_used_path_index()             const { return _max_used_path_index; }
277   jshort app_module_paths_start_index()    const { return _app_module_paths_start_index; }
278   jshort app_class_paths_start_index()     const { return _app_class_paths_start_index; }
279   int    num_module_paths()                const { return _num_module_paths; }
280 
281   void set_has_platform_or_app_classes(bool v)   { _has_platform_or_app_classes = v; }
282   void set_cloned_vtables(char* p)               { set_as_offset(p, &_cloned_vtables_offset); }
283   void set_serialized_data(char* p)              { set_as_offset(p, &_serialized_data_offset); }
284   void set_ptrmap_size_in_bits(size_t s)         { _ptrmap_size_in_bits = s; }
285   void set_mapped_base_address(char* p)          { _mapped_base_address = p; }
286   void set_heap_roots_offset(size_t n)           { _heap_roots_offset = n; }
287   void copy_base_archive_name(const char* name);
288 
289   void set_shared_path_table(SharedPathTable table) {
290     set_as_offset((char*)table.table(), &_shared_path_table_offset);

436   void  open_for_write();
437   void  write_header();
438   void  write_region(int region, char* base, size_t size,
439                      bool read_only, bool allow_exec);
440   char* write_bitmap_region(const CHeapBitMap* ptrmap, ArchiveHeapInfo* heap_info,
441                             size_t &size_in_bytes);
442   size_t write_heap_region(ArchiveHeapInfo* heap_info);
443   void  write_bytes(const void* buffer, size_t count);
444   void  write_bytes_aligned(const void* buffer, size_t count);
445   size_t  read_bytes(void* buffer, size_t count);
446   static size_t readonly_total();
447   MapArchiveResult map_regions(int regions[], int num_regions, char* mapped_base_address, ReservedSpace rs);
448   void  unmap_regions(int regions[], int num_regions);
449   void  map_or_load_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
450   void  fixup_mapped_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
451   void  patch_heap_embedded_pointers() NOT_CDS_JAVA_HEAP_RETURN;
452   bool  has_heap_region()  NOT_CDS_JAVA_HEAP_RETURN_(false);
453   MemRegion get_heap_region_requested_range() NOT_CDS_JAVA_HEAP_RETURN_(MemRegion());
454   bool  read_region(int i, char* base, size_t size, bool do_commit);
455   char* map_bitmap_region();
456   bool map_cached_code_region(ReservedSpace rs);
457   void  unmap_region(int i);
458   void  close();
459   bool  is_open() { return _file_open; }
460   ReservedSpace reserve_shared_memory();
461 
462   // JVM/TI RedefineClasses() support:
463   // Remap the shared readonly space to shared readwrite, private.
464   bool  remap_shared_readonly_as_readwrite();
465 
466   static bool memory_mapping_failed() {
467     CDS_ONLY(return _memory_mapping_failed;)
468     NOT_CDS(return false;)
469   }
470 
471   static void allocate_shared_path_table(TRAPS);
472   static int add_shared_classpaths(int i, const char* which, ClassPathEntry *cpe, TRAPS);
473   static void check_nonempty_dir_in_shared_path_table();
474   bool check_module_paths();
475   bool validate_shared_path_table();
476   void validate_non_existent_class_paths();

535   GrowableArray<const char*>* create_dumptime_app_classpath_array() NOT_CDS_RETURN_(nullptr);
536   GrowableArray<const char*>* create_path_array(const char* path) NOT_CDS_RETURN_(nullptr);
537   bool  classpath_failure(const char* msg, const char* name) NOT_CDS_RETURN_(false);
538   unsigned int longest_common_app_classpath_prefix_len(int num_paths,
539                                                        GrowableArray<const char*>* rp_array)
540                                                        NOT_CDS_RETURN_(0);
541   bool  check_paths(int shared_path_start_idx, int num_paths,
542                     GrowableArray<const char*>* rp_array,
543                     unsigned int dumptime_prefix_len,
544                     unsigned int runtime_prefix_len) NOT_CDS_RETURN_(false);
545   bool  validate_boot_class_paths() NOT_CDS_RETURN_(false);
546   bool  validate_app_class_paths(int shared_app_paths_len) NOT_CDS_RETURN_(false);
547   bool  map_heap_region_impl() NOT_CDS_JAVA_HEAP_RETURN_(false);
548   void  dealloc_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
549   bool  can_use_heap_region();
550   bool  load_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
551   bool  map_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
552   void  init_heap_region_relocation();
553   MapArchiveResult map_region(int i, intx addr_delta, char* mapped_base_address, ReservedSpace rs);
554   bool  relocate_pointers_in_core_regions(intx addr_delta);
555   void  relocate_pointers_in_cached_code_region();
556   static MemRegion _mapped_heap_memregion;
557 
558 public:
559   address heap_region_dumptime_address() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
560   address heap_region_requested_address() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
561   narrowOop encoded_heap_region_dumptime_address();
562 
563 private:
564 
565 #if INCLUDE_JVMTI
566   static ClassPathEntry** _classpath_entries_for_jvmti;
567   static ClassPathEntry* get_classpath_entry_for_jvmti(int i, TRAPS);
568 #endif
569 };
570 
571 #endif // SHARE_CDS_FILEMAP_HPP
< prev index next >