< prev index next >

src/hotspot/share/cds/filemap.hpp

Print this page

 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_CDS_FILEMAP_HPP
 26 #define SHARE_CDS_FILEMAP_HPP
 27 
 28 #include "cds/aotMetaspace.hpp"
 29 #include "cds/archiveUtils.hpp"
 30 #include "cds/heapShared.hpp"
 31 #include "include/cds.h"
 32 #include "logging/logLevel.hpp"
 33 #include "memory/allocation.hpp"
 34 #include "oops/array.hpp"
 35 #include "oops/compressedOops.hpp"

 36 #include "utilities/align.hpp"
 37 #include "utilities/bitMap.hpp"
 38 
 39 // To understand the layout of the CDS archive file:
 40 //
 41 // java -Xlog:cds+map=info:file=cds.map:none:filesize=0
 42 // java -Xlog:cds+map=debug:file=cds.map:none:filesize=0
 43 // java -Xlog:cds+map=trace:file=cds.map:none:filesize=0
 44 
 45 static const int JVM_IDENT_MAX = 256;
 46 
 47 class AOTClassLocationConfig;
 48 class BitMapView;
 49 class CHeapBitMap;
 50 class ClassFileStream;
 51 class ClassLoaderData;
 52 class ClassPathEntry;
 53 class outputStream;
 54 class ReservedSpace;
 55 

 82   size_t oopmap_size_in_bits()      const { assert_is_heap_region();     return _oopmap_size_in_bits; }
 83   size_t ptrmap_offset()            const { return _ptrmap_offset; }
 84   size_t ptrmap_size_in_bits()      const { return _ptrmap_size_in_bits; }
 85   bool   in_reserved_space()        const { return _in_reserved_space; }
 86 
 87   void set_file_offset(size_t s)     { _file_offset = s; }
 88   void set_read_only(bool v)         { _read_only = v; }
 89   void set_mapped_base(char* p)      { _mapped_base = p; }
 90   void set_mapped_from_file(bool v)  { _mapped_from_file = v; }
 91   void set_in_reserved_space(bool is_reserved) { _in_reserved_space = is_reserved; }
 92   void init(int region_index, size_t mapping_offset, size_t size, bool read_only,
 93             bool allow_exec, int crc);
 94   void init_oopmap(size_t offset, size_t size_in_bits);
 95   void init_ptrmap(size_t offset, size_t size_in_bits);
 96   bool has_ptrmap()                  { return _ptrmap_size_in_bits != 0; }
 97 
 98   bool check_region_crc(char* base) const;
 99   void print(outputStream* st, int region_index);
100 };
101 






























