24 |
24 |
25 #include "precompiled.hpp" |
25 #include "precompiled.hpp" |
26 #include "classfile/javaClasses.inline.hpp" |
26 #include "classfile/javaClasses.inline.hpp" |
27 #include "classfile/stringTable.hpp" |
27 #include "classfile/stringTable.hpp" |
28 #include "classfile/symbolTable.hpp" |
28 #include "classfile/symbolTable.hpp" |
|
29 #include "classfile/systemDictionaryShared.hpp" |
29 #include "classfile/vmSymbols.hpp" |
30 #include "classfile/vmSymbols.hpp" |
30 #include "logging/log.hpp" |
31 #include "logging/log.hpp" |
31 #include "logging/logMessage.hpp" |
32 #include "logging/logMessage.hpp" |
32 #include "logging/logStream.hpp" |
33 #include "logging/logStream.hpp" |
|
34 #include "memory/archiveUtils.hpp" |
33 #include "memory/filemap.hpp" |
35 #include "memory/filemap.hpp" |
34 #include "memory/heapShared.inline.hpp" |
36 #include "memory/heapShared.inline.hpp" |
35 #include "memory/iterator.inline.hpp" |
37 #include "memory/iterator.inline.hpp" |
36 #include "memory/metadataFactory.hpp" |
38 #include "memory/metadataFactory.hpp" |
37 #include "memory/metaspaceClosure.hpp" |
39 #include "memory/metaspaceClosure.hpp" |
|
40 #include "memory/metaspaceShared.hpp" |
38 #include "memory/resourceArea.hpp" |
41 #include "memory/resourceArea.hpp" |
39 #include "memory/universe.hpp" |
42 #include "memory/universe.hpp" |
40 #include "oops/compressedOops.inline.hpp" |
43 #include "oops/compressedOops.inline.hpp" |
41 #include "oops/fieldStreams.inline.hpp" |
44 #include "oops/fieldStreams.inline.hpp" |
42 #include "oops/oop.inline.hpp" |
45 #include "oops/oop.inline.hpp" |
381 log_info(cds, heap)( |
384 log_info(cds, heap)( |
382 "Archived object klass %s (%2d) => %s", |
385 "Archived object klass %s (%2d) => %s", |
383 _k->external_name(), i, subgraph_k->external_name()); |
386 _k->external_name(), i, subgraph_k->external_name()); |
384 } |
387 } |
385 _subgraph_object_klasses->at_put(i, subgraph_k); |
388 _subgraph_object_klasses->at_put(i, subgraph_k); |
386 } |
389 ArchivePtrMarker::mark_pointer(_subgraph_object_klasses->adr_at(i)); |
387 } |
390 } |
|
391 } |
|
392 |
|
393 ArchivePtrMarker::mark_pointer(&_k); |
|
394 ArchivePtrMarker::mark_pointer(&_entry_field_records); |
|
395 ArchivePtrMarker::mark_pointer(&_subgraph_object_klasses); |
388 } |
396 } |
389 |
397 |
390 struct CopyKlassSubGraphInfoToArchive : StackObj { |
398 struct CopyKlassSubGraphInfoToArchive : StackObj { |
391 CompactHashtableWriter* _writer; |
399 CompactHashtableWriter* _writer; |
392 CopyKlassSubGraphInfoToArchive(CompactHashtableWriter* writer) : _writer(writer) {} |
400 CopyKlassSubGraphInfoToArchive(CompactHashtableWriter* writer) : _writer(writer) {} |
395 if (info.subgraph_object_klasses() != NULL || info.subgraph_entry_fields() != NULL) { |
403 if (info.subgraph_object_klasses() != NULL || info.subgraph_entry_fields() != NULL) { |
396 ArchivedKlassSubGraphInfoRecord* record = |
404 ArchivedKlassSubGraphInfoRecord* record = |
397 (ArchivedKlassSubGraphInfoRecord*)MetaspaceShared::read_only_space_alloc(sizeof(ArchivedKlassSubGraphInfoRecord)); |
405 (ArchivedKlassSubGraphInfoRecord*)MetaspaceShared::read_only_space_alloc(sizeof(ArchivedKlassSubGraphInfoRecord)); |
398 record->init(&info); |
406 record->init(&info); |
399 |
407 |
400 unsigned int hash = primitive_hash<Klass*>(klass); |
408 unsigned int hash = SystemDictionaryShared::hash_for_shared_dictionary(klass); |
401 u4 delta = MetaspaceShared::object_delta_u4(record); |
409 u4 delta = MetaspaceShared::object_delta_u4(record); |
402 _writer->add(hash, delta); |
410 _writer->add(hash, delta); |
403 } |
411 } |
404 return true; // keep on iterating |
412 return true; // keep on iterating |
405 } |
413 } |
434 if (!open_archive_heap_region_mapped()) { |
442 if (!open_archive_heap_region_mapped()) { |
435 return; // nothing to do |
443 return; // nothing to do |
436 } |
444 } |
437 assert(!DumpSharedSpaces, "Should not be called with DumpSharedSpaces"); |
445 assert(!DumpSharedSpaces, "Should not be called with DumpSharedSpaces"); |
438 |
446 |
439 unsigned int hash = primitive_hash<Klass*>(k); |
447 unsigned int hash = SystemDictionaryShared::hash_for_shared_dictionary(k); |
440 const ArchivedKlassSubGraphInfoRecord* record = _run_time_subgraph_info_table.lookup(k, hash, 0); |
448 const ArchivedKlassSubGraphInfoRecord* record = _run_time_subgraph_info_table.lookup(k, hash, 0); |
441 |
449 |
442 // Initialize from archived data. Currently this is done only |
450 // Initialize from archived data. Currently this is done only |
443 // during VM initialization time. No lock is needed. |
451 // during VM initialization time. No lock is needed. |
444 if (record != NULL) { |
452 if (record != NULL) { |
604 bool is_closed_archive, |
612 bool is_closed_archive, |
605 TRAPS) { |
613 TRAPS) { |
606 assert(orig_obj != NULL, "must be"); |
614 assert(orig_obj != NULL, "must be"); |
607 assert(!is_archived_object(orig_obj), "sanity"); |
615 assert(!is_archived_object(orig_obj), "sanity"); |
608 |
616 |
609 // java.lang.Class instances cannot be included in an archived |
617 if (!JavaClasses::is_supported_for_archiving(orig_obj)) { |
610 // object sub-graph. |
618 // This object has injected fields that cannot be supported easily, so we disallow them for now. |
|
619 // If you get an error here, you probably made a change in the JDK library that has added |
|
620 // these objects that are referenced (directly or indirectly) by static fields. |
|
621 ResourceMark rm; |
|
622 log_error(cds, heap)("Cannot archive object of class %s", orig_obj->klass()->external_name()); |
|
623 vm_exit(1); |
|
624 } |
|
625 |
|
626 // java.lang.Class instances cannot be included in an archived object sub-graph. We only support |
|
627 // them as Klass::_archived_mirror because they need to be specially restored at run time. |
|
628 // |
|
629 // If you get an error here, you probably made a change in the JDK library that has added a Class |
|
630 // object that is referenced (directly or indirectly) by static fields. |
611 if (java_lang_Class::is_instance(orig_obj)) { |
631 if (java_lang_Class::is_instance(orig_obj)) { |
612 log_error(cds, heap)("(%d) Unknown java.lang.Class object is in the archived sub-graph", level); |
632 log_error(cds, heap)("(%d) Unknown java.lang.Class object is in the archived sub-graph", level); |
613 vm_exit(1); |
633 vm_exit(1); |
614 } |
634 } |
615 |
635 |