8145270: Need to eagerly initialize JVMCI compiler under -Xcomp
authordnsimon
Sun, 13 Dec 2015 22:51:13 +0100
changeset 35114 3d49d37ab9c4
parent 35112 b3c4347bb751
child 35115 629164893cbd
8145270: Need to eagerly initialize JVMCI compiler under -Xcomp Reviewed-by: twisti
hotspot/src/share/vm/compiler/compileBroker.cpp
hotspot/src/share/vm/compiler/compileBroker.hpp
hotspot/src/share/vm/runtime/thread.cpp
--- a/hotspot/src/share/vm/compiler/compileBroker.cpp	Mon Dec 07 15:42:47 2015 +0100
+++ b/hotspot/src/share/vm/compiler/compileBroker.cpp	Sun Dec 13 22:51:13 2015 +0100
@@ -56,6 +56,7 @@
 #if INCLUDE_JVMCI
 #include "jvmci/jvmciCompiler.hpp"
 #include "jvmci/jvmciRuntime.hpp"
+#include "jvmci/jvmciJavaClasses.hpp"
 #include "runtime/vframe.hpp"
 #endif
 #ifdef COMPILER2
@@ -498,7 +499,7 @@
 // CompileBroker::compilation_init
 //
 // Initialize the Compilation object
-void CompileBroker::compilation_init() {
+void CompileBroker::compilation_init(TRAPS) {
   _last_method_compiled[0] = '\0';
 
   // No need to initialize compilation system if we do not use it.
@@ -529,6 +530,17 @@
       } else {
         c1_count = JVMCIHostThreads;
       }
+
+      if (!UseInterpreter) {
+        // Force initialization of JVMCI compiler otherwise JVMCI
+        // compilations will not block until JVMCI is initialized
+        ResourceMark rm;
+        TempNewSymbol getCompiler = SymbolTable::new_symbol("getCompiler", CHECK);
+        TempNewSymbol sig = SymbolTable::new_symbol("()Ljdk/vm/ci/runtime/JVMCICompiler;", CHECK);
+        Handle jvmciRuntime = JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK);
+        JavaValue result(T_OBJECT);
+        JavaCalls::call_virtual(&result, jvmciRuntime, HotSpotJVMCIRuntime::klass(), getCompiler, sig, CHECK);
+      }
     }
   }
 #endif // INCLUDE_JVMCI
--- a/hotspot/src/share/vm/compiler/compileBroker.hpp	Mon Dec 07 15:42:47 2015 +0100
+++ b/hotspot/src/share/vm/compiler/compileBroker.hpp	Sun Dec 13 22:51:13 2015 +0100
@@ -276,7 +276,7 @@
     CompileQueue *q = compile_queue(comp_level);
     return q != NULL ? q->size() : 0;
   }
-  static void compilation_init();
+  static void compilation_init(TRAPS);
   static void init_compiler_thread_log();
   static nmethod* compile_method(const methodHandle& method,
                                  int osr_bci,
--- a/hotspot/src/share/vm/runtime/thread.cpp	Mon Dec 07 15:42:47 2015 +0100
+++ b/hotspot/src/share/vm/runtime/thread.cpp	Sun Dec 13 22:51:13 2015 +0100
@@ -3628,7 +3628,7 @@
 
   // initialize compiler(s)
 #if defined(COMPILER1) || defined(COMPILER2) || defined(SHARK) || INCLUDE_JVMCI
-  CompileBroker::compilation_init();
+  CompileBroker::compilation_init(CHECK_JNI_ERR);
 #endif
 
   // Pre-initialize some JSR292 core classes to avoid deadlock during class loading.