8327057: Parallel: Refactor ParMarkBitMap::iterate

Reviewed-by: tschatzl, iwalulya
This commit is contained in:
Albert Mingkun Yang 2024-03-04 18:50:45 +00:00
parent f615ac4bdf
commit 045eea1130
3 changed files with 22 additions and 55 deletions

View File

@ -173,27 +173,26 @@ ParMarkBitMap::iterate(ParMarkBitMapClosure* live_closure,
// The bitmap routines require the right boundary to be word-aligned.
const idx_t search_end = align_range_end(range_end);
idx_t cur_beg = find_obj_beg(range_beg, search_end);
while (cur_beg < range_end) {
const idx_t cur_end = find_obj_end(cur_beg, search_end);
if (cur_end >= range_end) {
// The obj ends outside the range.
live_closure->set_source(bit_to_addr(cur_beg));
return incomplete;
idx_t cur_beg = range_beg;
while (true) {
cur_beg = find_obj_beg(cur_beg, search_end);
if (cur_beg >= range_end) {
break;
}
const size_t size = obj_size(cur_beg, cur_end);
const size_t size = obj_size(cur_beg);
IterationStatus status = live_closure->do_addr(bit_to_addr(cur_beg), size);
if (status != incomplete) {
assert(status == would_overflow || status == full, "sanity");
return status;
}
// Successfully processed the object; look for the next object.
cur_beg = find_obj_beg(cur_end + 1, search_end);
cur_beg += words_to_bits(size);
if (cur_beg >= range_end) {
break;
}
}
live_closure->set_source(bit_to_addr(range_end));
return complete;
}
@ -210,45 +209,41 @@ ParMarkBitMap::iterate(ParMarkBitMapClosure* live_closure,
assert(range_end <= dead_range_end, "dead range invalid");
// The bitmap routines require the right boundary to be word-aligned.
const idx_t live_search_end = align_range_end(range_end);
const idx_t dead_search_end = align_range_end(dead_range_end);
idx_t cur_beg = range_beg;
if (range_beg < range_end && is_unmarked(range_beg)) {
// The range starts with dead space. Look for the next object, then fill.
// This must be the beginning of old/eden/from/to-space, so it's must be
// large enough for a filler.
cur_beg = find_obj_beg(range_beg + 1, dead_search_end);
const idx_t dead_space_end = MIN2(cur_beg - 1, dead_range_end - 1);
const idx_t dead_space_end = cur_beg - 1;
const size_t size = obj_size(range_beg, dead_space_end);
dead_closure->do_addr(bit_to_addr(range_beg), size);
}
while (cur_beg < range_end) {
const idx_t cur_end = find_obj_end(cur_beg, live_search_end);
if (cur_end >= range_end) {
// The obj ends outside the range.
live_closure->set_source(bit_to_addr(cur_beg));
return incomplete;
}
const size_t size = obj_size(cur_beg, cur_end);
const size_t size = obj_size(cur_beg);
IterationStatus status = live_closure->do_addr(bit_to_addr(cur_beg), size);
if (status != incomplete) {
assert(status == would_overflow || status == full, "sanity");
return status;
}
const idx_t dead_space_beg = cur_beg + words_to_bits(size);
if (dead_space_beg >= dead_search_end) {
break;
}
// Look for the start of the next object.
const idx_t dead_space_beg = cur_end + 1;
cur_beg = find_obj_beg(dead_space_beg, dead_search_end);
if (cur_beg > dead_space_beg) {
// Found dead space; compute the size and invoke the dead closure.
const idx_t dead_space_end = MIN2(cur_beg - 1, dead_range_end - 1);
const size_t size = obj_size(dead_space_beg, dead_space_end);
dead_closure->do_addr(bit_to_addr(dead_space_beg), size);
const idx_t dead_space_end = cur_beg - 1;
dead_closure->do_addr(bit_to_addr(dead_space_beg),
obj_size(dead_space_beg, dead_space_end));
}
}
live_closure->set_source(bit_to_addr(range_end));
return complete;
}

View File

@ -81,10 +81,6 @@ public:
// range [live_range_beg, live_range_end). This is used to iterate over the
// compacted region of the heap. Return values:
//
// incomplete The iteration is not complete. The last object that
// begins in the range does not end in the range;
// closure->source() is set to the start of that object.
//
// complete The iteration is complete. All objects in the range
// were processed and the closure is not full;
// closure->source() is set one past the end of the range.

View File

@ -2424,12 +2424,7 @@ PSParallelCompact::update_and_deadwood_in_dense_prefix(ParCompactionManager* cm,
// Create closures and iterate.
UpdateOnlyClosure update_closure(mbm, cm, space_id);
FillClosure fill_closure(cm, space_id);
ParMarkBitMap::IterationStatus status;
status = mbm->iterate(&update_closure, &fill_closure, beg_addr, end_addr,
dense_prefix_end);
if (status == ParMarkBitMap::incomplete) {
update_closure.do_addr(update_closure.source());
}
mbm->iterate(&update_closure, &fill_closure, beg_addr, end_addr, dense_prefix_end);
}
// Mark the regions as filled.
@ -2740,25 +2735,6 @@ void PSParallelCompact::fill_region(ParCompactionManager* cm, MoveAndUpdateClosu
src_space_top);
IterationStatus status = bitmap->iterate(&closure, cur_addr, end_addr);
if (status == ParMarkBitMap::incomplete) {
// The last obj that starts in the source region does not end in the
// region.
assert(closure.source() < end_addr, "sanity");
HeapWord* const obj_beg = closure.source();
HeapWord* const range_end = MIN2(obj_beg + closure.words_remaining(),
src_space_top);
HeapWord* const obj_end = bitmap->find_obj_end(obj_beg, range_end);
if (obj_end < range_end) {
// The end was found; the entire object will fit.
status = closure.do_addr(obj_beg, bitmap->obj_size(obj_beg, obj_end));
assert(status != ParMarkBitMap::would_overflow, "sanity");
} else {
// The end was not found; the object will not fit.
assert(range_end < src_space_top, "obj cannot cross space boundary");
status = ParMarkBitMap::would_overflow;
}
}
if (status == ParMarkBitMap::would_overflow) {
// The last object did not fit. Note that interior oop updates were
// deferred, then copy enough of the object to fill the region.