diff -r 4eebb9aadbe3 -r 408c445d04e8 src/hotspot/share/aot/aotCompiledMethod.cpp --- a/src/hotspot/share/aot/aotCompiledMethod.cpp Thu Sep 19 09:50:11 2019 +0200 +++ b/src/hotspot/share/aot/aotCompiledMethod.cpp Thu Sep 19 10:52:22 2019 +0200 @@ -165,7 +165,7 @@ { // Enter critical section. Does not block for safepoint. - MutexLocker pl(Patching_lock, Mutex::_no_safepoint_check_flag); + MutexLocker pl(CompiledMethod_lock, Mutex::_no_safepoint_check_flag); if (*_state_adr == new_state) { // another thread already performed this transition so nothing @@ -188,12 +188,10 @@ #endif // Remove AOTCompiledMethod from method. - if (method() != NULL && (method()->code() == this || - method()->from_compiled_entry() == verified_entry_point())) { - HandleMark hm; - method()->clear_code(false /* already owns Patching_lock */); + if (method() != NULL) { + method()->unlink_code(this); } - } // leave critical region under Patching_lock + } // leave critical region under CompiledMethod_lock if (TraceCreateZombies) { @@ -208,7 +206,6 @@ #ifdef TIERED bool AOTCompiledMethod::make_entrant() { assert(!method()->is_old(), "reviving evolved method!"); - assert(*_state_adr != not_entrant, "%s", method()->has_aot_code() ? "has_aot_code() not cleared" : "caller didn't check has_aot_code()"); // Make sure the method is not flushed in case of a safepoint in code below. methodHandle the_method(method()); @@ -216,9 +213,9 @@ { // Enter critical section. Does not block for safepoint. - MutexLocker pl(Patching_lock, Mutex::_no_safepoint_check_flag); + MutexLocker pl(CompiledMethod_lock, Mutex::_no_safepoint_check_flag); - if (*_state_adr == in_use) { + if (*_state_adr == in_use || *_state_adr == not_entrant) { // another thread already performed this transition so nothing // to do, but return false to indicate this. return false; @@ -230,7 +227,7 @@ // Log the transition once log_state_change(); - } // leave critical region under Patching_lock + } // leave critical region under CompiledMethod_lock if (TraceCreateZombies) {