< prev index next >

src/hotspot/share/memory/metaspaceShared.cpp

Print this page

*** 23,32 **** --- 23,33 ---- */ #include "precompiled.hpp" #include "jvm.h" #include "classfile/classLoaderDataGraph.hpp" + #include "classfile/classLoaderDataShared.hpp" #include "classfile/classListParser.hpp" #include "classfile/classLoaderExt.hpp" #include "classfile/dictionary.hpp" #include "classfile/loaderConstraints.hpp" #include "classfile/javaClasses.inline.hpp"
*** 88,97 **** --- 89,99 ---- 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
*** 238,247 **** --- 240,253 ---- 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);
*** 587,596 **** --- 593,604 ---- 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) {
*** 1081,1090 **** --- 1089,1099 ---- METASPACE_OBJ_TYPES_DO(f) \ f(SymbolHashentry) \ f(SymbolBucket) \ f(StringHashentry) \ f(StringBucket) \ + f(ModulesNatives) \ f(Other) enum Type { // Types are MetaspaceObj::ClassType, MetaspaceObj::SymbolType, etc SHAREDSPACE_OBJ_TYPES_DO(METASPACE_OBJ_TYPE_DECLARE)
*** 1116,1125 **** --- 1125,1139 ---- int which = (read_only) ? RO : RW; _counts[which][type] ++; _bytes [which][type] += byte_size; } + void record_modules(int byte_size, bool read_only) { + int which = (read_only) ? RO : RW; + _bytes [which][ModulesNativesType] += byte_size; + } + void record_other_type(int byte_size, bool read_only) { int which = (read_only) ? RO : RW; _bytes [which][OtherType] += byte_size; } void print_stats(int ro_all, int rw_all, int mc_all);
*** 1405,1423 **** --- 1419,1449 ---- _mc_region.pack(&_rw_region); ResourceMark rm; ShallowCopier rw_copier(false); iterate_roots(&rw_copier); + + #if INCLUDE_CDS_JAVA_HEAP + // Archive the ModuleEntry's and PackageEntry's of the 3 built-in loaders + char* start = _rw_region.top(); + ClassLoaderDataShared::allocate_archived_tables(); + ArchiveCompactor::alloc_stats()->record_modules(_rw_region.top() - start, /*read_only*/false); + #endif } { // allocate and shallow-copy of RO object, immediately following the RW region log_info(cds)("Allocating RO objects ... "); _rw_region.pack(&_ro_region); ResourceMark rm; ShallowCopier ro_copier(true); iterate_roots(&ro_copier); + #if INCLUDE_CDS_JAVA_HEAP + char* start = _ro_region.top(); + ClassLoaderDataShared::init_archived_tables(); + ArchiveCompactor::alloc_stats()->record_modules(_ro_region.top() - start, /*read_only*/true); + #endif } { log_info(cds)("Relocating embedded pointers ... "); ResourceMark rm; ShallowCopyEmbeddedRefRelocator emb_reloc;
*** 1508,1517 **** --- 1534,1550 ---- assert(pp != NULL, "must be"); Klass* klass = (Klass*)(*pp); assert(klass->is_klass(), "must be"); return klass; } + + static Symbol* get_relocated_symbol(Symbol* orig_symbol) { + assert(DumpSharedSpaces, "dump time only"); + address* pp = _new_loc_table->lookup((address)orig_symbol); + assert(pp != NULL, "must be"); + return (Symbol*)(*pp); + } }; DumpAllocStats* ArchiveCompactor::_alloc_stats; ArchiveCompactor::RelocationTable* ArchiveCompactor::_new_loc_table;
*** 1812,1821 **** --- 1845,1858 ---- k = (Klass*)(address(k) + final_delta()); } return k; } + Symbol* MetaspaceShared::get_relocated_symbol(Symbol* orig_symbol) { + return ArchiveCompactor::get_relocated_symbol(orig_symbol); + } + class LinkSharedClassesClosure : public KlassClosure { Thread* THREAD; bool _made_progress; public: LinkSharedClassesClosure(Thread* thread) : THREAD(thread), _made_progress(false) {}
*** 1926,1935 **** --- 1963,1978 ---- // 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); }
*** 2343,2353 **** // 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); } --- 2386,2397 ---- // 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); }
*** 2668,2677 **** --- 2712,2726 ---- 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() { + return _use_optimized_module_handling && _use_full_module_graph && + (UseSharedSpaces || DumpSharedSpaces) && HeapShared::is_heap_object_archiving_allowed(); + } + void MetaspaceShared::print_on(outputStream* st) { if (UseSharedSpaces || DumpSharedSpaces) { st->print("CDS archive(s) mapped at: "); address base; address top;
*** 2690,2699 **** } else { st->print("CDS disabled."); } st->cr(); } - - - - - --- 2739,2743 ----
< prev index next >