Skip to content

Commit

Permalink
Make is_oop() MT-safe
Browse files Browse the repository at this point in the history
  • Loading branch information
rkennke committed Sep 11, 2024
1 parent bff4dc1 commit b6c11f7
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/hotspot/share/gc/shared/collectedHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,20 @@ bool CollectedHeap::is_oop(oop object) const {
return false;
}

// With compact headers, we can't safely access the Klass* when
// the object has been forwarded, because non-full-GC-forwarding
// temporarily overwrites the mark-word, and thus the Klass*, with
// the forwarding pointer, and here we have no way to make a
// distinction between Full-GC and regular GC forwarding.
bool can_access_klass = !UseCompactObjectHeaders || !object->is_forwarded();
if (can_access_klass && !Metaspace::contains(object->klass_without_asserts())) {
if (UseCompactObjectHeaders) {
// With compact headers, we can't safely access the Klass* when
// the object has been forwarded, because non-full-GC-forwarding
// temporarily overwrites the mark-word, and thus the Klass*, with
// the forwarding pointer, and here we have no way to make a
// distinction between Full-GC and regular GC forwarding.
markWord mark = object->mark();
if (!mark.is_forwarded()) {
Klass* klass = mark.klass();
if (!Metaspace::contains(mark.klass_without_asserts())) {
return false;
}
}
} else if (!Metaspace::contains(object->klass_without_asserts())) {
return false;
}

Expand Down

0 comments on commit b6c11f7

Please sign in to comment.