8319376: ParallelGC: Forwarded objects found during heap inspection

Co-authored-by: Albert Mingkun Yang <ayang@openjdk.org>
Reviewed-by: ayang, tschatzl
This commit is contained in:
Roman Kennke 2023-11-08 15:18:40 +00:00
parent 7c7f8ea30d
commit 59e9981ec2

View File

@ -235,7 +235,18 @@ void MutableSpace::oop_iterate(OopIterateClosure* cl) {
void MutableSpace::object_iterate(ObjectClosure* cl) {
HeapWord* p = bottom();
while (p < top()) {
cl->do_object(cast_to_oop(p));
oop obj = cast_to_oop(p);
// When promotion-failure occurs during Young GC, eden/from space is not cleared,
// so we can encounter objects with "forwarded" markword.
// They are essentially dead, so skipping them
if (!obj->is_forwarded()) {
cl->do_object(obj);
}
#ifdef ASSERT
else {
assert(obj->forwardee() != obj, "must not be self-forwarded");
}
#endif
p += cast_to_oop(p)->size();
}
}