changeset 4457:5acf4a974e4a

fixed framestate for inlining multiple methods
author Christian Haeubl <christian.haeubl@oracle.com>
date Tue, 31 Jan 2012 17:09:11 -0800
parents f4c82dd4619e
children cdf13998f705
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.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.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/HotSpotMethodDataAccessor.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.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotProfilingInfo.java graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/BlockMap.java graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java
diffstat 10 files changed, 32 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiProfilingInfo.java	Tue Jan 31 11:37:16 2012 -0800
+++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiProfilingInfo.java	Tue Jan 31 17:09:11 2012 -0800
@@ -50,11 +50,10 @@
     RiTypeProfile getTypeProfile(int bci);
 
     /**
-     * Returns true if the given BCI did throw an implicit exception (NullPointerException, ClassCastException,
-     * ArrayStoreException, or ArithmeticException) during profiling.
-     * @return true if any of the exceptions was encountered during profiling, false otherwise.
+     * Returns true if the instruction at least once an exception was thrown at the given BCI.
+     * @return true if an exception was encountered during profiling, false otherwise.
      */
-    boolean getImplicitExceptionSeen(int bci);
+    boolean getExceptionSeen(int bci);
 
     /**
      * Returns an estimate how often the current BCI was executed. Avoid comparing execution counts to each other,
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java	Tue Jan 31 11:37:16 2012 -0800
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java	Tue Jan 31 17:09:11 2012 -0800
@@ -42,8 +42,8 @@
     public static boolean Inline                             = true;
     public static boolean Intrinsify                         = true;
     public static boolean CacheGraphs                        = ____;
-    public static boolean InlineWithTypeCheck                = true;
-    public static boolean InlineMultipleMethods              = true;
+    public static boolean InlineMonomorphicCalls             = true;
+    public static boolean InlinePolymorphicCalls             = true;
     public static int     MaximumInlineSize                  = 35;
     public static int     MaximumFreqInlineSize              = 300;
     public static int     FreqInlineRatio                    = 20;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.java	Tue Jan 31 11:37:16 2012 -0800
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.java	Tue Jan 31 17:09:11 2012 -0800
@@ -206,14 +206,13 @@
 
         @Override
         public void inline(StructuredGraph graph, GraalRuntime runtime, InliningCallback callback) {
-            MethodCallTargetNode callTargetNode = invoke.callTarget();
             int numberOfMethods = concretes.size();
             boolean hasReturnValue = invoke.node().kind() != CiKind.Void;
 
             // receiver null check must be the first node
             InliningUtil.receiverNullCheck(invoke);
             if (numberOfMethods > 1) {
-                inlineMultipleMethods(graph, callback, callTargetNode, numberOfMethods, hasReturnValue);
+                inlineMultipleMethods(graph, callback, numberOfMethods, hasReturnValue);
             } else {
                 inlineSingleMethod(graph, callback);
             }
@@ -223,7 +222,7 @@
             }
         }
 
-        private void inlineMultipleMethods(StructuredGraph graph, InliningCallback callback, MethodCallTargetNode callTargetNode, int numberOfMethods, boolean hasReturnValue) {
+        private void inlineMultipleMethods(StructuredGraph graph, InliningCallback callback, int numberOfMethods, boolean hasReturnValue) {
             assert concretes.size() > 1;
 
             // save continuation so that invoke can be deleted safely
@@ -299,7 +298,6 @@
             assert concretes.size() == 1;
 
             MergeNode calleeEntryNode = graph.add(new MergeNode());
-            calleeEntryNode.setStateAfter(invoke.stateAfter());
             FixedNode dispatchOnType = createDispatchOnType(graph, new BeginNode[] {calleeEntryNode});
 
             FixedWithNextNode pred = (FixedWithNextNode) invoke.node().predecessor();
@@ -384,7 +382,7 @@
         public String toString() {
             StringBuilder builder = new StringBuilder(String.format("type-checked inlining of %d methods with %d type checks: ", concretes.size(), types.length));
             for (int i = 0; i < concretes.size(); i++) {
-                builder.append(CiUtil.format("\n%H.%n(%p):%r", concretes.get(i)));
+                builder.append(CiUtil.format("\n        %H.%n(%p):%r", concretes.get(i)));
             }
             return builder.toString();
         }
@@ -474,16 +472,15 @@
             }
         }
         // TODO (tw) fix this
-        if (assumptions == null) {
-            return null;
-        }
-        RiResolvedMethod concrete = holder.uniqueConcreteMethod(callTarget.targetMethod());
-        if (concrete != null) {
-            if (checkTargetConditions(concrete)) {
-                double weight = callback == null ? 0 : callback.inliningWeight(parent, concrete, invoke);
-                return new AssumptionInlineInfo(invoke, weight, level, holder, concrete);
+        if (assumptions != null) {
+            RiResolvedMethod concrete = holder.uniqueConcreteMethod(callTarget.targetMethod());
+            if (concrete != null) {
+                if (checkTargetConditions(concrete)) {
+                    double weight = callback == null ? 0 : callback.inliningWeight(parent, concrete, invoke);
+                    return new AssumptionInlineInfo(invoke, weight, level, holder, concrete);
+                }
+                return null;
             }
-            return null;
         }
 
         RiProfilingInfo profilingInfo = parent.profilingInfo();
@@ -494,17 +491,17 @@
             double notRecordedProbability = typeProfile.getNotRecordedProbability();
             if (types != null && probabilities != null && types.length > 0) {
                 assert types.length == probabilities.length : "length must match";
-                if (GraalOptions.InlineWithTypeCheck) {
+                if (GraalOptions.InlineMonomorphicCalls) {
                     // type check and inlining...
                     if (types.length == 1) {
                         RiResolvedType type = types[0];
-                        concrete = type.resolveMethodImpl(callTarget.targetMethod());
+                        RiResolvedMethod concrete = type.resolveMethodImpl(callTarget.targetMethod());
                         if (concrete != null && checkTargetConditions(concrete)) {
                             double weight = callback == null ? 0 : callback.inliningWeight(parent, concrete, invoke);
                             return new TypeGuardInlineInfo(invoke, weight, level, concrete, type);
                         }
                         return null;
-                    } else if (GraalOptions.InlineMultipleMethods) {
+                    } else if (GraalOptions.InlinePolymorphicCalls) {
                         // TODO (ch) allow inlining only the most frequent calls (e.g. 8 different methods, inline only 2 and invoke others)
                         // may affect peak performance negatively if immature profiling information is used
                         // TODO (ch) sort types by probability
@@ -513,7 +510,7 @@
                         ArrayList<RiResolvedMethod> concreteMethods = new ArrayList<>();
                         int[] typesToConcretes = new int[types.length];
                         for (int i = 0; i < types.length; i++) {
-                            concrete = types[i].resolveMethodImpl(callTarget.targetMethod());
+                            RiResolvedMethod concrete = types[i].resolveMethodImpl(callTarget.targetMethod());
 
                             int index = concreteMethods.indexOf(concrete);
                             if (index < 0) {
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodData.java	Tue Jan 31 11:37:16 2012 -0800
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodData.java	Tue Jan 31 17:09:11 2012 -0800
@@ -161,7 +161,7 @@
     }
 
     private abstract static class AbstractMethodData implements HotSpotMethodDataAccessor {
-        private static final int IMPLICIT_EXCEPTIONS_MASK = 0x0E;
+        private static final int EXCEPTIONS_MASK = 0x08;
 
         private final int tag;
         private final int staticSize;
@@ -190,9 +190,8 @@
         }
 
         @Override
-        public boolean getImplicitExceptionSeen(HotSpotMethodData data, int position) {
-            // TODO (ch) might return true too often because flags are also used for deoptimization reasons
-            return (getFlags(data, position) & IMPLICIT_EXCEPTIONS_MASK) != 0;
+        public boolean getExceptionSeen(HotSpotMethodData data, int position) {
+            return (getFlags(data, position) & EXCEPTIONS_MASK) != 0;
         }
 
         @Override
@@ -239,7 +238,7 @@
 
 
         @Override
-        public boolean getImplicitExceptionSeen(HotSpotMethodData data, int position) {
+        public boolean getExceptionSeen(HotSpotMethodData data, int position) {
             return false;
         }
     }
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodDataAccessor.java	Tue Jan 31 11:37:16 2012 -0800
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodDataAccessor.java	Tue Jan 31 17:09:11 2012 -0800
@@ -51,6 +51,6 @@
     RiTypeProfile getTypeProfile(HotSpotMethodData data, int position);
     double getBranchTakenProbability(HotSpotMethodData data, int position);
     double[] getSwitchProbabilities(HotSpotMethodData data, int position);
-    boolean getImplicitExceptionSeen(HotSpotMethodData data, int position);
+    boolean getExceptionSeen(HotSpotMethodData data, int position);
     int getExecutionCount(HotSpotMethodData data, int position);
 }
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodResolvedImpl.java	Tue Jan 31 11:37:16 2012 -0800
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodResolvedImpl.java	Tue Jan 31 17:09:11 2012 -0800
@@ -241,7 +241,7 @@
                 TTY.println();
             }
 
-            if (profilingInfo.getImplicitExceptionSeen(i)) {
+            if (profilingInfo.getExceptionSeen(i)) {
                 TTY.println("  implicitExceptionSeen@%d: true", i);
             }
 
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotNoProfilingInfo.java	Tue Jan 31 11:37:16 2012 -0800
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotNoProfilingInfo.java	Tue Jan 31 17:09:11 2012 -0800
@@ -54,8 +54,8 @@
     }
 
     @Override
-    public boolean getImplicitExceptionSeen(int bci) {
-        return noData.getImplicitExceptionSeen(null, -1);
+    public boolean getExceptionSeen(int bci) {
+        return noData.getExceptionSeen(null, -1);
     }
 
     @Override
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotProfilingInfo.java	Tue Jan 31 11:37:16 2012 -0800
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotProfilingInfo.java	Tue Jan 31 17:09:11 2012 -0800
@@ -66,9 +66,9 @@
     }
 
     @Override
-    public boolean getImplicitExceptionSeen(int bci) {
+    public boolean getExceptionSeen(int bci) {
         findBCI(bci, true);
-        return dataAccessor.getImplicitExceptionSeen(methodData, position);
+        return dataAccessor.getExceptionSeen(methodData, position);
     }
 
     @Override
--- a/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/BlockMap.java	Tue Jan 31 11:37:16 2012 -0800
+++ b/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/BlockMap.java	Tue Jan 31 17:09:11 2012 -0800
@@ -388,7 +388,7 @@
             case PUTFIELD:
             case GETFIELD: {
                 if (GraalOptions.AllowExplicitExceptionChecks) {
-                    return profilingInfo.getImplicitExceptionSeen(bci);
+                    return profilingInfo.getExceptionSeen(bci);
                 }
             }
         }
--- a/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java	Tue Jan 31 11:37:16 2012 -0800
+++ b/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java	Tue Jan 31 17:09:11 2012 -0800
@@ -324,7 +324,7 @@
         assert bci == FrameState.BEFORE_BCI || bci == bci() : "invalid bci";
 
         if (GraalOptions.UseExceptionProbability && method.invocationCount() > GraalOptions.MatureInvocationCount) {
-            if (bci != FrameState.BEFORE_BCI && exceptionObject == null && !profilingInfo.getImplicitExceptionSeen(bci)) {
+            if (bci != FrameState.BEFORE_BCI && exceptionObject == null && !profilingInfo.getExceptionSeen(bci)) {
                 return null;
             }
         }