< prev index next >

src/hotspot/share/cds/archiveBuilder.cpp

Print this page

   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "cds/aotArtifactFinder.hpp"

  26 #include "cds/aotClassLinker.hpp"
  27 #include "cds/aotCompressedPointers.hpp"
  28 #include "cds/aotLogging.hpp"
  29 #include "cds/aotMapLogger.hpp"
  30 #include "cds/aotMetaspace.hpp"
  31 #include "cds/archiveBuilder.hpp"
  32 #include "cds/archiveUtils.hpp"
  33 #include "cds/cdsConfig.hpp"
  34 #include "cds/cppVtables.hpp"
  35 #include "cds/dumpAllocStats.hpp"
  36 #include "cds/dynamicArchive.hpp"

  37 #include "cds/heapShared.hpp"
  38 #include "cds/regeneratedClasses.hpp"
  39 #include "classfile/classLoader.hpp"
  40 #include "classfile/classLoaderDataShared.hpp"
  41 #include "classfile/javaClasses.hpp"
  42 #include "classfile/symbolTable.hpp"
  43 #include "classfile/systemDictionaryShared.hpp"
  44 #include "classfile/vmClasses.hpp"
  45 #include "code/aotCodeCache.hpp"
  46 #include "interpreter/abstractInterpreter.hpp"
  47 #include "jvm.h"
  48 #include "logging/log.hpp"
  49 #include "memory/allStatic.hpp"
  50 #include "memory/memoryReserver.hpp"
  51 #include "memory/memRegion.hpp"
  52 #include "memory/resourceArea.hpp"
  53 #include "oops/compressedKlass.inline.hpp"
  54 #include "oops/instanceKlass.hpp"
  55 #include "oops/methodCounters.hpp"
  56 #include "oops/methodData.hpp"
  57 #include "oops/objArrayKlass.hpp"
  58 #include "oops/objArrayOop.inline.hpp"
  59 #include "oops/oopHandle.inline.hpp"
  60 #include "oops/trainingData.hpp"
  61 #include "runtime/arguments.hpp"
  62 #include "runtime/globals_extension.hpp"
  63 #include "runtime/javaThread.hpp"

  64 #include "runtime/sharedRuntime.hpp"
  65 #include "utilities/align.hpp"
  66 #include "utilities/bitMap.inline.hpp"
  67 #include "utilities/formatBuffer.hpp"
  68 
  69 ArchiveBuilder* ArchiveBuilder::_current = nullptr;
  70 
  71 ArchiveBuilder::OtherROAllocMark::~OtherROAllocMark() {
  72   char* newtop = ArchiveBuilder::current()->_ro_region.top();
  73   ArchiveBuilder::alloc_stats()->record_other_type(int(newtop - _oldtop), true);
  74 }
  75 
  76 ArchiveBuilder::SourceObjList::SourceObjList() : _ptrmap(16 * K, mtClassShared) {
  77   _total_bytes = 0;
  78   _objs = new (mtClassShared) GrowableArray<SourceObjInfo*>(128 * K, mtClassShared);
  79 }
  80 
  81 ArchiveBuilder::SourceObjList::~SourceObjList() {
  82   delete _objs;
  83 }

 166   _ptrmap.iterate(&relocator, start, end);
 167 }
 168 
 169 ArchiveBuilder::ArchiveBuilder() :
 170   _current_dump_region(nullptr),
 171   _buffer_bottom(nullptr),
 172   _requested_static_archive_bottom(nullptr),
 173   _requested_static_archive_top(nullptr),
 174   _requested_dynamic_archive_bottom(nullptr),
 175   _requested_dynamic_archive_top(nullptr),
 176   _mapped_static_archive_bottom(nullptr),
 177   _mapped_static_archive_top(nullptr),
 178   _buffer_to_requested_delta(0),
 179   _pz_region("pz"), // protection zone -- used only during dumping; does NOT exist in cds archive.
 180   _rw_region("rw"),
 181   _ro_region("ro"),
 182   _ac_region("ac"),
 183   _ptrmap(mtClassShared),
 184   _rw_ptrmap(mtClassShared),
 185   _ro_ptrmap(mtClassShared),

 186   _rw_src_objs(),
 187   _ro_src_objs(),
 188   _src_obj_table(INITIAL_TABLE_SIZE, MAX_TABLE_SIZE),
 189   _buffered_to_src_table(INITIAL_TABLE_SIZE, MAX_TABLE_SIZE),
 190   _total_heap_region_size(0)
 191 {
 192   _klasses = new (mtClassShared) GrowableArray<Klass*>(4 * K, mtClassShared);
 193   _symbols = new (mtClassShared) GrowableArray<Symbol*>(256 * K, mtClassShared);
 194   _entropy_seed = 0x12345678;
 195   _relocated_ptr_info._num_ptrs = 0;
 196   _relocated_ptr_info._num_tagged_ptrs = 0;
 197   _relocated_ptr_info._num_nulled_ptrs = 0;
 198   assert(_current == nullptr, "must be");
 199   _current = this;
 200 }
 201 
 202 ArchiveBuilder::~ArchiveBuilder() {
 203   assert(_current == this, "must be");
 204   _current = nullptr;
 205 

 809 
 810   for (int i = 0; i < klasses()->length(); i++) {
 811     // Some of the code in ConstantPool::remove_unshareable_info() requires the classes
 812     // to be in linked state, so it must be call here before the next loop, which returns
 813     // all classes to unlinked state.
 814     Klass* k = get_buffered_addr(klasses()->at(i));
 815     if (k->is_instance_klass()) {
 816       InstanceKlass::cast(k)->constants()->remove_unshareable_info();
 817     }
 818   }
 819 
 820   for (int i = 0; i < klasses()->length(); i++) {
 821     const char* type;
 822     const char* unlinked = "";
 823     const char* kind = "";
 824     const char* hidden = "";
 825     const char* old = "";
 826     const char* generated = "";
 827     const char* aotlinked_msg = "";
 828     const char* inited_msg = "";

 829     Klass* k = get_buffered_addr(klasses()->at(i));
 830     bool inited = false;
 831     k->remove_java_mirror();
 832 #ifdef _LP64
 833     if (UseCompactObjectHeaders) {
 834       Klass* requested_k = to_requested(k);
 835       address narrow_klass_base = _requested_static_archive_bottom; // runtime encoding base == runtime mapping start
 836       const int narrow_klass_shift = precomputed_narrow_klass_shift();
 837       narrowKlass nk = CompressedKlassPointers::encode_not_null_without_asserts(requested_k, narrow_klass_base, narrow_klass_shift);
 838       k->set_prototype_header(markWord::prototype().set_narrow_klass(nk));
 839     }
 840 #endif //_LP64
 841     if (k->is_objArray_klass()) {
 842       // InstanceKlass and TypeArrayKlass will in turn call remove_unshareable_info
 843       // on their array classes.
 844       num_obj_array_klasses ++;
 845       type = "array";
 846     } else if (k->is_typeArray_klass()) {
 847       num_type_array_klasses ++;
 848       type = "array";

 917         ADD_COUNT(num_enum_klasses);
 918       }
 919 
 920       if (CDSConfig::is_old_class_for_verifier(ik)) {
 921         ADD_COUNT(num_old_klasses);
 922         old = " old";
 923       }
 924 
 925       if (ik->is_aot_generated_class()) {
 926         generated = " generated";
 927       }
 928       if (aotlinked) {
 929         aotlinked_msg = " aot-linked";
 930       }
 931       if (inited) {
 932         if (InstanceKlass::cast(k)->static_field_size() == 0) {
 933           inited_msg = " inited (no static fields)";
 934         } else {
 935           inited_msg = " inited";
 936         }



 937       }
 938 
 939       AOTMetaspace::rewrite_bytecodes_and_calculate_fingerprints(Thread::current(), ik);
 940       ik->remove_unshareable_info();
 941     }
 942 
 943     if (aot_log_is_enabled(Debug, aot, class)) {
 944       ResourceMark rm;
 945       aot_log_debug(aot, class)("klasses[%5d] = " PTR_FORMAT " %-5s %s%s%s%s%s%s%s%s", i,
 946                             p2i(to_requested(k)), type, k->external_name(),
 947                             kind, hidden, old, unlinked, generated, aotlinked_msg, inited_msg);
 948     }
 949   }
 950 
 951 #define STATS_FORMAT    "= %5d, aot-linked = %5d, inited = %5d"
 952 #define STATS_PARAMS(x) num_ ## x, num_ ## x ## _a, num_ ## x ## _i
 953 
 954   aot_log_info(aot)("Number of classes %d", num_instance_klasses + num_obj_array_klasses + num_type_array_klasses);
 955   aot_log_info(aot)("    instance classes   " STATS_FORMAT, STATS_PARAMS(instance_klasses));
 956   aot_log_info(aot)("      boot             " STATS_FORMAT, STATS_PARAMS(boot_klasses));
 957   aot_log_info(aot)("        vm             " STATS_FORMAT, STATS_PARAMS(vm_klasses));
 958   aot_log_info(aot)("      platform         " STATS_FORMAT, STATS_PARAMS(platform_klasses));
 959   aot_log_info(aot)("      app              " STATS_FORMAT, STATS_PARAMS(app_klasses));
 960   aot_log_info(aot)("      unregistered     " STATS_FORMAT, STATS_PARAMS(unregistered_klasses));
 961   aot_log_info(aot)("      (enum)           " STATS_FORMAT, STATS_PARAMS(enum_klasses));
 962   aot_log_info(aot)("      (hidden)         " STATS_FORMAT, STATS_PARAMS(hidden_klasses));
 963   aot_log_info(aot)("      (old)            " STATS_FORMAT, STATS_PARAMS(old_klasses));
 964   aot_log_info(aot)("      (unlinked)       = %5d, boot = %d, plat = %d, app = %d, unreg = %d",
 965                 num_unlinked_klasses, boot_unlinked, platform_unlinked, app_unlinked, unreg_unlinked);
 966   aot_log_info(aot)("    obj array classes  = %5d", num_obj_array_klasses);
 967   aot_log_info(aot)("    type array classes = %5d", num_type_array_klasses);

