changeset 10642:678cdd287d60

Merge.
author Christian Haeubl <haeubl@ssw.jku.at>
date Mon, 08 Jul 2013 17:32:05 +0200
parents 4b88e5c93f04 (diff) 87c441b324e9 (current diff)
children 2abf1c8b062a 204d8d4f91a4
files
diffstat 13 files changed, 44 insertions(+), 77 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationStatistics.java	Mon Jul 08 14:34:45 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationStatistics.java	Mon Jul 08 17:32:05 2013 +0200
@@ -75,8 +75,6 @@
 
     @NotReported private final long startTime;
     @NotReported private long threadAllocatedBytesStart;
-    @NotReported private int startInvCount;
-    @NotReported private int endInvCount;
 
     private int bytecodeCount;
     private int codeSize;
@@ -94,7 +92,6 @@
             name = method.getName();
             signature = method.getSignature().getMethodDescriptor();
             startTime = System.nanoTime();
-            startInvCount = method.invocationCount();
             bytecodeCount = method.getCodeSize();
             threadAllocatedBytesStart = getThreadAllocatedBytes();
         } else {
@@ -108,7 +105,6 @@
     public void finish(HotSpotResolvedJavaMethod method) {
         if (ENABLED) {
             duration = System.nanoTime() - startTime;
-            endInvCount = method.invocationCount();
             codeSize = method.getCompiledCodeSize();
             memoryUsed = getThreadAllocatedBytes() - threadAllocatedBytesStart;
             if (current.get().getLast() != this) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Mon Jul 08 14:34:45 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Mon Jul 08 17:32:05 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/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Mon Jul 08 14:34:45 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Mon Jul 08 17:32:05 2013 +0200
@@ -92,14 +92,6 @@
     ResolvedJavaType getUniqueImplementor(HotSpotResolvedObjectType interfaceType);
 
     /**
-     * Gets the invocation count for a method.
-     * 
-     * @param metaspaceMethod the metaspace Method object to query
-     * @return the invocation count for the method
-     */
-    int getInvocationCount(long metaspaceMethod);
-
-    /**
      * Initializes a {@link HotSpotResolvedJavaMethod} object from a metaspace Method object.
      * 
      * @param metaspaceMethod the metaspace Method object
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Mon Jul 08 14:34:45 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Mon Jul 08 17:32:05 2013 +0200
@@ -73,9 +73,6 @@
     public native ResolvedJavaType getUniqueImplementor(HotSpotResolvedObjectType interfaceType);
 
     @Override
-    public native int getInvocationCount(long metaspaceMethod);
-
-    @Override
     public native JavaType lookupType(String name, HotSpotResolvedObjectType accessingClass, boolean eagerResolve);
 
     @Override
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java	Mon Jul 08 14:34:45 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java	Mon Jul 08 17:32:05 2013 +0200
@@ -262,8 +262,8 @@
         return graalRuntime().getCompilerToVM().getCompiledCodeSize(metaspaceMethod);
     }
 
-    public int invocationCount() {
-        return graalRuntime().getCompilerToVM().getInvocationCount(metaspaceMethod);
+    public boolean hasCompiledCode() {
+        return getCompiledCodeSize() > 0;
     }
 
     @Override
--- a/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	Mon Jul 08 14:34:45 2013 +0200
+++ b/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	Mon Jul 08 17:32:05 2013 +0200
@@ -304,7 +304,7 @@
 // Helpers for commoning out cases in the various type of method entries.
 //
 
-#ifdef GRAAL
+#ifdef GRAALVM
 
 void graal_initialize_time(JavaThread* thread) {
   assert(ProfileInterpreter, "must be profiling interpreter");
@@ -314,7 +314,7 @@
   fr.interpreter_frame_method()->method_counters()->set_graal_invocation_time(os::javaTimeNanos());
 }
 
-#endif // GRAAL
+#endif // GRAALVM
 
 // increment invocation count & check for overflow
 //
@@ -369,7 +369,7 @@
               MethodCounters::interpreter_invocation_counter_offset()));
     }
 
-#ifdef GRAAL
+#ifdef GRAALVM
     if (CompilationPolicyChoice == 4) {
       Label not_zero;
       __ testl(rcx, InvocationCounter::count_mask_value);
@@ -383,13 +383,15 @@
       __ 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);
     }
-#endif // GRAAL
+#endif // GRAALVM
 
     // Update standard invocation counters
     __ movl(rcx, invocation_counter);
--- a/src/share/vm/graal/graalCompiler.cpp	Mon Jul 08 14:34:45 2013 +0200
+++ b/src/share/vm/graal/graalCompiler.cpp	Mon Jul 08 17:32:05 2013 +0200
@@ -171,8 +171,8 @@
   ResourceMark rm;
   JavaThread::current()->set_is_compiling(true);
   Handle holder = GraalCompiler::createHotSpotResolvedObjectType(method, CHECK);
-  MethodCounters* mcs = method->method_counters();
-  VMToCompiler::compileMethod(method(), holder, entry_bci, blocking, mcs->graal_priority());
+  int priority = GRAALVM_ONLY(method->method_counters()->graal_priority()) NOT_GRAALVM(0);
+  VMToCompiler::compileMethod(method(), holder, entry_bci, blocking, priority);
   JavaThread::current()->set_is_compiling(false);
 }
 
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Mon Jul 08 14:34:45 2013 +0200
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Mon Jul 08 17:32:05 2013 +0200
@@ -297,11 +297,6 @@
   return NULL;
 C2V_END
 
-C2V_ENTRY(jint, getInvocationCount, (JNIEnv *, jobject, jlong metaspace_method))
-  Method* method = asMethod(metaspace_method);
-  return method->invocation_count();
-C2V_END
-
 C2V_VMENTRY(void, initializeMethod,(JNIEnv *, jobject, jlong metaspace_method, jobject hotspot_method))
   methodHandle method = asMethod(metaspace_method);
   Handle name = java_lang_String::create_from_symbol(method->name(), CHECK);
@@ -325,33 +320,7 @@
   HotSpotMethodData::set_normalDataSize(hotspot_method_data, method_data->data_size());
   HotSpotMethodData::set_extraDataSize(hotspot_method_data, method_data->extra_data_size());
 C2V_END
-
-// ------------------------------------------------------------------
-// Adjust a CounterData count to be commensurate with
-// interpreter_invocation_count.  If the MDO exists for
-// only 25% of the time the method exists, then the
-// counts in the MDO should be scaled by 4X, so that
-// they can be usefully and stably compared against the
-// invocation counts in methods.
-int scale_count(MethodData* method_data, int count) {
-  if (count > 0) {
-    int counter_life;
-    int method_life = method_data->method()->interpreter_invocation_count();
-    int current_mileage = MethodData::mileage_of(method_data->method());
-    int creation_mileage = method_data->creation_mileage();
-    counter_life = current_mileage - creation_mileage;
-
-    // counter_life due to backedge_counter could be > method_life
-    if (counter_life > method_life)
-      counter_life = method_life;
-    if (0 < counter_life && counter_life <= method_life) {
-      count = (int)((double)count * method_life / counter_life + 0.5);
-      count = (count > 0) ? count : 1;
-    }
-  }
-  return count;
-}
-
+  
 C2V_ENTRY(jint, getCompiledCodeSize, (JNIEnv *env, jobject, jlong metaspace_method))
   nmethod* code = (asMethod(metaspace_method))->code();
   return code == NULL ? 0 : code->insts_size();
@@ -1262,7 +1231,6 @@
   {CC"initializeMethod",              CC"("METASPACE_METHOD HS_RESOLVED_METHOD")V",                     FN_PTR(initializeMethod)},
   {CC"initializeMethodData",          CC"("METASPACE_METHOD_DATA METHOD_DATA")V",                       FN_PTR(initializeMethodData)},
   {CC"isMethodCompilable",            CC"("METASPACE_METHOD")Z",                                        FN_PTR(isMethodCompilable)},
-  {CC"getInvocationCount",            CC"("METASPACE_METHOD")I",                                        FN_PTR(getInvocationCount)},
   {CC"getCompiledCodeSize",           CC"("METASPACE_METHOD")I",                                        FN_PTR(getCompiledCodeSize)},
   {CC"getVtableEntryOffset",          CC"("METASPACE_METHOD")I",                                        FN_PTR(getVtableEntryOffset)},
   {CC"hasVtableEntry",                CC"("METASPACE_METHOD")Z",                                        FN_PTR(hasVtableEntry)},
--- a/src/share/vm/interpreter/invocationCounter.cpp	Mon Jul 08 14:34:45 2013 +0200
+++ b/src/share/vm/interpreter/invocationCounter.cpp	Mon Jul 08 17:32:05 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 14:34:45 2013 +0200
+++ b/src/share/vm/oops/methodCounters.cpp	Mon Jul 08 17:32:05 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 14:34:45 2013 +0200
+++ b/src/share/vm/oops/methodCounters.hpp	Mon Jul 08 17:32:05 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 14:34:45 2013 +0200
+++ b/src/share/vm/runtime/compilationPolicy.cpp	Mon Jul 08 17:32:05 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 14:34:45 2013 +0200
+++ b/src/share/vm/runtime/globals.hpp	Mon Jul 08 17:32:05 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,                                      \