< prev index next >

src/hotspot/share/jvmci/jvmciRuntime.cpp

Print this page
rev 56252 : imported patch 8226705-v2

@@ -1518,25 +1518,30 @@
               char *method_name = method->name_and_sig_as_C_string();
               lt.print("Installing method (%d) %s [entry point: %p]",
                         comp_level, method_name, nm->entry_point());
             }
             // Allow the code to be executed
+            MutexLocker ml(CompiledMethod_lock, Mutex::_no_safepoint_check_flag);
+            if (nm->make_in_use()) {
             method->set_code(method, nm);
+            }
           } else {
             LogTarget(Info, nmethod, install) lt;
             if (lt.is_enabled()) {
               ResourceMark rm;
               char *method_name = method->name_and_sig_as_C_string();
               lt.print("Installing osr method (%d) %s @ %d",
                         comp_level, method_name, entry_bci);
             }
+            MutexLocker ml(CompiledMethod_lock, Mutex::_no_safepoint_check_flag);
+            if (nm->make_in_use()) {
             InstanceKlass::cast(method->method_holder())->add_osr_nmethod(nm);
           }
+          }
         } else {
           assert(!nmethod_mirror.is_hotspot() || data->get_nmethod_mirror(nm, /* phantom_ref */ false) == HotSpotJVMCI::resolve(nmethod_mirror), "must be");
         }
-        nm->make_in_use();
       }
       result = nm != NULL ? JVMCI::ok :JVMCI::cache_full;
     }
   }
 
< prev index next >