8075249: Cleanup forward_to_atomic and ClaimedForwardPtr

Reviewed-by: kbarrett, brutisso
This commit is contained in:
Stefan Karlsson 2015-03-17 15:53:55 +01:00
parent 366bf9ff09
commit 28adfbf0be
5 changed files with 29 additions and 36 deletions

View file

@ -630,6 +630,30 @@ inline bool oopDesc::cas_forward_to(oop p, markOop compare) {
return cas_set_mark(m, compare) == compare;
}
#if INCLUDE_ALL_GCS
inline oop oopDesc::forward_to_atomic(oop p) {
markOop oldMark = mark();
markOop forwardPtrMark = markOopDesc::encode_pointer_as_mark(p);
markOop curMark;
assert(forwardPtrMark->decode_pointer() == p, "encoding must be reversable");
assert(sizeof(markOop) == sizeof(intptr_t), "CAS below requires this.");
while (!oldMark->is_marked()) {
curMark = (markOop)Atomic::cmpxchg_ptr(forwardPtrMark, &_mark, oldMark);
assert(is_forwarded(), "object should have been forwarded");
if (curMark == oldMark) {
return NULL;
}
// If the CAS was unsuccessful then curMark->is_marked()
// should return true as another thread has CAS'd in another
// forwarding pointer.
oldMark = curMark;
}
return forwardee();
}
#endif
// Note that the forwardee is not the same thing as the displaced_mark.
// The forwardee is used when copying during scavenge and mark-sweep.
// It does need to clear the low two locking- and GC-related bits.