< 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.


2682   return true;
2683 }
2684 
2685 void MetaspaceShared::report_out_of_space(const char* name, size_t needed_bytes) {
2686   // This is highly unlikely to happen on 64-bits because we have reserved a 4GB space.
2687   // On 32-bit we reserve only 256MB so you could run out of space with 100,000 classes
2688   // or so.
2689   _mc_region.print_out_of_space_msg(name, needed_bytes);
2690   _rw_region.print_out_of_space_msg(name, needed_bytes);
2691   _ro_region.print_out_of_space_msg(name, needed_bytes);
2692 
2693   vm_exit_during_initialization(err_msg("Unable to allocate from '%s' region", name),
2694                                 "Please reduce the number of shared classes.");
2695 }
2696 
2697 // This is used to relocate the pointers so that the base archive can be mapped at
2698 // MetaspaceShared::requested_base_address() without runtime relocation.
2699 intx MetaspaceShared::final_delta() {
2700   return intx(MetaspaceShared::requested_base_address())  // We want the base archive to be mapped to here at runtime
2701        - intx(SharedBaseAddress);                         // .. but the base archive is mapped at here at dump time




2702 }
2703 
2704 void MetaspaceShared::print_on(outputStream* st) {
2705   if (UseSharedSpaces || DumpSharedSpaces) {
2706     st->print("CDS archive(s) mapped at: ");
2707     address base;
2708     address top;
2709     if (UseSharedSpaces) { // Runtime
2710       base = (address)MetaspaceObj::shared_metaspace_base();
2711       address static_top = (address)_shared_metaspace_static_top;
2712       top = (address)MetaspaceObj::shared_metaspace_top();
2713       st->print("[" PTR_FORMAT "-" PTR_FORMAT "-" PTR_FORMAT "), ", p2i(base), p2i(static_top), p2i(top));
2714     } else if (DumpSharedSpaces) { // Dump Time
2715       base = (address)_shared_rs.base();
2716       top = (address)_shared_rs.end();
2717       st->print("[" PTR_FORMAT "-" PTR_FORMAT "), ", p2i(base), p2i(top));
2718     }
2719     st->print("size " SIZE_FORMAT ", ", top - base);
2720     st->print("SharedBaseAddress: " PTR_FORMAT ", ArchiveRelocationMode: %d.", SharedBaseAddress, (int)ArchiveRelocationMode);
2721   } else {


  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.


2683   return true;
2684 }
2685 
2686 void MetaspaceShared::report_out_of_space(const char* name, size_t needed_bytes) {
2687   // This is highly unlikely to happen on 64-bits because we have reserved a 4GB space.
2688   // On 32-bit we reserve only 256MB so you could run out of space with 100,000 classes
2689   // or so.
2690   _mc_region.print_out_of_space_msg(name, needed_bytes);
2691   _rw_region.print_out_of_space_msg(name, needed_bytes);
2692   _ro_region.print_out_of_space_msg(name, needed_bytes);
2693 
2694   vm_exit_during_initialization(err_msg("Unable to allocate from '%s' region", name),
2695                                 "Please reduce the number of shared classes.");
2696 }
2697 
2698 // This is used to relocate the pointers so that the base archive can be mapped at
2699 // MetaspaceShared::requested_base_address() without runtime relocation.
2700 intx MetaspaceShared::final_delta() {
2701   return intx(MetaspaceShared::requested_base_address())  // We want the base archive to be mapped to here at runtime
2702        - intx(SharedBaseAddress);                         // .. but the base archive is mapped at here at dump time
2703 }
2704 
2705 bool MetaspaceShared::use_optimized_module_handling() {
2706   return _use_optimized_module_handling;
2707 }
2708 
2709 void MetaspaceShared::print_on(outputStream* st) {
2710   if (UseSharedSpaces || DumpSharedSpaces) {
2711     st->print("CDS archive(s) mapped at: ");
2712     address base;
2713     address top;
2714     if (UseSharedSpaces) { // Runtime
2715       base = (address)MetaspaceObj::shared_metaspace_base();
2716       address static_top = (address)_shared_metaspace_static_top;
2717       top = (address)MetaspaceObj::shared_metaspace_top();
2718       st->print("[" PTR_FORMAT "-" PTR_FORMAT "-" PTR_FORMAT "), ", p2i(base), p2i(static_top), p2i(top));
2719     } else if (DumpSharedSpaces) { // Dump Time
2720       base = (address)_shared_rs.base();
2721       top = (address)_shared_rs.end();
2722       st->print("[" PTR_FORMAT "-" PTR_FORMAT "), ", p2i(base), p2i(top));
2723     }
2724     st->print("size " SIZE_FORMAT ", ", top - base);
2725     st->print("SharedBaseAddress: " PTR_FORMAT ", ArchiveRelocationMode: %d.", SharedBaseAddress, (int)ArchiveRelocationMode);
2726   } else {
< prev index next >