changeset 13969:fe034af88233

Acquire proper locks before calling assign_compile_id
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Tue, 18 Feb 2014 10:47:13 -0800
parents 6c6d1eacc398
children bbf84e85b775
files src/share/vm/compiler/compileBroker.cpp src/share/vm/compiler/compileBroker.hpp src/share/vm/graal/graalCodeInstaller.cpp src/share/vm/graal/graalCompilerToVM.cpp
diffstat 4 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/compiler/compileBroker.cpp	Mon Feb 17 23:18:00 2014 +0100
+++ b/src/share/vm/compiler/compileBroker.cpp	Tue Feb 18 10:47:13 2014 -0800
@@ -1472,6 +1472,16 @@
 
 
 // ------------------------------------------------------------------
+// CompileBroker::assign_compile_id_unlocked
+//
+// Public wrapper for assign_compile_id that acquires the needed locks
+uint CompileBroker::assign_compile_id_unlocked(Thread* thread, methodHandle method, int osr_bci) {
+  MutexLocker locker(MethodCompileQueue_lock, thread);
+  return assign_compile_id(method, osr_bci);
+}
+
+
+// ------------------------------------------------------------------
 // CompileBroker::is_compile_blocking
 //
 // Should the current thread be blocked until this compilation request
--- a/src/share/vm/compiler/compileBroker.hpp	Mon Feb 17 23:18:00 2014 +0100
+++ b/src/share/vm/compiler/compileBroker.hpp	Tue Feb 18 10:47:13 2014 -0800
@@ -321,6 +321,7 @@
   static void init_compiler_threads(int c1_compiler_count, int c2_compiler_count);
   static bool compilation_is_complete  (methodHandle method, int osr_bci, int comp_level);
   static bool compilation_is_prohibited(methodHandle method, int osr_bci, int comp_level);
+  static uint assign_compile_id        (methodHandle method, int osr_bci);
   static bool is_compile_blocking      (methodHandle method, int osr_bci);
   static void preload_classes          (methodHandle method, TRAPS);
 
@@ -385,7 +386,8 @@
                                  int hot_count,
                                  const char* comment, Thread* thread);
 
-  static uint assign_compile_id        (methodHandle method, int osr_bci);
+  // Acquire any needed locks and assign a compile id
+  static uint assign_compile_id_unlocked(Thread* thread, methodHandle method, int osr_bci);
 
   static void compiler_thread_loop();
   static uint get_compilation_id() { return _compilation_id; }
--- a/src/share/vm/graal/graalCodeInstaller.cpp	Mon Feb 17 23:18:00 2014 +0100
+++ b/src/share/vm/graal/graalCodeInstaller.cpp	Tue Feb 18 10:47:13 2014 -0800
@@ -422,7 +422,7 @@
     jint id = HotSpotCompiledNmethod::id(compiled_code);
     if (id == -1) {
       // Make sure a valid compile_id is associated with every compile
-      id = CompileBroker::assign_compile_id(method, entry_bci);
+      id = CompileBroker::assign_compile_id_unlocked(Thread::current(), method, entry_bci);
     }
     result = GraalEnv::register_method(method, nm, entry_bci, &_offsets, _custom_stack_area_offset, &buffer, stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table,
         GraalCompiler::instance(), _debug_recorder, _dependencies, NULL, id, false, leaf_graph_ids, installed_code, speculation_log);
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Mon Feb 17 23:18:00 2014 +0100
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Tue Feb 18 10:47:13 2014 -0800
@@ -847,8 +847,7 @@
   HandleMark hm;
   ResourceMark rm;
   Method* method = getMethodFromHotSpotMethod(JNIHandles::resolve(hotspot_method));
-  MutexLocker locker(MethodCompileQueue_lock, thread);
-  return CompileBroker::assign_compile_id(method, entry_bci);
+  return CompileBroker::assign_compile_id_unlocked(THREAD, method, entry_bci);
 C2V_END