changeset 19945:f2bdbfe9201b

Experimentally disallow Graal compiling itself in tiered
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Tue, 17 Mar 2015 19:21:57 -0700
parents 077c16efeb6d
children a3ffdf6ec408
files src/share/vm/graal/graalCompiler.cpp src/share/vm/graal/graalGlobals.hpp src/share/vm/runtime/advancedThresholdPolicy.cpp src/share/vm/runtime/simpleThresholdPolicy.inline.hpp
diffstat 4 files changed, 41 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/graal/graalCompiler.cpp	Tue Mar 17 19:21:54 2015 -0700
+++ b/src/share/vm/graal/graalCompiler.cpp	Tue Mar 17 19:21:57 2015 -0700
@@ -65,6 +65,9 @@
 void GraalCompiler::bootstrap() {
   JavaThread* THREAD = JavaThread::current();
   _bootstrapping = true;
+  // Allow bootstrap to perform Graal compilations of itself
+  bool c1only = GraalCompileWithC1Only;
+  GraalCompileWithC1Only = false;
   ResourceMark rm;
   HandleMark hm;
   if (PrintBootstrap) {
@@ -105,6 +108,7 @@
   if (PrintBootstrap) {
     tty->print_cr(" in " JLONG_FORMAT " ms (compiled %d methods)", os::javaTimeMillis() - start, _methodsCompiled);
   }
+  GraalCompileWithC1Only = c1only;
   _bootstrapping = false;
 }
 
--- a/src/share/vm/graal/graalGlobals.hpp	Tue Mar 17 19:21:54 2015 -0700
+++ b/src/share/vm/graal/graalGlobals.hpp	Tue Mar 17 19:21:57 2015 -0700
@@ -82,6 +82,12 @@
   product(bool, GraalHProfEnabled, false,                                   \
           "Is Heap  Profiler enabled")                                      \
                                                                             \
+  product(bool, GraalCompileWithC1Only, true,                               \
+          "Only compile Graal classes with C1")                             \
+                                                                            \
+  product(bool, GraalCompileAppFirst, false,                                \
+          "Prioritize application compilations over Graal compilations")    \
+                                                                            \
   develop(bool, GraalUseFastLocking, true,                                  \
           "Use fast inlined locking code")                                  \
                                                                             \
--- a/src/share/vm/runtime/advancedThresholdPolicy.cpp	Tue Mar 17 19:21:54 2015 -0700
+++ b/src/share/vm/runtime/advancedThresholdPolicy.cpp	Tue Mar 17 19:21:57 2015 -0700
@@ -157,6 +157,9 @@
 
 // Called with the queue locked and with at least one element
 CompileTask* AdvancedThresholdPolicy::select_task(CompileQueue* compile_queue) {
+#ifdef COMPILERGRAAL
+  CompileTask *max_non_graal_task = NULL;
+#endif
   CompileTask *max_task = NULL;
   Method* max_method = NULL;
   jlong t = os::javaTimeMillis();
@@ -189,9 +192,30 @@
         max_method = method;
       }
     }
+#ifdef COMPILERGRAAL
+    if (GraalCompileAppFirst && (task->comp_level() == CompLevel_full_optimization || !method->has_compiled_code()) &&
+        SystemDictionary::graal_loader() != NULL &&
+        method->method_holder()->class_loader() != SystemDictionary::graal_loader()) {
+      if (max_non_graal_task == NULL) {
+        max_non_graal_task = task;
+      } else {
+        // Select a method with a higher rate
+        if (compare_methods(method, max_non_graal_task->method())) {
+          max_non_graal_task = task;
+        }
+      }
+    }
+#endif
     task = next_task;
   }
 
+#ifdef COMPILERGRAAL
+  if (max_non_graal_task != NULL) {
+    max_task = max_non_graal_task;
+    max_method = max_task->method();
+  }
+#endif
+
   if (max_task->comp_level() == CompLevel_full_profile && TieredStopAtLevel > CompLevel_full_profile
       && is_method_profiled(max_method)) {
     max_task->set_comp_level(CompLevel_limited_profile);
--- a/src/share/vm/runtime/simpleThresholdPolicy.inline.hpp	Tue Mar 17 19:21:54 2015 -0700
+++ b/src/share/vm/runtime/simpleThresholdPolicy.inline.hpp	Tue Mar 17 19:21:57 2015 -0700
@@ -55,6 +55,13 @@
 // Determine if a given method is such a case.
 bool SimpleThresholdPolicy::is_trivial(Method* method) {
   if (method->is_accessor()) return true;
+#ifdef COMPILERGRAAL
+  if (TieredCompilation && GraalCompileWithC1Only &&
+      SystemDictionary::graal_loader() != NULL &&
+      method->method_holder()->class_loader() == SystemDictionary::graal_loader()) {
+    return true;
+  }
+#endif
   if (method->code() != NULL) {
     MethodData* mdo = method->method_data();
     if (mdo != NULL && mdo->num_loops() == 0 &&