< prev index next >

src/hotspot/share/memory/metaspaceShared.cpp

Print this page




  72 #include "utilities/ostream.hpp"
  73 #include "utilities/defaultStream.hpp"
  74 #include "utilities/hashtable.inline.hpp"
  75 #if INCLUDE_G1GC
  76 #include "gc/g1/g1CollectedHeap.hpp"
  77 #endif
  78 
  79 ReservedSpace MetaspaceShared::_shared_rs;
  80 VirtualSpace MetaspaceShared::_shared_vs;
  81 ReservedSpace MetaspaceShared::_symbol_rs;
  82 VirtualSpace MetaspaceShared::_symbol_vs;
  83 MetaspaceSharedStats MetaspaceShared::_stats;
  84 bool MetaspaceShared::_has_error_classes;
  85 bool MetaspaceShared::_archive_loading_failed = false;
  86 bool MetaspaceShared::_remapped_readwrite = false;
  87 address MetaspaceShared::_i2i_entry_code_buffers = NULL;
  88 size_t MetaspaceShared::_i2i_entry_code_buffers_size = 0;
  89 void* MetaspaceShared::_shared_metaspace_static_top = NULL;
  90 intx MetaspaceShared::_relocation_delta;
  91 char* MetaspaceShared::_requested_base_address;

  92 
  93 // The CDS archive is divided into the following regions:
  94 //     mc  - misc code (the method entry trampolines, c++ vtables)
  95 //     rw  - read-write metadata
  96 //     ro  - read-only metadata and read-only tables
  97 //
  98 //     ca0 - closed archive heap space #0
  99 //     ca1 - closed archive heap space #1 (may be empty)
 100 //     oa0 - open archive heap space #0
 101 //     oa1 - open archive heap space #1 (may be empty)
 102 //
 103 // The mc, rw, and ro regions are linearly allocated, starting from
 104 // SharedBaseAddress, in the order of mc->rw->ro. The size of these 3 regions
 105 // are page-aligned, and there's no gap between any consecutive regions.
 106 //
 107 // These 3 regions are populated in the following steps:
 108 // [1] All classes are loaded in MetaspaceShared::preload_classes(). All metadata are
 109 //     temporarily allocated outside of the shared regions. Only the method entry
 110 //     trampolines are written into the mc region.
 111 // [2] C++ vtables are copied into the mc region.


