8077392: Stream fork/join tasks occasionally fail to complete
authordcubed
Mon, 04 Apr 2016 14:41:00 -0700
changeset 37250 2fecd8bdc8e9
parent 37248 11a660dbbb8e
child 37251 9fc139ad74b5
8077392: Stream fork/join tasks occasionally fail to complete 8131715: backout the fix for JDK-8079359 when JDK-8077392 is fixed Summary: Add missing BasicLock::_displaced_header init to ObjectSynchronizer::quick_enter() and re-enable Contended Locked "fast enter" bucket. Reviewed-by: gthornbr, dholmes, kvn, cvarming, acorn
hotspot/src/share/vm/runtime/sharedRuntime.cpp
hotspot/src/share/vm/runtime/synchronizer.cpp
--- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp	Mon Apr 04 12:57:48 2016 -0400
+++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp	Mon Apr 04 14:41:00 2016 -0700
@@ -1969,8 +1969,8 @@
 // Handles the uncommon case in locking, i.e., contention or an inflated lock.
 JRT_BLOCK_ENTRY(void, SharedRuntime::complete_monitor_locking_C(oopDesc* _obj, BasicLock* lock, JavaThread* thread))
   // Disable ObjectSynchronizer::quick_enter() in default config
-  // until JDK-8077392 is resolved.
-  if ((SyncFlags & 256) != 0 && !SafepointSynchronize::is_synchronizing()) {
+  // on AARCH64 until JDK-8153107 is resolved.
+  if (AARCH64_ONLY((SyncFlags & 256) != 0 &&) !SafepointSynchronize::is_synchronizing()) {
     // Only try quick_enter() if we're not trying to reach a safepoint
     // so that the calling thread reaches the safepoint more quickly.
     if (ObjectSynchronizer::quick_enter(_obj, thread, lock)) return;
--- a/hotspot/src/share/vm/runtime/synchronizer.cpp	Mon Apr 04 12:57:48 2016 -0400
+++ b/hotspot/src/share/vm/runtime/synchronizer.cpp	Mon Apr 04 14:41:00 2016 -0700
@@ -204,7 +204,7 @@
 // quick_enter() as our thread state remains _in_Java.
 
 bool ObjectSynchronizer::quick_enter(oop obj, Thread * Self,
-                                     BasicLock * Lock) {
+                                     BasicLock * lock) {
   assert(!SafepointSynchronize::is_at_safepoint(), "invariant");
   assert(Self->is_Java_thread(), "invariant");
   assert(((JavaThread *) Self)->thread_state() == _thread_in_Java, "invariant");
@@ -227,6 +227,18 @@
       return true;
     }
 
+    // This Java Monitor is inflated so obj's header will never be
+    // displaced to this thread's BasicLock. Make the displaced header
+    // non-NULL so this BasicLock is not seen as recursive nor as
+    // being locked. We do this unconditionally so that this thread's
+    // BasicLock cannot be mis-interpreted by any stack walkers. For
+    // performance reasons, stack walkers generally first check for
+    // Biased Locking in the object's header, the second check is for
+    // stack-locking in the object's header, the third check is for
+    // recursive stack-locking in the displaced header in the BasicLock,
+    // and last are the inflated Java Monitor (ObjectMonitor) checks.
+    lock->set_displaced_header(markOopDesc::unused_mark());
+
     if (owner == NULL &&
         Atomic::cmpxchg_ptr(Self, &(m->_owner), NULL) == NULL) {
       assert(m->_recursions == 0, "invariant");