Skip to content

Commit

Permalink
8319724: [Lilliput] ParallelGC: Forwarded objects found during heap i…
Browse files Browse the repository at this point in the history
…nspection

Backport-of: 0568386e062474b1fc31e2e7106db0079ded7d76
  • Loading branch information
rkennke committed Nov 9, 2023
1 parent 1e3f0fc commit 28fc5f2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
31 changes: 28 additions & 3 deletions src/hotspot/share/gc/parallel/mutableSpace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,36 @@ void MutableSpace::oop_iterate(OopIterateClosure* cl) {
}
}

void MutableSpace::object_iterate(ObjectClosure* cl) {
template<bool COMPACT_HEADERS>
void MutableSpace::object_iterate_impl(ObjectClosure* cl) {
HeapWord* p = bottom();
while (p < top()) {
cl->do_object(cast_to_oop(p));
p += cast_to_oop(p)->size();
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);
p += obj->size();
} else {
assert(obj->forwardee() != obj, "must not be self-forwarded");
if (COMPACT_HEADERS) {
// It is safe to use the forwardee here. Parallel GC only uses
// header-based forwarding during promotion. Full GC doesn't
// use the object header for forwarding at all.
p += obj->forwardee()->size();
} else {
p += obj->size();
}
}
}
}

void MutableSpace::object_iterate(ObjectClosure* cl) {
if (UseCompactObjectHeaders) {
object_iterate_impl<true>(cl);
} else {
object_iterate_impl<false>(cl);
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/gc/parallel/mutableSpace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ class MutableSpace: public CHeapObj<mtGC> {
void set_last_setup_region(MemRegion mr) { _last_setup_region = mr; }
MemRegion last_setup_region() const { return _last_setup_region; }

template<bool COMPACT_HEADERS>
void object_iterate_impl(ObjectClosure* cl);

public:
virtual ~MutableSpace();
MutableSpace(size_t page_size);
Expand Down

0 comments on commit 28fc5f2

Please sign in to comment.