Skip to content

Commit fdaa2c4

Browse files
committed
8309306: G1: Move is_obj_dead from HeapRegion to G1CollectedHeap
Reviewed-by: tschatzl, iwalulya
1 parent 4bc6bbb commit fdaa2c4

File tree

4 files changed

+19
-30
lines changed

4 files changed

+19
-30
lines changed

src/hotspot/share/gc/g1/g1CollectedHeap.inline.hpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,19 @@ inline bool G1CollectedHeap::is_obj_filler(const oop obj) {
247247
}
248248

249249
inline bool G1CollectedHeap::is_obj_dead(const oop obj, const HeapRegion* hr) const {
250-
return hr->is_obj_dead(obj, hr->parsable_bottom());
250+
if (hr->is_in_parsable_area(obj)) {
251+
// This object is in the parsable part of the heap, live unless scrubbed.
252+
return is_obj_filler(obj);
253+
} else {
254+
// From Remark until a region has been concurrently scrubbed, parts of the
255+
// region is not guaranteed to be parsable. Use the bitmap for liveness.
256+
return !concurrent_mark()->mark_bitmap()->is_marked(obj);
257+
}
251258
}
252259

253260
inline bool G1CollectedHeap::is_obj_dead(const oop obj) const {
254-
if (obj == nullptr) {
255-
return false;
256-
}
261+
assert(obj != nullptr, "precondition");
262+
257263
return is_obj_dead(obj, heap_region_containing(obj));
258264
}
259265

src/hotspot/share/gc/g1/g1HeapVerifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class VerifyObjsInRegionClosure: public ObjectClosure {
224224
}
225225

226226
o->oop_iterate(&isLive);
227-
if (_hr->obj_in_unparsable_area(o, _hr->parsable_bottom())) {
227+
if (!_hr->is_in_parsable_area(o)) {
228228
size_t obj_size = o->size();
229229
_live_bytes += (obj_size * HeapWordSize);
230230
}

src/hotspot/share/gc/g1/heapRegion.hpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,6 @@ class HeapRegion : public CHeapObj<mtGC> {
182182
// All allocated blocks are occupied by objects in a HeapRegion.
183183
bool block_is_obj(const HeapWord* p, HeapWord* pb) const;
184184

185-
// Returns whether the given object is dead based on the given parsable_bottom (pb).
186-
// For an object to be considered dead it must be below pb and scrubbed.
187-
bool is_obj_dead(oop obj, HeapWord* pb) const;
188-
189185
// Returns the object size for all valid block starts. If parsable_bottom (pb)
190186
// is given, calculates the block size based on that parsable_bottom, not the
191187
// current value of this HeapRegion.
@@ -524,9 +520,9 @@ class HeapRegion : public CHeapObj<mtGC> {
524520

525521
void record_surv_words_in_group(size_t words_survived);
526522

527-
// Determine if an object is in the parsable or the to-be-scrubbed area.
528-
inline static bool obj_in_parsable_area(const HeapWord* addr, HeapWord* pb);
529-
inline static bool obj_in_unparsable_area(oop obj, HeapWord* pb);
523+
// Determine if an address is in the parsable or the to-be-scrubbed area.
524+
inline bool is_in_parsable_area(const void* const addr) const;
525+
inline static bool is_in_parsable_area(const void* const addr, const void* const pb);
530526

531527
bool obj_allocated_since_marking_start(oop obj) const {
532528
return cast_from_oop<HeapWord*>(obj) >= top_at_mark_start();

src/hotspot/share/gc/g1/heapRegion.inline.hpp

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ inline HeapWord* HeapRegion::block_start(const void* addr, HeapWord* const pb) c
109109
return advance_to_block_containing_addr(addr, pb, first_block);
110110
}
111111

112-
inline bool HeapRegion::obj_in_unparsable_area(oop obj, HeapWord* const pb) {
113-
return !HeapRegion::obj_in_parsable_area(cast_from_oop<HeapWord*>(obj), pb);
112+
inline bool HeapRegion::is_in_parsable_area(const void* const addr) const {
113+
return is_in_parsable_area(addr, parsable_bottom());
114114
}
115115

116-
inline bool HeapRegion::obj_in_parsable_area(const HeapWord* addr, HeapWord* const pb) {
116+
inline bool HeapRegion::is_in_parsable_area(const void* const addr, const void* const pb) {
117117
return addr >= pb;
118118
}
119119

@@ -125,7 +125,7 @@ inline bool HeapRegion::block_is_obj(const HeapWord* const p, HeapWord* const pb
125125
assert(p >= bottom() && p < top(), "precondition");
126126
assert(!is_continues_humongous(), "p must point to block-start");
127127

128-
if (obj_in_parsable_area(p, pb)) {
128+
if (is_in_parsable_area(p, pb)) {
129129
return true;
130130
}
131131

@@ -140,19 +140,6 @@ inline bool HeapRegion::block_is_obj(const HeapWord* const p, HeapWord* const pb
140140
return is_marked_in_bitmap(cast_to_oop(p));
141141
}
142142

143-
inline bool HeapRegion::is_obj_dead(const oop obj, HeapWord* const pb) const {
144-
assert(is_in_reserved(obj), "Object " PTR_FORMAT " must be in region", p2i(obj));
145-
146-
// From Remark until a region has been concurrently scrubbed, parts of the
147-
// region is not guaranteed to be parsable. Use the bitmap for liveness.
148-
if (obj_in_unparsable_area(obj, pb)) {
149-
return !is_marked_in_bitmap(obj);
150-
}
151-
152-
// This object is in the parsable part of the heap, live unless scrubbed.
153-
return G1CollectedHeap::is_obj_filler(obj);
154-
}
155-
156143
inline HeapWord* HeapRegion::next_live_in_unparsable(G1CMBitMap* const bitmap, const HeapWord* p, HeapWord* const limit) const {
157144
return bitmap->get_next_marked_addr(p, limit);
158145
}
@@ -450,7 +437,7 @@ inline HeapWord* HeapRegion::oops_on_memregion_iterate(MemRegion mr, Closure* cl
450437
// safepoints.
451438
//
452439
HeapWord* cur = block_start(start, pb);
453-
if (!obj_in_parsable_area(start, pb)) {
440+
if (!is_in_parsable_area(start, pb)) {
454441
// Limit the MemRegion to the part of the area to scan to the unparsable one as using the bitmap
455442
// is slower than blindly iterating the objects.
456443
MemRegion mr_in_unparsable(mr.start(), MIN2(mr.end(), pb));

0 commit comments

Comments
 (0)