src/hotspot/share/memory/filemap.hpp
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 54927 1512d88b24c6
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
    47   enum {
    47   enum {
    48     modules_image_entry,
    48     modules_image_entry,
    49     jar_entry,
    49     jar_entry,
    50     signed_jar_entry,
    50     signed_jar_entry,
    51     dir_entry,
    51     dir_entry,
       
    52     non_existent_entry,
    52     unknown_entry
    53     unknown_entry
    53   };
    54   };
    54 protected:
    55 
       
    56   void set_name(const char* name, TRAPS);
       
    57 
    55   u1     _type;
    58   u1     _type;
       
    59   bool   _from_class_path_attr;
    56   time_t _timestamp;          // jar timestamp,  0 if is directory, modules image or other
    60   time_t _timestamp;          // jar timestamp,  0 if is directory, modules image or other
    57   long   _filesize;           // jar/jimage file size, -1 if is directory, -2 if other
    61   long   _filesize;           // jar/jimage file size, -1 if is directory, -2 if other
    58   Array<char>* _name;
    62   Array<char>* _name;
    59   Array<u1>*   _manifest;
    63   Array<u1>*   _manifest;
    60 
    64 
    61 public:
    65 public:
    62   void init(const char* name, bool is_modules_image, TRAPS);
    66   void init(bool is_modules_image, ClassPathEntry* cpe, TRAPS);
       
    67   void init_as_non_existent(const char* path, TRAPS);
    63   void metaspace_pointers_do(MetaspaceClosure* it);
    68   void metaspace_pointers_do(MetaspaceClosure* it);
    64   bool validate(bool is_class_path = true);
    69   bool validate(bool is_class_path = true) const;
    65 
    70 
    66   // The _timestamp only gets set for jar files.
    71   // The _timestamp only gets set for jar files.
    67   bool has_timestamp() {
    72   bool has_timestamp() const {
    68     return _timestamp != 0;
    73     return _timestamp != 0;
    69   }
    74   }
    70   bool is_dir()            { return _type == dir_entry; }
    75   bool is_dir()           const { return _type == dir_entry; }
    71   bool is_modules_image()  { return _type == modules_image_entry; }
    76   bool is_modules_image() const { return _type == modules_image_entry; }
    72   bool is_jar()            { return _type == jar_entry; }
    77   bool is_jar()           const { return _type == jar_entry; }
    73   bool is_signed()         { return _type == signed_jar_entry; }
    78   bool is_signed()        const { return _type == signed_jar_entry; }
    74   void set_is_signed()     {
    79   void set_is_signed() {
    75     _type = signed_jar_entry;
    80     _type = signed_jar_entry;
    76   }
    81   }
       
    82   bool from_class_path_attr() { return _from_class_path_attr; }
    77   time_t timestamp() const { return _timestamp; }
    83   time_t timestamp() const { return _timestamp; }
    78   long   filesize()  const { return _filesize; }
    84   long   filesize()  const { return _filesize; }
    79   const char* name() const { return _name->data(); }
    85   const char* name() const;
    80   const char* manifest() const {
    86   const char* manifest() const {
    81     return (_manifest == NULL) ? NULL : (const char*)_manifest->data();
    87     return (_manifest == NULL) ? NULL : (const char*)_manifest->data();
    82   }
    88   }
    83   int manifest_size() const {
    89   int manifest_size() const {
    84     return (_manifest == NULL) ? 0 : _manifest->length();
    90     return (_manifest == NULL) ? 0 : _manifest->length();
    85   }
    91   }
    86   void set_manifest(Array<u1>* manifest) {
    92   void set_manifest(Array<u1>* manifest) {
    87     _manifest = manifest;
    93     _manifest = manifest;
    88   }
    94   }
       
    95   bool check_non_existent() const;
    89 };
    96 };
    90 
    97 
    91 struct ArchiveHeapOopmapInfo {
    98 struct ArchiveHeapOopmapInfo {
    92   address _oopmap;               // bitmap for relocating embedded oops
    99   address _oopmap;               // bitmap for relocating embedded oops
    93   size_t  _oopmap_size_in_bits;
   100   size_t  _oopmap_size_in_bits;
   112     p += sizeof(SharedClassPathEntry) * index;
   119     p += sizeof(SharedClassPathEntry) * index;
   113     return (SharedClassPathEntry*)p;
   120     return (SharedClassPathEntry*)p;
   114   }
   121   }
   115   Array<u8>* table() {return _table;}
   122   Array<u8>* table() {return _table;}
   116   void set_table(Array<u8>* table) {_table = table;}
   123   void set_table(Array<u8>* table) {_table = table;}
   117 
       
   118 };
   124 };
   119 
   125 
   120 struct FileMapHeader : public CDSFileMapHeaderBase {
   126 
       
   127 class FileMapRegion: private CDSFileMapRegion {
       
   128   void assert_is_heap_region() const {
       
   129     assert(_is_heap_region, "must be heap region");
       
   130   }
       
   131   void assert_is_not_heap_region() const {
       
   132     assert(!_is_heap_region, "must not be heap region");
       
   133   }
       
   134 
       
   135 public:
       
   136   static FileMapRegion* cast(CDSFileMapRegion* p) {
       
   137     return (FileMapRegion*)p;
       
   138   }
       
   139 
       
   140   // Accessors
       
   141   int crc()                      const { return _crc; }
       
   142   size_t file_offset()           const { return _file_offset; }
       
   143   char*  base()                  const { assert_is_not_heap_region(); return _addr._base;  }
       
   144   narrowOop offset()             const { assert_is_heap_region();     return (narrowOop)(_addr._offset); }
       
   145   size_t used()                  const { return _used; }
       
   146   bool read_only()               const { return _read_only != 0; }
       
   147   bool allow_exec()              const { return _allow_exec != 0; }
       
   148   void* oopmap()                 const { return _oopmap; }
       
   149   size_t oopmap_size_in_bits()   const { return _oopmap_size_in_bits; }
       
   150 
       
   151   void set_file_offset(size_t s) { _file_offset = s; }
       
   152   void set_read_only(bool v)     { _read_only = v; }
       
   153   void mark_invalid()            { _addr._base = NULL; }
       
   154 
       
   155   void init(bool is_heap_region, char* base, size_t size, bool read_only,
       
   156             bool allow_exec, int crc);
       
   157 
       
   158   void init_oopmap(void* map, size_t size_in_bits) {
       
   159     _oopmap = map;
       
   160     _oopmap_size_in_bits = size_in_bits;
       
   161   }
       
   162 };
       
   163 
       
   164 class FileMapHeader: private CDSFileMapHeaderBase {
       
   165   friend class CDSOffsets;
       
   166   friend class VMStructs;
       
   167 
   121   size_t _header_size;
   168   size_t _header_size;
       
   169 
       
   170   // The following fields record the states of the VM during dump time.
       
   171   // They are compared with the runtime states to see if the archive
       
   172   // can be used.
   122   size_t _alignment;                // how shared archive should be aligned
   173   size_t _alignment;                // how shared archive should be aligned
   123   int    _obj_alignment;            // value of ObjectAlignmentInBytes
   174   int    _obj_alignment;            // value of ObjectAlignmentInBytes
   124   address _narrow_oop_base;         // compressed oop encoding base
   175   address _narrow_oop_base;         // compressed oop encoding base
   125   int    _narrow_oop_shift;         // compressed oop encoding shift
   176   int    _narrow_oop_shift;         // compressed oop encoding shift
   126   bool    _compact_strings;         // value of CompactStrings
   177   bool   _compact_strings;          // value of CompactStrings
   127   uintx  _max_heap_size;            // java max heap size during dumping
   178   uintx  _max_heap_size;            // java max heap size during dumping
   128   CompressedOops::Mode _narrow_oop_mode; // compressed oop encoding mode
   179   CompressedOops::Mode _narrow_oop_mode; // compressed oop encoding mode
   129   int     _narrow_klass_shift;      // save narrow klass base and shift
   180   int     _narrow_klass_shift;      // save narrow klass base and shift
   130   address _narrow_klass_base;
   181   address _narrow_klass_base;
   131   char*   _misc_data_patching_start;
   182   char*   _misc_data_patching_start;
   132   char*   _read_only_tables_start;
   183   char*   _serialized_data_start;  // Data accessed using {ReadClosure,WriteClosure}::serialize()
   133   address _cds_i2i_entry_code_buffers;
   184   address _i2i_entry_code_buffers;
   134   size_t  _cds_i2i_entry_code_buffers_size;
   185   size_t  _i2i_entry_code_buffers_size;
   135   size_t  _core_spaces_size;        // number of bytes allocated by the core spaces
   186   size_t  _core_spaces_size;        // number of bytes allocated by the core spaces
   136                                     // (mc, md, ro, rw and od).
   187                                     // (mc, md, ro, rw and od).
   137   MemRegion _heap_reserved;         // reserved region for the entire heap at dump time.
   188   address _heap_end;                // heap end at dump time.
   138   bool _base_archive_is_default;    // indicates if the base archive is the system default one
   189   bool _base_archive_is_default;    // indicates if the base archive is the system default one
   139 
   190 
   140   // The following fields are all sanity checks for whether this archive
   191   // The following fields are all sanity checks for whether this archive
   141   // will function correctly with this JVM and the bootclasspath it's
   192   // will function correctly with this JVM and the bootclasspath it's
   142   // invoked with.
   193   // invoked with.
   143   char  _jvm_ident[JVM_IDENT_MAX];      // identifier for jvm
   194   char  _jvm_ident[JVM_IDENT_MAX];  // identifier string of the jvm that created this dump
   144 
   195 
   145   // size of the base archive name including NULL terminator
   196   // size of the base archive name including NULL terminator
   146   int _base_archive_name_size;
   197   size_t _base_archive_name_size;
   147 
   198 
   148   // The _paths_misc_info is a variable-size structure that records "miscellaneous"
   199   // The following is a table of all the boot/app/module path entries that were used
   149   // information during dumping. It is generated and validated by the
   200   // during dumping. At run time, we validate these entries according to their
   150   // SharedPathsMiscInfo class. See SharedPathsMiscInfo.hpp for
   201   // SharedClassPathEntry::_type. See:
   151   // detailed description.
   202   //      check_nonempty_dir_in_shared_path_table()
   152   //
   203   //      validate_shared_path_table()
   153   // The _paths_misc_info data is stored as a byte array in the archive file header,
   204   //      validate_non_existent_class_paths()
   154   // immediately after the _header field. This information is used only when
       
   155   // checking the validity of the archive and is deallocated after the archive is loaded.
       
   156   //
       
   157   // Note that the _paths_misc_info does NOT include information for JAR files
       
   158   // that existed during dump time. Their information is stored in _shared_path_table.
       
   159   int _paths_misc_info_size;
       
   160 
       
   161   // The following is a table of all the class path entries that were used
       
   162   // during dumping. At run time, we require these files to exist and have the same
       
   163   // size/modification time, or else the archive will refuse to load.
       
   164   //
       
   165   // All of these entries must be JAR files. The dumping process would fail if a non-empty
       
   166   // directory was specified in the classpaths. If an empty directory was specified
       
   167   // it is checked by the _paths_misc_info as described above.
       
   168   //
       
   169   // FIXME -- if JAR files in the tail of the list were specified but not used during dumping,
       
   170   // they should be removed from this table, to save space and to avoid spurious
       
   171   // loading failures during runtime.
       
   172   SharedPathTable _shared_path_table;
   205   SharedPathTable _shared_path_table;
   173 
   206 
   174   jshort _app_class_paths_start_index;  // Index of first app classpath entry
   207   jshort _app_class_paths_start_index;  // Index of first app classpath entry
   175   jshort _app_module_paths_start_index; // Index of first module path entry
   208   jshort _app_module_paths_start_index; // Index of first module path entry
   176   jshort _num_module_paths;             // number of module path entries
   209   jshort _num_module_paths;             // number of module path entries
   179   bool   _verify_remote;                // BytecodeVerificationRemote setting
   212   bool   _verify_remote;                // BytecodeVerificationRemote setting
   180   bool   _has_platform_or_app_classes;  // Archive contains app classes
   213   bool   _has_platform_or_app_classes;  // Archive contains app classes
   181   size_t _shared_base_address;          // SharedBaseAddress used at dump time
   214   size_t _shared_base_address;          // SharedBaseAddress used at dump time
   182   bool   _allow_archiving_with_java_agent; // setting of the AllowArchivingWithJavaAgent option
   215   bool   _allow_archiving_with_java_agent; // setting of the AllowArchivingWithJavaAgent option
   183 
   216 
   184   void set_has_platform_or_app_classes(bool v) {
   217 public:
   185     _has_platform_or_app_classes = v;
   218   // Accessors -- fields declared in CDSFileMapHeaderBase
   186   }
   219   unsigned int magic() const {return _magic;}
   187   bool has_platform_or_app_classes() { return _has_platform_or_app_classes; }
   220   int crc()                               const { return _crc; }
   188   jshort max_used_path_index()       { return _max_used_path_index; }
   221   int version()                           const { return _version; }
   189   jshort app_module_paths_start_index() { return _app_module_paths_start_index; }
   222 
       
   223   void set_crc(int crc_value)                   { _crc = crc_value; }
       
   224   void set_version(int v)                       { _version = v; }
       
   225 
       
   226   // Accessors -- fields declared in FileMapHeader
       
   227 
       
   228   size_t header_size()                     const { return _header_size; }
       
   229   size_t alignment()                       const { return _alignment; }
       
   230   int obj_alignment()                      const { return _obj_alignment; }
       
   231   address narrow_oop_base()                const { return _narrow_oop_base; }
       
   232   int narrow_oop_shift()                   const { return _narrow_oop_shift; }
       
   233   bool compact_strings()                   const { return _compact_strings; }
       
   234   uintx max_heap_size()                    const { return _max_heap_size; }
       
   235   CompressedOops::Mode narrow_oop_mode()   const { return _narrow_oop_mode; }
       
   236   int narrow_klass_shift()                 const { return _narrow_klass_shift; }
       
   237   address narrow_klass_base()              const { return _narrow_klass_base; }
       
   238   char* misc_data_patching_start()         const { return _misc_data_patching_start; }
       
   239   char* serialized_data_start()            const { return _serialized_data_start; }
       
   240   address i2i_entry_code_buffers()         const { return _i2i_entry_code_buffers; }
       
   241   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; }
       
   244   bool base_archive_is_default()           const { return _base_archive_is_default; }
       
   245   const char* jvm_ident()                  const { return _jvm_ident; }
       
   246   size_t base_archive_name_size()          const { return _base_archive_name_size; }
       
   247   size_t shared_base_address()             const { return _shared_base_address; }
       
   248   bool has_platform_or_app_classes()       const { return _has_platform_or_app_classes; }
       
   249   SharedPathTable shared_path_table()      const { return _shared_path_table; }
       
   250 
       
   251   // FIXME: These should really return int
       
   252   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; }
       
   254   jshort app_class_paths_start_index()     const { return _app_class_paths_start_index; }
       
   255   jshort num_module_paths()                const { return _num_module_paths; }
       
   256 
       
   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; }
       
   259   void set_misc_data_patching_start(char* p)     { _misc_data_patching_start = p; }
       
   260   void set_serialized_data_start(char* p)        { _serialized_data_start   = p; }
       
   261   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; }
       
   263   void set_header_size(size_t s)                 { _header_size = s; }
       
   264 
       
   265   void set_i2i_entry_code_buffers(address p, size_t s) {
       
   266     _i2i_entry_code_buffers = p;
       
   267     _i2i_entry_code_buffers_size = s;
       
   268   }
       
   269 
       
   270   void relocate_shared_path_table(Array<u8>* t) {
       
   271     assert(DynamicDumpSharedSpaces, "only");
       
   272     _shared_path_table.set_table(t);
       
   273   }
       
   274 
       
   275   void shared_path_table_metaspace_pointers_do(MetaspaceClosure* it) {
       
   276     assert(DynamicDumpSharedSpaces, "only");
       
   277     _shared_path_table.metaspace_pointers_do(it);
       
   278   }
   190 
   279 
   191   bool validate();
   280   bool validate();
   192   int compute_crc();
   281   int compute_crc();
   193 
   282 
   194   CDSFileMapRegion* space_at(int i) {
   283   FileMapRegion* space_at(int i) {
   195     assert(i >= 0 && i < NUM_CDS_REGIONS, "invalid region");
   284     assert(is_valid_region(i), "invalid region");
   196     return &_space[i];
   285     return FileMapRegion::cast(&_space[i]);
   197   }
   286   }
   198 public:
   287 
   199   void populate(FileMapInfo* info, size_t alignment);
   288   void populate(FileMapInfo* info, size_t alignment);
       
   289 
       
   290   static bool is_valid_region(int region) {
       
   291     return (0 <= region && region < NUM_CDS_REGIONS);
       
   292   }
   200 };
   293 };
   201 
   294 
   202 class FileMapInfo : public CHeapObj<mtInternal> {
   295 class FileMapInfo : public CHeapObj<mtInternal> {
   203 private:
   296 private:
   204   friend class ManifestStream;
   297   friend class ManifestStream;
   205   friend class VMStructs;
   298   friend class VMStructs;
   206   friend struct FileMapHeader;
   299   friend class CDSOffsets;
   207 
   300   friend class FileMapHeader;
   208   bool    _is_static;
   301 
   209   bool    _file_open;
   302   bool           _is_static;
   210   int     _fd;
   303   bool           _file_open;
   211   size_t  _file_offset;
   304   int            _fd;
   212 
   305   size_t         _file_offset;
   213 private:
   306   const char*    _full_path;
       
   307   const char*    _base_archive_name;
       
   308   FileMapHeader* _header;
       
   309 
   214   // TODO: Probably change the following to be non-static
   310   // TODO: Probably change the following to be non-static
   215   static SharedPathTable       _shared_path_table;
   311   static SharedPathTable       _shared_path_table;
   216   static bool                  _validating_shared_path_table;
   312   static bool                  _validating_shared_path_table;
   217 
   313 
   218   // FileMapHeader describes the shared space data in the file to be
   314   // FileMapHeader describes the shared space data in the file to be
   219   // mapped.  This structure gets written to a file.  It is not a class, so
   315   // mapped.  This structure gets written to a file.  It is not a class, so
   220   // that the compilers don't add any compiler-private data to it.
   316   // that the compilers don't add any compiler-private data to it.
   221 
       
   222 public:
       
   223   struct FileMapHeaderBase : public CHeapObj<mtClass> {
       
   224     // Need to put something here. Otherwise, in product build, because CHeapObj has no virtual
       
   225     // methods, we would get sizeof(FileMapHeaderBase) == 1 with gcc.
       
   226     intx _dummy;
       
   227   };
       
   228 
       
   229 
       
   230   FileMapHeader * _header;
       
   231 
       
   232   const char* _full_path;
       
   233   char* _paths_misc_info;
       
   234   char* _base_archive_name;
       
   235 
   317 
   236   static FileMapInfo* _current_info;
   318   static FileMapInfo* _current_info;
   237   static FileMapInfo* _dynamic_archive_info;
   319   static FileMapInfo* _dynamic_archive_info;
   238   static bool _heap_pointers_need_patching;
   320   static bool _heap_pointers_need_patching;
   239   static bool _memory_mapping_failed;
   321   static bool _memory_mapping_failed;
       
   322   static GrowableArray<const char*>* _non_existent_class_paths;
       
   323 
       
   324   FileMapHeader *header() const       { return _header; }
       
   325 
       
   326 public:
   240   static bool get_base_archive_name_from_header(const char* archive_name,
   327   static bool get_base_archive_name_from_header(const char* archive_name,
   241                                                 int* size, char** base_archive_name);
   328                                                 int* size, char** base_archive_name);
   242   static bool check_archive(const char* archive_name, bool is_static);
   329   static bool check_archive(const char* archive_name, bool is_static);
   243   static bool  same_files(const char* file1, const char* file2);
       
   244   void restore_shared_path_table();
   330   void restore_shared_path_table();
   245   bool  init_from_file(int fd, bool is_static);
   331   bool init_from_file(int fd, bool is_static);
   246   static void metaspace_pointers_do(MetaspaceClosure* it);
   332   static void metaspace_pointers_do(MetaspaceClosure* it);
   247 
   333 
   248 public:
   334   void log_paths(const char* msg, int start_idx, int end_idx);
       
   335 
   249   FileMapInfo(bool is_static);
   336   FileMapInfo(bool is_static);
   250   ~FileMapInfo();
   337   ~FileMapInfo();
   251 
   338 
   252   int    compute_header_crc()         { return _header->compute_crc(); }
   339   // Accessors
   253   void   set_header_crc(int crc)      { _header->_crc = crc; }
   340   int    compute_header_crc()  const { return header()->compute_crc(); }
   254   int    space_crc(int i)             { return space_at(i)->_crc; }
   341   void   set_header_crc(int crc)     { header()->set_crc(crc); }
       
   342   int    space_crc(int i)      const { return space_at(i)->crc(); }
   255   void   populate_header(size_t alignment);
   343   void   populate_header(size_t alignment);
   256   bool   validate_header(bool is_static);
   344   bool   validate_header(bool is_static);
   257   void   invalidate();
   345   void   invalidate();
   258   int    crc()                        { return _header->_crc; }
   346   int    crc()                 const { return header()->crc(); }
   259   int    version()                    { return _header->_version; }
   347   int    version()             const { return header()->version(); }
   260   size_t alignment()                  { return _header->_alignment; }
   348   size_t alignment()           const { return header()->alignment(); }
   261   CompressedOops::Mode narrow_oop_mode() { return _header->_narrow_oop_mode; }
   349   address narrow_oop_base()    const { return header()->narrow_oop_base(); }
   262   address narrow_oop_base()    const  { return _header->_narrow_oop_base; }
   350   int     narrow_oop_shift()   const { return header()->narrow_oop_shift(); }
   263   int     narrow_oop_shift()   const  { return _header->_narrow_oop_shift; }
   351   uintx   max_heap_size()      const { return header()->max_heap_size(); }
   264   uintx   max_heap_size()      const  { return _header->_max_heap_size; }
   352   address narrow_klass_base()  const { return header()->narrow_klass_base(); }
   265   address narrow_klass_base()  const  { return _header->_narrow_klass_base; }
   353   int     narrow_klass_shift() const { return header()->narrow_klass_shift(); }
   266   int     narrow_klass_shift() const  { return _header->_narrow_klass_shift; }
   354 
   267   struct  FileMapHeader* header()     { return _header; }
   355   CompressedOops::Mode narrow_oop_mode()      const { return header()->narrow_oop_mode(); }
   268   char*   misc_data_patching_start()          { return _header->_misc_data_patching_start; }
   356   jshort app_module_paths_start_index()       const { return header()->app_module_paths_start_index(); }
   269   void set_misc_data_patching_start(char* p)  { _header->_misc_data_patching_start = p; }
   357   jshort app_class_paths_start_index()        const { return header()->app_class_paths_start_index(); }
   270   char* read_only_tables_start()              { return _header->_read_only_tables_start; }
   358 
   271   void set_read_only_tables_start(char* p)    { _header->_read_only_tables_start = p; }
   359   char* misc_data_patching_start()            const { return header()->misc_data_patching_start(); }
       
   360   void  set_misc_data_patching_start(char* p) const { header()->set_misc_data_patching_start(p); }
       
   361   char* serialized_data_start()               const { return header()->serialized_data_start(); }
       
   362   void  set_serialized_data_start(char* p)    const { header()->set_serialized_data_start(p); }
   272 
   363 
   273   bool  is_file_position_aligned() const;
   364   bool  is_file_position_aligned() const;
   274   void  align_file_position();
   365   void  align_file_position();
   275 
   366 
   276   address cds_i2i_entry_code_buffers() {
   367   address i2i_entry_code_buffers()            const { return header()->i2i_entry_code_buffers();  }
   277     return _header->_cds_i2i_entry_code_buffers;
   368   size_t i2i_entry_code_buffers_size()        const { return header()->i2i_entry_code_buffers_size(); }
   278   }
   369   void set_i2i_entry_code_buffers(address addr, size_t s) const {
   279   void set_cds_i2i_entry_code_buffers(address addr) {
   370     header()->set_i2i_entry_code_buffers(addr, s);
   280     _header->_cds_i2i_entry_code_buffers = addr;
   371   }
   281   }
   372 
   282   size_t cds_i2i_entry_code_buffers_size() {
   373   void set_core_spaces_size(size_t s)         const { header()->set_core_spaces_size(s); }
   283     return _header->_cds_i2i_entry_code_buffers_size;
   374   size_t core_spaces_size()                   const { return header()->core_spaces_size(); }
   284   }
   375 
   285   void set_cds_i2i_entry_code_buffers_size(size_t s) {
   376   class DynamicArchiveHeader* dynamic_header() const {
   286     _header->_cds_i2i_entry_code_buffers_size = s;
   377     assert(!_is_static, "must be");
   287   }
   378     return (DynamicArchiveHeader*)header();
   288   void set_core_spaces_size(size_t s)    {  _header->_core_spaces_size = s; }
   379   }
   289   size_t core_spaces_size()              { return _header->_core_spaces_size; }
   380 
       
   381   void set_has_platform_or_app_classes(bool v) {
       
   382     header()->set_has_platform_or_app_classes(v);
       
   383   }
       
   384   bool has_platform_or_app_classes() const {
       
   385     return header()->has_platform_or_app_classes();
       
   386   }
   290 
   387 
   291   static FileMapInfo* current_info() {
   388   static FileMapInfo* current_info() {
   292     CDS_ONLY(return _current_info;)
   389     CDS_ONLY(return _current_info;)
   293     NOT_CDS(return NULL;)
   390     NOT_CDS(return NULL;)
   294   }
   391   }
   311   void  write_header();
   408   void  write_header();
   312   void  write_region(int region, char* base, size_t size,
   409   void  write_region(int region, char* base, size_t size,
   313                      bool read_only, bool allow_exec);
   410                      bool read_only, bool allow_exec);
   314   size_t write_archive_heap_regions(GrowableArray<MemRegion> *heap_mem,
   411   size_t write_archive_heap_regions(GrowableArray<MemRegion> *heap_mem,
   315                                     GrowableArray<ArchiveHeapOopmapInfo> *oopmaps,
   412                                     GrowableArray<ArchiveHeapOopmapInfo> *oopmaps,
   316                                     int first_region_id, int max_num_regions,
   413                                     int first_region_id, int max_num_regions);
   317                                     bool print_log);
       
   318   void  write_bytes(const void* buffer, size_t count);
   414   void  write_bytes(const void* buffer, size_t count);
   319   void  write_bytes_aligned(const void* buffer, size_t count);
   415   void  write_bytes_aligned(const void* buffer, size_t count);
   320   size_t  read_bytes(void* buffer, size_t count);
   416   size_t  read_bytes(void* buffer, size_t count);
   321   char* map_regions(int regions[], char* saved_base[], size_t len);
   417   char* map_regions(int regions[], char* saved_base[], size_t len);
   322   char* map_region(int i, char** top_ret);
   418   char* map_region(int i, char** top_ret);
   350 
   446 
   351   // Stop CDS sharing and unmap CDS regions.
   447   // Stop CDS sharing and unmap CDS regions.
   352   static void stop_sharing_and_unmap(const char* msg);
   448   static void stop_sharing_and_unmap(const char* msg);
   353 
   449 
   354   static void allocate_shared_path_table();
   450   static void allocate_shared_path_table();
       
   451   static int add_shared_classpaths(int i, const char* which, ClassPathEntry *cpe, TRAPS);
   355   static void check_nonempty_dir_in_shared_path_table();
   452   static void check_nonempty_dir_in_shared_path_table();
   356   bool validate_shared_path_table();
   453   bool validate_shared_path_table();
   357   static void update_shared_classpath(ClassPathEntry *cpe, SharedClassPathEntry* ent, TRAPS);
   454   void validate_non_existent_class_paths();
       
   455   static void update_jar_manifest(ClassPathEntry *cpe, SharedClassPathEntry* ent, TRAPS);
       
   456   static int num_non_existent_class_paths();
       
   457   static void record_non_existent_class_path_entry(const char* path);
   358 
   458 
   359 #if INCLUDE_JVMTI
   459 #if INCLUDE_JVMTI
   360   static ClassFileStream* open_stream_for_jvmti(InstanceKlass* ik, Handle class_loader, TRAPS);
   460   static ClassFileStream* open_stream_for_jvmti(InstanceKlass* ik, Handle class_loader, TRAPS);
   361 #endif
   461 #endif
   362 
   462 
   374   }
   474   }
   375 
   475 
   376   char* region_addr(int idx);
   476   char* region_addr(int idx);
   377 
   477 
   378  private:
   478  private:
       
   479   void  seek_to_position(size_t pos);
       
   480   char* skip_first_path_entry(const char* path) NOT_CDS_RETURN_(NULL);
       
   481   int   num_paths(const char* path) NOT_CDS_RETURN_(0);
       
   482   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);
       
   484   bool  check_paths(int shared_path_start_idx, int num_paths,
       
   485                     GrowableArray<const char*>* rp_array) NOT_CDS_RETURN_(false);
       
   486   bool  validate_boot_class_paths() NOT_CDS_RETURN_(false);
       
   487   bool  validate_app_class_paths(int shared_app_paths_len) NOT_CDS_RETURN_(false);
   379   bool  map_heap_data(MemRegion **heap_mem, int first, int max, int* num,
   488   bool  map_heap_data(MemRegion **heap_mem, int first, int max, int* num,
   380                       bool is_open = false) NOT_CDS_JAVA_HEAP_RETURN_(false);
   489                       bool is_open = false) NOT_CDS_JAVA_HEAP_RETURN_(false);
   381   bool  region_crc_check(char* buf, size_t size, int expected_crc) NOT_CDS_RETURN_(false);
   490   bool  region_crc_check(char* buf, size_t size, int expected_crc) NOT_CDS_RETURN_(false);
   382   void  dealloc_archive_heap_regions(MemRegion* regions, int num, bool is_open) NOT_CDS_JAVA_HEAP_RETURN;
   491   void  dealloc_archive_heap_regions(MemRegion* regions, int num, bool is_open) NOT_CDS_JAVA_HEAP_RETURN;
   383 
   492 
   384   CDSFileMapRegion* space_at(int i) {
   493   FileMapRegion* space_at(int i) const {
   385     return _header->space_at(i);
   494     return header()->space_at(i);
   386   }
       
   387 
       
   388   narrowOop offset_of_space(CDSFileMapRegion* spc) {
       
   389     return (narrowOop)(spc->_addr._offset);
       
   390   }
   495   }
   391 
   496 
   392   // The starting address of spc, as calculated with CompressedOop::decode_non_null()
   497   // The starting address of spc, as calculated with CompressedOop::decode_non_null()
   393   address start_address_as_decoded_with_current_oop_encoding_mode(CDSFileMapRegion* spc) {
   498   address start_address_as_decoded_with_current_oop_encoding_mode(FileMapRegion* spc) {
   394     return decode_start_address(spc, true);
   499     return decode_start_address(spc, true);
   395   }
   500   }
   396 
   501 
   397   // The starting address of spc, as calculated with HeapShared::decode_from_archive()
   502   // The starting address of spc, as calculated with HeapShared::decode_from_archive()
   398   address start_address_as_decoded_from_archive(CDSFileMapRegion* spc) {
   503   address start_address_as_decoded_from_archive(FileMapRegion* spc) {
   399     return decode_start_address(spc, false);
   504     return decode_start_address(spc, false);
   400   }
   505   }
   401 
   506 
   402   address decode_start_address(CDSFileMapRegion* spc, bool with_current_oop_encoding_mode);
   507   address decode_start_address(FileMapRegion* spc, bool with_current_oop_encoding_mode);
   403 
   508 
   404 #if INCLUDE_JVMTI
   509 #if INCLUDE_JVMTI
   405   static ClassPathEntry** _classpath_entries_for_jvmti;
   510   static ClassPathEntry** _classpath_entries_for_jvmti;
   406   static ClassPathEntry* get_classpath_entry_for_jvmti(int i, TRAPS);
   511   static ClassPathEntry* get_classpath_entry_for_jvmti(int i, TRAPS);
   407 #endif
   512 #endif