changeset 4551:a7a16015e47f

changed profiling maturity so that profiling information is used more likely
author Christian Haeubl <christian.haeubl@oracle.com>
date Thu, 09 Feb 2012 13:26:51 -0800
parents df329f268a05
children bc14f8e7d5ed
files graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiProfilingInfo.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVM.java graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVMImpl.java graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodData.java graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodResolvedImpl.java graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotNoProfilingInfo.java graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/BciBlockMapping.java graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/DegeneratedLoopsTest.java src/share/vm/graal/graalCompiler.cpp src/share/vm/graal/graalCompilerToVM.cpp src/share/vm/graal/graalJavaAccess.hpp
diffstat 13 files changed, 23 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiProfilingInfo.java	Thu Feb 09 18:20:56 2012 +0100
+++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiProfilingInfo.java	Thu Feb 09 13:26:51 2012 -0800
@@ -24,9 +24,10 @@
 
 
 /**
- * Represents profiling information for one specific method.
- * Every accessor method returns the information that is available at the time of its invocation.
- * If a method is invoked multiple times, it may return a significantly different results for every invocation.
+ * Provides access to the profiling information of one specific method.
+ * Every accessor method returns the information that is available at the time of invocation.
+ * If a method is invoked multiple times, it may return significantly different results for every invocation
+ * as the profiling information may be changed by other Java threads at any time.
  */
 public interface RiProfilingInfo {
     /**
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java	Thu Feb 09 18:20:56 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java	Thu Feb 09 13:26:51 2012 -0800
@@ -70,6 +70,11 @@
     // absolute probability analysis
     public static boolean ProbabilityAnalysis                = true;
 
+    // profiling information
+    public static int     MatureExecutionsBranch             = 50;
+    public static int     MatureExecutionsPerSwitchCase      = 15;
+    public static int     MatureExecutionsTypeProfile        = 100;
+
     //rematerialize settings
     public static float   MinimumUsageProbability            = 0.95f;
 
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVM.java	Thu Feb 09 18:20:56 2012 +0100
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVM.java	Thu Feb 09 13:26:51 2012 -0800
@@ -51,8 +51,6 @@
 
     HotSpotMethodData RiMethod_methodData(HotSpotMethodResolved method);
 
-    boolean HotSpotMethodData_isMature(HotSpotMethodData methodData);
-
     RiType RiSignature_lookupType(String returnType, HotSpotTypeResolved accessingClass, boolean eagerResolve);
 
     Object RiConstantPool_lookupConstant(HotSpotTypeResolved pool, int cpi);
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVMImpl.java	Thu Feb 09 18:20:56 2012 +0100
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVMImpl.java	Thu Feb 09 13:26:51 2012 -0800
@@ -114,9 +114,6 @@
     public native HotSpotMethodData RiMethod_methodData(HotSpotMethodResolved method);
 
     @Override
-    public native boolean HotSpotMethodData_isMature(HotSpotMethodData methodData);
-
-    @Override
     public native RiType getType(Class<?> javaClass);
 
     @Override
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodData.java	Thu Feb 09 18:20:56 2012 +0100
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodData.java	Thu Feb 09 13:26:51 2012 -0800
@@ -27,6 +27,7 @@
 import sun.misc.*;
 
 import com.oracle.max.cri.ri.*;
+import com.oracle.max.graal.compiler.*;
 import com.oracle.max.graal.hotspot.*;
 import com.oracle.max.graal.hotspot.Compiler;
 
@@ -57,7 +58,6 @@
     private Object hotspotMirror;
     private int normalDataSize;
     private int extraDataSize;
-    private boolean mature;
 
     private HotSpotMethodData(Compiler compiler) {
         super(compiler);
@@ -76,19 +76,6 @@
         return normalDataSize;
     }
 
-    public boolean isMature() {
-        // TODO (ch) maturity of profiling information is an issue in general. Not all optimizations require mature data as long as the code
-        // does deoptimize/recompile on violations (might decrease startup and increase peak performance).
-        // Maturity is currently used on several levels:
-        // 1) whole method data
-        // 2) individual branch/switch profiling data
-        // 3) MatureInvocationCount for eliminating exception edges
-        if (!mature) {
-            mature = compiler.getVMEntries().HotSpotMethodData_isMature(this);
-        }
-        return mature;
-    }
-
     public boolean isWithin(int position) {
         return position >= 0 && position < normalDataSize + extraDataSize;
     }
@@ -381,7 +368,7 @@
             RiResolvedType[] types;
             double[] probabilities;
 
-            if (entries <= 0) {
+            if (entries <= 0 || totalCount < GraalOptions.MatureExecutionsTypeProfile) {
                 return null;
             } else if (entries < sparseTypes.length) {
                 types = Arrays.copyOf(sparseTypes, entries);
@@ -459,7 +446,6 @@
         private static final int BRANCH_DATA_TAG = 7;
         private static final int BRANCH_DATA_SIZE = cellIndexToOffset(3);
         private static final int NOT_TAKEN_COUNT_OFFSET = cellIndexToOffset(2);
-        private static final int BRANCH_DATA_MATURE_COUNT = 40;
 
         public BranchData() {
             super(BRANCH_DATA_TAG, BRANCH_DATA_SIZE);
@@ -471,7 +457,7 @@
             long notTakenCount = data.readUnsignedInt(position, NOT_TAKEN_COUNT_OFFSET);
             long total = takenCount + notTakenCount;
 
-            if (total < BRANCH_DATA_MATURE_COUNT) {
+            if (total < GraalOptions.MatureExecutionsBranch) {
                 return -1;
             } else {
                 return takenCount / (double) total;
@@ -536,7 +522,7 @@
                 result[i - 1] = count;
             }
 
-            if (totalCount < 10 * (length + 2)) {
+            if (totalCount < GraalOptions.MatureExecutionsPerSwitchCase * length) {
                 return null;
             } else {
                 for (int i = 0; i < length; i++) {
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodResolvedImpl.java	Thu Feb 09 18:20:56 2012 +0100
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodResolvedImpl.java	Thu Feb 09 13:26:51 2012 -0800
@@ -203,7 +203,7 @@
             methodData = compiler.getVMEntries().RiMethod_methodData(this);
         }
 
-        if (methodData == null || !methodData.isMature()) {
+        if (methodData == null) {
             return new HotSpotNoProfilingInfo(compiler);
         } else {
             return new HotSpotProfilingInfo(compiler, methodData);
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotNoProfilingInfo.java	Thu Feb 09 18:20:56 2012 +0100
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotNoProfilingInfo.java	Thu Feb 09 13:26:51 2012 -0800
@@ -26,13 +26,17 @@
 import com.oracle.max.graal.hotspot.*;
 import com.oracle.max.graal.hotspot.Compiler;
 
-
+/**
+ * Dummy profiling information in case that a method was not executed frequently enough so that
+ * no profiling information does exist yet.
+ */
 public final class HotSpotNoProfilingInfo extends CompilerObject implements RiProfilingInfo {
     /**
      *
      */
     private static final long serialVersionUID = 4357945025049704109L;
-    private static final HotSpotMethodDataAccessor noData = HotSpotMethodData.getNoDataExceptionPossibleAccessor();
+    // Be optimistic and return false for exceptionSeen. A methodDataOop is allocated in case of a deoptimization.
+    private static final HotSpotMethodDataAccessor noData = HotSpotMethodData.getNoDataNoExceptionAccessor();
 
     public HotSpotNoProfilingInfo(Compiler compiler) {
         super(compiler);
--- a/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/BciBlockMapping.java	Thu Feb 09 18:20:56 2012 +0100
+++ b/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/BciBlockMapping.java	Thu Feb 09 13:26:51 2012 -0800
@@ -388,7 +388,7 @@
             case PUTFIELD:
             case GETFIELD: {
                 if (GraalOptions.AllowExplicitExceptionChecks) {
-                    return profilingInfo.getExceptionSeen(bci) == RiExceptionSeen.TRUE;
+                    return profilingInfo.getExceptionSeen(bci) != RiExceptionSeen.FALSE;
                 }
             }
         }
--- a/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java	Thu Feb 09 18:20:56 2012 +0100
+++ b/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java	Thu Feb 09 13:26:51 2012 -0800
@@ -324,7 +324,7 @@
 
         if (GraalOptions.UseExceptionProbability) {
             // be conservative if information was not recorded (could result in endless recompiles otherwise)
-            if (bci != FrameState.BEFORE_BCI && exceptionObject == null && profilingInfo.getExceptionSeen(bci) != RiExceptionSeen.TRUE) {
+            if (bci != FrameState.BEFORE_BCI && exceptionObject == null && profilingInfo.getExceptionSeen(bci) == RiExceptionSeen.FALSE) {
                 return null;
             } else {
                 Debug.log("Creating exception edges at %d, exception object=%s, exception seen=%s", bci, exceptionObject, profilingInfo.getExceptionSeen(bci));
--- a/graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/DegeneratedLoopsTest.java	Thu Feb 09 18:20:56 2012 +0100
+++ b/graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/DegeneratedLoopsTest.java	Thu Feb 09 13:26:51 2012 -0800
@@ -23,9 +23,8 @@
 package com.oracle.max.graal.compiler.tests;
 
 import static com.oracle.max.graal.graph.iterators.NodePredicates.*;
-import junit.framework.*;
 
-import org.junit.Test;
+import org.junit.*;
 
 import com.oracle.max.graal.compiler.phases.*;
 import com.oracle.max.graal.debug.*;
--- a/src/share/vm/graal/graalCompiler.cpp	Thu Feb 09 18:20:56 2012 +0100
+++ b/src/share/vm/graal/graalCompiler.cpp	Thu Feb 09 13:26:51 2012 -0800
@@ -291,7 +291,6 @@
   HotSpotMethodData::set_hotspotMirror(obj, method_data());
   HotSpotMethodData::set_normalDataSize(obj, method_data()->data_size());
   HotSpotMethodData::set_extraDataSize(obj, method_data()->extra_data_size());
-  HotSpotMethodData::set_mature(obj, method_data()->is_mature());
 
   method_data->set_graal_mirror(obj());
   return obj;
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Thu Feb 09 18:20:56 2012 +0100
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Thu Feb 09 13:26:51 2012 -0800
@@ -200,13 +200,6 @@
   }
 }
 
-JNIEXPORT jboolean JNICALL Java_com_oracle_max_graal_hotspot_bridge_CompilerToVMImpl_HotSpotMethodData_1isMature(JNIEnv *, jobject, jobject hotspot_method_data) {
-  TRACE_graal_3("CompilerToVM::HotSpotMethodData_isMature");
-  VM_ENTRY_MARK;
-  methodDataHandle method_data = getMethodDataFromHotSpotMethodData(hotspot_method_data);
-  return method_data->is_mature();
-}
-
 // ------------------------------------------------------------------
 // Adjust a CounterData count to be commensurate with
 // interpreter_invocation_count.  If the MDO exists for
@@ -951,7 +944,6 @@
   {CC"RiMethod_uniqueConcreteMethod",     CC"("RESOLVED_METHOD")"METHOD,              FN_PTR(RiMethod_1uniqueConcreteMethod)},
   {CC"getRiMethod",                       CC"("REFLECT_METHOD")"METHOD,               FN_PTR(getRiMethod)},
   {CC"RiMethod_methodData",               CC"("RESOLVED_METHOD")"METHOD_DATA,         FN_PTR(RiMethod_1methodData)},
-  {CC"HotSpotMethodData_isMature",        CC"("METHOD_DATA")Z",                       FN_PTR(HotSpotMethodData_1isMature)},
   {CC"RiMethod_invocationCount",          CC"("RESOLVED_METHOD")I",                   FN_PTR(RiMethod_1invocationCount)},
   {CC"RiMethod_hasCompiledCode",          CC"("RESOLVED_METHOD")Z",                   FN_PTR(RiMethod_1hasCompiledCode)},
   {CC"RiMethod_getCompiledCodeSize",      CC"("RESOLVED_METHOD")I",                   FN_PTR(RiMethod_1getCompiledCodeSize)},
--- a/src/share/vm/graal/graalJavaAccess.hpp	Thu Feb 09 18:20:56 2012 +0100
+++ b/src/share/vm/graal/graalJavaAccess.hpp	Thu Feb 09 13:26:51 2012 -0800
@@ -75,7 +75,6 @@
     oop_field(HotSpotMethodData, hotspotMirror, "Ljava/lang/Object;")                   \
     int_field(HotSpotMethodData, normalDataSize)                                        \
     int_field(HotSpotMethodData, extraDataSize)                                         \
-    boolean_field(HotSpotMethodData, mature)                                            \
   end_class                                                                             \
   start_class(HotSpotType)                                                              \
     oop_field(HotSpotType, name, "Ljava/lang/String;")                                  \