hotspot/src/share/vm/runtime/sweeper.cpp
changeset 36844 ce97bc269a80
parent 36818 b40330c06dea
parent 36816 987a22271911
child 38133 78b95467b9f1
--- a/hotspot/src/share/vm/runtime/sweeper.cpp	Tue Mar 29 22:39:17 2016 +0000
+++ b/hotspot/src/share/vm/runtime/sweeper.cpp	Wed Mar 30 12:34:08 2016 +0200
@@ -613,7 +613,10 @@
       // Code cache state change is tracked in make_zombie()
       nm->make_zombie();
       SWEEP(nm);
-      if (nm->is_osr_method()) {
+      // The nmethod may have been locked by JVMTI after being made zombie (see
+      // JvmtiDeferredEvent::compiled_method_unload_event()). If so, we cannot
+      // flush the osr nmethod directly but have to wait for a later sweeper cycle.
+      if (nm->is_osr_method() && !nm->is_locked_by_vm()) {
         // No inline caches will ever point to osr methods, so we can just remove it.
         // Make sure that we unregistered the nmethod with the heap and flushed all
         // dependencies before removing the nmethod (done in make_zombie()).