< prev index next >

src/hotspot/share/cds/heapShared.cpp

Print this page

1289   return record;
1290 }
1291 
1292 void HeapShared::resolve_or_init(const char* klass_name, bool do_init, TRAPS) {
1293   TempNewSymbol klass_name_sym =  SymbolTable::new_symbol(klass_name);
1294   InstanceKlass* k = SystemDictionaryShared::find_builtin_class(klass_name_sym);
1295   if (k == nullptr) {
1296     return;
1297   }
1298   assert(k->defined_by_boot_loader(), "sanity");
1299   resolve_or_init(k, false, CHECK);
1300   if (do_init) {
1301     resolve_or_init(k, true, CHECK);
1302   }
1303 }
1304 
1305 void HeapShared::resolve_or_init(Klass* k, bool do_init, TRAPS) {
1306   if (!do_init) {
1307     if (k->class_loader_data() == nullptr) {
1308       Klass* resolved_k = SystemDictionary::resolve_or_null(k->name(), CHECK);
1309       assert(resolved_k == k, "classes used by archived heap must not be replaced by JVMTI ClassFileLoadHook");




1310     }
1311   } else {
1312     assert(k->class_loader_data() != nullptr, "must have been resolved by HeapShared::resolve_classes");
1313     if (k->is_instance_klass()) {
1314       InstanceKlass* ik = InstanceKlass::cast(k);
1315       ik->initialize(CHECK);
1316     } else if (k->is_objArray_klass()) {
1317       ObjArrayKlass* oak = ObjArrayKlass::cast(k);
1318       oak->initialize(CHECK);
1319     }
1320   }
1321 }
1322 
1323 void HeapShared::init_archived_fields_for(Klass* k, const ArchivedKlassSubGraphInfoRecord* record) {
1324   verify_the_heap(k, "before");
1325 
1326   // Load the subgraph entry fields from the record and store them back to
1327   // the corresponding fields within the mirror.
1328   oop m = k->java_mirror();
1329   Array<int>* entry_field_records = record->entry_field_records();

2031   }
2032 }
2033 
2034 void HeapShared::archive_object_subgraphs(ArchivableStaticFieldInfo fields[],
2035                                           bool is_full_module_graph) {
2036   _num_total_subgraph_recordings = 0;
2037   _num_total_walked_objs = 0;
2038   _num_total_archived_objs = 0;
2039   _num_total_recorded_klasses = 0;
2040   _num_total_verifications = 0;
2041 
2042   // For each class X that has one or more archived fields:
2043   // [1] Dump the subgraph of each archived field
2044   // [2] Create a list of all the class of the objects that can be reached
2045   //     by any of these static fields.
2046   //     At runtime, these classes are initialized before X's archived fields
2047   //     are restored by HeapShared::initialize_from_archived_subgraph().
2048   for (int i = 0; fields[i].valid(); ) {
2049     ArchivableStaticFieldInfo* info = &fields[i];
2050     const char* klass_name = info->klass_name;







2051     start_recording_subgraph(info->klass, klass_name, is_full_module_graph);
2052 
2053     // If you have specified consecutive fields of the same klass in
2054     // fields[], these will be archived in the same
2055     // {start_recording_subgraph ... done_recording_subgraph} pass to
2056     // save time.
2057     for (; fields[i].valid(); i++) {
2058       ArchivableStaticFieldInfo* f = &fields[i];
2059       if (f->klass_name != klass_name) {
2060         break;
2061       }
2062 
2063       archive_reachable_objects_from_static_field(f->klass, f->klass_name,
2064                                                   f->offset, f->field_name);
2065     }
2066     done_recording_subgraph(info->klass, klass_name);
2067   }
2068 
2069   log_info(aot, heap)("Archived subgraph records = %d",
2070                       _num_total_subgraph_recordings);

1289   return record;
1290 }
1291 
1292 void HeapShared::resolve_or_init(const char* klass_name, bool do_init, TRAPS) {
1293   TempNewSymbol klass_name_sym =  SymbolTable::new_symbol(klass_name);
1294   InstanceKlass* k = SystemDictionaryShared::find_builtin_class(klass_name_sym);
1295   if (k == nullptr) {
1296     return;
1297   }
1298   assert(k->defined_by_boot_loader(), "sanity");
1299   resolve_or_init(k, false, CHECK);
1300   if (do_init) {
1301     resolve_or_init(k, true, CHECK);
1302   }
1303 }
1304 
1305 void HeapShared::resolve_or_init(Klass* k, bool do_init, TRAPS) {
1306   if (!do_init) {
1307     if (k->class_loader_data() == nullptr) {
1308       Klass* resolved_k = SystemDictionary::resolve_or_null(k->name(), CHECK);
1309       if (resolved_k->is_array_klass()) {
1310         assert(resolved_k == k || resolved_k == k->super(), "classes used by archived heap must not be replaced by JVMTI ClassFileLoadHook");
1311       } else {
1312         assert(resolved_k == k, "classes used by archived heap must not be replaced by JVMTI ClassFileLoadHook");
1313       }
1314     }
1315   } else {
1316     assert(k->class_loader_data() != nullptr, "must have been resolved by HeapShared::resolve_classes");
1317     if (k->is_instance_klass()) {
1318       InstanceKlass* ik = InstanceKlass::cast(k);
1319       ik->initialize(CHECK);
1320     } else if (k->is_objArray_klass()) {
1321       ObjArrayKlass* oak = ObjArrayKlass::cast(k);
1322       oak->initialize(CHECK);
1323     }
1324   }
1325 }
1326 
1327 void HeapShared::init_archived_fields_for(Klass* k, const ArchivedKlassSubGraphInfoRecord* record) {
1328   verify_the_heap(k, "before");
1329 
1330   // Load the subgraph entry fields from the record and store them back to
1331   // the corresponding fields within the mirror.
1332   oop m = k->java_mirror();
1333   Array<int>* entry_field_records = record->entry_field_records();

2035   }
2036 }
2037 
2038 void HeapShared::archive_object_subgraphs(ArchivableStaticFieldInfo fields[],
2039                                           bool is_full_module_graph) {
2040   _num_total_subgraph_recordings = 0;
2041   _num_total_walked_objs = 0;
2042   _num_total_archived_objs = 0;
2043   _num_total_recorded_klasses = 0;
2044   _num_total_verifications = 0;
2045 
2046   // For each class X that has one or more archived fields:
2047   // [1] Dump the subgraph of each archived field
2048   // [2] Create a list of all the class of the objects that can be reached
2049   //     by any of these static fields.
2050   //     At runtime, these classes are initialized before X's archived fields
2051   //     are restored by HeapShared::initialize_from_archived_subgraph().
2052   for (int i = 0; fields[i].valid(); ) {
2053     ArchivableStaticFieldInfo* info = &fields[i];
2054     const char* klass_name = info->klass_name;
2055 
2056     if (CDSConfig::is_valhalla_preview() && strcmp(klass_name, "jdk/internal/module/ArchivedModuleGraph") == 0) {
2057       // FIXME -- ArchivedModuleGraph doesn't work when java.base is patched with valhalla classes.
2058       i++;
2059       continue;
2060     }
2061 
2062     start_recording_subgraph(info->klass, klass_name, is_full_module_graph);
2063 
2064     // If you have specified consecutive fields of the same klass in
2065     // fields[], these will be archived in the same
2066     // {start_recording_subgraph ... done_recording_subgraph} pass to
2067     // save time.
2068     for (; fields[i].valid(); i++) {
2069       ArchivableStaticFieldInfo* f = &fields[i];
2070       if (f->klass_name != klass_name) {
2071         break;
2072       }
2073 
2074       archive_reachable_objects_from_static_field(f->klass, f->klass_name,
2075                                                   f->offset, f->field_name);
2076     }
2077     done_recording_subgraph(info->klass, klass_name);
2078   }
2079 
2080   log_info(aot, heap)("Archived subgraph records = %d",
2081                       _num_total_subgraph_recordings);
< prev index next >