< prev index next >

src/hotspot/share/memory/filemap.hpp

Print this page


 127     }
 128 
 129     int    _magic;                    // identify file type.
 130     int    _crc;                      // header crc checksum.
 131     int    _version;                  // (from enum, above.)
 132     size_t _alignment;                // how shared archive should be aligned
 133     int    _obj_alignment;            // value of ObjectAlignmentInBytes
 134     address _narrow_oop_base;         // compressed oop encoding base
 135     int    _narrow_oop_shift;         // compressed oop encoding shift
 136     bool    _compact_strings;         // value of CompactStrings
 137     uintx  _max_heap_size;            // java max heap size during dumping
 138     Universe::NARROW_OOP_MODE _narrow_oop_mode; // compressed oop encoding mode
 139     int     _narrow_klass_shift;      // save narrow klass base and shift
 140     address _narrow_klass_base;
 141     char*   _misc_data_patching_start;
 142     char*   _read_only_tables_start;
 143     address _cds_i2i_entry_code_buffers;
 144     size_t  _cds_i2i_entry_code_buffers_size;
 145     size_t  _core_spaces_size;        // number of bytes allocated by the core spaces
 146                                       // (mc, md, ro, rw and od).

 147     struct space_info {
 148       int    _crc;           // crc checksum of the current space
 149       size_t _file_offset;   // sizeof(this) rounded to vm page size
 150       union {
 151         char*  _base;        // copy-on-write base address
 152         intx   _offset;      // offset from the compressed oop encoding base, only used
 153                              // by archive heap space
 154       } _addr;
 155       size_t _used;          // for setting space top on read
 156       bool   _read_only;     // read only space?
 157       bool   _allow_exec;    // executable code in space?
 158     } _space[MetaspaceShared::n_regions];
 159 
 160     // The following fields are all sanity checks for whether this archive
 161     // will function correctly with this JVM and the bootclasspath it's
 162     // invoked with.
 163     char  _jvm_ident[JVM_IDENT_MAX];      // identifier for jvm
 164 
 165     // The _paths_misc_info is a variable-size structure that records "miscellaneous"
 166     // information during dumping. It is generated and validated by the


 197     bool   _has_platform_or_app_classes;  // Archive contains app classes
 198 
 199     void set_has_platform_or_app_classes(bool v) {
 200       _has_platform_or_app_classes = v;
 201     }
 202     bool has_platform_or_app_classes() { return _has_platform_or_app_classes; }
 203 
 204     char* region_addr(int idx);
 205 
 206     bool validate();
 207     void populate(FileMapInfo* info, size_t alignment);
 208     int compute_crc();
 209   };
 210 
 211   FileMapHeader * _header;
 212 
 213   const char* _full_path;
 214   char* _paths_misc_info;
 215 
 216   static FileMapInfo* _current_info;

 217 
 218   bool  init_from_file(int fd);
 219   void  align_file_position();
 220   bool  validate_header_impl();
 221   static void metaspace_pointers_do(MetaspaceClosure* it);
 222 
 223 public:
 224   FileMapInfo();
 225   ~FileMapInfo();
 226 
 227   static int current_version()        { return _current_version; }
 228   int    compute_header_crc()         { return _header->compute_crc(); }
 229   void   set_header_crc(int crc)      { _header->_crc = crc; }
 230   void   populate_header(size_t alignment);
 231   bool   validate_header();
 232   void   invalidate();
 233   int    version()                    { return _header->_version; }
 234   size_t alignment()                  { return _header->_alignment; }
 235   Universe::NARROW_OOP_MODE narrow_oop_mode() { return _header->_narrow_oop_mode; }
 236   address narrow_oop_base()    const  { return _header->_narrow_oop_base; }


 261 
 262   static FileMapInfo* current_info() {
 263     CDS_ONLY(return _current_info;)
 264     NOT_CDS(return NULL;)
 265   }
 266 
 267   static void assert_mark(bool check);
 268 
 269   // File manipulation.
 270   bool  initialize() NOT_CDS_RETURN_(false);
 271   bool  open_for_read();
 272   void  open_for_write();
 273   void  write_header();
 274   void  write_region(int region, char* base, size_t size,
 275                      bool read_only, bool allow_exec);
 276   size_t write_archive_heap_regions(GrowableArray<MemRegion> *heap_mem,
 277                                     int first_region_id, int max_num_regions);
 278   void  write_bytes(const void* buffer, int count);
 279   void  write_bytes_aligned(const void* buffer, int count);
 280   char* map_region(int i, char** top_ret);

 281   void  map_heap_regions() NOT_CDS_JAVA_HEAP_RETURN;
 282   void  fixup_mapped_heap_regions() NOT_CDS_JAVA_HEAP_RETURN;



 283   void  unmap_region(int i);
 284   bool  verify_region_checksum(int i);
 285   void  close();
 286   bool  is_open() { return _file_open; }
 287   ReservedSpace reserve_shared_memory();
 288 
 289   // JVM/TI RedefineClasses() support:
 290   // Remap the shared readonly space to shared readwrite, private.
 291   bool  remap_shared_readonly_as_readwrite();
 292 
 293   // Errors.
 294   static void fail_stop(const char *msg, ...) ATTRIBUTE_PRINTF(1, 2);
 295   static void fail_continue(const char *msg, ...) ATTRIBUTE_PRINTF(1, 2);
 296 
 297   bool is_in_shared_region(const void* p, int idx) NOT_CDS_RETURN_(false);
 298   void print_shared_spaces() NOT_CDS_RETURN;
 299 
 300   // Stop CDS sharing and unmap CDS regions.
 301   static void stop_sharing_and_unmap(const char* msg);
 302 




 127     }
 128 
 129     int    _magic;                    // identify file type.
 130     int    _crc;                      // header crc checksum.
 131     int    _version;                  // (from enum, above.)
 132     size_t _alignment;                // how shared archive should be aligned
 133     int    _obj_alignment;            // value of ObjectAlignmentInBytes
 134     address _narrow_oop_base;         // compressed oop encoding base
 135     int    _narrow_oop_shift;         // compressed oop encoding shift
 136     bool    _compact_strings;         // value of CompactStrings
 137     uintx  _max_heap_size;            // java max heap size during dumping
 138     Universe::NARROW_OOP_MODE _narrow_oop_mode; // compressed oop encoding mode
 139     int     _narrow_klass_shift;      // save narrow klass base and shift
 140     address _narrow_klass_base;
 141     char*   _misc_data_patching_start;
 142     char*   _read_only_tables_start;
 143     address _cds_i2i_entry_code_buffers;
 144     size_t  _cds_i2i_entry_code_buffers_size;
 145     size_t  _core_spaces_size;        // number of bytes allocated by the core spaces
 146                                       // (mc, md, ro, rw and od).
 147     MemRegion _g1_reserved;           // reserved region at dump time.
 148     struct space_info {
 149       int    _crc;           // crc checksum of the current space
 150       size_t _file_offset;   // sizeof(this) rounded to vm page size
 151       union {
 152         char*  _base;        // copy-on-write base address
 153         intx   _offset;      // offset from the compressed oop encoding base, only used
 154                              // by archive heap space
 155       } _addr;
 156       size_t _used;          // for setting space top on read
 157       bool   _read_only;     // read only space?
 158       bool   _allow_exec;    // executable code in space?
 159     } _space[MetaspaceShared::n_regions];
 160 
 161     // The following fields are all sanity checks for whether this archive
 162     // will function correctly with this JVM and the bootclasspath it's
 163     // invoked with.
 164     char  _jvm_ident[JVM_IDENT_MAX];      // identifier for jvm
 165 
 166     // The _paths_misc_info is a variable-size structure that records "miscellaneous"
 167     // information during dumping. It is generated and validated by the


 198     bool   _has_platform_or_app_classes;  // Archive contains app classes
 199 
 200     void set_has_platform_or_app_classes(bool v) {
 201       _has_platform_or_app_classes = v;
 202     }
 203     bool has_platform_or_app_classes() { return _has_platform_or_app_classes; }
 204 
 205     char* region_addr(int idx);
 206 
 207     bool validate();
 208     void populate(FileMapInfo* info, size_t alignment);
 209     int compute_crc();
 210   };
 211 
 212   FileMapHeader * _header;
 213 
 214   const char* _full_path;
 215   char* _paths_misc_info;
 216 
 217   static FileMapInfo* _current_info;
 218   static bool _heap_pointers_need_relocation;
 219 
 220   bool  init_from_file(int fd);
 221   void  align_file_position();
 222   bool  validate_header_impl();
 223   static void metaspace_pointers_do(MetaspaceClosure* it);
 224 
 225 public:
 226   FileMapInfo();
 227   ~FileMapInfo();
 228 
 229   static int current_version()        { return _current_version; }
 230   int    compute_header_crc()         { return _header->compute_crc(); }
 231   void   set_header_crc(int crc)      { _header->_crc = crc; }
 232   void   populate_header(size_t alignment);
 233   bool   validate_header();
 234   void   invalidate();
 235   int    version()                    { return _header->_version; }
 236   size_t alignment()                  { return _header->_alignment; }
 237   Universe::NARROW_OOP_MODE narrow_oop_mode() { return _header->_narrow_oop_mode; }
 238   address narrow_oop_base()    const  { return _header->_narrow_oop_base; }


 263 
 264   static FileMapInfo* current_info() {
 265     CDS_ONLY(return _current_info;)
 266     NOT_CDS(return NULL;)
 267   }
 268 
 269   static void assert_mark(bool check);
 270 
 271   // File manipulation.
 272   bool  initialize() NOT_CDS_RETURN_(false);
 273   bool  open_for_read();
 274   void  open_for_write();
 275   void  write_header();
 276   void  write_region(int region, char* base, size_t size,
 277                      bool read_only, bool allow_exec);
 278   size_t write_archive_heap_regions(GrowableArray<MemRegion> *heap_mem,
 279                                     int first_region_id, int max_num_regions);
 280   void  write_bytes(const void* buffer, int count);
 281   void  write_bytes_aligned(const void* buffer, int count);
 282   char* map_region(int i, char** top_ret);
 283   void  map_heap_regions_impl() NOT_CDS_JAVA_HEAP_RETURN;
 284   void  map_heap_regions() NOT_CDS_JAVA_HEAP_RETURN;
 285   void  fixup_mapped_heap_regions() NOT_CDS_JAVA_HEAP_RETURN;
 286   void  relocate_archived_heap_embedded_pointers() NOT_CDS_JAVA_HEAP_RETURN;
 287   void  relocate_archived_heap_embedded_pointers_impl(MemRegion *heap_mem, int num) NOT_CDS_JAVA_HEAP_RETURN;
 288   bool  has_heap_regions()  NOT_CDS_JAVA_HEAP_RETURN;
 289   void  unmap_region(int i);
 290   bool  verify_region_checksum(int i);
 291   void  close();
 292   bool  is_open() { return _file_open; }
 293   ReservedSpace reserve_shared_memory();
 294 
 295   // JVM/TI RedefineClasses() support:
 296   // Remap the shared readonly space to shared readwrite, private.
 297   bool  remap_shared_readonly_as_readwrite();
 298 
 299   // Errors.
 300   static void fail_stop(const char *msg, ...) ATTRIBUTE_PRINTF(1, 2);
 301   static void fail_continue(const char *msg, ...) ATTRIBUTE_PRINTF(1, 2);
 302 
 303   bool is_in_shared_region(const void* p, int idx) NOT_CDS_RETURN_(false);
 304   void print_shared_spaces() NOT_CDS_RETURN;
 305 
 306   // Stop CDS sharing and unmap CDS regions.
 307   static void stop_sharing_and_unmap(const char* msg);
 308 


< prev index next >