< prev index next >

src/hotspot/cpu/x86/macroAssembler_x86.cpp

Print this page
rev 56046 : v2.00 -> v2.05 (CR5/v2.05/8-for-jdk13) patches combined into one; merge with 8229212.patch; merge with jdk-14+11; merge with 8230184.patch.

@@ -1837,12 +1837,32 @@
   lock();
   cmpxchgptr(r15_thread, Address(scrReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
   // Unconditionally set box->_displaced_header = markWord::unused_mark().
   // Without cast to int32_t movptr will destroy r10 which is typically obj.
   movptr(Address(boxReg, 0), (int32_t)intptr_t(markWord::unused_mark().value()));
+  // The following code to verify that the object field still refers
+  // to the object we are trying to lock is not needed with safepoint
+  // based deflation. It is also not needed with async deflation when
+  // the DEFLATER_MARKER is allowed to linger in the owner field in an
+  // async deflated ObjectMonitor until replaced by the next owner value.
+  // We keep this code as a sanity check against bugs in other parts
+  // of the async deflation mechanism.
+  //
+  // If we weren't able to swing _owner from NULL to r15_thread
+  // then take the slow path.
+  jccb(Assembler::notZero, DONE_LABEL);
+  // r15_thread is now the owner so verify that the ObjectMonitor
+  // still refers to the same object.
+  cmpptr(objReg, Address(scrReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(object)));
+  // The ObjectMonitor still refers to the same object so
+  // r15_thread's ownership is valid.
+  jccb(Assembler::zero, DONE_LABEL);
+  // The ObjectMonitor does not refer to the same object so
+  // drop ownership.
+  movptr(Address(scrReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)), NULL_WORD);
   // Intentional fall-through into DONE_LABEL ...
-  // Propagate ICC.ZF from CAS above into DONE_LABEL.
+  // Propagate ICC.ZF from cmpptr() above into DONE_LABEL.
 #endif // _LP64
 #if INCLUDE_RTM_OPT
   } // use_rtm()
 #endif
   // DONE_LABEL is a hot target - we'd really like to place it at the
< prev index next >