< prev index next >

src/hotspot/share/memory/metaspaceShared.hpp

Print this page


  61 
  62   // CDS support
  63 
  64   // Note: _shared_rs and _symbol_rs are only used at dump time.
  65   static ReservedSpace _shared_rs;
  66   static VirtualSpace _shared_vs;
  67   static ReservedSpace _symbol_rs;
  68   static VirtualSpace _symbol_vs;
  69   static int _max_alignment;
  70   static MetaspaceSharedStats _stats;
  71   static bool _has_error_classes;
  72   static bool _archive_loading_failed;
  73   static bool _remapped_readwrite;
  74   static address _i2i_entry_code_buffers;
  75   static size_t  _i2i_entry_code_buffers_size;
  76   static size_t  _core_spaces_size;
  77   static void* _shared_metaspace_static_top;
  78   static intx _relocation_delta;
  79   static char* _requested_base_address;
  80   static bool _use_optimized_module_handling;

  81  public:
  82   enum {
  83     // core archive spaces
  84     mc = 0,  // miscellaneous code for method trampolines
  85     rw = 1,  // read-write shared space in the heap
  86     ro = 2,  // read-only shared space in the heap
  87     bm = 3,  // relocation bitmaps (freed after file mapping is finished)
  88     num_core_region = 3,
  89     num_non_heap_spaces = 4,
  90 
  91     // mapped java heap regions
  92     first_closed_archive_heap_region = bm + 1,
  93     max_closed_archive_heap_region = 2,
  94     last_closed_archive_heap_region = first_closed_archive_heap_region + max_closed_archive_heap_region - 1,
  95     first_open_archive_heap_region = last_closed_archive_heap_region + 1,
  96     max_open_archive_heap_region = 2,
  97     last_open_archive_heap_region = first_open_archive_heap_region + max_open_archive_heap_region - 1,
  98 
  99     last_valid_region = last_open_archive_heap_region,
 100     n_regions =  last_valid_region + 1 // total number of regions


 196   static void link_and_cleanup_shared_classes(TRAPS) NOT_CDS_RETURN;
 197 
 198 #if INCLUDE_CDS
 199   static size_t reserved_space_alignment();
 200   static void init_shared_dump_space(DumpRegion* first_space);
 201   static DumpRegion* misc_code_dump_space();
 202   static DumpRegion* read_write_dump_space();
 203   static DumpRegion* read_only_dump_space();
 204   static void pack_dump_space(DumpRegion* current, DumpRegion* next,
 205                               ReservedSpace* rs);
 206 
 207   static void rewrite_nofast_bytecodes_and_calculate_fingerprints(Thread* thread, InstanceKlass* ik);
 208 #endif
 209 
 210   // Allocate a block of memory from the temporary "symbol" region.
 211   static char* symbol_space_alloc(size_t num_bytes);
 212 
 213   // Allocate a block of memory from the "mc" or "ro" regions.
 214   static char* misc_code_space_alloc(size_t num_bytes);
 215   static char* read_only_space_alloc(size_t num_bytes);

 216 
 217   template <typename T>
 218   static Array<T>* new_ro_array(int length) {
 219 #if INCLUDE_CDS
 220     size_t byte_size = Array<T>::byte_sizeof(length, sizeof(T));
 221     Array<T>* array = (Array<T>*)read_only_space_alloc(byte_size);
 222     array->initialize(length);
 223     return array;
 224 #else
 225     return NULL;
 226 #endif





 227   }
 228 
 229   template <typename T>
 230   static size_t ro_array_bytesize(int length) {
 231     size_t byte_size = Array<T>::byte_sizeof(length, sizeof(T));
 232     return align_up(byte_size, BytesPerWord);
 233   }
 234 
 235   static address i2i_entry_code_buffers(size_t total_size);
 236 
 237   static address i2i_entry_code_buffers() {
 238     return _i2i_entry_code_buffers;
 239   }
 240   static size_t i2i_entry_code_buffers_size() {
 241     return _i2i_entry_code_buffers_size;
 242   }
 243   static void relocate_klass_ptr(oop o);
 244 
 245   static Klass* get_relocated_klass(Klass *k, bool is_final=false);

 246 
 247   static void allocate_cloned_cpp_vtptrs();
 248   static intptr_t* get_archived_cpp_vtable(MetaspaceObj::Type msotype, address obj);
 249   static void initialize_ptr_marker(CHeapBitMap* ptrmap);
 250 
 251   // This is the base address as specified by -XX:SharedBaseAddress during -Xshare:dump.
 252   // Both the base/top archives are written using this as their base address.
 253   static char* requested_base_address() {
 254     return _requested_base_address;
 255   }
 256 
 257   // Non-zero if the archive(s) need to be mapped a non-default location due to ASLR.
 258   static intx relocation_delta() { return _relocation_delta; }
 259   static intx final_delta();
 260   static bool use_windows_memory_mapping() {
 261     const bool is_windows = (NOT_WINDOWS(false) WINDOWS_ONLY(true));
 262     //const bool is_windows = true; // enable this to allow testing the windows mmap semantics on Linux, etc.
 263     return is_windows;
 264   }
 265 
 266   static void write_core_archive_regions(FileMapInfo* mapinfo,
 267                                          GrowableArray<ArchiveHeapOopmapInfo>* closed_oopmaps,
 268                                          GrowableArray<ArchiveHeapOopmapInfo>* open_oopmaps);
 269 
 270   // Can we skip some expensive operations related to modules?
 271   static bool use_optimized_module_handling()     { return _use_optimized_module_handling;  }
 272   static void disable_optimized_module_handling() { _use_optimized_module_handling = false; }




 273 
 274 private:
 275 #if INCLUDE_CDS
 276   static void write_region(FileMapInfo* mapinfo, int region_idx, DumpRegion* dump_region,
 277                            bool read_only,  bool allow_exec);
 278 #endif
 279   static void read_extra_data(const char* filename, TRAPS) NOT_CDS_RETURN;
 280   static FileMapInfo* open_static_archive();
 281   static FileMapInfo* open_dynamic_archive();
 282   // use_requested_addr: If true (default), attempt to map at the address the
 283   static MapArchiveResult map_archives(FileMapInfo* static_mapinfo, FileMapInfo* dynamic_mapinfo,
 284                                        bool use_requested_addr);
 285   static char* reserve_address_space_for_archives(FileMapInfo* static_mapinfo,
 286                                                   FileMapInfo* dynamic_mapinfo,
 287                                                   bool use_archive_base_addr,
 288                                                   ReservedSpace& archive_space_rs,
 289                                                   ReservedSpace& class_space_rs);
 290   static void release_reserved_spaces(ReservedSpace& archive_space_rs,
 291                                       ReservedSpace& class_space_rs);
 292   static MapArchiveResult map_archive(FileMapInfo* mapinfo, char* mapped_base_address, ReservedSpace rs);


  61 
  62   // CDS support
  63 
  64   // Note: _shared_rs and _symbol_rs are only used at dump time.
  65   static ReservedSpace _shared_rs;
  66   static VirtualSpace _shared_vs;
  67   static ReservedSpace _symbol_rs;
  68   static VirtualSpace _symbol_vs;
  69   static int _max_alignment;
  70   static MetaspaceSharedStats _stats;
  71   static bool _has_error_classes;
  72   static bool _archive_loading_failed;
  73   static bool _remapped_readwrite;
  74   static address _i2i_entry_code_buffers;
  75   static size_t  _i2i_entry_code_buffers_size;
  76   static size_t  _core_spaces_size;
  77   static void* _shared_metaspace_static_top;
  78   static intx _relocation_delta;
  79   static char* _requested_base_address;
  80   static bool _use_optimized_module_handling;
  81   static bool _use_full_module_graph;
  82  public:
  83   enum {
  84     // core archive spaces
  85     mc = 0,  // miscellaneous code for method trampolines
  86     rw = 1,  // read-write shared space in the heap
  87     ro = 2,  // read-only shared space in the heap
  88     bm = 3,  // relocation bitmaps (freed after file mapping is finished)
  89     num_core_region = 3,
  90     num_non_heap_spaces = 4,
  91 
  92     // mapped java heap regions
  93     first_closed_archive_heap_region = bm + 1,
  94     max_closed_archive_heap_region = 2,
  95     last_closed_archive_heap_region = first_closed_archive_heap_region + max_closed_archive_heap_region - 1,
  96     first_open_archive_heap_region = last_closed_archive_heap_region + 1,
  97     max_open_archive_heap_region = 2,
  98     last_open_archive_heap_region = first_open_archive_heap_region + max_open_archive_heap_region - 1,
  99 
 100     last_valid_region = last_open_archive_heap_region,
 101     n_regions =  last_valid_region + 1 // total number of regions


 197   static void link_and_cleanup_shared_classes(TRAPS) NOT_CDS_RETURN;
 198 
 199 #if INCLUDE_CDS
 200   static size_t reserved_space_alignment();
 201   static void init_shared_dump_space(DumpRegion* first_space);
 202   static DumpRegion* misc_code_dump_space();
 203   static DumpRegion* read_write_dump_space();
 204   static DumpRegion* read_only_dump_space();
 205   static void pack_dump_space(DumpRegion* current, DumpRegion* next,
 206                               ReservedSpace* rs);
 207 
 208   static void rewrite_nofast_bytecodes_and_calculate_fingerprints(Thread* thread, InstanceKlass* ik);
 209 #endif
 210 
 211   // Allocate a block of memory from the temporary "symbol" region.
 212   static char* symbol_space_alloc(size_t num_bytes);
 213 
 214   // Allocate a block of memory from the "mc" or "ro" regions.
 215   static char* misc_code_space_alloc(size_t num_bytes);
 216   static char* read_only_space_alloc(size_t num_bytes);
 217   static char* read_write_space_alloc(size_t num_bytes);
 218 
 219   template <typename T>
 220   static Array<T>* new_ro_array(int length) {

 221     size_t byte_size = Array<T>::byte_sizeof(length, sizeof(T));
 222     Array<T>* array = (Array<T>*)read_only_space_alloc(byte_size);
 223     array->initialize(length);
 224     return array;
 225   }
 226 
 227   template <typename T>
 228   static Array<T>* new_rw_array(int length) {
 229     size_t byte_size = Array<T>::byte_sizeof(length, sizeof(T));
 230     Array<T>* array = (Array<T>*)read_write_space_alloc(byte_size);
 231     array->initialize(length);
 232     return array;
 233   }
 234 
 235   template <typename T>
 236   static size_t ro_array_bytesize(int length) {
 237     size_t byte_size = Array<T>::byte_sizeof(length, sizeof(T));
 238     return align_up(byte_size, BytesPerWord);
 239   }
 240 
 241   static address i2i_entry_code_buffers(size_t total_size);
 242 
 243   static address i2i_entry_code_buffers() {
 244     return _i2i_entry_code_buffers;
 245   }
 246   static size_t i2i_entry_code_buffers_size() {
 247     return _i2i_entry_code_buffers_size;
 248   }
 249   static void relocate_klass_ptr(oop o);
 250 
 251   static Klass* get_relocated_klass(Klass *k, bool is_final=false);
 252   static Symbol* get_relocated_symbol(Symbol* orig_symbol);
 253 
 254   static void allocate_cloned_cpp_vtptrs();
 255   static intptr_t* get_archived_cpp_vtable(MetaspaceObj::Type msotype, address obj);
 256   static void initialize_ptr_marker(CHeapBitMap* ptrmap);
 257 
 258   // This is the base address as specified by -XX:SharedBaseAddress during -Xshare:dump.
 259   // Both the base/top archives are written using this as their base address.
 260   static char* requested_base_address() {
 261     return _requested_base_address;
 262   }
 263 
 264   // Non-zero if the archive(s) need to be mapped a non-default location due to ASLR.
 265   static intx relocation_delta() { return _relocation_delta; }
 266   static intx final_delta();
 267   static bool use_windows_memory_mapping() {
 268     const bool is_windows = (NOT_WINDOWS(false) WINDOWS_ONLY(true));
 269     //const bool is_windows = true; // enable this to allow testing the windows mmap semantics on Linux, etc.
 270     return is_windows;
 271   }
 272 
 273   static void write_core_archive_regions(FileMapInfo* mapinfo,
 274                                          GrowableArray<ArchiveHeapOopmapInfo>* closed_oopmaps,
 275                                          GrowableArray<ArchiveHeapOopmapInfo>* open_oopmaps);
 276 
 277   // Can we skip some expensive operations related to modules?
 278   static bool use_optimized_module_handling() { return NOT_CDS(false) CDS_ONLY(_use_optimized_module_handling); }
 279   static void disable_optimized_module_handling() { _use_optimized_module_handling = false; }
 280 
 281   // Can we use the full archived modue graph?
 282   static bool use_full_module_graph() NOT_CDS_RETURN_(false);
 283   static void disable_full_module_graph() { _use_full_module_graph = false; }
 284 
 285 private:
 286 #if INCLUDE_CDS
 287   static void write_region(FileMapInfo* mapinfo, int region_idx, DumpRegion* dump_region,
 288                            bool read_only,  bool allow_exec);
 289 #endif
 290   static void read_extra_data(const char* filename, TRAPS) NOT_CDS_RETURN;
 291   static FileMapInfo* open_static_archive();
 292   static FileMapInfo* open_dynamic_archive();
 293   // use_requested_addr: If true (default), attempt to map at the address the
 294   static MapArchiveResult map_archives(FileMapInfo* static_mapinfo, FileMapInfo* dynamic_mapinfo,
 295                                        bool use_requested_addr);
 296   static char* reserve_address_space_for_archives(FileMapInfo* static_mapinfo,
 297                                                   FileMapInfo* dynamic_mapinfo,
 298                                                   bool use_archive_base_addr,
 299                                                   ReservedSpace& archive_space_rs,
 300                                                   ReservedSpace& class_space_rs);
 301   static void release_reserved_spaces(ReservedSpace& archive_space_rs,
 302                                       ReservedSpace& class_space_rs);
 303   static MapArchiveResult map_archive(FileMapInfo* mapinfo, char* mapped_base_address, ReservedSpace rs);
< prev index next >