提交 a669d665 编写于 作者: J johnc

6994628: G1: Test gc/gctests/FinalizeTest05 fails (one live object is finalized)

Summary: The Solaris Studio 12 update 1 C++ compiler was incorrectly re-ordering the reads of an object's mark word in oopDesc::forward_to_atomic(). This opened a small window where one thread could execute the successful CAS path even though another thread had already successfully forwarded the object. This could result in an object being copied twice. The code in oopDesc::forward_to_atomic() was changed to read the mark word once.
Reviewed-by: ysr, tonyp
上级 8bbfe8dd
...@@ -118,12 +118,15 @@ inline oop oopDesc::forward_to_atomic(oop p) { ...@@ -118,12 +118,15 @@ inline oop oopDesc::forward_to_atomic(oop p) {
assert(forwardPtrMark->decode_pointer() == p, "encoding must be reversable"); assert(forwardPtrMark->decode_pointer() == p, "encoding must be reversable");
assert(sizeof(markOop) == sizeof(intptr_t), "CAS below requires this."); assert(sizeof(markOop) == sizeof(intptr_t), "CAS below requires this.");
while (!is_forwarded()) { while (!oldMark->is_marked()) {
curMark = (markOop)Atomic::cmpxchg_ptr(forwardPtrMark, &_mark, oldMark); curMark = (markOop)Atomic::cmpxchg_ptr(forwardPtrMark, &_mark, oldMark);
assert(is_forwarded(), "object should have been forwarded");
if (curMark == oldMark) { if (curMark == oldMark) {
assert(is_forwarded(), "the CAS should have succeeded.");
return NULL; 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; oldMark = curMark;
} }
return forwardee(); return forwardee();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册