comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp @ 6796:07a6e56a6936

8027959: Early reclamation of large objects in G1 Summary: Try to reclaim humongous objects at every young collection after doing a conservative estimate of its liveness. Reviewed-by: brutisso, mgerdin
author tschatzl
date Wed, 23 Jul 2014 09:03:32 +0200
parents 1b9686c03509
children 6c9cd9128efb
comparison
equal deleted inserted replaced
27:32df2cf1542f 28:07d332839a15
38 // Inline functions for G1CollectedHeap 38 // Inline functions for G1CollectedHeap
39 39
40 // Return the region with the given index. It assumes the index is valid. 40 // Return the region with the given index. It assumes the index is valid.
41 inline HeapRegion* G1CollectedHeap::region_at(uint index) const { return _hrs.at(index); } 41 inline HeapRegion* G1CollectedHeap::region_at(uint index) const { return _hrs.at(index); }
42 42
43 inline uint G1CollectedHeap::addr_to_region(HeapWord* addr) const {
44 assert(is_in_reserved(addr),
45 err_msg("Cannot calculate region index for address "PTR_FORMAT" that is outside of the heap ["PTR_FORMAT", "PTR_FORMAT")",
46 p2i(addr), p2i(_reserved.start()), p2i(_reserved.end())));
47 return (uint)(pointer_delta(addr, _reserved.start(), sizeof(uint8_t)) >> HeapRegion::LogOfHRGrainBytes);
48 }
49
43 template <class T> 50 template <class T>
44 inline HeapRegion* 51 inline HeapRegion*
45 G1CollectedHeap::heap_region_containing_raw(const T addr) const { 52 G1CollectedHeap::heap_region_containing_raw(const T addr) const {
46 assert(addr != NULL, "invariant"); 53 assert(addr != NULL, "invariant");
47 assert(_g1_reserved.contains((const void*) addr), 54 assert(_g1_reserved.contains((const void*) addr),
170 177
171 inline bool G1CollectedHeap::isMarkedNext(oop obj) const { 178 inline bool G1CollectedHeap::isMarkedNext(oop obj) const {
172 return _cm->nextMarkBitMap()->isMarked((HeapWord *)obj); 179 return _cm->nextMarkBitMap()->isMarked((HeapWord *)obj);
173 } 180 }
174 181
175
176 // This is a fast test on whether a reference points into the 182 // This is a fast test on whether a reference points into the
177 // collection set or not. Assume that the reference 183 // collection set or not. Assume that the reference
178 // points into the heap. 184 // points into the heap.
179 inline bool G1CollectedHeap::in_cset_fast_test(oop obj) { 185 inline bool G1CollectedHeap::is_in_cset(oop obj) {
180 bool ret = _in_cset_fast_test.get_by_address((HeapWord*)obj); 186 bool ret = _in_cset_fast_test.is_in_cset((HeapWord*)obj);
181 // let's make sure the result is consistent with what the slower 187 // let's make sure the result is consistent with what the slower
182 // test returns 188 // test returns
183 assert( ret || !obj_in_cs(obj), "sanity"); 189 assert( ret || !obj_in_cs(obj), "sanity");
184 assert(!ret || obj_in_cs(obj), "sanity"); 190 assert(!ret || obj_in_cs(obj), "sanity");
185 return ret; 191 return ret;
192 }
193
194 bool G1CollectedHeap::is_in_cset_or_humongous(const oop obj) {
195 return _in_cset_fast_test.is_in_cset_or_humongous((HeapWord*)obj);
196 }
197
198 G1CollectedHeap::in_cset_state_t G1CollectedHeap::in_cset_state(const oop obj) {
199 return _in_cset_fast_test.at((HeapWord*)obj);
200 }
201
202 void G1CollectedHeap::register_humongous_region_with_in_cset_fast_test(uint index) {
203 _in_cset_fast_test.set_humongous(index);
186 } 204 }
187 205
188 #ifndef PRODUCT 206 #ifndef PRODUCT
189 // Support for G1EvacuationFailureALot 207 // Support for G1EvacuationFailureALot
190 208
286 return false; 304 return false;
287 } 305 }
288 return is_obj_ill(obj, heap_region_containing(obj)); 306 return is_obj_ill(obj, heap_region_containing(obj));
289 } 307 }
290 308
309 inline void G1CollectedHeap::set_humongous_is_live(oop obj) {
310 uint region = addr_to_region((HeapWord*)obj);
311 // We not only set the "live" flag in the humongous_is_live table, but also
312 // reset the entry in the _in_cset_fast_test table so that subsequent references
313 // to the same humongous object do not go into the slow path again.
314 // This is racy, as multiple threads may at the same time enter here, but this
315 // is benign.
316 // During collection we only ever set the "live" flag, and only ever clear the
317 // entry in the in_cset_fast_table.
318 // We only ever evaluate the contents of these tables (in the VM thread) after
319 // having synchronized the worker threads with the VM thread, or in the same
320 // thread (i.e. within the VM thread).
321 if (!_humongous_is_live.is_live(region)) {
322 _humongous_is_live.set_live(region);
323 _in_cset_fast_test.clear_humongous(region);
324 }
325 }
326
291 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP 327 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP