changeset 10640:88672775a26c

Compilation policy fixes and changed default compilation policy.
author Christian Haeubl <haeubl@ssw.jku.at>
date Mon, 08 Jul 2013 16:55:28 +0200
parents 08e06d4a9e73
children 4b88e5c93f04
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java src/cpu/x86/vm/templateInterpreter_x86_64.cpp src/share/vm/interpreter/invocationCounter.cpp src/share/vm/oops/methodCounters.cpp src/share/vm/oops/methodCounters.hpp src/share/vm/runtime/compilationPolicy.cpp src/share/vm/runtime/globals.hpp
diffstat 7 files changed, 35 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Mon Jul 08 12:01:51 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Mon Jul 08 16:55:28 2013 +0200
@@ -75,6 +75,7 @@
     }
 
     private CompilationTask(HotSpotGraalRuntime graalRuntime, PhasePlan plan, OptimisticOptimizations optimisticOpts, HotSpotResolvedJavaMethod method, int entryBCI, int id, int priority) {
+        assert id >= 0;
         this.graalRuntime = graalRuntime;
         this.plan = plan;
         this.suitesProvider = graalRuntime.getCapability(SuitesProvider.class);
@@ -90,6 +91,10 @@
         return method;
     }
 
+    public int getId() {
+        return id;
+    }
+
     public int getPriority() {
         return priority;
     }