1151     patcher.doit();
1152   }
1153 }
1154 
1155 void ArchiveBuilder::print_stats() {
1156   _alloc_stats.print_stats(int(_ro_region.used()), int(_rw_region.used()));
1157 }
1158 
1159 void ArchiveBuilder::write_archive(FileMapInfo* mapinfo, AOTMappedHeapInfo* mapped_heap_info, AOTStreamedHeapInfo* streamed_heap_info) {
1160   // Make sure NUM_CDS_REGIONS (exported in cds.h) agrees with
1161   // AOTMetaspace::n_regions (internal to hotspot).
1162   assert(NUM_CDS_REGIONS == AOTMetaspace::n_regions, "sanity");
1163 
1164   ResourceMark rm;
1165 
1166   write_region(mapinfo, AOTMetaspace::rw, &_rw_region, /*read_only=*/false,/*allow_exec=*/false);
1167   write_region(mapinfo, AOTMetaspace::ro, &_ro_region, /*read_only=*/true, /*allow_exec=*/false);
1168   write_region(mapinfo, AOTMetaspace::ac, &_ac_region, /*read_only=*/false,/*allow_exec=*/false);
1169 
1170   // Split pointer map into read-write and read-only bitmaps
1171   ArchivePtrMarker::initialize_rw_ro_maps(&_rw_ptrmap, &_ro_ptrmap);
1172 
1173   size_t bitmap_size_in_bytes;
1174   char* bitmap = mapinfo->write_bitmap_region(ArchivePtrMarker::rw_ptrmap(),
1175                                               ArchivePtrMarker::ro_ptrmap(),

1176                                               mapped_heap_info,
1177                                               streamed_heap_info,
1178                                               bitmap_size_in_bytes);
1179 
1180   if (mapped_heap_info != nullptr && mapped_heap_info->is_used()) {
1181     _total_heap_region_size = mapinfo->write_mapped_heap_region(mapped_heap_info);
1182   } else if (streamed_heap_info != nullptr && streamed_heap_info->is_used()) {
1183     _total_heap_region_size = mapinfo->write_streamed_heap_region(streamed_heap_info);
1184   }
1185 
1186   print_region_stats(mapinfo, mapped_heap_info, streamed_heap_info);
1187 
1188   mapinfo->set_requested_base((char*)AOTMetaspace::requested_base_address());
1189   mapinfo->set_header_crc(mapinfo->compute_header_crc());
1190   // After this point, we should not write any data into mapinfo->header() since this
1191   // would corrupt its checksum we have calculated before.
1192   mapinfo->write_header();
1193   mapinfo->close();
1194 

1195   if (log_is_enabled(Info, aot)) {
1196     log_info(aot)("Full module graph = %s", CDSConfig::is_dumping_full_module_graph() ? "enabled" : "disabled");
1197     print_stats();
1198   }
1199 
1200   if (log_is_enabled(Info, aot, map)) {
1201     AOTMapLogger::dumptime_log(this, mapinfo, mapped_heap_info, streamed_heap_info, bitmap, bitmap_size_in_bytes);
1202   }
1203   CDS_JAVA_HEAP_ONLY(HeapShared::destroy_archived_object_cache());
1204   FREE_C_HEAP_ARRAY(char, bitmap);
1205 }
1206 
1207 void ArchiveBuilder::write_region(FileMapInfo* mapinfo, int region_idx, DumpRegion* dump_region, bool read_only,  bool allow_exec) {
1208   mapinfo->write_region(region_idx, dump_region->base(), dump_region->used(), read_only, allow_exec);
1209 }
1210 
1211 void ArchiveBuilder::count_relocated_pointer(bool tagged, bool nulled) {
1212   _relocated_ptr_info._num_ptrs ++;
1213   _relocated_ptr_info._num_tagged_ptrs += tagged ? 1 : 0;
1214   _relocated_ptr_info._num_nulled_ptrs += nulled ? 1 : 0;
1215 }
1216 

   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "cds/aotArtifactFinder.hpp"
  26 #include "cds/aotCacheAccess.hpp"
  27 #include "cds/aotClassLinker.hpp"
  28 #include "cds/aotCompressedPointers.hpp"
  29 #include "cds/aotLogging.hpp"
  30 #include "cds/aotMapLogger.hpp"
  31 #include "cds/aotMetaspace.hpp"
  32 #include "cds/archiveBuilder.hpp"
  33 #include "cds/archiveUtils.hpp"
  34 #include "cds/cdsConfig.hpp"
  35 #include "cds/cppVtables.hpp"
  36 #include "cds/dumpAllocStats.hpp"
  37 #include "cds/dynamicArchive.hpp"
  38 #include "cds/finalImageRecipes.hpp"
  39 #include "cds/heapShared.hpp"
  40 #include "cds/regeneratedClasses.hpp"
  41 #include "classfile/classLoader.hpp"
  42 #include "classfile/classLoaderDataShared.hpp"
  43 #include "classfile/javaClasses.hpp"
  44 #include "classfile/symbolTable.hpp"
  45 #include "classfile/systemDictionaryShared.hpp"
  46 #include "classfile/vmClasses.hpp"
  47 #include "code/aotCodeCache.hpp"
  48 #include "interpreter/abstractInterpreter.hpp"
  49 #include "jvm.h"
  50 #include "logging/log.hpp"
  51 #include "memory/allStatic.hpp"
  52 #include "memory/memoryReserver.hpp"
  53 #include "memory/memRegion.hpp"
  54 #include "memory/resourceArea.hpp"
  55 #include "oops/compressedKlass.inline.hpp"
  56 #include "oops/instanceKlass.hpp"
  57 #include "oops/methodCounters.hpp"
  58 #include "oops/methodData.hpp"
  59 #include "oops/objArrayKlass.hpp"
  60 #include "oops/objArrayOop.inline.hpp"
  61 #include "oops/oopHandle.inline.hpp"
  62 #include "oops/trainingData.hpp"
  63 #include "runtime/arguments.hpp"
  64 #include "runtime/globals_extension.hpp"
  65 #include "runtime/javaThread.hpp"
  66 #include "runtime/safepointVerifiers.hpp"
  67 #include "runtime/sharedRuntime.hpp"
  68 #include "utilities/align.hpp"
  69 #include "utilities/bitMap.inline.hpp"
  70 #include "utilities/formatBuffer.hpp"
  71 
  72 ArchiveBuilder* ArchiveBuilder::_current = nullptr;
  73 
  74 ArchiveBuilder::OtherROAllocMark::~OtherROAllocMark() {
  75   char* newtop = ArchiveBuilder::current()->_ro_region.top();
  76   ArchiveBuilder::alloc_stats()->record_other_type(int(newtop - _oldtop), true);
  77 }
  78 
  79 ArchiveBuilder::SourceObjList::SourceObjList() : _ptrmap(16 * K, mtClassShared) {
  80   _total_bytes = 0;
  81   _objs = new (mtClassShared) GrowableArray<SourceObjInfo*>(128 * K, mtClassShared);
  82 }
  83 
  84 ArchiveBuilder::SourceObjList::~SourceObjList() {
  85   delete _objs;
  86 }

 169   _ptrmap.iterate(&relocator, start, end);
 170 }
 171 
 172 ArchiveBuilder::ArchiveBuilder() :
 173   _current_dump_region(nullptr),
 174   _buffer_bottom(nullptr),
 175   _requested_static_archive_bottom(nullptr),
 176   _requested_static_archive_top(nullptr),
 177   _requested_dynamic_archive_bottom(nullptr),
 178   _requested_dynamic_archive_top(nullptr),
 179   _mapped_static_archive_bottom(nullptr),
 180   _mapped_static_archive_top(nullptr),
 181   _buffer_to_requested_delta(0),
 182   _pz_region("pz"), // protection zone -- used only during dumping; does NOT exist in cds archive.
 183   _rw_region("rw"),
 184   _ro_region("ro"),
 185   _ac_region("ac"),
 186   _ptrmap(mtClassShared),
 187   _rw_ptrmap(mtClassShared),
 188   _ro_ptrmap(mtClassShared),
 189   _ac_ptrmap(mtClassShared),
 190   _rw_src_objs(),
 191   _ro_src_objs(),
 192   _src_obj_table(INITIAL_TABLE_SIZE, MAX_TABLE_SIZE),
 193   _buffered_to_src_table(INITIAL_TABLE_SIZE, MAX_TABLE_SIZE),
 194   _total_heap_region_size(0)
 195 {
 196   _klasses = new (mtClassShared) GrowableArray<Klass*>(4 * K, mtClassShared);
 197   _symbols = new (mtClassShared) GrowableArray<Symbol*>(256 * K, mtClassShared);
 198   _entropy_seed = 0x12345678;
 199   _relocated_ptr_info._num_ptrs = 0;
 200   _relocated_ptr_info._num_tagged_ptrs = 0;
 201   _relocated_ptr_info._num_nulled_ptrs = 0;
 202   assert(_current == nullptr, "must be");
 203   _current = this;
 204 }
 205 
 206 ArchiveBuilder::~ArchiveBuilder() {
 207   assert(_current == this, "must be");
 208   _current = nullptr;
 209 

 813 
 814   for (int i = 0; i < klasses()->length(); i++) {
 815     // Some of the code in ConstantPool::remove_unshareable_info() requires the classes
 816     // to be in linked state, so it must be call here before the next loop, which returns
 817     // all classes to unlinked state.
 818     Klass* k = get_buffered_addr(klasses()->at(i));
 819     if (k->is_instance_klass()) {
 820       InstanceKlass::cast(k)->constants()->remove_unshareable_info();
 821     }
 822   }
 823 
 824   for (int i = 0; i < klasses()->length(); i++) {
 825     const char* type;
 826     const char* unlinked = "";
 827     const char* kind = "";
 828     const char* hidden = "";
 829     const char* old = "";
 830     const char* generated = "";
 831     const char* aotlinked_msg = "";
 832     const char* inited_msg = "";
 833     const char* early_init_msg = "";
 834     Klass* k = get_buffered_addr(klasses()->at(i));
 835     bool inited = false;
 836     k->remove_java_mirror();
 837 #ifdef _LP64
 838     if (UseCompactObjectHeaders) {
 839       Klass* requested_k = to_requested(k);
 840       address narrow_klass_base = _requested_static_archive_bottom; // runtime encoding base == runtime mapping start
 841       const int narrow_klass_shift = precomputed_narrow_klass_shift();
 842       narrowKlass nk = CompressedKlassPointers::encode_not_null_without_asserts(requested_k, narrow_klass_base, narrow_klass_shift);
 843       k->set_prototype_header(markWord::prototype().set_narrow_klass(nk));
 844     }
 845 #endif //_LP64
 846     if (k->is_objArray_klass()) {
 847       // InstanceKlass and TypeArrayKlass will in turn call remove_unshareable_info
 848       // on their array classes.
 849       num_obj_array_klasses ++;
 850       type = "array";
 851     } else if (k->is_typeArray_klass()) {
 852       num_type_array_klasses ++;
 853       type = "array";

 922         ADD_COUNT(num_enum_klasses);
 923       }
 924 
 925       if (CDSConfig::is_old_class_for_verifier(ik)) {
 926         ADD_COUNT(num_old_klasses);
 927         old = " old";
 928       }
 929 
 930       if (ik->is_aot_generated_class()) {
 931         generated = " generated";
 932       }
 933       if (aotlinked) {
 934         aotlinked_msg = " aot-linked";
 935       }
 936       if (inited) {
 937         if (InstanceKlass::cast(k)->static_field_size() == 0) {
 938           inited_msg = " inited (no static fields)";
 939         } else {
 940           inited_msg = " inited";
 941         }
 942         if (AOTCacheAccess::is_early_aot_inited_class(ik)) {
 943           early_init_msg = " early";
 944         }
 945       }
 946 
 947       AOTMetaspace::rewrite_bytecodes_and_calculate_fingerprints(Thread::current(), ik);
 948       ik->remove_unshareable_info();
 949     }
 950 
 951     if (aot_log_is_enabled(Debug, aot, class)) {
 952       ResourceMark rm;
 953       aot_log_debug(aot, class)("klasses[%5d] = " PTR_FORMAT " %-5s %s%s%s%s%s%s%s%s%s", i,
 954                             p2i(to_requested(k)), type, k->external_name(),
 955                             kind, hidden, old, unlinked, generated, aotlinked_msg, early_init_msg, inited_msg);
 956     }
 957   }
 958 
 959 #define STATS_FORMAT    "= %5d, aot-linked = %5d, inited = %5d"
 960 #define STATS_PARAMS(x) num_ ## x, num_ ## x ## _a, num_ ## x ## _i
 961 
 962   aot_log_info(aot)("Number of classes %d", num_instance_klasses + num_obj_array_klasses + num_type_array_klasses);
 963   aot_log_info(aot)("    instance classes   " STATS_FORMAT, STATS_PARAMS(instance_klasses));
 964   aot_log_info(aot)("      boot             " STATS_FORMAT, STATS_PARAMS(boot_klasses));
 965   aot_log_info(aot)("        vm             " STATS_FORMAT, STATS_PARAMS(vm_klasses));
 966   aot_log_info(aot)("      platform         " STATS_FORMAT, STATS_PARAMS(platform_klasses));
 967   aot_log_info(aot)("      app              " STATS_FORMAT, STATS_PARAMS(app_klasses));
 968   aot_log_info(aot)("      unregistered     " STATS_FORMAT, STATS_PARAMS(unregistered_klasses));
 969   aot_log_info(aot)("      (enum)           " STATS_FORMAT, STATS_PARAMS(enum_klasses));
 970   aot_log_info(aot)("      (hidden)         " STATS_FORMAT, STATS_PARAMS(hidden_klasses));
 971   aot_log_info(aot)("      (old)            " STATS_FORMAT, STATS_PARAMS(old_klasses));
 972   aot_log_info(aot)("      (unlinked)       = %5d, boot = %d, plat = %d, app = %d, unreg = %d",
 973                 num_unlinked_klasses, boot_unlinked, platform_unlinked, app_unlinked, unreg_unlinked);
 974   aot_log_info(aot)("    obj array classes  = %5d", num_obj_array_klasses);
 975   aot_log_info(aot)("    type array classes = %5d", num_type_array_klasses);

