84 struct FileMapHeader : FileMapHeaderBase { 85 // Use data() and data_size() to memcopy to/from the FileMapHeader. We need to 86 // avoid read/writing the C++ vtable pointer. 87 static size_t data_size(); 88 char* data() { 89 return ((char*)this) + sizeof(FileMapHeaderBase); 90 } 91 92 int _magic; // identify file type. 93 int _crc; // header crc checksum. 94 int _version; // (from enum, above.) 95 size_t _alignment; // how shared archive should be aligned 96 int _obj_alignment; // value of ObjectAlignmentInBytes 97 int _narrow_oop_shift; // compressed oop encoding shift 98 bool _compact_strings; // value of CompactStrings 99 uintx _max_heap_size; // java max heap size during dumping 100 Universe::NARROW_OOP_MODE _narrow_oop_mode; // compressed oop encoding mode 101 int _narrow_klass_shift; // save narrow klass base and shift 102 address _narrow_klass_base; 103 char* _misc_data_patching_start; 104 105 struct space_info { 106 int _crc; // crc checksum of the current space 107 size_t _file_offset; // sizeof(this) rounded to vm page size 108 union { 109 char* _base; // copy-on-write base address 110 intx _offset; // offset from the compressed oop encoding base, only used 111 // by string space 112 } _addr; 113 size_t _capacity; // for validity checking 114 size_t _used; // for setting space top on read 115 bool _read_only; // read only space? 116 bool _allow_exec; // executable code in space? 117 } _space[MetaspaceShared::n_regions]; 118 119 // The following fields are all sanity checks for whether this archive 120 // will function correctly with this JVM and the bootclasspath it's 121 // invoked with. 122 char _jvm_ident[JVM_IDENT_MAX]; // identifier for jvm 123 172 ~FileMapInfo(); 173 174 static int current_version() { return _current_version; } 175 int compute_header_crc() { return _header->compute_crc(); } 176 void set_header_crc(int crc) { _header->_crc = crc; } 177 void populate_header(size_t alignment); 178 bool validate_header(); 179 void invalidate(); 180 int version() { return _header->_version; } 181 size_t alignment() { return _header->_alignment; } 182 Universe::NARROW_OOP_MODE narrow_oop_mode() { return _header->_narrow_oop_mode; } 183 int narrow_oop_shift() { return _header->_narrow_oop_shift; } 184 uintx max_heap_size() { return _header->_max_heap_size; } 185 address narrow_klass_base() const { return _header->_narrow_klass_base; } 186 int narrow_klass_shift() const { return _header->_narrow_klass_shift; } 187 size_t space_capacity(int i) { return _header->_space[i]._capacity; } 188 struct FileMapHeader* header() { return _header; } 189 char* misc_data_patching_start() { return _header->_misc_data_patching_start; } 190 void set_misc_data_patching_start(char* p) { _header->_misc_data_patching_start = p; } 191 192 static FileMapInfo* current_info() { 193 CDS_ONLY(return _current_info;) 194 NOT_CDS(return NULL;) 195 } 196 197 static void assert_mark(bool check); 198 199 // File manipulation. 200 bool initialize() NOT_CDS_RETURN_(false); 201 bool open_for_read(); 202 void open_for_write(); 203 void write_header(); 204 void write_space(int i, Metaspace* space, bool read_only); 205 void write_region(int region, char* base, size_t size, 206 size_t capacity, bool read_only, bool allow_exec); 207 void write_string_regions(GrowableArray<MemRegion> *regions); 208 void write_bytes(const void* buffer, int count); 209 void write_bytes_aligned(const void* buffer, int count); 210 char* map_region(int i); 211 bool map_string_regions(); | 84 struct FileMapHeader : FileMapHeaderBase { 85 // Use data() and data_size() to memcopy to/from the FileMapHeader. We need to 86 // avoid read/writing the C++ vtable pointer. 87 static size_t data_size(); 88 char* data() { 89 return ((char*)this) + sizeof(FileMapHeaderBase); 90 } 91 92 int _magic; // identify file type. 93 int _crc; // header crc checksum. 94 int _version; // (from enum, above.) 95 size_t _alignment; // how shared archive should be aligned 96 int _obj_alignment; // value of ObjectAlignmentInBytes 97 int _narrow_oop_shift; // compressed oop encoding shift 98 bool _compact_strings; // value of CompactStrings 99 uintx _max_heap_size; // java max heap size during dumping 100 Universe::NARROW_OOP_MODE _narrow_oop_mode; // compressed oop encoding mode 101 int _narrow_klass_shift; // save narrow klass base and shift 102 address _narrow_klass_base; 103 char* _misc_data_patching_start; 104 address _cds_i2i_entry_code_buffers; 105 size_t _cds_i2i_entry_code_buffers_size; 106 107 struct space_info { 108 int _crc; // crc checksum of the current space 109 size_t _file_offset; // sizeof(this) rounded to vm page size 110 union { 111 char* _base; // copy-on-write base address 112 intx _offset; // offset from the compressed oop encoding base, only used 113 // by string space 114 } _addr; 115 size_t _capacity; // for validity checking 116 size_t _used; // for setting space top on read 117 bool _read_only; // read only space? 118 bool _allow_exec; // executable code in space? 119 } _space[MetaspaceShared::n_regions]; 120 121 // The following fields are all sanity checks for whether this archive 122 // will function correctly with this JVM and the bootclasspath it's 123 // invoked with. 124 char _jvm_ident[JVM_IDENT_MAX]; // identifier for jvm 125 174 ~FileMapInfo(); 175 176 static int current_version() { return _current_version; } 177 int compute_header_crc() { return _header->compute_crc(); } 178 void set_header_crc(int crc) { _header->_crc = crc; } 179 void populate_header(size_t alignment); 180 bool validate_header(); 181 void invalidate(); 182 int version() { return _header->_version; } 183 size_t alignment() { return _header->_alignment; } 184 Universe::NARROW_OOP_MODE narrow_oop_mode() { return _header->_narrow_oop_mode; } 185 int narrow_oop_shift() { return _header->_narrow_oop_shift; } 186 uintx max_heap_size() { return _header->_max_heap_size; } 187 address narrow_klass_base() const { return _header->_narrow_klass_base; } 188 int narrow_klass_shift() const { return _header->_narrow_klass_shift; } 189 size_t space_capacity(int i) { return _header->_space[i]._capacity; } 190 struct FileMapHeader* header() { return _header; } 191 char* misc_data_patching_start() { return _header->_misc_data_patching_start; } 192 void set_misc_data_patching_start(char* p) { _header->_misc_data_patching_start = p; } 193 194 address cds_i2i_entry_code_buffers() { 195 return _header->_cds_i2i_entry_code_buffers; 196 } 197 void set_cds_i2i_entry_code_buffers(address addr) { 198 _header->_cds_i2i_entry_code_buffers = addr; 199 } 200 size_t cds_i2i_entry_code_buffers_size() { 201 return _header->_cds_i2i_entry_code_buffers_size; 202 } 203 void set_cds_i2i_entry_code_buffers_size(size_t s) { 204 _header->_cds_i2i_entry_code_buffers_size = s; 205 } 206 207 static FileMapInfo* current_info() { 208 CDS_ONLY(return _current_info;) 209 NOT_CDS(return NULL;) 210 } 211 212 static void assert_mark(bool check); 213 214 // File manipulation. 215 bool initialize() NOT_CDS_RETURN_(false); 216 bool open_for_read(); 217 void open_for_write(); 218 void write_header(); 219 void write_space(int i, Metaspace* space, bool read_only); 220 void write_region(int region, char* base, size_t size, 221 size_t capacity, bool read_only, bool allow_exec); 222 void write_string_regions(GrowableArray<MemRegion> *regions); 223 void write_bytes(const void* buffer, int count); 224 void write_bytes_aligned(const void* buffer, int count); 225 char* map_region(int i); 226 bool map_string_regions(); |