@@ -105,9 +110,6 @@
     public void run() {
         withinEnqueue.set(Boolean.FALSE);
         try {
-            if (!tryToChangeStatus(CompilationStatus.Queued, CompilationStatus.Running)) {
-                return;
-            }
             if (DynamicCompilePriority.getValue()) {
                 int threadPriority = priority < VMToCompilerImpl.SlowQueueCutoff.getValue() ? Thread.NORM_PRIORITY : Thread.MIN_PRIORITY;
                 if (Thread.currentThread().getPriority() != threadPriority) {
@@ -129,6 +131,10 @@
     public static final DebugTimer CompilationTime = Debug.timer("CompilationTime");
 
     public void runCompilation() {
+        if (!tryToChangeStatus(CompilationStatus.Queued, CompilationStatus.Running) || method.hasCompiledCode()) {
+            return;
+        }
+
         CompilationStatistics stats = CompilationStatistics.create(method, entryBCI != StructuredGraph.INVOCATION_ENTRY_BCI);
         try (TimerCloseable a = CompilationTime.start()) {
             final boolean printCompilation = PrintCompilation.getValue() && !TTY.isSuppressed();
@@ -229,13 +235,11 @@
 
     @Override
     public int compareTo(CompilationTask o) {
-        if (priority < o.priority) {
-            return -1;
+        if (priority != o.priority) {
+            return priority - o.priority;
+        } else {
+            return id - o.id;
         }
-        if (priority > o.priority) {
-            return 1;
-        }
-        return id < o.id ? -1 : (id > o.id ? 1 : 0);
     }
 
     @Override
--- a/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	Mon Jul 08 12:01:51 2013 +0200
+++ b/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	Mon Jul 08 16:55:28 2013 +0200
@@ -383,9 +383,11 @@
       __ pop(rcx);
       __ pop(rax);
 
+#ifdef ASSERT
       __ testl(rcx, InvocationCounter::count_mask_value);
       __ jcc(Assembler::zero, not_zero);
       __ stop("unexpected counter value in rcx");
+#endif
 
       __ bind(not_zero);
     }
--- a/src/share/vm/interpreter/invocationCounter.cpp	Mon Jul 08 12:01:51 2013 +0200
+++ b/src/share/vm/interpreter/invocationCounter.cpp	Mon Jul 08 16:55:28 2013 +0200
@@ -48,11 +48,11 @@
   // executed many more times before re-entering the VM.
   int old_count = count();
   int new_count;
-  if (CompilationPolicyChoice == 4) {
+#ifdef GRAALVM
     new_count = 1;
-  } else {
+#else
     new_count = MIN2(old_count, (int) (CompileThreshold / 2));
-  }
+#endif
   // prevent from going to zero, to distinguish from never-executed methods
   if (new_count == 0)  new_count = 1;
   if (old_count != new_count)  set(state(), new_count);
--- a/src/share/vm/oops/methodCounters.cpp	Mon Jul 08 12:01:51 2013 +0200
+++ b/src/share/vm/oops/methodCounters.cpp	Mon Jul 08 16:55:28 2013 +0200
@@ -32,6 +32,10 @@
 void MethodCounters::clear_counters() {
   invocation_counter()->reset();
   backedge_counter()->reset();
+#ifdef GRAALVM
+  set_graal_priority(0);
+  set_graal_invocation_time(0L);
+#endif
   set_interpreter_throwout_count(0);
   set_interpreter_invocation_count(0);
 }
--- a/src/share/vm/oops/methodCounters.hpp	Mon Jul 08 12:01:51 2013 +0200
+++ b/src/share/vm/oops/methodCounters.hpp	Mon Jul 08 16:55:28 2013 +0200
@@ -37,7 +37,7 @@
   InvocationCounter _invocation_counter;         // Incremented before each activation of the method - used to trigger frequency-based optimizations
   InvocationCounter _backedge_counter;           // Incremented before each backedge taken - used to trigger frequencey-based optimizations
 
-#ifdef GRAAL
+#ifdef GRAALVM
   jlong             _graal_invocation_time;
   int               _graal_priority;
 #endif
@@ -49,6 +49,11 @@
   MethodCounters() : _interpreter_invocation_count(0),
                      _interpreter_throwout_count(0),
                      _number_of_breakpoints(0)
+#ifdef GRAALVM
+                     , _graal_invocation_time(0L)
+                     , _graal_priority(0)
+#endif
+
 #ifdef TIERED
                    , _rate(0),
                      _prev_time(0)
@@ -97,7 +102,7 @@
   void decr_number_of_breakpoints()    { --_number_of_breakpoints; }
   void clear_number_of_breakpoints()   { _number_of_breakpoints = 0; }
 
-#ifdef GRAAL
+#ifdef GRAALVM
   void set_graal_invocation_time(jlong time) { _graal_invocation_time = time; }
   jlong graal_invocation_time()              { return _graal_invocation_time; }
 
--- a/src/share/vm/runtime/compilationPolicy.cpp	Mon Jul 08 12:01:51 2013 +0200
+++ b/src/share/vm/runtime/compilationPolicy.cpp	Mon Jul 08 16:55:28 2013 +0200
@@ -454,11 +454,6 @@
 
   if (is_compilation_enabled() && can_be_compiled(m, comp_level)) {
     nmethod* nm = m->code();
-#ifdef GRAALVM
-    if (m->queued_for_compilation()) {
-      delay_compilation(m());
-    } else
-#endif
     if (nm == NULL ) {
       CompileBroker::compile_method(m, InvocationEntryBci, comp_level, m, hot_count, comment, thread);
     }
@@ -469,6 +464,9 @@
   const int comp_level = CompLevel_highest_tier;
   const int hot_count = m->backedge_count();
   const char* comment = "backedge_count";
+#ifdef GRAALVM
+  reset_counter_for_back_branch_event(m);
+#endif
 
   if (is_compilation_enabled() && !m->is_not_osr_compilable(comp_level) && can_be_compiled(m, comp_level)) {
     CompileBroker::compile_method(m, bci, comp_level, m, hot_count, comment, thread);
@@ -513,7 +511,7 @@
           }
         }
       }
-     
+
       if (!m->queued_for_compilation()) {
         if (TraceCompilationPolicy) {
           tty->print("method invocation trigger: ");
@@ -531,6 +529,7 @@
 void GraalCompPolicy::method_back_branch_event(methodHandle m, int bci, JavaThread* thread) {
   int hot_count = m->backedge_count();
   const char* comment = "backedge_count";
+  reset_counter_for_back_branch_event(m);
 
   if (is_compilation_enabled() && !m->is_not_osr_compilable() && can_be_compiled(m) && !m->queued_for_compilation() && m->code() == NULL) {
     if (TraceCompilationPolicy) {
--- a/src/share/vm/runtime/globals.hpp	Mon Jul 08 12:01:51 2013 +0200
+++ b/src/share/vm/runtime/globals.hpp	Mon Jul 08 16:55:28 2013 +0200
@@ -2399,7 +2399,7 @@
   product(intx, CICompilerCount, CI_COMPILER_COUNT,                         \
           "Number of compiler threads to run")                              \
                                                                             \
-  product(intx, CompilationPolicyChoice, NOT_GRAALVM(0) GRAALVM_ONLY(4),    \
+  product(intx, CompilationPolicyChoice, 0,                                 \
           "which compilation policy (0/1)")                                 \
                                                                             \
   develop(bool, UseStackBanging, true,                                      \