diff --git a/src/hotspot/share/code/nmethod.cpp b/src/hotspot/share/code/nmethod.cpp index be10fc0..3c7124b 100644 --- a/src/hotspot/share/code/nmethod.cpp +++ b/src/hotspot/share/code/nmethod.cpp @@ -1366,8 +1366,8 @@ void nmethod::flush() { } #if INCLUDE_JVMCI - assert(_jvmci_installed_code == NULL, "should have been nulled out when transitioned to zombie"); - assert(_speculation_log == NULL, "should have been nulled out when transitioned to zombie"); + clear_jvmci_installed_code(); + clear_speculation_log(); #endif CodeBlob::flush(); @@ -1662,13 +1662,10 @@ void nmethod::do_unloading(bool unloading_occurred) { make_unloaded(); } else { #if INCLUDE_JVMCI - if (_jvmci_installed_code != NULL) { - if (JNIHandles::is_global_weak_cleared(_jvmci_installed_code)) { - if (_jvmci_installed_code_triggers_invalidation) { - make_not_entrant(); - } - clear_jvmci_installed_code(); - } + if (_jvmci_installed_code != NULL && + JNIHandles::is_global_weak_cleared(_jvmci_installed_code) && + _jvmci_installed_code_triggers_invalidation) { + make_not_entrant(); } #endif @@ -2959,7 +2956,6 @@ void nmethod::print_statistics() { #if INCLUDE_JVMCI void nmethod::clear_jvmci_installed_code() { - assert_locked_or_safepoint(Patching_lock); if (_jvmci_installed_code != NULL) { JNIHandles::destroy_weak_global(_jvmci_installed_code); _jvmci_installed_code = NULL; @@ -2967,7 +2963,6 @@ void nmethod::clear_jvmci_installed_code() { } void nmethod::clear_speculation_log() { - assert_locked_or_safepoint(Patching_lock); if (_speculation_log != NULL) { JNIHandles::destroy_weak_global(_speculation_log); _speculation_log = NULL; @@ -3001,12 +2996,6 @@ void nmethod::maybe_invalidate_installed_code() { } } } - if (!is_alive() || is_unloading()) { - // Clear these out after the nmethod has been unregistered and any - // updates to the InstalledCode instance have been performed. - clear_jvmci_installed_code(); - clear_speculation_log(); - } } void nmethod::invalidate_installed_code(Handle installedCode, TRAPS) {