8231321: compiler/codecache/stress/UnexpectedDeoptimizationAllTest.java failed assertion
authorrehn
Fri, 27 Sep 2019 15:15:07 +0200
changeset 58377 975f2d30f6b3
parent 58376 d10b732966ba
child 58378 98ea90226198
8231321: compiler/codecache/stress/UnexpectedDeoptimizationAllTest.java failed assertion Reviewed-by: thartmann, eosterlund
src/hotspot/share/code/nmethod.cpp
--- a/src/hotspot/share/code/nmethod.cpp	Fri Sep 27 20:06:02 2019 +0800
+++ b/src/hotspot/share/code/nmethod.cpp	Fri Sep 27 15:15:07 2019 +0200
@@ -1293,7 +1293,6 @@
  */
 bool nmethod::make_not_entrant_or_zombie(int state) {
   assert(state == zombie || state == not_entrant, "must be zombie or not_entrant");
-  assert(!is_zombie(), "should not already be a zombie");
 
   if (Atomic::load(&_state) >= state) {
     // Avoid taking the lock if already in required state.
@@ -1316,20 +1315,18 @@
   // This flag is used to remember whether we need to later lock and unregister.
   bool nmethod_needs_unregister = false;
 
-  // invalidate osr nmethod before acquiring the patching lock since
-  // they both acquire leaf locks and we don't want a deadlock.
-  // This logic is equivalent to the logic below for patching the
-  // verified entry point of regular methods. We check that the
-  // nmethod is in use to ensure that it is invalidated only once.
-  if (is_osr_method() && is_in_use()) {
-    // this effectively makes the osr nmethod not entrant
-    invalidate_osr_method();
-  }
-
   {
     // Enter critical section.  Does not block for safepoint.
     MutexLocker ml(CompiledMethod_lock->owned_by_self() ? NULL : CompiledMethod_lock, Mutex::_no_safepoint_check_flag);
 
+    // This logic is equivalent to the logic below for patching the
+    // verified entry point of regular methods. We check that the
+    // nmethod is in use to ensure that it is invalidated only once.
+    if (is_osr_method() && is_in_use()) {
+      // this effectively makes the osr nmethod not entrant
+      invalidate_osr_method();
+    }
+
     if (Atomic::load(&_state) >= state) {
       // another thread already performed this transition so nothing
       // to do, but return false to indicate this.