8160121: [JVMCI] JvmciNotifyBootstrapFinishedEventTest.java failed NoClassDefFoundError: jdk/vm/ci/runtime/JVMCI
authornever
Tue, 28 Jun 2016 17:22:56 +0000
changeset 40034 4a288aaf8511
parent 40032 bc2e42cd23ea
child 40035 bae79d28e9b1
8160121: [JVMCI] JvmciNotifyBootstrapFinishedEventTest.java failed NoClassDefFoundError: jdk/vm/ci/runtime/JVMCI Reviewed-by: kvn
hotspot/src/share/vm/compiler/compileBroker.cpp
hotspot/src/share/vm/jvmci/jvmciRuntime.cpp
hotspot/src/share/vm/jvmci/jvmciRuntime.hpp
hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp
hotspot/src/share/vm/runtime/thread.cpp
hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java
hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java
hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.java
--- a/hotspot/src/share/vm/compiler/compileBroker.cpp	Mon Jun 27 17:23:15 2016 +0300
+++ b/hotspot/src/share/vm/compiler/compileBroker.cpp	Tue Jun 28 17:22:56 2016 +0000
@@ -551,17 +551,6 @@
       } else {
         c1_count = JVMCIHostThreads;
       }
-
-      if (!UseInterpreter || !BackgroundCompilation) {
-        // 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/jvmci/jvmciRuntime.cpp	Mon Jun 27 17:23:15 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp	Tue Jun 28 17:22:56 2016 +0000
@@ -612,6 +612,17 @@
   return value;
 JRT_END
 
+void JVMCIRuntime::force_initialization(TRAPS) {
+  JVMCIRuntime::initialize_well_known_classes(CHECK);
+
+  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);
+}
+
 // private static JVMCIRuntime JVMCI.initializeRuntime()
 JVM_ENTRY(jobject, JVM_GetJVMCIRuntime(JNIEnv *env, jclass c))
   if (!EnableJVMCI) {
--- a/hotspot/src/share/vm/jvmci/jvmciRuntime.hpp	Mon Jun 27 17:23:15 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/jvmciRuntime.hpp	Tue Jun 28 17:22:56 2016 +0000
@@ -157,6 +157,9 @@
   static void throw_klass_external_name_exception(JavaThread* thread, const char* exception, Klass* klass);
   static void throw_class_cast_exception(JavaThread* thread, const char* exception, Klass* caster_klass, Klass* target_klass);
 
+  // Forces initialization of the JVMCI runtime.
+  static void force_initialization(TRAPS);
+
   // Test only function
   static int test_deoptimize_call_int(JavaThread* thread, int value);
 };
--- a/hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp	Mon Jun 27 17:23:15 2016 +0300
+++ b/hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp	Tue Jun 28 17:22:56 2016 +0000
@@ -238,9 +238,14 @@
   }
 
 #if INCLUDE_JVMCI
-  // We can't compile with a JVMCI compiler until the module system is initialized.
-  if (level == CompLevel_full_optimization && UseJVMCICompiler && !Universe::is_module_initialized()) {
-    return;
+  // We can't compile with a JVMCI compiler until the module system is initialized past
+  // phase 3.  The JVMCI API itself isn't available until phase 2 and ServiceLoader isn't
+  // usable until after phase 3.
+  if (level == CompLevel_full_optimization && EnableJVMCI && UseJVMCICompiler) {
+    if (SystemDictionary::java_system_loader() == NULL) {
+      return;
+     }
+     assert(Universe::is_module_initialized(), "must be");
   }
 #endif
 
--- a/hotspot/src/share/vm/runtime/thread.cpp	Mon Jun 27 17:23:15 2016 +0300
+++ b/hotspot/src/share/vm/runtime/thread.cpp	Tue Jun 28 17:22:56 2016 +0000
@@ -3770,6 +3770,13 @@
   // Final system initialization including security manager and system class loader
   call_initPhase3(CHECK_JNI_ERR);
 
+#if INCLUDE_JVMCI
+  if (EnableJVMCI && UseJVMCICompiler && (!UseInterpreter || !BackgroundCompilation)) {
+    // 8145270: Force initialization of JVMCI runtime otherwise requests for blocking
+    // compilations via JVMCI will not actually block until JVMCI is initialized.
+    JVMCIRuntime::force_initialization(CHECK_JNI_ERR);
+  }
+#endif
   // cache the system class loader
   SystemDictionary::compute_java_system_loader(CHECK_(JNI_ERR));
 
--- a/hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java	Mon Jun 27 17:23:15 2016 +0300
+++ b/hotspot/test/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java	Tue Jun 28 17:22:56 2016 +0000
@@ -43,6 +43,8 @@
  * @run main ClassFileInstaller
  *     compiler.jvmci.common.JVMCIHelpers$EmptyHotspotCompiler
  *     compiler.jvmci.common.JVMCIHelpers$EmptyCompilerFactory
+ *     compiler.jvmci.common.JVMCIHelpers$EmptyCompilationRequestResult
+ *     compiler.jvmci.common.JVMCIHelpers$EmptyVMEventListener
  *     compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest
  *     jdk.test.lib.Asserts
  *     jdk.test.lib.Utils
--- a/hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java	Mon Jun 27 17:23:15 2016 +0300
+++ b/hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java	Tue Jun 28 17:22:56 2016 +0000
@@ -44,6 +44,8 @@
  * @run main ClassFileInstaller
  *     compiler.jvmci.common.JVMCIHelpers$EmptyHotspotCompiler
  *     compiler.jvmci.common.JVMCIHelpers$EmptyCompilerFactory
+ *     compiler.jvmci.common.JVMCIHelpers$EmptyCompilationRequestResult
+ *     compiler.jvmci.common.JVMCIHelpers$EmptyVMEventListener
  *     compiler.jvmci.events.JvmciNotifyInstallEventTest
  *     compiler.jvmci.common.CTVMUtilities
  *     compiler.jvmci.common.testcases.SimpleClass
--- a/hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.java	Mon Jun 27 17:23:15 2016 +0300
+++ b/hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.java	Tue Jun 28 17:22:56 2016 +0000
@@ -40,6 +40,8 @@
  * @run main ClassFileInstaller
  *     compiler.jvmci.common.JVMCIHelpers$EmptyHotspotCompiler
  *     compiler.jvmci.common.JVMCIHelpers$EmptyCompilerFactory
+ *     compiler.jvmci.common.JVMCIHelpers$EmptyCompilationRequestResult
+ *     compiler.jvmci.common.JVMCIHelpers$EmptyVMEventListener
  *     compiler.jvmci.events.JvmciShutdownEventListener
  * @run main/othervm compiler.jvmci.events.JvmciShutdownEventTest
  */