< prev index next >
src/hotspot/share/memory/heapShared.cpp
Print this page
@@ -24,19 +24,22 @@
#include "precompiled.hpp"
#include "classfile/javaClasses.inline.hpp"
#include "classfile/stringTable.hpp"
#include "classfile/symbolTable.hpp"
+#include "classfile/systemDictionaryShared.hpp"
#include "classfile/vmSymbols.hpp"
#include "logging/log.hpp"
#include "logging/logMessage.hpp"
#include "logging/logStream.hpp"
+#include "memory/archiveUtils.hpp"
#include "memory/filemap.hpp"
#include "memory/heapShared.inline.hpp"
#include "memory/iterator.inline.hpp"
#include "memory/metadataFactory.hpp"
#include "memory/metaspaceClosure.hpp"
+#include "memory/metaspaceShared.hpp"
#include "memory/resourceArea.hpp"
#include "memory/universe.hpp"
#include "oops/compressedOops.inline.hpp"
#include "oops/fieldStreams.hpp"
#include "oops/oop.inline.hpp"
@@ -381,12 +384,17 @@
log_info(cds, heap)(
"Archived object klass %s (%2d) => %s",
_k->external_name(), i, subgraph_k->external_name());
}
_subgraph_object_klasses->at_put(i, subgraph_k);
+ ArchivePtrMarker::mark_pointer(_subgraph_object_klasses->adr_at(i));
}
}
+
+ ArchivePtrMarker::mark_pointer(&_k);
+ ArchivePtrMarker::mark_pointer(&_entry_field_records);
+ ArchivePtrMarker::mark_pointer(&_subgraph_object_klasses);
}
struct CopyKlassSubGraphInfoToArchive : StackObj {
CompactHashtableWriter* _writer;
CopyKlassSubGraphInfoToArchive(CompactHashtableWriter* writer) : _writer(writer) {}
@@ -395,11 +403,11 @@
if (info.subgraph_object_klasses() != NULL || info.subgraph_entry_fields() != NULL) {
ArchivedKlassSubGraphInfoRecord* record =
(ArchivedKlassSubGraphInfoRecord*)MetaspaceShared::read_only_space_alloc(sizeof(ArchivedKlassSubGraphInfoRecord));
record->init(&info);
- unsigned int hash = primitive_hash<Klass*>(klass);
+ unsigned int hash = SystemDictionaryShared::hash_for_shared_dictionary(klass);
u4 delta = MetaspaceShared::object_delta_u4(record);
_writer->add(hash, delta);
}
return true; // keep on iterating
}
@@ -429,16 +437,16 @@
void HeapShared::serialize_subgraph_info_table_header(SerializeClosure* soc) {
_run_time_subgraph_info_table.serialize_header(soc);
}
void HeapShared::initialize_from_archived_subgraph(Klass* k) {
- if (!open_archive_heap_region_mapped()) {
+ if (!open_archive_heap_region_mapped() || !MetaspaceObj::is_shared(k)) {
return; // nothing to do
}
assert(!DumpSharedSpaces, "Should not be called with DumpSharedSpaces");
- unsigned int hash = primitive_hash<Klass*>(k);
+ unsigned int hash = SystemDictionaryShared::hash_for_shared_dictionary(k);
const ArchivedKlassSubGraphInfoRecord* record = _run_time_subgraph_info_table.lookup(k, hash, 0);
// Initialize from archived data. Currently this is done only
// during VM initialization time. No lock is needed.
if (record != NULL) {
@@ -603,11 +611,18 @@
oop orig_obj,
bool is_closed_archive,
TRAPS) {
assert(orig_obj != NULL, "must be");
assert(!is_archived_object(orig_obj), "sanity");
-
+ DEBUG_ONLY({
+ Klass* klass = orig_obj->klass();
+ assert(klass != SystemDictionary::Module_klass() &&
+ klass != SystemDictionary::ResolvedMethodName_klass() &&
+ klass != SystemDictionary::MemberName_klass() &&
+ klass != SystemDictionary::Context_klass() &&
+ klass != SystemDictionary::ClassLoader_klass(), "we can only relocate metaspace object pointers inside java_lang_Class instances");
+ });
// java.lang.Class instances cannot be included in an archived
// object sub-graph.
if (java_lang_Class::is_instance(orig_obj)) {
log_error(cds, heap)("(%d) Unknown java.lang.Class object is in the archived sub-graph", level);
vm_exit(1);
< prev index next >