diff src/share/vm/prims/jni.cpp @ 18134:6a2f814224b1

hotspot/graal: simplify CTW logic. now, the following configurations are supported: (1) CTW with Graal, graal compiled by itself with bootstrap (--vm graal -XX:+BootstrapGraal -XX:-TieredCompilation -XX:+CompileTheWorld) (2) CTW with Graal, graal compiled by C1/itself aka. tiered with bootstrap (--vm graal -XX:+BootstrapGraal -XX:+TieredCompilation +XX:+CompileTheWorld) (3) CTW with Graal, graal compiled by itself without bootstrap (--vm graal -XX:-BootstrapGraal -XX:-TieredCompilation -XX:+CompileTheWorld) (4) CTW with Graal, graal compiled by C1/itself aka. tiered without bootstrap (--vm graal -XX:-BootstrapGraal -XX:+TieredCompilation -XX:+CompileTheWorld) (5) CTW with Graal, graal compiled by C1/C2 aka. hosted (--vm server -XX:+CompileTheWorld)
author Bernhard Urban <bernhard.urban@jku.at>
date Tue, 21 Oct 2014 10:17:06 +0200
parents 52b4284cb496
children 104304a54b0c
line wrap: on
line diff
--- a/src/share/vm/prims/jni.cpp	Tue Oct 21 02:31:32 2014 +0200
+++ b/src/share/vm/prims/jni.cpp	Tue Oct 21 10:17:06 2014 +0200
@@ -5199,11 +5199,28 @@
     *vm = (JavaVM *)(&main_vm);
     *(JNIEnv**)penv = thread->jni_environment();
 
+#if defined(GRAAL) && !defined(PRODUCT)
+    // We turn off CompileTheWorld so that compilation requests are not ignored during bootstrap or that Graal can be compiled by C1/C2.
+    bool doCTW = CompileTheWorld;
+    CompileTheWorld = false;
+#endif
+
 #ifdef COMPILERGRAAL
     // Graal is initialized on a CompilerThread
     if (FLAG_IS_DEFAULT(BootstrapGraal) ? !TieredCompilation : BootstrapGraal) {
       GraalCompiler::instance()->bootstrap();
     }
+#elif defined(GRAAL) && !defined(PRODUCT)
+    if (doCTW) {
+      // required for hosted CTW.
+      CompilationPolicy::completed_vm_startup();
+    }
+#endif
+
+#if defined(GRAAL) && !defined(PRODUCT)
+    if (doCTW) {
+      GraalCompiler::instance()->compile_the_world();
+    }
 #endif
 
     // Tracks the time application was running before GC
@@ -5226,19 +5243,7 @@
   #endif
 
     // Check if we should compile all classes on bootclasspath
-#ifdef GRAAL
-#ifndef COMPILERGRAAL
-    if (CompileTheWorld) {
-      // Graal is considered as application code so we need to
-      // stop the VM deferring compilation now.
-      CompilationPolicy::completed_vm_startup();
-
-      GraalCompiler::instance()->compile_the_world();
-    }
-#endif
-#else
     if (CompileTheWorld) ClassLoader::compile_the_world();
-#endif
     if (ReplayCompiles) ciReplay::replay(thread);
 
     // Some platforms (like Win*) need a wrapper around these test