diff -r ae2e53e379cb -r 80b27dc96ca3 src/hotspot/share/aot/aotCompiledMethod.cpp --- a/src/hotspot/share/aot/aotCompiledMethod.cpp Mon Jun 24 16:51:23 2019 -0400 +++ b/src/hotspot/share/aot/aotCompiledMethod.cpp Mon Jun 24 22:38:17 2019 -0400 @@ -165,7 +165,7 @@ { // Enter critical section. Does not block for safepoint. - MutexLocker pl(CompiledMethod_lock, Mutex::_no_safepoint_check_flag); + MutexLocker pl(Patching_lock, Mutex::_no_safepoint_check_flag); if (*_state_adr == new_state) { // another thread already performed this transition so nothing @@ -188,10 +188,12 @@ #endif // Remove AOTCompiledMethod from method. - if (method() != NULL) { - method()->unlink_code(this); + if (method() != NULL && (method()->code() == this || + method()->from_compiled_entry() == verified_entry_point())) { + HandleMark hm; + method()->clear_code(false /* already owns Patching_lock */); } - } // leave critical region under CompiledMethod_lock + } // leave critical region under Patching_lock if (TraceCreateZombies) { @@ -214,7 +216,7 @@ { // Enter critical section. Does not block for safepoint. - MutexLocker pl(CompiledMethod_lock, Mutex::_no_safepoint_check_flag); + MutexLocker pl(Patching_lock, Mutex::_no_safepoint_check_flag); if (*_state_adr == in_use) { // another thread already performed this transition so nothing @@ -228,7 +230,7 @@ // Log the transition once log_state_change(); - } // leave critical region under CompiledMethod_lock + } // leave critical region under Patching_lock if (TraceCreateZombies) {