Skip to content

Commit

Permalink
More touch-ups, fix Shenandoah oop iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
rkennke committed Sep 10, 2024
1 parent 6b27782 commit 5da250c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
7 changes: 5 additions & 2 deletions src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,11 @@ class ShenandoahVerifyOopClosure : public BasicOopIterateClosure {
*/
void verify_oops_from(oop obj) {
_loc = obj;
Klass* klass = ShenandoahForwarding::klass(obj);
obj->oop_iterate_backwards(this, klass);
// oop_iterate() can not deal with forwarded objects, because
// it needs to load klass(), which may be overridden by the
// forwarding pointer.
oop fwd = ShenandoahForwarding::get_forwardee_raw(obj);
fwd->oop_iterate(this);
_loc = nullptr;
}

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/oops/oop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ bool oopDesc::is_objArray_noinline() const { return is_objArray(); }
bool oopDesc::is_typeArray_noinline() const { return is_typeArray(); }

bool oopDesc::has_klass_gap() {
// Only has a klass gap when compressed class pointers are used.
// Except when using compact headers.
// Only has a klass gap when compressed class pointers are used and not
// using compact headers.
return UseCompressedClassPointers && !UseCompactObjectHeaders;
}

Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/oops/oop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ class oopDesc {
// For klass field compression
static inline void set_klass_gap(HeapWord* mem, int z);

// size of object header, aligned to platform wordSize
// Size of object header, aligned to platform wordSize
static int header_size() {
if (UseCompactObjectHeaders) {
return sizeof(markWord) / HeapWordSize;
} else {
return sizeof(oopDesc) / HeapWordSize;
return sizeof(oopDesc) / HeapWordSize;
}
}

Expand Down Expand Up @@ -337,7 +337,7 @@ class oopDesc {
// of LoadNKlass instructions. This value could be any value that is not a valid
// field offset. Use an offset halfway into the markWord, as the markWord is never
// partially loaded from C2.
return mark_offset_in_bytes() + sizeof(markWord) / 2;
return 4;
} else
#endif
{
Expand Down
6 changes: 5 additions & 1 deletion src/hotspot/share/oops/oop.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ bool oopDesc::is_self_forwarded() const {

// Used by scavengers
void oopDesc::forward_to(oop p) {
assert(cast_from_oop<oopDesc*>(p) != this,
"must not be used for self-forwarding, use forward_to_self() instead");
markWord m = markWord::encode_pointer_as_mark(p);
assert(m.decode_pointer() == p, "encoding must be reversible");
set_mark(m);
Expand All @@ -312,6 +314,8 @@ oop oopDesc::cas_set_forwardee(markWord new_mark, markWord compare, atomic_memor
}

oop oopDesc::forward_to_atomic(oop p, markWord compare, atomic_memory_order order) {
assert(cast_from_oop<oopDesc*>(p) != this,
"must not be used for self-forwarding, use forward_to_self_atomic() instead");
markWord m = markWord::encode_pointer_as_mark(p);
assert(forwardee(m) == p, "encoding must be reversible");
return cas_set_forwardee(m, compare, order);
Expand Down Expand Up @@ -398,7 +402,7 @@ void oopDesc::oop_iterate_backwards(OopClosureType* cl) {
template <typename OopClosureType>
void oopDesc::oop_iterate_backwards(OopClosureType* cl, Klass* k) {
// In this assert, we cannot safely access the Klass* with compact headers.
assert(UseCompactObjectHeaders || k == klass(), "wrong klass");
assert(k == klass(), "wrong klass");
OopIteratorClosureDispatch::oop_oop_iterate_backwards(cl, this, k);
}

Expand Down

0 comments on commit 5da250c

Please sign in to comment.