< prev index next >

src/hotspot/share/cds/filemap.hpp

Print this page

 15  * You should have received a copy of the GNU General Public License version
 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/archiveUtils.hpp"
 29 #include "cds/metaspaceShared.hpp"
 30 #include "include/cds.h"
 31 #include "logging/logLevel.hpp"
 32 #include "memory/allocation.hpp"
 33 #include "oops/array.hpp"
 34 #include "oops/compressedOops.hpp"

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

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































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

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


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

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




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

 15  * You should have received a copy of the GNU General Public License version
 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/archiveUtils.hpp"
 29 #include "cds/metaspaceShared.hpp"
 30 #include "include/cds.h"
 31 #include "logging/logLevel.hpp"
 32 #include "memory/allocation.hpp"
 33 #include "oops/array.hpp"
 34 #include "oops/compressedOops.hpp"
 35 #include "runtime/globals.hpp"
 36 #include "utilities/align.hpp"
 37 
 38 // To understand the layout of the CDS archive file:
 39 //
 40 // java -Xlog:cds+map=info:file=cds.map:none:filesize=0
 41 // java -Xlog:cds+map=debug:file=cds.map:none:filesize=0
 42 // java -Xlog:cds+map=trace:file=cds.map:none:filesize=0
 43 
 44 static const int JVM_IDENT_MAX = 256;
 45 
 46 class AOTClassLocationConfig;
 47 class ArchiveHeapInfo;
 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 #define CDS_MUST_MATCH_FLAGS_DO(f) \
103   f(EnableValhalla) \
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    _compressed_oops;                       // save the flag UseCompressedOops
150   bool    _compressed_class_ptrs;                 // save the flag UseCompressedClassPointers
151   int     _narrow_klass_pointer_bits;             // save number of bits in narrowKlass
152   int     _narrow_klass_shift;                    // save shift width used to pre-compute narrowKlass IDs in archived heap objects

155   size_t  _serialized_data_offset;                // Data accessed using {ReadClosure,WriteClosure}::serialize()
156 
157   // The following fields are all sanity checks for whether this archive
158   // will function correctly with this JVM and the bootclasspath it's
159   // invoked with.
160   char  _jvm_ident[JVM_IDENT_MAX];  // identifier string of the jvm that created this dump
161 
162   size_t _class_location_config_offset;
163 
164   bool   _verify_local;                 // BytecodeVerificationLocal setting
165   bool   _verify_remote;                // BytecodeVerificationRemote setting
166   bool   _has_platform_or_app_classes;  // Archive contains app or platform classes
167   char*  _requested_base_address;       // Archive relocation is not necessary if we map with this base address.
168   char*  _mapped_base_address;          // Actual base address where archive is mapped.
169 
170   bool   _allow_archiving_with_java_agent; // setting of the AllowArchivingWithJavaAgent option
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 -XX:+EnableValhalla?
176   CDSMustMatchFlags _must_match;        // These flags must be the same between dumptime and runtime
177   HeapRootSegments _heap_root_segments; // Heap root segments info
178   size_t _heap_oopmap_start_pos;        // The first bit in the oopmap corresponds to this position in the heap.
179   size_t _heap_ptrmap_start_pos;        // The first bit in the ptrmap corresponds to this position in the heap.
180   size_t _rw_ptrmap_start_pos;          // The first bit in the ptrmap corresponds to this position in the rw region
181   size_t _ro_ptrmap_start_pos;          // The first bit in the ptrmap corresponds to this position in the ro region
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   }

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