src/hotspot/share/memory/filemap.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File open Sdiff src/hotspot/share/memory

src/hotspot/share/memory/filemap.hpp

Print this page
rev 49528 : [mq]: module_path


  36 //   [magic # = 0xF00BABA2]
  37 //  ... padding to align on page-boundary
  38 //  read-write space
  39 //  read-only space
  40 //  misc data (block offset table, string table, symbols, dictionary, etc.)
  41 //  tag(666)
  42 
  43 static const int JVM_IDENT_MAX = 256;
  44 
  45 class SharedClassPathEntry {
  46 protected:
  47   bool   _is_dir;
  48   time_t _timestamp;          // jar/jimage timestamp,  0 if is directory or other
  49   long   _filesize;           // jar/jimage file size, -1 if is directory, -2 if other
  50   Array<char>* _name;
  51   Array<u1>*   _manifest;
  52 
  53 public:
  54   void init(const char* name, TRAPS);
  55   void metaspace_pointers_do(MetaspaceClosure* it);
  56   bool validate();
  57 
  58   // The _timestamp only gets set for jar files and "modules" jimage.
  59   bool is_jar_or_bootimage() {
  60     return _timestamp != 0;
  61   }
  62   bool is_dir() { return _is_dir; }
  63   bool is_modules_image() { return ClassLoader::is_modules_image(name()); }
  64   time_t timestamp() const { return _timestamp; }
  65   long   filesize()  const { return _filesize; }
  66   const char* name() const { return _name->data(); }
  67   const char* manifest() const {
  68     return (_manifest == NULL) ? NULL : (const char*)_manifest->data();
  69   }
  70   int manifest_size() const {
  71     return (_manifest == NULL) ? 0 : _manifest->length();
  72   }
  73 };
  74 
  75 class FileMapInfo : public CHeapObj<mtInternal> {
  76 private:
  77   friend class ManifestStream;
  78   enum {
  79     _invalid_version = -1,
  80     _current_version = 3
  81   };
  82 
  83   bool  _file_open;
  84   int   _fd;
  85   size_t  _file_offset;
  86 
  87 private:
  88   static Array<u8>*            _classpath_entry_table;
  89   static int                   _classpath_entry_table_size;
  90   static size_t                _classpath_entry_size;
  91   static bool                  _validating_classpath_entry_table;
  92 
  93   // FileMapHeader describes the shared space data in the file to be
  94   // mapped.  This structure gets written to a file.  It is not a class, so
  95   // that the compilers don't add any compiler-private data to it.
  96 
  97 public:
  98   struct FileMapHeaderBase : public CHeapObj<mtClass> {
  99     virtual bool validate() = 0;
 100     virtual void populate(FileMapInfo* info, size_t alignment) = 0;
 101   };
 102   struct FileMapHeader : FileMapHeaderBase {
 103     // Use data() and data_size() to memcopy to/from the FileMapHeader. We need to
 104     // avoid read/writing the C++ vtable pointer.
 105     static size_t data_size();
 106     char* data() {
 107       return ((char*)this) + sizeof(FileMapHeaderBase);
 108     }
 109 
 110     int    _magic;                    // identify file type.
 111     int    _crc;                      // header crc checksum.


 136       size_t _used;          // for setting space top on read
 137       bool   _read_only;     // read only space?
 138       bool   _allow_exec;    // executable code in space?
 139     } _space[MetaspaceShared::n_regions];
 140 
 141     // The following fields are all sanity checks for whether this archive
 142     // will function correctly with this JVM and the bootclasspath it's
 143     // invoked with.
 144     char  _jvm_ident[JVM_IDENT_MAX];      // identifier for jvm
 145 
 146     // The _paths_misc_info is a variable-size structure that records "miscellaneous"
 147     // information during dumping. It is generated and validated by the
 148     // SharedPathsMiscInfo class. See SharedPathsMiscInfo.hpp and sharedClassUtil.hpp for
 149     // detailed description.
 150     //
 151     // The _paths_misc_info data is stored as a byte array in the archive file header,
 152     // immediately after the _header field. This information is used only when
 153     // checking the validity of the archive and is deallocated after the archive is loaded.
 154     //
 155     // Note that the _paths_misc_info does NOT include information for JAR files
 156     // that existed during dump time. Their information is stored in _classpath_entry_table.
 157     int _paths_misc_info_size;
 158 
 159     // The following is a table of all the class path entries that were used
 160     // during dumping. At run time, we require these files to exist and have the same
 161     // size/modification time, or else the archive will refuse to load.
 162     //
 163     // All of these entries must be JAR files. The dumping process would fail if a non-empty
 164     // directory was specified in the classpaths. If an empty directory was specified
 165     // it is checked by the _paths_misc_info as described above.
 166     //
 167     // FIXME -- if JAR files in the tail of the list were specified but not used during dumping,
 168     // they should be removed from this table, to save space and to avoid spurious
 169     // loading failures during runtime.
 170     int _classpath_entry_table_size;
 171     size_t _classpath_entry_size;
 172     Array<u8>* _classpath_entry_table;
 173 
 174     char* region_addr(int idx);
 175 
 176     virtual bool validate();
 177     virtual void populate(FileMapInfo* info, size_t alignment);
 178     int compute_crc();
 179   };
 180 
 181   FileMapHeader * _header;
 182 
 183   const char* _full_path;
 184   char* _paths_misc_info;
 185 
 186   static FileMapInfo* _current_info;
 187 
 188   bool  init_from_file(int fd);
 189   void  align_file_position();
 190   bool  validate_header_impl();
 191   static void metaspace_pointers_do(MetaspaceClosure* it);
 192 


 253   void  unmap_region(int i);
 254   bool  verify_region_checksum(int i);
 255   void  close();
 256   bool  is_open() { return _file_open; }
 257   ReservedSpace reserve_shared_memory();
 258 
 259   // JVM/TI RedefineClasses() support:
 260   // Remap the shared readonly space to shared readwrite, private.
 261   bool  remap_shared_readonly_as_readwrite();
 262 
 263   // Errors.
 264   static void fail_stop(const char *msg, ...) ATTRIBUTE_PRINTF(1, 2);
 265   static void fail_continue(const char *msg, ...) ATTRIBUTE_PRINTF(1, 2);
 266 
 267   bool is_in_shared_region(const void* p, int idx) NOT_CDS_RETURN_(false);
 268   void print_shared_spaces() NOT_CDS_RETURN;
 269 
 270   // Stop CDS sharing and unmap CDS regions.
 271   static void stop_sharing_and_unmap(const char* msg);
 272 
 273   static void allocate_classpath_entry_table();
 274   bool validate_classpath_entry_table();
 275 
 276   static SharedClassPathEntry* shared_classpath(int index) {
 277     if (index < 0) {
 278       return NULL;
 279     }
 280     assert(index < _classpath_entry_table_size, "sanity");
 281     char* p = (char*)_classpath_entry_table->data();
 282     p += _classpath_entry_size * index;
 283     return (SharedClassPathEntry*)p;
 284   }
 285   static const char* shared_classpath_name(int index) {

 286     assert(index >= 0, "Sanity");
 287     return shared_classpath(index)->name();
 288   }
 289 
 290   static int get_number_of_share_classpaths() {
 291     return _classpath_entry_table_size;
 292   }
 293 
 294  private:
 295   bool  map_heap_data(MemRegion **heap_mem, int first, int max, int* num,
 296                       bool is_open = false) NOT_CDS_JAVA_HEAP_RETURN_(false);
 297   bool  verify_mapped_heap_regions(int first, int num) NOT_CDS_JAVA_HEAP_RETURN_(false);
 298   void  dealloc_archive_heap_regions(MemRegion* regions, int num) NOT_CDS_JAVA_HEAP_RETURN;
 299 };
 300 
 301 #endif // SHARE_VM_MEMORY_FILEMAP_HPP


  36 //   [magic # = 0xF00BABA2]
  37 //  ... padding to align on page-boundary
  38 //  read-write space
  39 //  read-only space
  40 //  misc data (block offset table, string table, symbols, dictionary, etc.)
  41 //  tag(666)
  42 
  43 static const int JVM_IDENT_MAX = 256;
  44 
  45 class SharedClassPathEntry {
  46 protected:
  47   bool   _is_dir;
  48   time_t _timestamp;          // jar/jimage timestamp,  0 if is directory or other
  49   long   _filesize;           // jar/jimage file size, -1 if is directory, -2 if other
  50   Array<char>* _name;
  51   Array<u1>*   _manifest;
  52 
  53 public:
  54   void init(const char* name, TRAPS);
  55   void metaspace_pointers_do(MetaspaceClosure* it);
  56   bool validate(bool is_class_path = true);
  57 
  58   // The _timestamp only gets set for jar files and "modules" jimage.
  59   bool is_jar_or_bootimage() {
  60     return _timestamp != 0;
  61   }
  62   bool is_dir() { return _is_dir; }
  63   bool is_modules_image() { return ClassLoader::is_modules_image(name()); }
  64   time_t timestamp() const { return _timestamp; }
  65   long   filesize()  const { return _filesize; }
  66   const char* name() const { return _name->data(); }
  67   const char* manifest() const {
  68     return (_manifest == NULL) ? NULL : (const char*)_manifest->data();
  69   }
  70   int manifest_size() const {
  71     return (_manifest == NULL) ? 0 : _manifest->length();
  72   }
  73 };
  74 
  75 class FileMapInfo : public CHeapObj<mtInternal> {
  76 private:
  77   friend class ManifestStream;
  78   enum {
  79     _invalid_version = -1,
  80     _current_version = 3
  81   };
  82 
  83   bool  _file_open;
  84   int   _fd;
  85   size_t  _file_offset;
  86 
  87 private:
  88   static Array<u8>*            _shared_path_table;
  89   static int                   _shared_path_table_size;
  90   static size_t                _shared_path_entry_size;
  91   static bool                  _validating_shared_path_table;
  92 
  93   // FileMapHeader describes the shared space data in the file to be
  94   // mapped.  This structure gets written to a file.  It is not a class, so
  95   // that the compilers don't add any compiler-private data to it.
  96 
  97 public:
  98   struct FileMapHeaderBase : public CHeapObj<mtClass> {
  99     virtual bool validate() = 0;
 100     virtual void populate(FileMapInfo* info, size_t alignment) = 0;
 101   };
 102   struct FileMapHeader : FileMapHeaderBase {
 103     // Use data() and data_size() to memcopy to/from the FileMapHeader. We need to
 104     // avoid read/writing the C++ vtable pointer.
 105     static size_t data_size();
 106     char* data() {
 107       return ((char*)this) + sizeof(FileMapHeaderBase);
 108     }
 109 
 110     int    _magic;                    // identify file type.
 111     int    _crc;                      // header crc checksum.


 136       size_t _used;          // for setting space top on read
 137       bool   _read_only;     // read only space?
 138       bool   _allow_exec;    // executable code in space?
 139     } _space[MetaspaceShared::n_regions];
 140 
 141     // The following fields are all sanity checks for whether this archive
 142     // will function correctly with this JVM and the bootclasspath it's
 143     // invoked with.
 144     char  _jvm_ident[JVM_IDENT_MAX];      // identifier for jvm
 145 
 146     // The _paths_misc_info is a variable-size structure that records "miscellaneous"
 147     // information during dumping. It is generated and validated by the
 148     // SharedPathsMiscInfo class. See SharedPathsMiscInfo.hpp and sharedClassUtil.hpp for
 149     // detailed description.
 150     //
 151     // The _paths_misc_info data is stored as a byte array in the archive file header,
 152     // immediately after the _header field. This information is used only when
 153     // checking the validity of the archive and is deallocated after the archive is loaded.
 154     //
 155     // Note that the _paths_misc_info does NOT include information for JAR files
 156     // that existed during dump time. Their information is stored in _shared_path_table.
 157     int _paths_misc_info_size;
 158 
 159     // The following is a table of all the class path entries that were used
 160     // during dumping. At run time, we require these files to exist and have the same
 161     // size/modification time, or else the archive will refuse to load.
 162     //
 163     // All of these entries must be JAR files. The dumping process would fail if a non-empty
 164     // directory was specified in the classpaths. If an empty directory was specified
 165     // it is checked by the _paths_misc_info as described above.
 166     //
 167     // FIXME -- if JAR files in the tail of the list were specified but not used during dumping,
 168     // they should be removed from this table, to save space and to avoid spurious
 169     // loading failures during runtime.
 170     int _shared_path_table_size;
 171     size_t _shared_path_entry_size;
 172     Array<u8>* _shared_path_table;
 173 
 174     char* region_addr(int idx);
 175 
 176     virtual bool validate();
 177     virtual void populate(FileMapInfo* info, size_t alignment);
 178     int compute_crc();
 179   };
 180 
 181   FileMapHeader * _header;
 182 
 183   const char* _full_path;
 184   char* _paths_misc_info;
 185 
 186   static FileMapInfo* _current_info;
 187 
 188   bool  init_from_file(int fd);
 189   void  align_file_position();
 190   bool  validate_header_impl();
 191   static void metaspace_pointers_do(MetaspaceClosure* it);
 192 


 253   void  unmap_region(int i);
 254   bool  verify_region_checksum(int i);
 255   void  close();
 256   bool  is_open() { return _file_open; }
 257   ReservedSpace reserve_shared_memory();
 258 
 259   // JVM/TI RedefineClasses() support:
 260   // Remap the shared readonly space to shared readwrite, private.
 261   bool  remap_shared_readonly_as_readwrite();
 262 
 263   // Errors.
 264   static void fail_stop(const char *msg, ...) ATTRIBUTE_PRINTF(1, 2);
 265   static void fail_continue(const char *msg, ...) ATTRIBUTE_PRINTF(1, 2);
 266 
 267   bool is_in_shared_region(const void* p, int idx) NOT_CDS_RETURN_(false);
 268   void print_shared_spaces() NOT_CDS_RETURN;
 269 
 270   // Stop CDS sharing and unmap CDS regions.
 271   static void stop_sharing_and_unmap(const char* msg);
 272 
 273   static void allocate_shared_path_table();
 274   bool validate_shared_path_table();
 275 
 276   static SharedClassPathEntry* shared_path(int index) {
 277     if (index < 0) {
 278       return NULL;
 279     }
 280     assert(index < _shared_path_table_size, "sanity");
 281     char* p = (char*)_shared_path_table->data();
 282     p += _shared_path_entry_size * index;
 283     return (SharedClassPathEntry*)p;
 284   }
 285 
 286   static const char* shared_path_name(int index) {
 287     assert(index >= 0, "Sanity");
 288     return shared_path(index)->name();
 289   }
 290 
 291   static int get_number_of_shared_paths() {
 292     return _shared_path_table_size;
 293   }
 294 
 295  private:
 296   bool  map_heap_data(MemRegion **heap_mem, int first, int max, int* num,
 297                       bool is_open = false) NOT_CDS_JAVA_HEAP_RETURN_(false);
 298   bool  verify_mapped_heap_regions(int first, int num) NOT_CDS_JAVA_HEAP_RETURN_(false);
 299   void  dealloc_archive_heap_regions(MemRegion* regions, int num) NOT_CDS_JAVA_HEAP_RETURN;
 300 };
 301 
 302 #endif // SHARE_VM_MEMORY_FILEMAP_HPP
src/hotspot/share/memory/filemap.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File