< prev index next >
src/share/vm/gc_implementation/g1/g1PageBasedVirtualSpace.cpp
Print this page
rev 7618 : 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
Summary: Making sure committed memory is cleared when re-committed, even if using large pages.
Reviewed-by:
*** 41,53 ****
#endif
#ifdef TARGET_OS_FAMILY_bsd
# include "os_bsd.inline.hpp"
#endif
#include "utilities/bitMap.inline.hpp"
G1PageBasedVirtualSpace::G1PageBasedVirtualSpace() : _low_boundary(NULL),
! _high_boundary(NULL), _committed(), _page_size(0), _special(false), _executable(false) {
}
bool G1PageBasedVirtualSpace::initialize_with_granularity(ReservedSpace rs, size_t page_size) {
if (!rs.is_reserved()) {
return false; // Allocation failed.
--- 41,55 ----
#endif
#ifdef TARGET_OS_FAMILY_bsd
# include "os_bsd.inline.hpp"
#endif
#include "utilities/bitMap.inline.hpp"
+ #include "utilities/copy.hpp"
G1PageBasedVirtualSpace::G1PageBasedVirtualSpace() : _low_boundary(NULL),
! _high_boundary(NULL), _committed(), _page_size(0), _special(false),
! _needs_clear_on_commit(), _executable(false) {
}
bool G1PageBasedVirtualSpace::initialize_with_granularity(ReservedSpace rs, size_t page_size) {
if (!rs.is_reserved()) {
return false; // Allocation failed.
*** 64,73 ****
--- 66,78 ----
_page_size = page_size;
assert(_committed.size() == 0, "virtual space initialized more than once");
uintx size_in_bits = rs.size() / page_size;
_committed.resize(size_in_bits, /* in_resource_area */ false);
+ if (_special) {
+ _needs_clear_on_commit.resize(size_in_bits, /* in_resource_area */ false);
+ }
return true;
}
*** 82,91 ****
--- 87,97 ----
_high_boundary = NULL;
_special = false;
_executable = false;
_page_size = 0;
_committed.resize(0, false);
+ _needs_clear_on_commit.resize(0, false);
}
size_t G1PageBasedVirtualSpace::committed_size() const {
return _committed.count_one_bits() * _page_size;
}
*** 122,132 ****
MemRegion G1PageBasedVirtualSpace::commit(uintptr_t start, size_t size_in_pages) {
// We need to make sure to commit all pages covered by the given area.
guarantee(is_area_uncommitted(start, size_in_pages), "Specified area is not uncommitted");
! if (!_special) {
os::commit_memory_or_exit(page_start(start), byte_size_for_pages(size_in_pages), _executable,
err_msg("Failed to commit pages from "SIZE_FORMAT" of length "SIZE_FORMAT, start, size_in_pages));
}
_committed.set_range(start, start + size_in_pages);
--- 128,148 ----
MemRegion G1PageBasedVirtualSpace::commit(uintptr_t start, size_t size_in_pages) {
// We need to make sure to commit all pages covered by the given area.
guarantee(is_area_uncommitted(start, size_in_pages), "Specified area is not uncommitted");
! if (_special) {
! // When the memory is _special it is not really uncommitted. _needs_clear_on_commit
! // is used to communicate that the memory needs to be cleared because it is seen by
! // others as uncommitted.
! for (uintptr_t page_index = start; page_index < start + size_in_pages; page_index++) {
! if (_needs_clear_on_commit.at(page_index)) {
! Copy::zero_to_bytes((HeapWord*)page_start(page_index), _page_size);
! _needs_clear_on_commit.clear_bit(page_index);
! }
! }
! } else {
os::commit_memory_or_exit(page_start(start), byte_size_for_pages(size_in_pages), _executable,
err_msg("Failed to commit pages from "SIZE_FORMAT" of length "SIZE_FORMAT, start, size_in_pages));
}
_committed.set_range(start, start + size_in_pages);
*** 138,148 ****
}
MemRegion G1PageBasedVirtualSpace::uncommit(uintptr_t start, size_t size_in_pages) {
guarantee(is_area_committed(start, size_in_pages), "checking");
! if (!_special) {
os::uncommit_memory(page_start(start), byte_size_for_pages(size_in_pages));
}
_committed.clear_range(start, start + size_in_pages);
--- 154,167 ----
}
MemRegion G1PageBasedVirtualSpace::uncommit(uintptr_t start, size_t size_in_pages) {
guarantee(is_area_committed(start, size_in_pages), "checking");
! if (_special) {
! // Mark that memory needs to be cleared if committed again.
! _needs_clear_on_commit.set_range(start, start + size_in_pages);
! } else {
os::uncommit_memory(page_start(start), byte_size_for_pages(size_in_pages));
}
_committed.clear_range(start, start + size_in_pages);
< prev index next >