Mercurial > hg > truffle
diff src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp @ 3766:c3f1170908be
7045330: G1: Simplify/fix the HeapRegionSeq class
7042285: G1: native memory leak during humongous object allocation
6804436: G1: heap region indices should be size_t
Summary: A series of fixes and improvements to the HeapRegionSeq class: a) replace the _regions growable array with a standard C array, b) avoid de-allocating / re-allocating HeapRegion instances when the heap shrinks / grows (fix for 7042285), c) introduce fast method to map address to HeapRegion via a "biased" array pointer, d) embed the _hrs object in G1CollectedHeap, instead of pointing to it via an indirection, e) assume that all the regions added to the HeapRegionSeq instance are contiguous, f) replace int's with size_t's for indexes (and expand that to HeapRegion as part of 6804436), g) remove unnecessary / unused methods, h) rename a couple of fields (_alloc_search_start and _seq_bottom), i) fix iterate_from() not to always start from index 0 irrespective of the region passed to it, j) add a verification method to check the HeapRegionSeq assumptions, k) always call the wrappers for _hrs.iterate(), _hrs_length(), and _hrs.at() from G1CollectedHeap, not those methods directly, and l) unify the code that expands the sequence (by either re-using or creating a new HeapRegion) and make it robust wrt to a HeapRegion allocation failing.
Reviewed-by: stefank, johnc, brutisso
author | tonyp |
---|---|
date | Fri, 10 Jun 2011 13:16:40 -0400 |
parents | abdfc822206f |
children | f44782f04dd4 |
line wrap: on
line diff
--- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp Wed Jun 08 21:48:38 2011 -0400 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp Fri Jun 10 13:16:40 2011 -0400 @@ -34,9 +34,10 @@ // Inline functions for G1CollectedHeap +template <class T> inline HeapRegion* -G1CollectedHeap::heap_region_containing(const void* addr) const { - HeapRegion* hr = _hrs->addr_to_region(addr); +G1CollectedHeap::heap_region_containing(const T addr) const { + HeapRegion* hr = _hrs.addr_to_region((HeapWord*) addr); // hr can be null if addr in perm_gen if (hr != NULL && hr->continuesHumongous()) { hr = hr->humongous_start_region(); @@ -44,19 +45,16 @@ return hr; } +template <class T> inline HeapRegion* -G1CollectedHeap::heap_region_containing_raw(const void* addr) const { - assert(_g1_reserved.contains(addr), "invariant"); - size_t index = pointer_delta(addr, _g1_reserved.start(), 1) - >> HeapRegion::LogOfHRGrainBytes; - - HeapRegion* res = _hrs->at(index); - assert(res == _hrs->addr_to_region(addr), "sanity"); +G1CollectedHeap::heap_region_containing_raw(const T addr) const { + assert(_g1_reserved.contains((const void*) addr), "invariant"); + HeapRegion* res = _hrs.addr_to_region_unsafe((HeapWord*) addr); return res; } inline bool G1CollectedHeap::obj_in_cs(oop obj) { - HeapRegion* r = _hrs->addr_to_region(obj); + HeapRegion* r = _hrs.addr_to_region((HeapWord*) obj); return r != NULL && r->in_collection_set(); }