102 class FileMapHeader: private CDSFileMapHeaderBase {
103   friend class CDSConstants;
104   friend class VMStructs;
105 
106 private:
107   // The following fields record the states of the VM during dump time.
108   // They are compared with the runtime states to see if the archive
109   // can be used.
110   size_t _core_region_alignment;                  // how shared archive should be aligned
111   int    _obj_alignment;                          // value of ObjectAlignmentInBytes
112   address _narrow_oop_base;                       // compressed oop encoding base
113   int    _narrow_oop_shift;                       // compressed oop encoding shift
114   bool   _compact_strings;                        // value of CompactStrings
115   bool   _compact_headers;                        // value of UseCompactObjectHeaders
116   uintx  _max_heap_size;                          // java max heap size during dumping
117   CompressedOops::Mode _narrow_oop_mode;          // compressed oop encoding mode
118   bool    _object_streaming_mode;                 // dump was created for object streaming
119   bool    _compressed_oops;                       // save the flag UseCompressedOops
120   bool    _compressed_class_ptrs;                 // save the flag UseCompressedClassPointers
121   int     _narrow_klass_pointer_bits;             // save number of bits in narrowKlass

124   size_t  _early_serialized_data_offset;          // Data accessed using {ReadClosure,WriteClosure}::serialize()
125   size_t  _serialized_data_offset;                // Data accessed using {ReadClosure,WriteClosure}::serialize()
126 
127   // The following fields are all sanity checks for whether this archive
128   // will function correctly with this JVM and the bootclasspath it's
129   // invoked with.
130   char  _jvm_ident[JVM_IDENT_MAX];  // identifier string of the jvm that created this dump
131 
132   size_t _class_location_config_offset;
133 
134   bool   _verify_local;                 // BytecodeVerificationLocal setting
135   bool   _verify_remote;                // BytecodeVerificationRemote setting
136   bool   _has_platform_or_app_classes;  // Archive contains app or platform classes
137   char*  _requested_base_address;       // Archive relocation is not necessary if we map with this base address.
138   char*  _mapped_base_address;          // Actual base address where archive is mapped.
139 
140   bool   _use_optimized_module_handling;// No module-relation VM options were specified, so we can skip
141                                         // some expensive operations.
142   bool   _has_aot_linked_classes;       // Was the CDS archive created with -XX:+AOTClassLinking
143   bool   _has_full_module_graph;        // Does this CDS archive contain the full archived module graph?


144   size_t _rw_ptrmap_start_pos;          // The first bit in the ptrmap corresponds to this position in the rw region
145   size_t _ro_ptrmap_start_pos;          // The first bit in the ptrmap corresponds to this position in the ro region
146 
147   ArchiveMappedHeapHeader _mapped_heap_header;
148   ArchiveStreamedHeapHeader _streamed_heap_header;
149 
150   // The following are parameters that affect MethodData layout.
151   u1      _compiler_type;
152   uint    _type_profile_level;
153   int     _type_profile_args_limit;
154   int     _type_profile_parms_limit;
155   intx    _type_profile_width;
156   intx    _bci_profile_width;
157   bool    _profile_traps;
158   bool    _type_profile_casts;
159   int     _spec_trap_limit_extra_entries;
160 
161   template <typename T> T from_mapped_offset(size_t offset) const {
162     return (T)(mapped_base_address() + offset);
163   }

235 
236   void set_requested_base(char* b) {
237     _requested_base_address = b;
238     _mapped_base_address = nullptr;
239   }
240 
241   bool validate();
242   int compute_crc();
243 
244   FileMapRegion* region_at(int i) {
245     assert(is_valid_region(i), "invalid region");
246     return FileMapRegion::cast(&_regions[i]);
247   }
248 
249   void populate(FileMapInfo *info, size_t core_region_alignment, size_t header_size,
250                 size_t base_archive_name_size, size_t base_archive_name_offset);
251   static bool is_valid_region(int region) {
252     return (0 <= region && region < NUM_CDS_REGIONS);
253   }
254 




255   void print(outputStream* st);
256 };
257 
258 class FileMapInfo : public CHeapObj<mtInternal> {
259 private:
260   friend class ManifestStream;
261   friend class VMStructs;
262   friend class ArchiveBuilder;
263   friend class CDSOffsets;
264   friend class FileMapHeader;
265 
266   bool           _is_static;
267   bool           _file_open;
268   bool           _is_mapped;
269   int            _fd;
270   size_t         _file_offset;
271   const char*    _full_path;
272   const char*    _base_archive_name;
273   FileMapHeader* _header;
274 

 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_CDS_FILEMAP_HPP
 26 #define SHARE_CDS_FILEMAP_HPP
 27 
 28 #include "cds/aotMetaspace.hpp"
 29 #include "cds/archiveUtils.hpp"
 30 #include "cds/heapShared.hpp"
 31 #include "include/cds.h"
 32 #include "logging/logLevel.hpp"
 33 #include "memory/allocation.hpp"
 34 #include "oops/array.hpp"
 35 #include "oops/compressedOops.hpp"
 36 #include "runtime/globals.hpp"
 37 #include "utilities/align.hpp"
 38 #include "utilities/bitMap.hpp"
 39 
 40 // To understand the layout of the CDS archive file:
 41 //
 42 // java -Xlog:cds+map=info:file=cds.map:none:filesize=0
 43 // java -Xlog:cds+map=debug:file=cds.map:none:filesize=0
 44 // java -Xlog:cds+map=trace:file=cds.map:none:filesize=0
 45 
 46 static const int JVM_IDENT_MAX = 256;
 47 
 48 class AOTClassLocationConfig;
 49 class BitMapView;
 50 class CHeapBitMap;
 51 class ClassFileStream;
 52 class ClassLoaderData;
 53 class ClassPathEntry;
 54 class outputStream;
 55 class ReservedSpace;
 56 

 83   size_t oopmap_size_in_bits()      const { assert_is_heap_region();     return _oopmap_size_in_bits; }
 84   size_t ptrmap_offset()            const { return _ptrmap_offset; }
 85   size_t ptrmap_size_in_bits()      const { return _ptrmap_size_in_bits; }
 86   bool   in_reserved_space()        const { return _in_reserved_space; }
 87 
 88   void set_file_offset(size_t s)     { _file_offset = s; }
 89   void set_read_only(bool v)         { _read_only = v; }
 90   void set_mapped_base(char* p)      { _mapped_base = p; }
 91   void set_mapped_from_file(bool v)  { _mapped_from_file = v; }
 92   void set_in_reserved_space(bool is_reserved) { _in_reserved_space = is_reserved; }
 93   void init(int region_index, size_t mapping_offset, size_t size, bool read_only,
 94             bool allow_exec, int crc);
 95   void init_oopmap(size_t offset, size_t size_in_bits);
 96   void init_ptrmap(size_t offset, size_t size_in_bits);
 97   bool has_ptrmap()                  { return _ptrmap_size_in_bits != 0; }
 98 
 99   bool check_region_crc(char* base) const;
100   void print(outputStream* st, int region_index);
101 };
102 
103 #define CDS_MUST_MATCH_FLAGS_DO(f) \
104   f(UseArrayFlattening) \
105   f(UseFieldFlattening) \
106   f(InlineTypePassFieldsAsArgs) \
107   f(InlineTypeReturnedAsFields) \
108   f(UseNonAtomicValueFlattening) \
109   f(UseAtomicValueFlattening) \
110   f(UseNullableValueFlattening)
111 
112 
113 class CDSMustMatchFlags {
114 private:
115   size_t _max_name_width;
116 #define DECLARE_CDS_MUST_MATCH_FLAG(n) \
117   decltype(n) _v_##n;
118   CDS_MUST_MATCH_FLAGS_DO(DECLARE_CDS_MUST_MATCH_FLAG);
119 #undef DECLARE_CDS_MUST_MATCH_FLAG
120 
121   inline static void do_print(outputStream* st, bool v);
122   inline static void do_print(outputStream* st, intx v);
123   inline static void do_print(outputStream* st, uintx v);
124   inline static void do_print(outputStream* st, double v);
125   void print_info() const;
126 
127 public:
128   void init();
129   bool runtime_check() const;
130   void print(outputStream* st) const;
131 };
132 
133 class FileMapHeader: private CDSFileMapHeaderBase {
134   friend class CDSConstants;
135   friend class VMStructs;
136 
137 private:
138   // The following fields record the states of the VM during dump time.
139   // They are compared with the runtime states to see if the archive
140   // can be used.
141   size_t _core_region_alignment;                  // how shared archive should be aligned
142   int    _obj_alignment;                          // value of ObjectAlignmentInBytes
143   address _narrow_oop_base;                       // compressed oop encoding base
144   int    _narrow_oop_shift;                       // compressed oop encoding shift
145   bool   _compact_strings;                        // value of CompactStrings
146   bool   _compact_headers;                        // value of UseCompactObjectHeaders
147   uintx  _max_heap_size;                          // java max heap size during dumping
148   CompressedOops::Mode _narrow_oop_mode;          // compressed oop encoding mode
149   bool    _object_streaming_mode;                 // dump was created for object streaming
150   bool    _compressed_oops;                       // save the flag UseCompressedOops
151   bool    _compressed_class_ptrs;                 // save the flag UseCompressedClassPointers
152   int     _narrow_klass_pointer_bits;             // save number of bits in narrowKlass

155   size_t  _early_serialized_data_offset;          // Data accessed using {ReadClosure,WriteClosure}::serialize()
156   size_t  _serialized_data_offset;                // Data accessed using {ReadClosure,WriteClosure}::serialize()
157 
158   // The following fields are all sanity checks for whether this archive
159   // will function correctly with this JVM and the bootclasspath it's
160   // invoked with.
161   char  _jvm_ident[JVM_IDENT_MAX];  // identifier string of the jvm that created this dump
162 
163   size_t _class_location_config_offset;
164 
165   bool   _verify_local;                 // BytecodeVerificationLocal setting
166   bool   _verify_remote;                // BytecodeVerificationRemote setting
167   bool   _has_platform_or_app_classes;  // Archive contains app or platform classes
168   char*  _requested_base_address;       // Archive relocation is not necessary if we map with this base address.
169   char*  _mapped_base_address;          // Actual base address where archive is mapped.
170 
171   bool   _use_optimized_module_handling;// No module-relation VM options were specified, so we can skip
172                                         // some expensive operations.
173   bool   _has_aot_linked_classes;       // Was the CDS archive created with -XX:+AOTClassLinking
174   bool   _has_full_module_graph;        // Does this CDS archive contain the full archived module graph?
175   bool   _has_valhalla_patched_classes; // Is this archived dumped with --enable-preview?
176   CDSMustMatchFlags _must_match;        // These flags must be the same between dumptime and runtime
177   size_t _rw_ptrmap_start_pos;          // The first bit in the ptrmap corresponds to this position in the rw region
178   size_t _ro_ptrmap_start_pos;          // The first bit in the ptrmap corresponds to this position in the ro region
179 
180   ArchiveMappedHeapHeader _mapped_heap_header;
181   ArchiveStreamedHeapHeader _streamed_heap_header;
182 
183   // The following are parameters that affect MethodData layout.
184   u1      _compiler_type;
185   uint    _type_profile_level;
186   int     _type_profile_args_limit;
187   int     _type_profile_parms_limit;
188   intx    _type_profile_width;
189   intx    _bci_profile_width;
190   bool    _profile_traps;
191   bool    _type_profile_casts;
192   int     _spec_trap_limit_extra_entries;
193 
194   template <typename T> T from_mapped_offset(size_t offset) const {
195     return (T)(mapped_base_address() + offset);
196   }

268 
269   void set_requested_base(char* b) {
270     _requested_base_address = b;
271     _mapped_base_address = nullptr;
272   }
273 
274   bool validate();
275   int compute_crc();
276 
277   FileMapRegion* region_at(int i) {
278     assert(is_valid_region(i), "invalid region");
279     return FileMapRegion::cast(&_regions[i]);
280   }
281 
282   void populate(FileMapInfo *info, size_t core_region_alignment, size_t header_size,
283                 size_t base_archive_name_size, size_t base_archive_name_offset);
284   static bool is_valid_region(int region) {
285     return (0 <= region && region < NUM_CDS_REGIONS);
286   }
287 
288   bool check_must_match_flags() const {
289     return _must_match.runtime_check();
290   }
291 
292   void print(outputStream* st);
293 };
294 
295 class FileMapInfo : public CHeapObj<mtInternal> {
296 private:
297   friend class ManifestStream;
298   friend class VMStructs;
299   friend class ArchiveBuilder;
300   friend class CDSOffsets;
301   friend class FileMapHeader;
302 
303   bool           _is_static;
304   bool           _file_open;
305   bool           _is_mapped;
306   int            _fd;
307   size_t         _file_offset;
308   const char*    _full_path;
309   const char*    _base_archive_name;
310   FileMapHeader* _header;
311 
< prev index next >