# HG changeset patch # User rehn # Date 1569590107 -7200 # Node ID 975f2d30f6b3f9050d3d4197021d1c00c4c5b1cc # Parent d10b732966ba64e7112c9b81ac1c690bb438a007 8231321: compiler/codecache/stress/UnexpectedDeoptimizationAllTest.java failed assertion Reviewed-by: thartmann, eosterlund diff -r d10b732966ba -r 975f2d30f6b3 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.