< prev index next >

src/hotspot/share/memory/metaspace/metachunk.cpp

Print this page
rev 53600 : imported patch autouncommit-metachunks

*** 21,30 **** --- 21,31 ---- * questions. * */ #include "precompiled.hpp" + #include "logging/log.hpp" #include "memory/allocation.hpp" #include "memory/metaspace/metachunk.hpp" #include "memory/metaspace/occupancyMap.hpp" #include "memory/metaspace/virtualSpaceNode.hpp" #include "utilities/align.hpp"
*** 132,141 **** --- 133,182 ---- p2i(this), word_size() * sizeof(MetaWord), required_alignment); } #endif // ASSERT + bool Metachunk::calc_uncommit_range(address* start, size_t* len) const { + // All but the first page (which contains the header) can be uncommitted + if (size() * sizeof(MetaWord) > (size_t)os::vm_page_size()) { + address from = align_up((address)initial_top(), os::vm_page_size()); + address to = align_down((address)end(), os::vm_page_size()); + if (from < to) { + *start = from; + *len = to - from; + return true; + } + } + return false; + } + + bool Metachunk::commit() { + bool rc = false; + address p = NULL; size_t len = 0; + if (calc_uncommit_range(&p, &len)) { + rc = os::commit_memory((char*)p, len, false); + if (rc) { + log_info(gc, metaspace)("Committed chunk " PTR_FORMAT " (payload area from " PTR_FORMAT " to " PTR_FORMAT ")", + p2i(this), p2i(p), p2i(p + len)); + } + } + return rc; + } + + bool Metachunk::uncommit() { + bool rc = false; + address p = NULL; size_t len = 0; + if (calc_uncommit_range(&p, &len)) { + rc = os::uncommit_memory((char*)p, len); + if (rc) { + log_info(gc, metaspace)("Uncommitted chunk " PTR_FORMAT " (payload area from " PTR_FORMAT " to " PTR_FORMAT ")", + p2i(this), p2i(p), p2i(p + len)); + } + } + return rc; + } + // Helper, returns a descriptive name for the given index. const char* chunk_size_name(ChunkIndex index) { switch (index) { case SpecializedIndex: return "specialized";
< prev index next >