src/hotspot/share/memory/filemap.hpp
changeset 59070 22ee476cc664
parent 58278 e47b459b315c
equal deleted inserted replaced
59069:e0d59f0c2b7d 59070:22ee476cc664
    41 //  misc data (block offset table, string table, symbols, dictionary, etc.)
    41 //  misc data (block offset table, string table, symbols, dictionary, etc.)
    42 //  tag(666)
    42 //  tag(666)
    43 
    43 
    44 static const int JVM_IDENT_MAX = 256;
    44 static const int JVM_IDENT_MAX = 256;
    45 
    45 
       
    46 class CHeapBitMap;
       
    47 
    46 class SharedClassPathEntry {
    48 class SharedClassPathEntry {
    47   enum {
    49   enum {
    48     modules_image_entry,
    50     modules_image_entry,
    49     jar_entry,
    51     jar_entry,
    50     signed_jar_entry,
    52     signed_jar_entry,
   102 
   104 
   103 class SharedPathTable {
   105 class SharedPathTable {
   104   Array<u8>* _table;
   106   Array<u8>* _table;
   105   int _size;
   107   int _size;
   106 public:
   108 public:
       
   109   SharedPathTable() : _table(NULL), _size(0) {}
       
   110   SharedPathTable(Array<u8>* table, int size) : _table(table), _size(size) {}
       
   111 
   107   void dumptime_init(ClassLoaderData* loader_data, Thread* THREAD);
   112   void dumptime_init(ClassLoaderData* loader_data, Thread* THREAD);
   108   void metaspace_pointers_do(MetaspaceClosure* it);
   113   void metaspace_pointers_do(MetaspaceClosure* it);
   109 
   114 
   110   int size() {
   115   int size() {
   111     return _size;
   116     return _size;
   136   static FileMapRegion* cast(CDSFileMapRegion* p) {
   141   static FileMapRegion* cast(CDSFileMapRegion* p) {
   137     return (FileMapRegion*)p;
   142     return (FileMapRegion*)p;
   138   }
   143   }
   139 
   144 
   140   // Accessors
   145   // Accessors
   141   int crc()                      const { return _crc; }
   146   int crc()                         const { return _crc; }
   142   size_t file_offset()           const { return _file_offset; }
   147   size_t file_offset()              const { return _file_offset; }
   143   char*  base()                  const { assert_is_not_heap_region(); return _addr._base;  }
   148   size_t mapping_offset()           const { return _mapping_offset; }
   144   narrowOop offset()             const { assert_is_heap_region();     return (narrowOop)(_addr._offset); }
   149   size_t mapping_end_offset()       const { return _mapping_offset + used_aligned(); }
   145   size_t used()                  const { return _used; }
   150   size_t used()                     const { return _used; }
   146   bool read_only()               const { return _read_only != 0; }
   151   size_t used_aligned()             const; // aligned up to os::vm_allocation_granularity()
   147   bool allow_exec()              const { return _allow_exec != 0; }
   152   char*  mapped_base()              const { assert_is_not_heap_region(); return _mapped_base; }
   148   void* oopmap()                 const { return _oopmap; }
   153   char*  mapped_end()               const { return mapped_base()        + used_aligned(); }
   149   size_t oopmap_size_in_bits()   const { return _oopmap_size_in_bits; }
   154   bool   read_only()                const { return _read_only != 0; }
   150 
   155   bool   allow_exec()               const { return _allow_exec != 0; }
   151   void set_file_offset(size_t s) { _file_offset = s; }
   156   bool   mapped_from_file()         const { return _mapped_from_file != 0; }
   152   void set_read_only(bool v)     { _read_only = v; }
   157   size_t oopmap_offset()            const { assert_is_heap_region();     return _oopmap_offset; }
   153   void mark_invalid()            { _addr._base = NULL; }
   158   size_t oopmap_size_in_bits()      const { assert_is_heap_region();     return _oopmap_size_in_bits; }
   154 
   159 
   155   void init(bool is_heap_region, char* base, size_t size, bool read_only,
   160   void set_file_offset(size_t s)     { _file_offset = s; }
       
   161   void set_read_only(bool v)         { _read_only = v; }
       
   162   void set_mapped_base(char* p)      { _mapped_base = p; }
       
   163   void set_mapped_from_file(bool v)  { _mapped_from_file = v; }
       
   164   void init(int region_index, char* base, size_t size, bool read_only,
   156             bool allow_exec, int crc);
   165             bool allow_exec, int crc);
   157 
   166 
   158   void init_oopmap(void* map, size_t size_in_bits) {
   167   void init_oopmap(size_t oopmap_offset, size_t size_in_bits) {
   159     _oopmap = map;
   168     _oopmap_offset = oopmap_offset;
   160     _oopmap_size_in_bits = size_in_bits;
   169     _oopmap_size_in_bits = size_in_bits;
   161   }
   170   }
   162 };
   171 };
   163 
   172 
   164 class FileMapHeader: private CDSFileMapHeaderBase {
   173 class FileMapHeader: private CDSFileMapHeaderBase {
   176   int    _narrow_oop_shift;         // compressed oop encoding shift
   185   int    _narrow_oop_shift;         // compressed oop encoding shift
   177   bool   _compact_strings;          // value of CompactStrings
   186   bool   _compact_strings;          // value of CompactStrings
   178   uintx  _max_heap_size;            // java max heap size during dumping
   187   uintx  _max_heap_size;            // java max heap size during dumping
   179   CompressedOops::Mode _narrow_oop_mode; // compressed oop encoding mode
   188   CompressedOops::Mode _narrow_oop_mode; // compressed oop encoding mode
   180   int     _narrow_klass_shift;      // save narrow klass base and shift
   189   int     _narrow_klass_shift;      // save narrow klass base and shift
   181   address _narrow_klass_base;
   190   size_t  _misc_data_patching_offset;
   182   char*   _misc_data_patching_start;
   191   size_t  _serialized_data_offset;  // Data accessed using {ReadClosure,WriteClosure}::serialize()
   183   char*   _serialized_data_start;  // Data accessed using {ReadClosure,WriteClosure}::serialize()
   192   size_t  _i2i_entry_code_buffers_offset;
   184   address _i2i_entry_code_buffers;
       
   185   size_t  _i2i_entry_code_buffers_size;
   193   size_t  _i2i_entry_code_buffers_size;
   186   size_t  _core_spaces_size;        // number of bytes allocated by the core spaces
       
   187                                     // (mc, md, ro, rw and od).
       
   188   address _heap_end;                // heap end at dump time.
   194   address _heap_end;                // heap end at dump time.
   189   bool _base_archive_is_default;    // indicates if the base archive is the system default one
   195   bool _base_archive_is_default;    // indicates if the base archive is the system default one
   190 
   196 
   191   // The following fields are all sanity checks for whether this archive
   197   // The following fields are all sanity checks for whether this archive
   192   // will function correctly with this JVM and the bootclasspath it's
   198   // will function correctly with this JVM and the bootclasspath it's
   200   // during dumping. At run time, we validate these entries according to their
   206   // during dumping. At run time, we validate these entries according to their
   201   // SharedClassPathEntry::_type. See:
   207   // SharedClassPathEntry::_type. See:
   202   //      check_nonempty_dir_in_shared_path_table()
   208   //      check_nonempty_dir_in_shared_path_table()
   203   //      validate_shared_path_table()
   209   //      validate_shared_path_table()
   204   //      validate_non_existent_class_paths()
   210   //      validate_non_existent_class_paths()
   205   SharedPathTable _shared_path_table;
   211   size_t _shared_path_table_offset;
       
   212   int    _shared_path_table_size;
   206 
   213 
   207   jshort _app_class_paths_start_index;  // Index of first app classpath entry
   214   jshort _app_class_paths_start_index;  // Index of first app classpath entry
   208   jshort _app_module_paths_start_index; // Index of first module path entry
   215   jshort _app_module_paths_start_index; // Index of first module path entry
   209   jshort _num_module_paths;             // number of module path entries
   216   jshort _num_module_paths;             // number of module path entries
   210   jshort _max_used_path_index;          // max path index referenced during CDS dump
   217   jshort _max_used_path_index;          // max path index referenced during CDS dump
   211   bool   _verify_local;                 // BytecodeVerificationLocal setting
   218   bool   _verify_local;                 // BytecodeVerificationLocal setting
   212   bool   _verify_remote;                // BytecodeVerificationRemote setting
   219   bool   _verify_remote;                // BytecodeVerificationRemote setting
   213   bool   _has_platform_or_app_classes;  // Archive contains app classes
   220   bool   _has_platform_or_app_classes;  // Archive contains app classes
   214   size_t _shared_base_address;          // SharedBaseAddress used at dump time
   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 
   215   bool   _allow_archiving_with_java_agent; // setting of the AllowArchivingWithJavaAgent option
   224   bool   _allow_archiving_with_java_agent; // setting of the AllowArchivingWithJavaAgent option
   216 
   225   size_t _ptrmap_size_in_bits;          // Size of pointer relocation bitmap
       
   226 
       
   227   char* from_mapped_offset(size_t offset) const {
       
   228     return mapped_base_address() + offset;
       
   229   }
       
   230   void set_mapped_offset(char* p, size_t *offset) {
       
   231     assert(p >= mapped_base_address(), "sanity");
       
   232     *offset = p - mapped_base_address();
       
   233   }
   217 public:
   234 public:
   218   // Accessors -- fields declared in CDSFileMapHeaderBase
   235   // Accessors -- fields declared in CDSFileMapHeaderBase
   219   unsigned int magic() const {return _magic;}
   236   unsigned int magic() const {return _magic;}
   220   int crc()                               const { return _crc; }
   237   int crc()                               const { return _crc; }
   221   int version()                           const { return _version; }
   238   int version()                           const { return _version; }
   232   int narrow_oop_shift()                   const { return _narrow_oop_shift; }
   249   int narrow_oop_shift()                   const { return _narrow_oop_shift; }
   233   bool compact_strings()                   const { return _compact_strings; }
   250   bool compact_strings()                   const { return _compact_strings; }
   234   uintx max_heap_size()                    const { return _max_heap_size; }
   251   uintx max_heap_size()                    const { return _max_heap_size; }
   235   CompressedOops::Mode narrow_oop_mode()   const { return _narrow_oop_mode; }
   252   CompressedOops::Mode narrow_oop_mode()   const { return _narrow_oop_mode; }
   236   int narrow_klass_shift()                 const { return _narrow_klass_shift; }
   253   int narrow_klass_shift()                 const { return _narrow_klass_shift; }
   237   address narrow_klass_base()              const { return _narrow_klass_base; }
   254   address narrow_klass_base()              const { return (address)mapped_base_address(); }
   238   char* misc_data_patching_start()         const { return _misc_data_patching_start; }
   255   char* misc_data_patching_start()         const { return from_mapped_offset(_misc_data_patching_offset); }
   239   char* serialized_data_start()            const { return _serialized_data_start; }
   256   char* serialized_data_start()            const { return from_mapped_offset(_serialized_data_offset); }
   240   address i2i_entry_code_buffers()         const { return _i2i_entry_code_buffers; }
   257   address i2i_entry_code_buffers()         const { return (address)from_mapped_offset(_i2i_entry_code_buffers_offset); }
   241   size_t i2i_entry_code_buffers_size()     const { return _i2i_entry_code_buffers_size; }
   258   size_t i2i_entry_code_buffers_size()     const { return _i2i_entry_code_buffers_size; }
   242   size_t core_spaces_size()                const { return _core_spaces_size; }
       
   243   address heap_end()                       const { return _heap_end; }
   259   address heap_end()                       const { return _heap_end; }
   244   bool base_archive_is_default()           const { return _base_archive_is_default; }
   260   bool base_archive_is_default()           const { return _base_archive_is_default; }
   245   const char* jvm_ident()                  const { return _jvm_ident; }
   261   const char* jvm_ident()                  const { return _jvm_ident; }
   246   size_t base_archive_name_size()          const { return _base_archive_name_size; }
   262   size_t base_archive_name_size()          const { return _base_archive_name_size; }
   247   size_t shared_base_address()             const { return _shared_base_address; }
   263   char* requested_base_address()           const { return _requested_base_address; }
       
   264   char* mapped_base_address()              const { return _mapped_base_address; }
   248   bool has_platform_or_app_classes()       const { return _has_platform_or_app_classes; }
   265   bool has_platform_or_app_classes()       const { return _has_platform_or_app_classes; }
   249   SharedPathTable shared_path_table()      const { return _shared_path_table; }
   266   size_t ptrmap_size_in_bits()             const { return _ptrmap_size_in_bits; }
   250 
   267 
   251   // FIXME: These should really return int
   268   // FIXME: These should really return int
   252   jshort max_used_path_index()             const { return _max_used_path_index; }
   269   jshort max_used_path_index()             const { return _max_used_path_index; }
   253   jshort app_module_paths_start_index()    const { return _app_module_paths_start_index; }
   270   jshort app_module_paths_start_index()    const { return _app_module_paths_start_index; }
   254   jshort app_class_paths_start_index()     const { return _app_class_paths_start_index; }
   271   jshort app_class_paths_start_index()     const { return _app_class_paths_start_index; }
   255   jshort num_module_paths()                const { return _num_module_paths; }
   272   jshort num_module_paths()                const { return _num_module_paths; }
   256 
   273 
   257   void set_core_spaces_size(size_t s)            { _core_spaces_size = s; }
       
   258   void set_has_platform_or_app_classes(bool v)   { _has_platform_or_app_classes = v; }
   274   void set_has_platform_or_app_classes(bool v)   { _has_platform_or_app_classes = v; }
   259   void set_misc_data_patching_start(char* p)     { _misc_data_patching_start = p; }
   275   void set_misc_data_patching_start(char* p)     { set_mapped_offset(p, &_misc_data_patching_offset); }
   260   void set_serialized_data_start(char* p)        { _serialized_data_start   = p; }
   276   void set_serialized_data_start(char* p)        { set_mapped_offset(p, &_serialized_data_offset); }
   261   void set_base_archive_name_size(size_t s)      { _base_archive_name_size = s; }
   277   void set_base_archive_name_size(size_t s)      { _base_archive_name_size = s; }
   262   void set_base_archive_is_default(bool b)       { _base_archive_is_default = b; }
   278   void set_base_archive_is_default(bool b)       { _base_archive_is_default = b; }
   263   void set_header_size(size_t s)                 { _header_size = s; }
   279   void set_header_size(size_t s)                 { _header_size = s; }
   264 
   280   void set_ptrmap_size_in_bits(size_t s)         { _ptrmap_size_in_bits = s; }
       
   281   void set_mapped_base_address(char* p)          { _mapped_base_address = p; }
   265   void set_i2i_entry_code_buffers(address p, size_t s) {
   282   void set_i2i_entry_code_buffers(address p, size_t s) {
   266     _i2i_entry_code_buffers = p;
   283     set_mapped_offset((char*)p, &_i2i_entry_code_buffers_offset);
   267     _i2i_entry_code_buffers_size = s;
   284     _i2i_entry_code_buffers_size = s;
   268   }
   285   }
   269 
   286 
   270   void relocate_shared_path_table(Array<u8>* t) {
   287   void set_shared_path_table(SharedPathTable table) {
   271     assert(DynamicDumpSharedSpaces, "only");
   288     set_mapped_offset((char*)table.table(), &_shared_path_table_offset);
   272     _shared_path_table.set_table(t);
   289     _shared_path_table_size = table.size();
   273   }
   290   }
   274 
   291 
   275   void shared_path_table_metaspace_pointers_do(MetaspaceClosure* it) {
   292   void set_final_requested_base(char* b) {
   276     assert(DynamicDumpSharedSpaces, "only");
   293     _requested_base_address = b;
   277     _shared_path_table.metaspace_pointers_do(it);
   294     _mapped_base_address = 0;
       
   295   }
       
   296 
       
   297   SharedPathTable shared_path_table() const {
       
   298     return SharedPathTable((Array<u8>*)from_mapped_offset(_shared_path_table_offset),
       
   299                            _shared_path_table_size);
   278   }
   300   }
   279 
   301 
   280   bool validate();
   302   bool validate();
   281   int compute_crc();
   303   int compute_crc();
   282 
   304 
   299   friend class CDSOffsets;
   321   friend class CDSOffsets;
   300   friend class FileMapHeader;
   322   friend class FileMapHeader;
   301 
   323 
   302   bool           _is_static;
   324   bool           _is_static;
   303   bool           _file_open;
   325   bool           _file_open;
       
   326   bool           _is_mapped;
   304   int            _fd;
   327   int            _fd;
   305   size_t         _file_offset;
   328   size_t         _file_offset;
   306   const char*    _full_path;
   329   const char*    _full_path;
   307   const char*    _base_archive_name;
   330   const char*    _base_archive_name;
   308   FileMapHeader* _header;
   331   FileMapHeader* _header;
   325 
   348 
   326 public:
   349 public:
   327   static bool get_base_archive_name_from_header(const char* archive_name,
   350   static bool get_base_archive_name_from_header(const char* archive_name,
   328                                                 int* size, char** base_archive_name);
   351                                                 int* size, char** base_archive_name);
   329   static bool check_archive(const char* archive_name, bool is_static);
   352   static bool check_archive(const char* archive_name, bool is_static);
       
   353   static SharedPathTable shared_path_table() {
       
   354     return _shared_path_table;
       
   355   }
   330   void restore_shared_path_table();
   356   void restore_shared_path_table();
   331   bool init_from_file(int fd, bool is_static);
   357   bool init_from_file(int fd);
   332   static void metaspace_pointers_do(MetaspaceClosure* it);
   358   static void metaspace_pointers_do(MetaspaceClosure* it);
   333 
   359 
   334   void log_paths(const char* msg, int start_idx, int end_idx);
   360   void log_paths(const char* msg, int start_idx, int end_idx);
   335 
   361 
   336   FileMapInfo(bool is_static);
   362   FileMapInfo(bool is_static);
   339   // Accessors
   365   // Accessors
   340   int    compute_header_crc()  const { return header()->compute_crc(); }
   366   int    compute_header_crc()  const { return header()->compute_crc(); }
   341   void   set_header_crc(int crc)     { header()->set_crc(crc); }
   367   void   set_header_crc(int crc)     { header()->set_crc(crc); }
   342   int    space_crc(int i)      const { return space_at(i)->crc(); }
   368   int    space_crc(int i)      const { return space_at(i)->crc(); }
   343   void   populate_header(size_t alignment);
   369   void   populate_header(size_t alignment);
   344   bool   validate_header(bool is_static);
   370   bool   validate_header();
   345   void   invalidate();
   371   void   invalidate();
   346   int    crc()                 const { return header()->crc(); }
   372   int    crc()                 const { return header()->crc(); }
   347   int    version()             const { return header()->version(); }
   373   int    version()             const { return header()->version(); }
   348   size_t alignment()           const { return header()->alignment(); }
   374   size_t alignment()           const { return header()->alignment(); }
   349   address narrow_oop_base()    const { return header()->narrow_oop_base(); }
   375   address narrow_oop_base()    const { return header()->narrow_oop_base(); }
   368   size_t i2i_entry_code_buffers_size()        const { return header()->i2i_entry_code_buffers_size(); }
   394   size_t i2i_entry_code_buffers_size()        const { return header()->i2i_entry_code_buffers_size(); }
   369   void set_i2i_entry_code_buffers(address addr, size_t s) const {
   395   void set_i2i_entry_code_buffers(address addr, size_t s) const {
   370     header()->set_i2i_entry_code_buffers(addr, s);
   396     header()->set_i2i_entry_code_buffers(addr, s);
   371   }
   397   }
   372 
   398 
   373   void set_core_spaces_size(size_t s)         const { header()->set_core_spaces_size(s); }
   399   bool is_static()                            const { return _is_static; }
   374   size_t core_spaces_size()                   const { return header()->core_spaces_size(); }
   400   bool is_mapped()                            const { return _is_mapped; }
       
   401   void set_is_mapped(bool v)                        { _is_mapped = v; }
       
   402   const char* full_path()                     const { return _full_path; }
       
   403   void set_final_requested_base(char* b);
       
   404 
       
   405   char* requested_base_address()           const { return header()->requested_base_address(); }
       
   406 
   375 
   407 
   376   class DynamicArchiveHeader* dynamic_header() const {
   408   class DynamicArchiveHeader* dynamic_header() const {
   377     assert(!_is_static, "must be");
   409     assert(!is_static(), "must be");
   378     return (DynamicArchiveHeader*)header();
   410     return (DynamicArchiveHeader*)header();
   379   }
   411   }
   380 
   412 
   381   void set_has_platform_or_app_classes(bool v) {
   413   void set_has_platform_or_app_classes(bool v) {
   382     header()->set_has_platform_or_app_classes(v);
   414     header()->set_has_platform_or_app_classes(v);
   400   }
   432   }
   401 
   433 
   402   static void assert_mark(bool check);
   434   static void assert_mark(bool check);
   403 
   435 
   404   // File manipulation.
   436   // File manipulation.
   405   bool  initialize(bool is_static) NOT_CDS_RETURN_(false);
   437   bool  initialize() NOT_CDS_RETURN_(false);
   406   bool  open_for_read(const char* path = NULL);
   438   bool  open_for_read();
   407   void  open_for_write(const char* path = NULL);
   439   void  open_for_write(const char* path = NULL);
   408   void  write_header();
   440   void  write_header();
   409   void  write_region(int region, char* base, size_t size,
   441   void  write_region(int region, char* base, size_t size,
   410                      bool read_only, bool allow_exec);
   442                      bool read_only, bool allow_exec);
       
   443   void  write_bitmap_region(const CHeapBitMap* ptrmap);
   411   size_t write_archive_heap_regions(GrowableArray<MemRegion> *heap_mem,
   444   size_t write_archive_heap_regions(GrowableArray<MemRegion> *heap_mem,
   412                                     GrowableArray<ArchiveHeapOopmapInfo> *oopmaps,
   445                                     GrowableArray<ArchiveHeapOopmapInfo> *oopmaps,
   413                                     int first_region_id, int max_num_regions);
   446                                     int first_region_id, int max_num_regions);
   414   void  write_bytes(const void* buffer, size_t count);
   447   void  write_bytes(const void* buffer, size_t count);
   415   void  write_bytes_aligned(const void* buffer, size_t count);
   448   void  write_bytes_aligned(const void* buffer, size_t count);
   416   size_t  read_bytes(void* buffer, size_t count);
   449   size_t  read_bytes(void* buffer, size_t count);
   417   char* map_regions(int regions[], char* saved_base[], size_t len);
   450   MapArchiveResult map_regions(int regions[], int num_regions, char* mapped_base_address, ReservedSpace rs);
   418   char* map_region(int i, char** top_ret);
   451   void  unmap_regions(int regions[], int num_regions);
   419   void  map_heap_regions_impl() NOT_CDS_JAVA_HEAP_RETURN;
       
   420   void  map_heap_regions() NOT_CDS_JAVA_HEAP_RETURN;
   452   void  map_heap_regions() NOT_CDS_JAVA_HEAP_RETURN;
   421   void  fixup_mapped_heap_regions() NOT_CDS_JAVA_HEAP_RETURN;
   453   void  fixup_mapped_heap_regions() NOT_CDS_JAVA_HEAP_RETURN;
   422   void  patch_archived_heap_embedded_pointers() NOT_CDS_JAVA_HEAP_RETURN;
   454   void  patch_archived_heap_embedded_pointers() NOT_CDS_JAVA_HEAP_RETURN;
   423   void  patch_archived_heap_embedded_pointers(MemRegion* ranges, int num_ranges,
   455   void  patch_archived_heap_embedded_pointers(MemRegion* ranges, int num_ranges,
   424                                               int first_region_idx) NOT_CDS_JAVA_HEAP_RETURN;
   456                                               int first_region_idx) NOT_CDS_JAVA_HEAP_RETURN;
   425   bool  has_heap_regions()  NOT_CDS_JAVA_HEAP_RETURN_(false);
   457   bool  has_heap_regions()  NOT_CDS_JAVA_HEAP_RETURN_(false);
   426   MemRegion get_heap_regions_range_with_current_oop_encoding_mode() NOT_CDS_JAVA_HEAP_RETURN_(MemRegion());
   458   MemRegion get_heap_regions_range_with_current_oop_encoding_mode() NOT_CDS_JAVA_HEAP_RETURN_(MemRegion());
   427   void  unmap_regions(int regions[], char* saved_base[], size_t len);
       
   428   void  unmap_region(int i);
   459   void  unmap_region(int i);
   429   bool  verify_region_checksum(int i);
   460   bool  verify_region_checksum(int i);
   430   void  close();
   461   void  close();
   431   bool  is_open() { return _file_open; }
   462   bool  is_open() { return _file_open; }
   432   ReservedSpace reserve_shared_memory();
   463   ReservedSpace reserve_shared_memory();
   450   static void allocate_shared_path_table();
   481   static void allocate_shared_path_table();
   451   static int add_shared_classpaths(int i, const char* which, ClassPathEntry *cpe, TRAPS);
   482   static int add_shared_classpaths(int i, const char* which, ClassPathEntry *cpe, TRAPS);
   452   static void check_nonempty_dir_in_shared_path_table();
   483   static void check_nonempty_dir_in_shared_path_table();
   453   bool validate_shared_path_table();
   484   bool validate_shared_path_table();
   454   void validate_non_existent_class_paths();
   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   }
   455   static void update_jar_manifest(ClassPathEntry *cpe, SharedClassPathEntry* ent, TRAPS);
   489   static void update_jar_manifest(ClassPathEntry *cpe, SharedClassPathEntry* ent, TRAPS);
   456   static int num_non_existent_class_paths();
   490   static int num_non_existent_class_paths();
   457   static void record_non_existent_class_path_entry(const char* path);
   491   static void record_non_existent_class_path_entry(const char* path);
   458 
   492 
   459 #if INCLUDE_JVMTI
   493 #if INCLUDE_JVMTI
   472   static int get_number_of_shared_paths() {
   506   static int get_number_of_shared_paths() {
   473     return _shared_path_table.size();
   507     return _shared_path_table.size();
   474   }
   508   }
   475 
   509 
   476   char* region_addr(int idx);
   510   char* region_addr(int idx);
       
   511 
       
   512   // The offset of the first core region in the archive, relative to SharedBaseAddress
       
   513   size_t mapping_base_offset() const { return first_core_space()->mapping_offset(); }
       
   514   // The offset of the (exclusive) end of the last core region in this archive, relative to SharedBaseAddress
       
   515   size_t mapping_end_offset()  const { return last_core_space()->mapping_end_offset(); }
       
   516 
       
   517   char* mapped_base()    const { return first_core_space()->mapped_base(); }
       
   518   char* mapped_end()     const { return last_core_space()->mapped_end();   }
       
   519 
       
   520   // Non-zero if the archive needs to be mapped a non-default location due to ASLR.
       
   521   intx relocation_delta() const {
       
   522     return header()->mapped_base_address() - header()->requested_base_address();
       
   523   }
       
   524 
       
   525   FileMapRegion* first_core_space() const;
       
   526   FileMapRegion* last_core_space() const;
   477 
   527 
   478  private:
   528  private:
   479   void  seek_to_position(size_t pos);
   529   void  seek_to_position(size_t pos);
   480   char* skip_first_path_entry(const char* path) NOT_CDS_RETURN_(NULL);
   530   char* skip_first_path_entry(const char* path) NOT_CDS_RETURN_(NULL);
   481   int   num_paths(const char* path) NOT_CDS_RETURN_(0);
   531   int   num_paths(const char* path) NOT_CDS_RETURN_(0);
   482   GrowableArray<const char*>* create_path_array(const char* path) NOT_CDS_RETURN_(NULL);
   532   GrowableArray<const char*>* create_path_array(const char* path) NOT_CDS_RETURN_(NULL);
   483   bool  fail(const char* msg, const char* name) NOT_CDS_RETURN_(false);
   533   bool  classpath_failure(const char* msg, const char* name) NOT_CDS_RETURN_(false);
   484   bool  check_paths(int shared_path_start_idx, int num_paths,
   534   bool  check_paths(int shared_path_start_idx, int num_paths,
   485                     GrowableArray<const char*>* rp_array) NOT_CDS_RETURN_(false);
   535                     GrowableArray<const char*>* rp_array) NOT_CDS_RETURN_(false);
   486   bool  validate_boot_class_paths() NOT_CDS_RETURN_(false);
   536   bool  validate_boot_class_paths() NOT_CDS_RETURN_(false);
   487   bool  validate_app_class_paths(int shared_app_paths_len) NOT_CDS_RETURN_(false);
   537   bool  validate_app_class_paths(int shared_app_paths_len) NOT_CDS_RETURN_(false);
   488   bool  map_heap_data(MemRegion **heap_mem, int first, int max, int* num,
   538   bool  map_heap_data(MemRegion **heap_mem, int first, int max, int* num,
   489                       bool is_open = false) NOT_CDS_JAVA_HEAP_RETURN_(false);
   539                       bool is_open = false) NOT_CDS_JAVA_HEAP_RETURN_(false);
   490   bool  region_crc_check(char* buf, size_t size, int expected_crc) NOT_CDS_RETURN_(false);
   540   bool  region_crc_check(char* buf, size_t size, int expected_crc) NOT_CDS_RETURN_(false);
   491   void  dealloc_archive_heap_regions(MemRegion* regions, int num, bool is_open) NOT_CDS_JAVA_HEAP_RETURN;
   541   void  dealloc_archive_heap_regions(MemRegion* regions, int num, bool is_open) NOT_CDS_JAVA_HEAP_RETURN;
       
   542   void  map_heap_regions_impl() NOT_CDS_JAVA_HEAP_RETURN;
       
   543   char* map_relocation_bitmap(size_t& bitmap_size);
       
   544   MapArchiveResult map_region(int i, intx addr_delta, char* mapped_base_address, ReservedSpace rs);
       
   545   bool  read_region(int i, char* base, size_t size);
       
   546   bool  relocate_pointers(intx addr_delta);
   492 
   547 
   493   FileMapRegion* space_at(int i) const {
   548   FileMapRegion* space_at(int i) const {
   494     return header()->space_at(i);
   549     return header()->space_at(i);
   495   }
   550   }
   496 
   551