2359   }
2360 
2361   if (result == MAP_ARCHIVE_SUCCESS) {
2362     SharedBaseAddress = (size_t)mapped_base_address;
2363     LP64_ONLY({
2364         if (Metaspace::using_class_space()) {
2365           // Set up ccs in metaspace.
2366           Metaspace::initialize_class_space(class_space_rs);
2367 
2368           // Set up compressed Klass pointer encoding: the encoding range must
2369           //  cover both archive and class space.
2370           address cds_base = (address)static_mapinfo->mapped_base();
2371           address ccs_end = (address)class_space_rs.end();
2372           CompressedKlassPointers::initialize(cds_base, ccs_end - cds_base);
2373 
2374           // map_heap_regions() compares the current narrow oop and klass encodings
2375           // with the archived ones, so it must be done after all encodings are determined.
2376           static_mapinfo->map_heap_regions();
2377         }
2378       });

2379   } else {
2380     unmap_archive(static_mapinfo);
2381     unmap_archive(dynamic_mapinfo);
2382     release_reserved_spaces(archive_space_rs, class_space_rs);
2383   }
2384 
2385   return result;
2386 }
2387 
2388 
2389 // This will reserve two address spaces suitable to house Klass structures, one
2390 //  for the cds archives (static archive and optionally dynamic archive) and
2391 //  optionally one move for ccs.
2392 //
2393 // Since both spaces must fall within the compressed class pointer encoding
2394 //  range, they are allocated close to each other.
2395 //
2396 // Space for archives will be reserved first, followed by a potential gap,
2397 //  followed by the space for ccs:
2398 //




  72 #include "utilities/ostream.hpp"
  73 #include "utilities/defaultStream.hpp"
  74 #include "utilities/hashtable.inline.hpp"
  75 #if INCLUDE_G1GC
  76 #include "gc/g1/g1CollectedHeap.hpp"
  77 #endif
  78 
  79 ReservedSpace MetaspaceShared::_shared_rs;
  80 VirtualSpace MetaspaceShared::_shared_vs;
  81 ReservedSpace MetaspaceShared::_symbol_rs;
  82 VirtualSpace MetaspaceShared::_symbol_vs;
  83 MetaspaceSharedStats MetaspaceShared::_stats;
  84 bool MetaspaceShared::_has_error_classes;
  85 bool MetaspaceShared::_archive_loading_failed = false;
  86 bool MetaspaceShared::_remapped_readwrite = false;
  87 address MetaspaceShared::_i2i_entry_code_buffers = NULL;
  88 size_t MetaspaceShared::_i2i_entry_code_buffers_size = 0;
  89 void* MetaspaceShared::_shared_metaspace_static_top = NULL;
  90 intx MetaspaceShared::_relocation_delta;
  91 char* MetaspaceShared::_requested_base_address;
  92 bool MetaspaceShared::_use_optimized_module_handling = true;
  93 
  94 // The CDS archive is divided into the following regions:
  95 //     mc  - misc code (the method entry trampolines, c++ vtables)
  96 //     rw  - read-write metadata
  97 //     ro  - read-only metadata and read-only tables
  98 //
  99 //     ca0 - closed archive heap space #0
 100 //     ca1 - closed archive heap space #1 (may be empty)
 101 //     oa0 - open archive heap space #0
 102 //     oa1 - open archive heap space #1 (may be empty)
 103 //
 104 // The mc, rw, and ro regions are linearly allocated, starting from
 105 // SharedBaseAddress, in the order of mc->rw->ro. The size of these 3 regions
 106 // are page-aligned, and there's no gap between any consecutive regions.
 107 //
 108 // These 3 regions are populated in the following steps:
 109 // [1] All classes are loaded in MetaspaceShared::preload_classes(). All metadata are
 110 //     temporarily allocated outside of the shared regions. Only the method entry
 111 //     trampolines are written into the mc region.
 112 // [2] C++ vtables are copied into the mc region.


2360   }
2361 
2362   if (result == MAP_ARCHIVE_SUCCESS) {
2363     SharedBaseAddress = (size_t)mapped_base_address;
2364     LP64_ONLY({
2365         if (Metaspace::using_class_space()) {
2366           // Set up ccs in metaspace.
2367           Metaspace::initialize_class_space(class_space_rs);
2368 
2369           // Set up compressed Klass pointer encoding: the encoding range must
2370           //  cover both archive and class space.
2371           address cds_base = (address)static_mapinfo->mapped_base();
2372           address ccs_end = (address)class_space_rs.end();
2373           CompressedKlassPointers::initialize(cds_base, ccs_end - cds_base);
2374 
2375           // map_heap_regions() compares the current narrow oop and klass encodings
2376           // with the archived ones, so it must be done after all encodings are determined.
2377           static_mapinfo->map_heap_regions();
2378         }
2379       });
2380     log_info(cds)("Using optimized module handling %s", MetaspaceShared::use_optimized_module_handling() ? "enabled" : "disabled");
2381   } else {
2382     unmap_archive(static_mapinfo);
2383     unmap_archive(dynamic_mapinfo);
2384     release_reserved_spaces(archive_space_rs, class_space_rs);
2385   }
2386 
2387   return result;
2388 }
2389 
2390 
2391 // This will reserve two address spaces suitable to house Klass structures, one
2392 //  for the cds archives (static archive and optionally dynamic archive) and
2393 //  optionally one move for ccs.
2394 //
2395 // Since both spaces must fall within the compressed class pointer encoding
2396 //  range, they are allocated close to each other.
2397 //
2398 // Space for archives will be reserved first, followed by a potential gap,
2399 //  followed by the space for ccs:
2400 //


< prev index next >