--- old/src/share/vm/gc_implementation/g1/g1PageBasedVirtualSpace.cpp 2015-01-09 12:22:06.078584515 +0100 +++ new/src/share/vm/gc_implementation/g1/g1PageBasedVirtualSpace.cpp 2015-01-09 12:22:05.946584513 +0100 @@ -46,7 +46,7 @@ G1PageBasedVirtualSpace::G1PageBasedVirtualSpace() : _low_boundary(NULL), _high_boundary(NULL), _committed(), _page_size(0), _special(false), - _needs_zeroing(), _executable(false) { + _dirty(), _executable(false) { } bool G1PageBasedVirtualSpace::initialize_with_granularity(ReservedSpace rs, size_t page_size) { @@ -68,7 +68,7 @@ uintx size_in_bits = rs.size() / page_size; _committed.resize(size_in_bits, /* in_resource_area */ false); if (_special) { - _needs_zeroing.resize(size_in_bits, /* in_resource_area */ false); + _dirty.resize(size_in_bits, /* in_resource_area */ false); } return true; @@ -88,7 +88,7 @@ _executable = false; _page_size = 0; _committed.resize(0, false); - _needs_zeroing.resize(0, false); + _dirty.resize(0, false); } size_t G1PageBasedVirtualSpace::committed_size() const { @@ -133,12 +133,10 @@ uintptr_t end = start + size_in_pages; if (_special) { - // When the memory is _special it is not really uncommitted. _needs_zeroing is - // used to keep track if the current committed range contains pages that are all - // zeroed or not. - if (_needs_zeroing.get_next_one_offset(start,end) < end) { + // Check for dirty pages and update zero_filled if any found. + if (_dirty.get_next_one_offset(start,end) < end) { zero_filled = false; - _needs_zeroing.clear_range(start, end); + _dirty.clear_range(start, end); } } else { os::commit_memory_or_exit(page_start(start), byte_size_for_pages(size_in_pages), _executable, @@ -156,8 +154,9 @@ guarantee(is_area_committed(start, size_in_pages), "checking"); if (_special) { - // Mark that memory needs to be cleared if committed again. - _needs_zeroing.set_range(start, start + size_in_pages); + // Mark that memory is dirty. If committed again the memory might + // need to be cleared explicitly. + _dirty.set_range(start, start + size_in_pages); } else { os::uncommit_memory(page_start(start), byte_size_for_pages(size_in_pages)); } --- old/src/share/vm/gc_implementation/g1/g1PageBasedVirtualSpace.hpp 2015-01-09 12:22:06.762584526 +0100 +++ new/src/share/vm/gc_implementation/g1/g1PageBasedVirtualSpace.hpp 2015-01-09 12:22:06.634584524 +0100 @@ -49,9 +49,11 @@ // Bitmap used for verification of commit/uncommit operations. BitMap _committed; - // For _special spaces we need to keep track if the memory needs to be zeroed - // after commit or not. - BitMap _needs_zeroing; + // Bitmap used to keep track of which pages are dirty or not for _special + // spaces. This is needed because for those spaces the underlying memory + // will only be zero filled the first time it is committed. Calls to commit + // will use this bitmap and return whether or not the memory is zero filled. + BitMap _dirty; // Indicates that the entire space has been committed and pinned in memory, // os::commit_memory() or os::uncommit_memory() have no function.