Mercurial > hg > graal-jvmci-8
comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp @ 20305:755930f931e3
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 | b0c374311c4e |
children | eec72fa4b108 |
comparison
equal
deleted
inserted
replaced
20304:a22acf6d7598 | 20305:755930f931e3 |
---|---|
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(const T addr) const { | 52 G1CollectedHeap::heap_region_containing(const T addr) const { |
46 HeapRegion* hr = _hrs.addr_to_region((HeapWord*) addr); | 53 HeapRegion* hr = _hrs.addr_to_region((HeapWord*) addr); |
47 // hr can be null if addr in perm_gen | 54 // hr can be null if addr in perm_gen |
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 |
288 else return true; | 306 else return true; |
289 } | 307 } |
290 else return is_obj_ill(obj, hr); | 308 else return is_obj_ill(obj, hr); |
291 } | 309 } |
292 | 310 |
311 inline void G1CollectedHeap::set_humongous_is_live(oop obj) { | |
312 uint region = addr_to_region((HeapWord*)obj); | |
313 // We not only set the "live" flag in the humongous_is_live table, but also | |
314 // reset the entry in the _in_cset_fast_test table so that subsequent references | |
315 // to the same humongous object do not go into the slow path again. | |
316 // This is racy, as multiple threads may at the same time enter here, but this | |
317 // is benign. | |
318 // During collection we only ever set the "live" flag, and only ever clear the | |
319 // entry in the in_cset_fast_table. | |
320 // We only ever evaluate the contents of these tables (in the VM thread) after | |
321 // having synchronized the worker threads with the VM thread, or in the same | |
322 // thread (i.e. within the VM thread). | |
323 if (!_humongous_is_live.is_live(region)) { | |
324 _humongous_is_live.set_live(region); | |
325 _in_cset_fast_test.clear_humongous(region); | |
326 } | |
327 } | |
328 | |
293 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP | 329 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP |