< prev index next >
src/hotspot/share/memory/metaspaceShared.cpp
Print this page
*** 22,31 ****
--- 22,32 ----
*
*/
#include "precompiled.hpp"
#include "classfile/classLoaderDataGraph.hpp"
+ #include "classfile/classLoaderDataShared.hpp"
#include "classfile/classListParser.hpp"
#include "classfile/classLoaderExt.hpp"
#include "classfile/loaderConstraints.hpp"
#include "classfile/javaClasses.inline.hpp"
#include "classfile/placeholders.hpp"
*** 38,47 ****
--- 39,49 ----
#include "interpreter/bytecodes.hpp"
#include "logging/log.hpp"
#include "logging/logMessage.hpp"
#include "memory/archiveBuilder.hpp"
#include "memory/archiveUtils.inline.hpp"
+ #include "memory/dumpAllocStats.hpp"
#include "memory/dynamicArchive.hpp"
#include "memory/filemap.hpp"
#include "memory/heapShared.inline.hpp"
#include "memory/metaspace.hpp"
#include "memory/metaspaceClosure.hpp"
*** 84,93 ****
--- 86,96 ----
size_t MetaspaceShared::_i2i_entry_code_buffers_size = 0;
void* MetaspaceShared::_shared_metaspace_static_top = NULL;
intx MetaspaceShared::_relocation_delta;
char* MetaspaceShared::_requested_base_address;
bool MetaspaceShared::_use_optimized_module_handling = true;
+ bool MetaspaceShared::_use_full_module_graph = true;
// The CDS archive is divided into the following regions:
// mc - misc code (the method entry trampolines, c++ vtables)
// rw - read-write metadata
// ro - read-only metadata and read-only tables
*** 148,157 ****
--- 151,164 ----
char* MetaspaceShared::read_only_space_alloc(size_t num_bytes) {
return _ro_region.allocate(num_bytes);
}
+ char* MetaspaceShared::read_write_space_alloc(size_t num_bytes) {
+ return _rw_region.allocate(num_bytes);
+ }
+
size_t MetaspaceShared::reserved_space_alignment() { return os::vm_allocation_granularity(); }
static bool shared_base_valid(char* shared_base) {
#ifdef _LP64
return CompressedKlassPointers::is_valid_base((address)shared_base);
*** 497,506 ****
--- 504,515 ----
soc->do_tag(--tag);
serialize_cloned_cpp_vtptrs(soc);
soc->do_tag(--tag);
+ CDS_JAVA_HEAP_ONLY(ClassLoaderDataShared::serialize(soc));
+
soc->do_tag(666);
}
address MetaspaceShared::i2i_entry_code_buffers(size_t total_size) {
if (DumpSharedSpaces) {
*** 1061,1074 ****
--- 1070,1102 ----
MetaspaceShared::allocate_cloned_cpp_vtptrs();
char* cloned_vtables = _mc_region.top();
MetaspaceShared::allocate_cpp_vtable_clones();
+ {
_mc_region.pack(&_rw_region);
builder.dump_rw_region();
+ #if INCLUDE_CDS_JAVA_HEAP
+ if (MetaspaceShared::use_full_module_graph()) {
+ // Archive the ModuleEntry's and PackageEntry's of the 3 built-in loaders
+ char* start = _rw_region.top();
+ ClassLoaderDataShared::allocate_archived_tables();
+ ArchiveBuilder::alloc_stats()->record_modules(_rw_region.top() - start, /*read_only*/false);
+ }
+ #endif
+ }
+ {
_rw_region.pack(&_ro_region);
builder.dump_ro_region();
+ #if INCLUDE_CDS_JAVA_HEAP
+ if (MetaspaceShared::use_full_module_graph()) {
+ char* start = _ro_region.top();
+ ClassLoaderDataShared::init_archived_tables();
+ ArchiveBuilder::alloc_stats()->record_modules(_ro_region.top() - start, /*read_only*/true);
+ }
+ #endif
+ }
builder.relocate_pointers();
dump_symbols();
// Dump supported java heap objects
*** 1216,1225 ****
--- 1244,1257 ----
k = (Klass*)(address(k) + final_delta());
}
return k;
}
+ Symbol* MetaspaceShared::get_relocated_symbol(Symbol* orig_symbol) {
+ return ArchiveBuilder::get_relocated_symbol(orig_symbol);
+ }
+
class LinkSharedClassesClosure : public KlassClosure {
Thread* THREAD;
bool _made_progress;
public:
LinkSharedClassesClosure(Thread* thread) : THREAD(thread), _made_progress(false) {}
*** 1330,1339 ****
--- 1362,1377 ----
// fails verification, all other interfaces that were not specified in the classlist but
// are implemented by K are not verified.
link_and_cleanup_shared_classes(CATCH);
log_info(cds)("Rewriting and linking classes: done");
+ #if INCLUDE_CDS_JAVA_HEAP
+ if (use_full_module_graph()) {
+ HeapShared::reset_archived_object_states(THREAD);
+ }
+ #endif
+
VM_PopulateDumpSharedSpace op;
MutexLocker ml(THREAD, HeapShared::is_heap_object_archiving_allowed() ?
Heap_lock : NULL); // needed by HeapShared::run_gc()
VMThread::execute(&op);
}
*** 1697,1707 ****
// map_heap_regions() compares the current narrow oop and klass encodings
// with the archived ones, so it must be done after all encodings are determined.
static_mapinfo->map_heap_regions();
}
});
! log_info(cds)("Using optimized module handling %s", MetaspaceShared::use_optimized_module_handling() ? "enabled" : "disabled");
} else {
unmap_archive(static_mapinfo);
unmap_archive(dynamic_mapinfo);
release_reserved_spaces(archive_space_rs, class_space_rs);
}
--- 1735,1746 ----
// map_heap_regions() compares the current narrow oop and klass encodings
// with the archived ones, so it must be done after all encodings are determined.
static_mapinfo->map_heap_regions();
}
});
! log_info(cds)("optimized module handling: %s", MetaspaceShared::use_optimized_module_handling() ? "enabled" : "disabled");
! log_info(cds)("full module graph: %s", MetaspaceShared::use_full_module_graph() ? "enabled" : "disabled");
} else {
unmap_archive(static_mapinfo);
unmap_archive(dynamic_mapinfo);
release_reserved_spaces(archive_space_rs, class_space_rs);
}
*** 2022,2031 ****
--- 2061,2081 ----
intx MetaspaceShared::final_delta() {
return intx(MetaspaceShared::requested_base_address()) // We want the base archive to be mapped to here at runtime
- intx(SharedBaseAddress); // .. but the base archive is mapped at here at dump time
}
+ bool MetaspaceShared::use_full_module_graph() {
+ bool result = _use_optimized_module_handling && _use_full_module_graph &&
+ (UseSharedSpaces || DumpSharedSpaces) && HeapShared::is_heap_object_archiving_allowed();
+ if (result && UseSharedSpaces) {
+ // Classes used by the archived full module graph are loaded in JVMTI early phase.
+ assert(!(JvmtiExport::should_post_class_file_load_hook() && JvmtiExport::has_early_class_hook_env()),
+ "CDS should be disabled if early class hooks are enabled");
+ }
+ return result;
+ }
+
void MetaspaceShared::print_on(outputStream* st) {
if (UseSharedSpaces || DumpSharedSpaces) {
st->print("CDS archive(s) mapped at: ");
address base;
address top;
< prev index next >