1159     patcher.doit();
1160   }
1161 }
1162 
1163 void ArchiveBuilder::print_stats() {
1164   _alloc_stats.print_stats(int(_ro_region.used()), int(_rw_region.used()));
1165 }
1166 
1167 void ArchiveBuilder::write_archive(FileMapInfo* mapinfo, AOTMappedHeapInfo* mapped_heap_info, AOTStreamedHeapInfo* streamed_heap_info) {
1168   // Make sure NUM_CDS_REGIONS (exported in cds.h) agrees with
1169   // AOTMetaspace::n_regions (internal to hotspot).
1170   assert(NUM_CDS_REGIONS == AOTMetaspace::n_regions, "sanity");
1171 
1172   ResourceMark rm;
1173 
1174   write_region(mapinfo, AOTMetaspace::rw, &_rw_region, /*read_only=*/false,/*allow_exec=*/false);
1175   write_region(mapinfo, AOTMetaspace::ro, &_ro_region, /*read_only=*/true, /*allow_exec=*/false);
1176   write_region(mapinfo, AOTMetaspace::ac, &_ac_region, /*read_only=*/false,/*allow_exec=*/false);
1177 
1178   // Split pointer map into read-write and read-only bitmaps
1179   ArchivePtrMarker::initialize_rw_ro_ac_maps(&_rw_ptrmap, &_ro_ptrmap, &_ac_ptrmap);
1180 
1181   size_t bitmap_size_in_bytes;
1182   char* bitmap = mapinfo->write_bitmap_region(ArchivePtrMarker::rw_ptrmap(),
1183                                               ArchivePtrMarker::ro_ptrmap(),
1184                                               ArchivePtrMarker::ac_ptrmap(),
1185                                               mapped_heap_info,
1186                                               streamed_heap_info,
1187                                               bitmap_size_in_bytes);
1188 
1189   if (mapped_heap_info != nullptr && mapped_heap_info->is_used()) {
1190     _total_heap_region_size = mapinfo->write_mapped_heap_region(mapped_heap_info);
1191   } else if (streamed_heap_info != nullptr && streamed_heap_info->is_used()) {
1192     _total_heap_region_size = mapinfo->write_streamed_heap_region(streamed_heap_info);
1193   }
1194 
1195   print_region_stats(mapinfo, mapped_heap_info, streamed_heap_info);
1196 
1197   mapinfo->set_requested_base((char*)AOTMetaspace::requested_base_address());
1198   mapinfo->set_header_crc(mapinfo->compute_header_crc());
1199   // After this point, we should not write any data into mapinfo->header() since this
1200   // would corrupt its checksum we have calculated before.
1201   mapinfo->write_header();
1202   mapinfo->close();
1203 
1204   aot_log_info(aot)("Full module graph = %s", CDSConfig::is_dumping_full_module_graph() ? "enabled" : "disabled");
1205   if (log_is_enabled(Info, aot)) {

1206     print_stats();
1207   }
1208 
1209   if (log_is_enabled(Info, aot, map)) {
1210     AOTMapLogger::dumptime_log(this, mapinfo, mapped_heap_info, streamed_heap_info, bitmap, bitmap_size_in_bytes);
1211   }
1212   CDS_JAVA_HEAP_ONLY(HeapShared::destroy_archived_object_cache());
1213   FREE_C_HEAP_ARRAY(char, bitmap);
1214 }
1215 
1216 void ArchiveBuilder::write_region(FileMapInfo* mapinfo, int region_idx, DumpRegion* dump_region, bool read_only,  bool allow_exec) {
1217   mapinfo->write_region(region_idx, dump_region->base(), dump_region->used(), read_only, allow_exec);
1218 }
1219 
1220 void ArchiveBuilder::count_relocated_pointer(bool tagged, bool nulled) {
1221   _relocated_ptr_info._num_ptrs ++;
1222   _relocated_ptr_info._num_tagged_ptrs += tagged ? 1 : 0;
1223   _relocated_ptr_info._num_nulled_ptrs += nulled ? 1 : 0;
1224 }
1225 
< prev index next >