< prev index next >
src/hotspot/share/memory/metaspaceShared.cpp
Print this page
@@ -37,10 +37,11 @@
#include "interpreter/bytecodeStream.hpp"
#include "interpreter/bytecodes.hpp"
#include "logging/log.hpp"
#include "logging/logMessage.hpp"
#include "memory/filemap.hpp"
+#include "memory/heapShared.hpp"
#include "memory/metaspace.hpp"
#include "memory/metaspaceClosure.hpp"
#include "memory/metaspaceShared.hpp"
#include "memory/resourceArea.hpp"
#include "oops/compressedOops.inline.hpp"
@@ -205,10 +206,14 @@
char* MetaspaceShared::read_only_space_alloc(size_t num_bytes) {
return _ro_region.allocate(num_bytes);
}
+char* MetaspaceShared::read_only_space_top() {
+ return _ro_region.top();
+}
+
void MetaspaceShared::initialize_runtime_shared_and_meta_spaces() {
assert(UseSharedSpaces, "Must be called when UseSharedSpaces is enabled");
// If using shared space, open the file that contains the shared space
// and map in the memory before initializing the rest of metaspace (so
@@ -454,10 +459,11 @@
java_lang_Module::serialize(soc);
java_lang_StackTraceElement::serialize(soc);
java_lang_StackFrameInfo::serialize(soc);
java_lang_LiveStackFrameInfo::serialize(soc);
java_util_concurrent_locks_AbstractOwnableSynchronizer::serialize(soc);
+ jdk_internal_module_ArchivedModuleGraph::serialize(soc);
}
address MetaspaceShared::cds_i2i_entry_code_buffers(size_t total_size) {
if (DumpSharedSpaces) {
if (_cds_i2i_entry_code_buffers == NULL) {
@@ -1348,10 +1354,15 @@
size_t table_bytes = SystemDictionary::count_bytes_for_table();
char* table_top = _ro_region.allocate(table_bytes, sizeof(intptr_t));
SystemDictionary::copy_table(table_top, _ro_region.top());
+ // Write the archived object sub-graph infos. For each klass with sub-graphs,
+ // the info includes the static fields (sub-graph entry points) and Klasses
+ // of objects included in the sub-graph.
+ HeapShared::write_archived_subgraph_infos();
+
// Write the other data to the output array.
WriteClosure wc(&_ro_region);
MetaspaceShared::serialize(&wc);
char* newtop = _ro_region.top();
@@ -1859,10 +1870,12 @@
java_lang_Class::archive_basic_type_mirrors(THREAD);
MetaspaceShared::archive_klass_objects(THREAD);
+ HeapShared::archive_module_graph_objects(THREAD);
+
G1CollectedHeap::heap()->end_archive_alloc_range(open_archive,
os::vm_allocation_granularity());
}
unsigned MetaspaceShared::obj_hash(oop const& p) {
@@ -1904,18 +1917,20 @@
Copy::aligned_disjoint_words((HeapWord*)obj, (HeapWord*)archived_oop, len);
relocate_klass_ptr(archived_oop);
ArchivedObjectCache* cache = MetaspaceShared::archive_object_cache();
cache->put(obj, archived_oop);
}
- log_debug(cds)("Archived heap object " PTR_FORMAT " ==> " PTR_FORMAT,
+ log_debug(cds, heap)("Archived heap object " PTR_FORMAT " ==> " PTR_FORMAT,
p2i(obj), p2i(archived_oop));
return archived_oop;
}
oop MetaspaceShared::materialize_archived_object(oop obj) {
- assert(obj != NULL, "sanity");
+ if (obj != NULL) {
return G1CollectedHeap::heap()->materialize_archived_object(obj);
+ }
+ return NULL;
}
void MetaspaceShared::archive_klass_objects(Thread* THREAD) {
int i;
for (i = 0; i < _global_klass_objects->length(); i++) {
@@ -2119,10 +2134,13 @@
int len = *(intptr_t*)buffer; // skip over shared dictionary entries
buffer += sizeof(intptr_t);
buffer += len;
+ // The table of archived java heap object sub-graph infos
+ buffer = HeapShared::read_archived_subgraph_infos(buffer);
+
// Verify various attributes of the archive, plus initialize the
// shared string/symbol tables
intptr_t* array = (intptr_t*)buffer;
ReadClosure rc(&array);
serialize(&rc);
< prev index next >