src/hotspot/share/memory/heapShared.cpp
changeset 51425 4e9667589c43
parent 51388 0dcd27526967
child 51429 d9f6e3ee7fcb
equal deleted inserted replaced
51424:083e731da31a 51425:4e9667589c43
   350     oop obj = RawAccess<>::oop_load(p);
   350     oop obj = RawAccess<>::oop_load(p);
   351     if (!CompressedOops::is_null(obj)) {
   351     if (!CompressedOops::is_null(obj)) {
   352       // A java.lang.Class instance can not be included in an archived
   352       // A java.lang.Class instance can not be included in an archived
   353       // object sub-graph.
   353       // object sub-graph.
   354       if (java_lang_Class::is_instance(obj)) {
   354       if (java_lang_Class::is_instance(obj)) {
   355         tty->print("Unknown java.lang.Class object is in the archived sub-graph\n");
   355         log_error(cds, heap)("Unknown java.lang.Class object is in the archived sub-graph\n");
   356         vm_exit(1);
   356         vm_exit(1);
   357       }
   357       }
   358 
   358 
   359       LogTarget(Debug, cds, heap) log;
   359       LogTarget(Debug, cds, heap) log;
   360       LogStream ls(log);
   360       LogStream ls(log);
   390 
   390 
   391       int l = _level + 1;
   391       int l = _level + 1;
   392       Thread* THREAD = Thread::current();
   392       Thread* THREAD = Thread::current();
   393       // Archive the current oop before iterating through its references
   393       // Archive the current oop before iterating through its references
   394       archived = MetaspaceShared::archive_heap_object(obj, THREAD);
   394       archived = MetaspaceShared::archive_heap_object(obj, THREAD);
       
   395       if (archived == NULL) {
       
   396         ResourceMark rm;
       
   397         LogTarget(Error, cds, heap) log_err;
       
   398         LogStream ls_err(log_err);
       
   399         outputStream* out_err = &ls_err;
       
   400         log_err.print("Failed to archive %s object ("
       
   401                       PTR_FORMAT "), size[" SIZE_FORMAT "] in sub-graph",
       
   402                       obj->klass()->external_name(), p2i(obj), (size_t)obj->size());
       
   403         obj->print_on(out_err);
       
   404         vm_exit(1);
       
   405       }
   395       assert(MetaspaceShared::is_archive_object(archived), "must be archived");
   406       assert(MetaspaceShared::is_archive_object(archived), "must be archived");
   396       log.print("=== archiving oop " PTR_FORMAT " ==> " PTR_FORMAT,
   407       log.print("=== archiving oop " PTR_FORMAT " ==> " PTR_FORMAT,
   397                  p2i(obj), p2i(archived));
   408                  p2i(obj), p2i(archived));
   398 
   409 
   399       // Following the references in the current oop and archive any
   410       // Following the references in the current oop and archive any
   478       log.print("Start from: ");
   489       log.print("Start from: ");
   479       f->print_on(out);
   490       f->print_on(out);
   480 
   491 
   481       // get the archived copy of the field referenced object
   492       // get the archived copy of the field referenced object
   482       oop af = MetaspaceShared::archive_heap_object(f, THREAD);
   493       oop af = MetaspaceShared::archive_heap_object(f, THREAD);
       
   494       if (af == NULL) {
       
   495         // Skip archiving the sub-graph referenced from the current entry field.
       
   496         ResourceMark rm;
       
   497         log_info(cds, heap)(
       
   498           "Cannot archive the sub-graph referenced from %s object ("
       
   499           PTR_FORMAT ") size[" SIZE_FORMAT "], skipped.",
       
   500           f->klass()->external_name(), p2i(f), (size_t)f->size());
       
   501         return;
       
   502       }
   483       if (!MetaspaceShared::is_archive_object(f)) {
   503       if (!MetaspaceShared::is_archive_object(f)) {
   484         WalkOopAndArchiveClosure walker(1, subgraph_info, f, af);
   504         WalkOopAndArchiveClosure walker(1, subgraph_info, f, af);
   485         f->oop_iterate(&walker);
   505         f->oop_iterate(&walker);
   486       }
   506       }
   487 
   507 
   490       // information is restored from the archive at runtime.
   510       // information is restored from the archive at runtime.
   491       subgraph_info->add_subgraph_entry_field(field_offset, af);
   511       subgraph_info->add_subgraph_entry_field(field_offset, af);
   492       Klass *relocated_k = af->klass();
   512       Klass *relocated_k = af->klass();
   493       Klass *orig_k = f->klass();
   513       Klass *orig_k = f->klass();
   494       subgraph_info->add_subgraph_object_klass(orig_k, relocated_k);
   514       subgraph_info->add_subgraph_object_klass(orig_k, relocated_k);
       
   515       ResourceMark rm;
       
   516       log_info(cds, heap)(
       
   517           "Archived the sub-graph referenced from %s object " PTR_FORMAT,
       
   518           f->klass()->external_name(), p2i(f));
   495     } else {
   519     } else {
   496       // The field contains null, we still need to record the entry point,
   520       // The field contains null, we still need to record the entry point,
   497       // so it can be restored at runtime.
   521       // so it can be restored at runtime.
   498       subgraph_info->add_subgraph_entry_field(field_offset, NULL);
   522       subgraph_info->add_subgraph_entry_field(field_offset, NULL);
   499     }
   523     }