Skip to content

Commit ccdb9f1

Browse files
committed
8278482: G1: Improve HeapRegion::block_is_obj
Reviewed-by: sjohanss, tschatzl, mli
1 parent 8b5ff4b commit ccdb9f1

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,8 @@ void HeapRegion::verify(VerifyOption vo,
655655
VerifyLiveClosure vl_cl(g1h, vo);
656656
VerifyRemSetClosure vr_cl(g1h, vo);
657657
bool is_region_humongous = is_humongous();
658+
// We cast p to an oop, so region-bottom must be an obj-start.
659+
assert(!is_region_humongous || is_starts_humongous(), "invariant");
658660
size_t object_num = 0;
659661
while (p < top()) {
660662
oop obj = cast_to_oop(p);

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,8 @@ inline bool HeapRegion::is_obj_dead_with_size(const oop obj, const G1CMBitMap* c
104104
}
105105

106106
inline bool HeapRegion::block_is_obj(const HeapWord* p) const {
107-
G1CollectedHeap* g1h = G1CollectedHeap::heap();
108-
109-
if (!this->is_in(p)) {
110-
assert(is_continues_humongous(), "This case can only happen for humongous regions");
111-
return (p == humongous_start_region()->bottom());
112-
}
107+
assert(p >= bottom() && p < top(), "precondition");
108+
assert(!is_continues_humongous(), "p must point to block-start");
113109
// When class unloading is enabled it is not safe to only consider top() to conclude if the
114110
// given pointer is a valid object. The situation can occur both for class unloading in a
115111
// Full GC and during a concurrent cycle.
@@ -118,9 +114,9 @@ inline bool HeapRegion::block_is_obj(const HeapWord* p) const {
118114
// During a concurrent cycle class unloading is done after marking is complete and objects
119115
// for the unloaded classes will be stale until the regions are collected.
120116
if (ClassUnloading) {
121-
return !g1h->is_obj_dead(cast_to_oop(p), this);
117+
return !G1CollectedHeap::heap()->is_obj_dead(cast_to_oop(p), this);
122118
}
123-
return p < top();
119+
return true;
124120
}
125121

126122
inline size_t HeapRegion::block_size_using_bitmap(const HeapWord* addr, const G1CMBitMap* const prev_bitmap) const {

0 commit comments

Comments
 (0)