src/hotspot/share/memory/metaspaceShared.cpp
changeset 55296 357c9dcb6eb9
parent 55251 92eec0732eed
child 58096 0d97bf7cf8a4
equal deleted inserted replaced
55295:14283f280695 55296:357c9dcb6eb9
    88 // The CDS archive is divided into the following regions:
    88 // The CDS archive is divided into the following regions:
    89 //     mc  - misc code (the method entry trampolines)
    89 //     mc  - misc code (the method entry trampolines)
    90 //     rw  - read-write metadata
    90 //     rw  - read-write metadata
    91 //     ro  - read-only metadata and read-only tables
    91 //     ro  - read-only metadata and read-only tables
    92 //     md  - misc data (the c++ vtables)
    92 //     md  - misc data (the c++ vtables)
    93 //     od  - optional data (original class files)
       
    94 //
    93 //
    95 //     ca0 - closed archive heap space #0
    94 //     ca0 - closed archive heap space #0
    96 //     ca1 - closed archive heap space #1 (may be empty)
    95 //     ca1 - closed archive heap space #1 (may be empty)
    97 //     oa0 - open archive heap space #0
    96 //     oa0 - open archive heap space #0
    98 //     oa1 - open archive heap space #1 (may be empty)
    97 //     oa1 - open archive heap space #1 (may be empty)
    99 //
    98 //
   100 // The mc, rw, ro, md and od regions are linearly allocated, starting from
    99 // The mc, rw, ro, and md regions are linearly allocated, starting from
   101 // SharedBaseAddress, in the order of mc->rw->ro->md->od. The size of these 5 regions
   100 // SharedBaseAddress, in the order of mc->rw->ro->md. The size of these 4 regions
   102 // are page-aligned, and there's no gap between any consecutive regions.
   101 // are page-aligned, and there's no gap between any consecutive regions.
   103 //
   102 //
   104 // These 5 regions are populated in the following steps:
   103 // These 4 regions are populated in the following steps:
   105 // [1] All classes are loaded in MetaspaceShared::preload_classes(). All metadata are
   104 // [1] All classes are loaded in MetaspaceShared::preload_classes(). All metadata are
   106 //     temporarily allocated outside of the shared regions. Only the method entry
   105 //     temporarily allocated outside of the shared regions. Only the method entry
   107 //     trampolines are written into the mc region.
   106 //     trampolines are written into the mc region.
   108 // [2] ArchiveCompactor copies RW metadata into the rw region.
   107 // [2] ArchiveCompactor copies RW metadata into the rw region.
   109 // [3] ArchiveCompactor copies RO metadata into the ro region.
   108 // [3] ArchiveCompactor copies RO metadata into the ro region.
   110 // [4] SymbolTable, StringTable, SystemDictionary, and a few other read-only data
   109 // [4] SymbolTable, StringTable, SystemDictionary, and a few other read-only data
   111 //     are copied into the ro region as read-only tables.
   110 //     are copied into the ro region as read-only tables.
   112 // [5] C++ vtables are copied into the md region.
   111 // [5] C++ vtables are copied into the md region.
   113 // [6] Original class files are copied into the od region.
       
   114 //
   112 //
   115 // The s0/s1 and oa0/oa1 regions are populated inside HeapShared::archive_java_heap_objects.
   113 // The s0/s1 and oa0/oa1 regions are populated inside HeapShared::archive_java_heap_objects.
   116 // Their layout is independent of the other 5 regions.
   114 // Their layout is independent of the other 4 regions.
   117 
   115 
   118 char* DumpRegion::expand_top_to(char* newtop) {
   116 char* DumpRegion::expand_top_to(char* newtop) {
   119   assert(is_allocatable(), "must be initialized and not packed");
   117   assert(is_allocatable(), "must be initialized and not packed");
   120   assert(newtop >= _top, "must not grow backwards");
   118   assert(newtop >= _top, "must not grow backwards");
   121   if (newtop > _end) {
   119   if (newtop > _end) {
   172     next->_base = next->_top = this->_end;
   170     next->_base = next->_top = this->_end;
   173     next->_end = MetaspaceShared::shared_rs()->end();
   171     next->_end = MetaspaceShared::shared_rs()->end();
   174   }
   172   }
   175 }
   173 }
   176 
   174 
   177 DumpRegion _mc_region("mc"), _ro_region("ro"), _rw_region("rw"), _md_region("md"), _od_region("od");
   175 DumpRegion _mc_region("mc"), _ro_region("ro"), _rw_region("rw"), _md_region("md");
   178 size_t _total_closed_archive_region_size = 0, _total_open_archive_region_size = 0;
   176 size_t _total_closed_archive_region_size = 0, _total_open_archive_region_size = 0;
   179 
   177 
   180 void MetaspaceShared::init_shared_dump_space(DumpRegion* first_space, address first_space_bottom) {
   178 void MetaspaceShared::init_shared_dump_space(DumpRegion* first_space, address first_space_bottom) {
   181   // Start with 0 committed bytes. The memory will be committed as needed by
   179   // Start with 0 committed bytes. The memory will be committed as needed by
   182   // MetaspaceShared::commit_shared_space_to().
   180   // MetaspaceShared::commit_shared_space_to().
   194   return &_rw_region;
   192   return &_rw_region;
   195 }
   193 }
   196 
   194 
   197 DumpRegion* MetaspaceShared::read_only_dump_space() {
   195 DumpRegion* MetaspaceShared::read_only_dump_space() {
   198   return &_ro_region;
   196   return &_ro_region;
   199 }
       
   200 
       
   201 DumpRegion* MetaspaceShared::optional_data_dump_space() {
       
   202   return &_od_region;
       
   203 }
   197 }
   204 
   198 
   205 void MetaspaceShared::pack_dump_space(DumpRegion* current, DumpRegion* next,
   199 void MetaspaceShared::pack_dump_space(DumpRegion* current, DumpRegion* next,
   206                                       ReservedSpace* rs) {
   200                                       ReservedSpace* rs) {
   207   current->pack(next);
   201   current->pack(next);
   288   // On 64-bit VM, the heap and class space layout will be the same as if
   282   // On 64-bit VM, the heap and class space layout will be the same as if
   289   // you're running in -Xshare:on mode:
   283   // you're running in -Xshare:on mode:
   290   //
   284   //
   291   //                              +-- SharedBaseAddress (default = 0x800000000)
   285   //                              +-- SharedBaseAddress (default = 0x800000000)
   292   //                              v
   286   //                              v
   293   // +-..---------+---------+ ... +----+----+----+----+----+---------------+
   287   // +-..---------+---------+ ... +----+----+----+----+---------------+
   294   // |    Heap    | Archive |     | MC | RW | RO | MD | OD | class space   |
   288   // |    Heap    | Archive |     | MC | RW | RO | MD | class space   |
   295   // +-..---------+---------+ ... +----+----+----+----+----+---------------+
   289   // +-..---------+---------+ ... +----+----+----+----+---------------+
   296   // |<--   MaxHeapSize  -->|     |<-- UnscaledClassSpaceMax = 4GB ------->|
   290   // |<--   MaxHeapSize  -->|     |<-- UnscaledClassSpaceMax = 4GB -->|
   297   //
   291   //
   298   const uint64_t UnscaledClassSpaceMax = (uint64_t(max_juint) + 1);
   292   const uint64_t UnscaledClassSpaceMax = (uint64_t(max_juint) + 1);
   299   const size_t cds_total = align_down(UnscaledClassSpaceMax, reserve_alignment);
   293   const size_t cds_total = align_down(UnscaledClassSpaceMax, reserve_alignment);
   300 #else
   294 #else
   301   // We don't support archives larger than 256MB on 32-bit due to limited virtual address space.
   295   // We don't support archives larger than 256MB on 32-bit due to limited virtual address space.
  1072   const char *sep = "--------------------+---------------------------+---------------------------+--------------------------";
  1066   const char *sep = "--------------------+---------------------------+---------------------------+--------------------------";
  1073   const char *hdr = "                        ro_cnt   ro_bytes     % |   rw_cnt   rw_bytes     % |  all_cnt  all_bytes     %";
  1067   const char *hdr = "                        ro_cnt   ro_bytes     % |   rw_cnt   rw_bytes     % |  all_cnt  all_bytes     %";
  1074 
  1068 
  1075   LogMessage(cds) msg;
  1069   LogMessage(cds) msg;
  1076 
  1070 
  1077   msg.info("Detailed metadata info (excluding od/st regions; rw stats include md/mc regions):");
  1071   msg.info("Detailed metadata info (excluding st regions; rw stats include md/mc regions):");
  1078   msg.info("%s", hdr);
  1072   msg.info("%s", hdr);
  1079   msg.info("%s", sep);
  1073   msg.info("%s", sep);
  1080   for (int type = 0; type < int(_number_of_types); type ++) {
  1074   for (int type = 0; type < int(_number_of_types); type ++) {
  1081     const char *name = type_name((Type)type);
  1075     const char *name = type_name((Type)type);
  1082     int ro_count = _counts[RO][type];
  1076     int ro_count = _counts[RO][type];