8328075: Shenandoah: Avoid forwarding when objects don't move in full-GC

Reviewed-by: wkemper, shade, kdnilsen, ysr
This commit is contained in:
Roman Kennke 2024-03-15 11:08:21 +00:00
parent 5249cc0a79
commit 80ccc989a8

View File

@ -364,11 +364,13 @@ public:
_compact_point = _to_region->bottom();
}
// Object fits into current region, record new location:
// Object fits into current region, record new location, if object does not move:
assert(_compact_point + obj_size <= _to_region->end(), "must fit");
shenandoah_assert_not_forwarded(nullptr, p);
_preserved_marks->push_if_necessary(p, p->mark());
p->forward_to(cast_to_oop(_compact_point));
if (_compact_point != cast_from_oop<HeapWord*>(p)) {
_preserved_marks->push_if_necessary(p, p->mark());
p->forward_to(cast_to_oop(_compact_point));
}
_compact_point += obj_size;
}
};
@ -864,6 +866,7 @@ public:
if (p->is_forwarded()) {
HeapWord* compact_from = cast_from_oop<HeapWord*>(p);
HeapWord* compact_to = cast_from_oop<HeapWord*>(p->forwardee());
assert(compact_from != compact_to, "Forwarded object should move");
Copy::aligned_conjoint_words(compact_from, compact_to, size);
oop new_obj = cast_to_oop(compact_to);