src/hotspot/share/runtime/sharedRuntime.cpp
changeset 52384 d6dc479bcdd3
parent 51591 9183040e34d8
child 52661 4f45c682eab0
--- a/src/hotspot/share/runtime/sharedRuntime.cpp	Fri Nov 02 07:58:22 2018 +0100
+++ b/src/hotspot/share/runtime/sharedRuntime.cpp	Thu Nov 01 14:57:26 2018 +0100
@@ -1351,7 +1351,7 @@
 
   // grab lock, check for deoptimization and potentially patch caller
   {
-    MutexLocker ml_patch(CompiledIC_lock);
+    CompiledICLocker ml(caller_nm);
 
     // Lock blocks for safepoint during which both nmethods can change state.
 
@@ -1382,7 +1382,7 @@
       }
     }
 
-  } // unlock CompiledIC_lock
+  } // unlock CompiledICLocker
 
   return callee_method;
 }
@@ -1585,11 +1585,13 @@
   JvmtiDynamicCodeEventCollector event_collector;
 
   // Update inline cache to megamorphic. Skip update if we are called from interpreted.
-  { MutexLocker ml_patch (CompiledIC_lock);
+  {
     RegisterMap reg_map(thread, false);
     frame caller_frame = thread->last_frame().sender(&reg_map);
     CodeBlob* cb = caller_frame.cb();
     CompiledMethod* caller_nm = cb->as_compiled_method_or_null();
+    CompiledICLocker ml(caller_nm);
+
     if (cb->is_compiled()) {
       CompiledIC* inline_cache = CompiledIC_before(((CompiledMethod*)cb), caller_frame.pc());
       bool should_be_mono = false;
@@ -1647,7 +1649,7 @@
     } else {
       fatal("Unimplemented");
     }
-  } // Release CompiledIC_lock
+  } // Release CompiledICLocker
 
   return callee_method;
 }
@@ -1731,8 +1733,7 @@
       // to a wrong method). It should not be performance critical, since the
       // resolve is only done once.
 
-      bool is_nmethod = caller_nm->is_nmethod();
-      MutexLocker ml(CompiledIC_lock);
+      CompiledICLocker ml(caller_nm);
       if (is_static_call) {
         CompiledStaticCall* ssc = caller_nm->compiledStaticCall_at(call_addr);
         ssc->set_to_clean();