< prev index next >

src/hotspot/share/memory/heapShared.cpp

Print this page




 341  protected:
 342   template <class T> void do_oop_work(T *p) {
 343     oop obj = RawAccess<>::oop_load(p);
 344     if (!CompressedOops::is_null(obj)) {
 345       // A java.lang.Class instance can not be included in an archived
 346       // object sub-graph.
 347       if (java_lang_Class::is_instance(obj)) {
 348         tty->print("Unknown java.lang.Class object is in the archived sub-graph\n");
 349         vm_exit(1);
 350       }
 351 
 352       LogTarget(Debug, cds, heap) log;
 353       LogStream ls(log);
 354       outputStream* out = &ls;
 355       {
 356         ResourceMark rm;
 357         log.print("(%d) %s <--- referenced from:  %s",
 358                   _level, obj->klass()->external_name(),
 359                   CompressedOops::is_null(_orig_referencing_obj) ?
 360                          "" : _orig_referencing_obj->klass()->external_name());
 361         obj->print_on(out);
 362       }
 363 
 364       if (MetaspaceShared::is_archive_object(obj)) {
 365         // The current oop is an archived oop, nothing needs to be done
 366         log.print("--- object is already archived ---");
 367         return;
 368       }
 369 
 370       size_t field_delta = pointer_delta(
 371         p, _orig_referencing_obj, sizeof(char));
 372       T* new_p = (T*)(address(_archived_referencing_obj) + field_delta);
 373       oop archived = MetaspaceShared::find_archived_heap_object(obj);
 374       if (archived != NULL) {
 375         // There is an archived copy existing, update reference to point
 376         // to the archived copy
 377         RawAccess<IS_NOT_NULL>::oop_store(new_p, archived);
 378         log.print(
 379           "--- found existing archived copy, store archived " PTR_FORMAT " in " PTR_FORMAT,
 380           p2i(archived), p2i(new_p));
 381         return;


 452   assert(InstanceKlass::cast(k)->is_shared_boot_class(),
 453          "must be boot class");
 454 
 455   oop m = k->java_mirror();
 456   oop archived_m = MetaspaceShared::find_archived_heap_object(m);
 457   if (CompressedOops::is_null(archived_m)) {
 458     return;
 459   }
 460 
 461   if (field_type == T_OBJECT) {
 462     // obtain k's subGraph Info
 463     KlassSubGraphInfo* subgraph_info = get_subgraph_info(k);
 464 
 465     // get the object referenced by the field
 466     oop f = m->obj_field(field_offset);
 467     if (!CompressedOops::is_null(f)) {
 468       LogTarget(Debug, cds, heap) log;
 469       LogStream ls(log);
 470       outputStream* out = &ls;
 471       log.print("Start from: ");
 472       f->print_on(out);
 473 
 474       // get the archived copy of the field referenced object
 475       oop af = MetaspaceShared::archive_heap_object(f, THREAD);
 476       if (!MetaspaceShared::is_archive_object(f)) {
 477         WalkOopAndArchiveClosure walker(1, subgraph_info, f, af);
 478         f->oop_iterate(&walker);
 479       }
 480 
 481       // The field value is not preserved in the archived mirror.
 482       // Record the field as a new subGraph entry point. The recorded
 483       // information is restored from the archive at runtime.
 484       subgraph_info->add_subgraph_entry_field(field_offset, af);
 485       Klass *relocated_k = af->klass();
 486       Klass *orig_k = f->klass();
 487       subgraph_info->add_subgraph_object_klass(orig_k, relocated_k);
 488     } else {
 489       // The field contains null, we still need to record the entry point,
 490       // so it can be restored at runtime.
 491       subgraph_info->add_subgraph_entry_field(field_offset, NULL);
 492     }


 341  protected:
 342   template <class T> void do_oop_work(T *p) {
 343     oop obj = RawAccess<>::oop_load(p);
 344     if (!CompressedOops::is_null(obj)) {
 345       // A java.lang.Class instance can not be included in an archived
 346       // object sub-graph.
 347       if (java_lang_Class::is_instance(obj)) {
 348         tty->print("Unknown java.lang.Class object is in the archived sub-graph\n");
 349         vm_exit(1);
 350       }
 351 
 352       LogTarget(Debug, cds, heap) log;
 353       LogStream ls(log);
 354       outputStream* out = &ls;
 355       {
 356         ResourceMark rm;
 357         log.print("(%d) %s <--- referenced from:  %s",
 358                   _level, obj->klass()->external_name(),
 359                   CompressedOops::is_null(_orig_referencing_obj) ?
 360                          "" : _orig_referencing_obj->klass()->external_name());
 361         oopDesc::print_on(out, obj);
 362       }
 363 
 364       if (MetaspaceShared::is_archive_object(obj)) {
 365         // The current oop is an archived oop, nothing needs to be done
 366         log.print("--- object is already archived ---");
 367         return;
 368       }
 369 
 370       size_t field_delta = pointer_delta(
 371         p, _orig_referencing_obj, sizeof(char));
 372       T* new_p = (T*)(address(_archived_referencing_obj) + field_delta);
 373       oop archived = MetaspaceShared::find_archived_heap_object(obj);
 374       if (archived != NULL) {
 375         // There is an archived copy existing, update reference to point
 376         // to the archived copy
 377         RawAccess<IS_NOT_NULL>::oop_store(new_p, archived);
 378         log.print(
 379           "--- found existing archived copy, store archived " PTR_FORMAT " in " PTR_FORMAT,
 380           p2i(archived), p2i(new_p));
 381         return;


 452   assert(InstanceKlass::cast(k)->is_shared_boot_class(),
 453          "must be boot class");
 454 
 455   oop m = k->java_mirror();
 456   oop archived_m = MetaspaceShared::find_archived_heap_object(m);
 457   if (CompressedOops::is_null(archived_m)) {
 458     return;
 459   }
 460 
 461   if (field_type == T_OBJECT) {
 462     // obtain k's subGraph Info
 463     KlassSubGraphInfo* subgraph_info = get_subgraph_info(k);
 464 
 465     // get the object referenced by the field
 466     oop f = m->obj_field(field_offset);
 467     if (!CompressedOops::is_null(f)) {
 468       LogTarget(Debug, cds, heap) log;
 469       LogStream ls(log);
 470       outputStream* out = &ls;
 471       log.print("Start from: ");
 472       oopDesc::print_on(out, f);
 473 
 474       // get the archived copy of the field referenced object
 475       oop af = MetaspaceShared::archive_heap_object(f, THREAD);
 476       if (!MetaspaceShared::is_archive_object(f)) {
 477         WalkOopAndArchiveClosure walker(1, subgraph_info, f, af);
 478         f->oop_iterate(&walker);
 479       }
 480 
 481       // The field value is not preserved in the archived mirror.
 482       // Record the field as a new subGraph entry point. The recorded
 483       // information is restored from the archive at runtime.
 484       subgraph_info->add_subgraph_entry_field(field_offset, af);
 485       Klass *relocated_k = af->klass();
 486       Klass *orig_k = f->klass();
 487       subgraph_info->add_subgraph_object_klass(orig_k, relocated_k);
 488     } else {
 489       // The field contains null, we still need to record the entry point,
 490       // so it can be restored at runtime.
 491       subgraph_info->add_subgraph_entry_field(field_offset, NULL);
 492     }
< prev index next >