Skip to content

Commit

Permalink
8290221: G1: Merge multiple calls of get_next_marked_addr in HeapRegi…
Browse files Browse the repository at this point in the history
…on::oops_on_memregion_iterate_in_unparsable

Reviewed-by: tschatzl, iwalulya
  • Loading branch information
albertnetymk committed Jul 14, 2022
1 parent be58cbc commit c7c2066
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/hotspot/share/gc/g1/heapRegion.inline.hpp
Expand Up @@ -398,32 +398,29 @@ HeapWord* HeapRegion::do_oops_on_memregion_in_humongous(MemRegion mr,
template <class Closure>
inline HeapWord* HeapRegion::oops_on_memregion_iterate_in_unparsable(MemRegion mr, HeapWord* block_start, Closure* cl) {
HeapWord* const start = mr.start();
// Only scan until parsable_bottom.
HeapWord* const end = mr.end();

G1CMBitMap* bitmap = G1CollectedHeap::heap()->concurrent_mark()->mark_bitmap();

HeapWord* cur = block_start;
// The passed block_start may point at a dead block - during the concurrent phase the scrubbing
// may have written a (partial) filler object header exactly crossing that perceived object
// start; during GC pause this might just be a dead object that we should not read from.
// So we have to advance to the next live object (using the bitmap) to be able to start
// the following iteration over the objects.
if (!bitmap->is_marked(cur)) {
cur = bitmap->get_next_marked_addr(cur, end);
}

while (cur != end) {
assert(bitmap->is_marked(cur), "must be");
while (true) {
// Using bitmap to locate marked objs in the unparsable area
cur = bitmap->get_next_marked_addr(cur, end);
if (cur == end) {
return end;
}
assert(bitmap->is_marked(cur), "inv");

oop obj = cast_to_oop(cur);
assert(oopDesc::is_oop(obj, true), "Not an oop at " PTR_FORMAT, p2i(cur));

cur += obj->size();
bool is_precise = false;
bool is_precise;

if (!obj->is_objArray() || (cast_from_oop<HeapWord*>(obj) >= start && cur <= end)) {
obj->oop_iterate(cl);
is_precise = false;
} else {
obj->oop_iterate(cl, mr);
is_precise = true;
Expand All @@ -432,10 +429,7 @@ inline HeapWord* HeapRegion::oops_on_memregion_iterate_in_unparsable(MemRegion m
if (cur >= end) {
return is_precise ? end : cur;
}

cur = bitmap->get_next_marked_addr(cur, end);
}
return end;
}

// Applies cl to all reference fields of live objects in mr in non-humongous regions.
Expand Down

1 comment on commit c7c2066

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.