comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp @ 20335:eec72fa4b108

8040722: G1: Clean up usages of heap_region_containing Reviewed-by: tschatzl, jmasa
author brutisso
date Tue, 19 Aug 2014 12:39:06 +0200
parents a3953c777565
children 6701abbc4441
comparison
equal deleted inserted replaced
20334:ff3169f25621 20335:eec72fa4b108
47 return (uint)(pointer_delta(addr, _reserved.start(), sizeof(uint8_t)) >> HeapRegion::LogOfHRGrainBytes); 47 return (uint)(pointer_delta(addr, _reserved.start(), sizeof(uint8_t)) >> HeapRegion::LogOfHRGrainBytes);
48 } 48 }
49 49
50 template <class T> 50 template <class T>
51 inline HeapRegion* 51 inline HeapRegion*
52 G1CollectedHeap::heap_region_containing(const T addr) const { 52 G1CollectedHeap::heap_region_containing_raw(const T addr) const {
53 HeapRegion* hr = _hrs.addr_to_region((HeapWord*) addr); 53 assert(addr != NULL, "invariant");
54 // hr can be null if addr in perm_gen 54 assert(_g1_reserved.contains((const void*) addr),
55 if (hr != NULL && hr->continuesHumongous()) { 55 err_msg("Address "PTR_FORMAT" is outside of the heap ranging from ["PTR_FORMAT" to "PTR_FORMAT")",
56 hr = hr->humongous_start_region(); 56 p2i((void*)addr), p2i(_g1_reserved.start()), p2i(_g1_reserved.end())));
57 } 57 return _hrs.addr_to_region((HeapWord*) addr);
58 return hr;
59 } 58 }
60 59
61 template <class T> 60 template <class T>
62 inline HeapRegion* 61 inline HeapRegion*
63 G1CollectedHeap::heap_region_containing_raw(const T addr) const { 62 G1CollectedHeap::heap_region_containing(const T addr) const {
64 assert(_g1_reserved.contains((const void*) addr), "invariant"); 63 HeapRegion* hr = heap_region_containing_raw(addr);
65 HeapRegion* res = _hrs.addr_to_region_unsafe((HeapWord*) addr); 64 if (hr->continuesHumongous()) {
66 return res; 65 return hr->humongous_start_region();
66 }
67 return hr;
67 } 68 }
68 69
69 inline void G1CollectedHeap::reset_gc_time_stamp() { 70 inline void G1CollectedHeap::reset_gc_time_stamp() {
70 _gc_time_stamp = 0; 71 _gc_time_stamp = 0;
71 OrderAccess::fence(); 72 OrderAccess::fence();
152 153
153 // Assign the containing region to containing_hr so that we don't 154 // Assign the containing region to containing_hr so that we don't
154 // have to keep calling heap_region_containing_raw() in the 155 // have to keep calling heap_region_containing_raw() in the
155 // asserts below. 156 // asserts below.
156 DEBUG_ONLY(HeapRegion* containing_hr = heap_region_containing_raw(start);) 157 DEBUG_ONLY(HeapRegion* containing_hr = heap_region_containing_raw(start);)
157 assert(containing_hr != NULL && start != NULL && word_size > 0, 158 assert(word_size > 0, "pre-condition");
158 "pre-condition");
159 assert(containing_hr->is_in(start), "it should contain start"); 159 assert(containing_hr->is_in(start), "it should contain start");
160 assert(containing_hr->is_young(), "it should be young"); 160 assert(containing_hr->is_young(), "it should be young");
161 assert(!containing_hr->isHumongous(), "it should not be humongous"); 161 assert(!containing_hr->isHumongous(), "it should not be humongous");
162 162
163 HeapWord* end = start + word_size; 163 HeapWord* end = start + word_size;
275 } 275 }
276 } 276 }
277 #endif // #ifndef PRODUCT 277 #endif // #ifndef PRODUCT
278 278
279 inline bool G1CollectedHeap::is_in_young(const oop obj) { 279 inline bool G1CollectedHeap::is_in_young(const oop obj) {
280 HeapRegion* hr = heap_region_containing(obj); 280 if (obj == NULL) {
281 return hr != NULL && hr->is_young(); 281 return false;
282 }
283 return heap_region_containing(obj)->is_young();
282 } 284 }
283 285
284 // We don't need barriers for initializing stores to objects 286 // We don't need barriers for initializing stores to objects
285 // in the young gen: for the SATB pre-barrier, there is no 287 // in the young gen: for the SATB pre-barrier, there is no
286 // pre-value that needs to be remembered; for the remembered-set 288 // pre-value that needs to be remembered; for the remembered-set
289 inline bool G1CollectedHeap::can_elide_initializing_store_barrier(oop new_obj) { 291 inline bool G1CollectedHeap::can_elide_initializing_store_barrier(oop new_obj) {
290 return is_in_young(new_obj); 292 return is_in_young(new_obj);
291 } 293 }
292 294
293 inline bool G1CollectedHeap::is_obj_dead(const oop obj) const { 295 inline bool G1CollectedHeap::is_obj_dead(const oop obj) const {
294 const HeapRegion* hr = heap_region_containing(obj); 296 if (obj == NULL) {
295 if (hr == NULL) { 297 return false;
296 if (obj == NULL) return false; 298 }
297 else return true; 299 return is_obj_dead(obj, heap_region_containing(obj));
298 }
299 else return is_obj_dead(obj, hr);
300 } 300 }
301 301
302 inline bool G1CollectedHeap::is_obj_ill(const oop obj) const { 302 inline bool G1CollectedHeap::is_obj_ill(const oop obj) const {
303 const HeapRegion* hr = heap_region_containing(obj); 303 if (obj == NULL) {
304 if (hr == NULL) { 304 return false;
305 if (obj == NULL) return false; 305 }
306 else return true; 306 return is_obj_ill(obj, heap_region_containing(obj));
307 }
308 else return is_obj_ill(obj, hr);
309 } 307 }
310 308
311 inline void G1CollectedHeap::set_humongous_is_live(oop obj) { 309 inline void G1CollectedHeap::set_humongous_is_live(oop obj) {
312 uint region = addr_to_region((HeapWord*)obj); 310 uint region = addr_to_region((HeapWord*)obj);
313 // We not only set the "live" flag in the humongous_is_live table, but also 311 // We not only set the "live" flag in the humongous_is_live table, but also