changeset 13769:af344056124f

Only use mature method datas
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Wed, 22 Jan 2014 11:10:09 -0800
parents a7cb9f383ec4
children 6187b0862ba0
files graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/DefaultProfilingInfo.java graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ProfilingInfo.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ProfilingInfoTest.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProfilingInfo.java src/share/vm/graal/graalCompilerToVM.cpp
diffstat 8 files changed, 59 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/DefaultProfilingInfo.java	Wed Jan 22 10:54:38 2014 -0800
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/DefaultProfilingInfo.java	Wed Jan 22 11:10:09 2014 -0800
@@ -95,4 +95,8 @@
     public String toString() {
         return "BaseProfilingInfo<" + MetaUtil.profileToString(this, null, "; ") + ">";
     }
+
+    public void setMature() {
+        // Do nothing
+    }
 }
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ProfilingInfo.java	Wed Jan 22 10:54:38 2014 -0800
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ProfilingInfo.java	Wed Jan 22 11:10:09 2014 -0800
@@ -121,4 +121,9 @@
      */
     boolean isMature();
 
+    /**
+     * Force data to be treated as mature if possible.
+     */
+
+    void setMature();
 }
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ProfilingInfoTest.java	Wed Jan 22 10:54:38 2014 -0800
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ProfilingInfoTest.java	Wed Jan 22 11:10:09 2014 -0800
@@ -323,7 +323,10 @@
             }
         }
 
-        return javaMethod.getProfilingInfo();
+        ProfilingInfo info = javaMethod.getProfilingInfo();
+        // The execution counts are low so force maturity
+        info.setMature();
+        return info;
     }
 
     private void resetProfile(String methodName) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Wed Jan 22 10:54:38 2014 -0800
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Wed Jan 22 11:10:09 2014 -0800
@@ -258,6 +258,8 @@
      */
     long[] collectCounters();
 
+    boolean isMature(long metaspaceMethodData);
+
     /**
      * Generate a unique id to identify the result of the compile.
      */
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Wed Jan 22 10:54:38 2014 -0800
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Wed Jan 22 11:10:09 2014 -0800
@@ -169,5 +169,7 @@
 
     public native long[] collectCounters();
 
+    public native boolean isMature(long method);
+
     public native int allocateCompileId(HotSpotResolvedJavaMethod method, int entryBCI);
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java	Wed Jan 22 10:54:38 2014 -0800
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java	Wed Jan 22 11:10:09 2014 -0800
@@ -207,6 +207,14 @@
         return cells * config.dataLayoutCellSize;
     }
 
+    /**
+     * Returns whether profiling ran long enough that the profile information is mature. Other
+     * informational data will still be valid even if the profile isn't mature.
+     */
+    public boolean isProfileMature() {
+        return runtime().getCompilerToVM().isMature(metaspaceMethodData);
+    }
+
     @Override
     public String toString() {
         StringBuilder sb = new StringBuilder();
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProfilingInfo.java	Wed Jan 22 10:54:38 2014 -0800
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProfilingInfo.java	Wed Jan 22 11:10:09 2014 -0800
@@ -34,6 +34,7 @@
     private final HotSpotMethodData methodData;
     private final HotSpotResolvedJavaMethod method;
 
+    private boolean isMature;
     private int position;
     private int hintPosition;
     private int hintBCI;
@@ -47,6 +48,7 @@
         this.method = method;
         this.includeNormal = includeNormal;
         this.includeOSR = includeOSR;
+        this.isMature = methodData.isProfileMature();
         hintPosition = 0;
         hintBCI = -1;
     }
@@ -58,24 +60,36 @@
 
     @Override
     public JavaTypeProfile getTypeProfile(int bci) {
+        if (!isMature) {
+            return null;
+        }
         findBCI(bci, false);
         return dataAccessor.getTypeProfile(methodData, position);
     }
 
     @Override
     public JavaMethodProfile getMethodProfile(int bci) {
+        if (!isMature) {
+            return null;
+        }
         findBCI(bci, false);
         return dataAccessor.getMethodProfile(methodData, position);
     }
 
     @Override
     public double getBranchTakenProbability(int bci) {
+        if (!isMature) {
+            return -1;
+        }
         findBCI(bci, false);
         return dataAccessor.getBranchTakenProbability(methodData, position);
     }
 
     @Override
     public double[] getSwitchProbabilities(int bci) {
+        if (!isMature) {
+            return null;
+        }
         findBCI(bci, false);
         return dataAccessor.getSwitchProbabilities(methodData, position);
     }
@@ -94,6 +108,9 @@
 
     @Override
     public int getExecutionCount(int bci) {
+        if (!isMature) {
+            return -1;
+        }
         findBCI(bci, false);
         return dataAccessor.getExecutionCount(methodData, position);
     }
@@ -172,11 +189,20 @@
 
     @Override
     public boolean isMature() {
-        return true;
+        return isMature;
+    }
+
+    public void ignoreMature() {
+        isMature = true;
     }
 
     @Override
     public String toString() {
         return "HotSpotProfilingInfo<" + MetaUtil.profileToString(this, null, "; ") + ">";
     }
+
+    @Override
+    public void setMature() {
+        isMature = true;
+    }
 }
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Wed Jan 22 10:54:38 2014 -0800
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Wed Jan 22 11:10:09 2014 -0800
@@ -827,6 +827,11 @@
 C2V_END
 
 
+C2V_VMENTRY(jboolean, isMature, (JNIEnv *env, jobject, jlong metaspace_method_data))
+  MethodData* mdo = asMethodData(metaspace_method_data);
+  return mdo != NULL && mdo->is_mature();
+C2V_END
+
 #define CC (char*)  /*cast a literal from (const char*)*/
 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(c2v_ ## f))
 
@@ -846,6 +851,7 @@
 #define HS_INSTALLED_CODE     "Lcom/oracle/graal/hotspot/meta/HotSpotInstalledCode;"
 #define METASPACE_KLASS       "J"
 #define METASPACE_METHOD      "J"
+#define METASPACE_METHOD_DATA "J"
 #define METASPACE_CONSTANT_POOL "J"
 
 JNINativeMethod CompilerToVM_methods[] = {
@@ -889,6 +895,7 @@
   {CC"readUnsafeKlassPointer",        CC"("OBJECT")J",                                                  FN_PTR(readUnsafeKlassPointer)},
   {CC"collectCounters",               CC"()[J",                                                         FN_PTR(collectCounters)},
   {CC"allocateCompileId",             CC"("HS_RESOLVED_METHOD"I)I",                                     FN_PTR(allocateCompileId)},
+  {CC"isMature",                      CC"("METASPACE_METHOD_DATA")Z",                                   FN_PTR(isMature)},
 };
 
 int CompilerToVM_methods_count() {