changeset 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 5c1bd485c54b
children 1700d12ba0ad
files src/share/vm/graal/graalCompiler.cpp src/share/vm/prims/jni.cpp
diffstat 2 files changed, 17 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/graal/graalCompiler.cpp	Tue Oct 21 02:31:32 2014 +0200
+++ b/src/share/vm/graal/graalCompiler.cpp	Tue Oct 21 10:17:06 2014 +0200
@@ -62,12 +62,6 @@
     // Graal is considered as application code so we need to
     // stop the VM deferring compilation now.
     CompilationPolicy::completed_vm_startup();
-
-#ifndef PRODUCT
-    if (CompileTheWorld && !BootstrapGraal) {
-      compile_the_world();
-    }
-#endif
   }
 #endif // COMPILERGRAAL
 }
@@ -75,13 +69,6 @@
 #ifdef COMPILERGRAAL
 void GraalCompiler::bootstrap() {
   JavaThread* THREAD = JavaThread::current();
-#ifndef PRODUCT
-  // We turn off CompileTheWorld so that compilation requests are not ignored during bootstrap.
-  bool doCTW = CompileTheWorld;
-  if (CompileTheWorld) {
-    CompileTheWorld = false;
-  }
-#endif
   _bootstrapping = true;
   ResourceMark rm;
   HandleMark hm;
@@ -121,11 +108,6 @@
     tty->print_cr(" in " JLONG_FORMAT " ms (compiled %d methods)", os::javaTimeMillis() - start, _methodsCompiled);
   }
   _bootstrapping = false;
-#ifndef PRODUCT
-    if (doCTW) {
-      compile_the_world();
-    }
-#endif
 }
 
 void GraalCompiler::compile_method(methodHandle method, int entry_bci, CompileTask* task) {
@@ -167,11 +149,7 @@
 
 #ifndef PRODUCT
 void GraalCompiler::compile_the_world() {
-  // We turn off CompileTheWorld so that Graal can
-  // be compiled by C1/C2 when Graal does a CTW.
-  CompileTheWorld = false;
   HandleMark hm;
-
   JavaThread* THREAD = JavaThread::current();
   TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/HotSpotGraalRuntime", CHECK_ABORT);
   KlassHandle klass = GraalRuntime::load_required_class(name);
--- 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