changeset 9706:f44d7e24cebd

Fixes for the merge and inlining cleanups.
author Christian Haeubl <haeubl@ssw.jku.at>
date Tue, 14 May 2013 10:17:06 +0200
parents de7319e48e48
children cf0e31151830
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java
diffstat 4 files changed, 40 insertions(+), 102 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Mon May 13 17:43:42 2013 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Tue May 14 10:17:06 2013 +0200
@@ -145,13 +145,12 @@
                     new IterativeConditionalEliminationPhase().apply(graph, highTierContext);
                 }
             }
-            InliningPhase.storeHighLevelStatistics(graph);
+            InliningPhase.storeStatisticsAfterInlining(graph);
         }
         TypeProfileProxyNode.cleanFromGraph(graph);
 
         plan.runPhases(PhasePosition.HIGH_LEVEL, graph);
         Suites.DEFAULT.getHighTier().apply(graph, highTierContext);
-        InliningPhase.storeMidLevelStatistics(graph);
 
         MidTierContext midTierContext = new MidTierContext(runtime, assumptions, replacements, target, optimisticOpts);
         Suites.DEFAULT.getMidTier().apply(graph, midTierContext);
@@ -160,7 +159,7 @@
 
         LowTierContext lowTierContext = new LowTierContext(runtime, assumptions, replacements, target);
         Suites.DEFAULT.getLowTier().apply(graph, lowTierContext);
-        InliningPhase.storeLowLevelStatistics(graph);
+        InliningPhase.storeStatisticsAfterLowTier(graph);
 
         final SchedulePhase schedule = new SchedulePhase();
         schedule.apply(graph);
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java	Mon May 13 17:43:42 2013 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java	Tue May 14 10:17:06 2013 +0200
@@ -89,25 +89,16 @@
         return inliningCount;
     }
 
-    public static void storeHighLevelStatistics(StructuredGraph graph) {
+    public static void storeStatisticsAfterInlining(StructuredGraph graph) {
         ResolvedJavaMethod method = graph.method();
         if (method != null) {
             CompiledMethodInfo info = compiledMethodInfo(method);
             double summedUpProbabilityOfRemainingInvokes = sumUpInvokeProbabilities(graph);
             info.setSummedUpProbabilityOfRemainingInvokes(summedUpProbabilityOfRemainingInvokes);
-            info.setHighLevelNodeCount(graph.getNodeCount());
         }
     }
 
-    public static void storeMidLevelStatistics(StructuredGraph graph) {
-        ResolvedJavaMethod method = graph.method();
-        if (method != null) {
-            CompiledMethodInfo info = compiledMethodInfo(graph.method());
-            info.setMidLevelNodeCount(graph.getNodeCount());
-        }
-    }
-
-    public static void storeLowLevelStatistics(StructuredGraph graph) {
+    public static void storeStatisticsAfterLowTier(StructuredGraph graph) {
         ResolvedJavaMethod method = graph.method();
         if (method != null) {
             CompiledMethodInfo info = compiledMethodInfo(graph.method());
@@ -185,7 +176,7 @@
         InlineInfo callee = calleeInfo.callee();
         try {
             List<Node> invokeUsages = callee.invoke().asNode().usages().snapshot();
-            callee.inline(runtime, callerAssumptions);
+            callee.inline(runtime, callerAssumptions, replacements);
             callerAssumptions.record(calleeInfo.assumptions());
             metricInliningRuns.increment();
             Debug.dump(callerGraph, "after %s", callee);
@@ -253,33 +244,31 @@
                     parseBytecodes(newGraph, assumptions);
                 }
 
-                if (GraalOptions.PropagateArgumentsDuringInlining) {
-                    boolean callerHasMoreInformationAboutArguments = false;
-                    NodeInputList<ValueNode> args = invoke.callTarget().arguments();
-                    for (LocalNode localNode : newGraph.getNodes(LocalNode.class).snapshot()) {
-                        ValueNode arg = args.get(localNode.index());
-                        if (arg.isConstant()) {
-                            Constant constant = arg.asConstant();
-                            newGraph.replaceFloating(localNode, ConstantNode.forConstant(constant, runtime, newGraph));
+                boolean callerHasMoreInformationAboutArguments = false;
+                NodeInputList<ValueNode> args = invoke.callTarget().arguments();
+                for (LocalNode localNode : newGraph.getNodes(LocalNode.class).snapshot()) {
+                    ValueNode arg = args.get(localNode.index());
+                    if (arg.isConstant()) {
+                        Constant constant = arg.asConstant();
+                        newGraph.replaceFloating(localNode, ConstantNode.forConstant(constant, runtime, newGraph));
+                        callerHasMoreInformationAboutArguments = true;
+                    } else {
+                        Stamp joinedStamp = localNode.stamp().join(arg.stamp());
+                        if (!joinedStamp.equals(localNode.stamp())) {
+                            localNode.setStamp(joinedStamp);
                             callerHasMoreInformationAboutArguments = true;
-                        } else {
-                            Stamp joinedStamp = localNode.stamp().join(arg.stamp());
-                            if (!joinedStamp.equals(localNode.stamp())) {
-                                localNode.setStamp(joinedStamp);
-                                callerHasMoreInformationAboutArguments = true;
-                            }
                         }
                     }
+                }
 
-                    if (!callerHasMoreInformationAboutArguments) {
-                        // TODO (chaeubl): if args are not more concrete, inlining should be avoided
-                        // in most cases or we could at least use the previous graph size + invoke
-                        // probability to check the inlining
-                    }
+                if (!callerHasMoreInformationAboutArguments) {
+                    // TODO (chaeubl): if args are not more concrete, inlining should be avoided
+                    // in most cases or we could at least use the previous graph size + invoke
+                    // probability to check the inlining
+                }
 
-                    if (GraalOptions.OptCanonicalizer) {
-                        new CanonicalizerPhase.Instance(runtime, assumptions).apply(newGraph);
-                    }
+                if (GraalOptions.OptCanonicalizer) {
+                    new CanonicalizerPhase.Instance(runtime, assumptions).apply(newGraph);
                 }
 
                 return newGraph;
@@ -387,22 +376,6 @@
             return true;
         }
 
-        protected static int previousHighLevelGraphSize(InlineInfo info) {
-            int size = 0;
-            for (int i = 0; i < info.numberOfMethods(); i++) {
-                size += compiledMethodInfo(info.methodAt(i)).highLevelNodeCount();
-            }
-            return size;
-        }
-
-        protected static int previousMidLevelGraphSize(InlineInfo info) {
-            int size = 0;
-            for (int i = 0; i < info.numberOfMethods(); i++) {
-                size += compiledMethodInfo(info.methodAt(i)).midLevelNodeCount();
-            }
-            return size;
-        }
-
         protected static int previousLowLevelGraphSize(InlineInfo info) {
             int size = 0;
             for (int i = 0; i < info.numberOfMethods(); i++) {
@@ -467,16 +440,6 @@
 
             double inliningBonus = getInliningBonus(info);
 
-            int highLevelGraphSize = previousHighLevelGraphSize(info);
-            if (GraalOptions.SmallCompiledHighLevelGraphSize > 0 && highLevelGraphSize > GraalOptions.SmallCompiledHighLevelGraphSize * inliningBonus) {
-                return InliningUtil.logNotInlinedMethod(info, "too large previous high-level graph: %d", highLevelGraphSize);
-            }
-
-            int midLevelGraphSize = previousMidLevelGraphSize(info);
-            if (GraalOptions.SmallCompiledMidLevelGraphSize > 0 && midLevelGraphSize > GraalOptions.SmallCompiledMidLevelGraphSize * inliningBonus) {
-                return InliningUtil.logNotInlinedMethod(info, "too large previous mid-level graph: %d", midLevelGraphSize);
-            }
-
             int lowLevelGraphSize = previousLowLevelGraphSize(info);
             if (GraalOptions.SmallCompiledLowLevelGraphSize > 0 && lowLevelGraphSize > GraalOptions.SmallCompiledLowLevelGraphSize * inliningBonus) {
                 return InliningUtil.logNotInlinedMethod(info, "too large previous low-level graph: %d", lowLevelGraphSize);
@@ -817,30 +780,12 @@
 
     private static class CompiledMethodInfo {
 
-        private int highLevelNodes;
-        private int midLevelNodes;
         private int lowLevelNodes;
         private double summedUpProbabilityOfRemainingInvokes;
 
         public CompiledMethodInfo() {
         }
 
-        public int highLevelNodeCount() {
-            return highLevelNodes;
-        }
-
-        public void setHighLevelNodeCount(int highLevelNodes) {
-            this.highLevelNodes = highLevelNodes;
-        }
-
-        public int midLevelNodeCount() {
-            return midLevelNodes;
-        }
-
-        public void setMidLevelNodeCount(int midLevelNodes) {
-            this.midLevelNodes = midLevelNodes;
-        }
-
         public int lowLevelNodeCount() {
             return lowLevelNodes;
         }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java	Mon May 13 17:43:42 2013 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java	Tue May 14 10:17:06 2013 +0200
@@ -249,7 +249,7 @@
          * return value of the inlined method (or null for void methods and methods that have no
          * non-exceptional exit).
          **/
-        void inline(MetaAccessProvider runtime, Assumptions assumptions);
+        void inline(MetaAccessProvider runtime, Assumptions assumptions, Replacements replacements);
 
         /**
          * Try to make the call static bindable to avoid interface and virtual method calls.
@@ -337,7 +337,7 @@
         }
 
         @Override
-        public void inline(MetaAccessProvider runtime, Assumptions assumptions) {
+        public void inline(MetaAccessProvider runtime, Assumptions assumptions, Replacements replacements) {
             inline(invoke, concrete, inlineableElement, assumptions, true);
         }
 
@@ -440,7 +440,7 @@
         }
 
         @Override
-        public void inline(MetaAccessProvider runtime, Assumptions assumptions) {
+        public void inline(MetaAccessProvider runtime, Assumptions assumptions, Replacements replacements) {
             createGuard(graph(), runtime);
             inline(invoke, concrete, inlineableElement, assumptions, false);
         }
@@ -560,13 +560,13 @@
         }
 
         @Override
-        public void inline(MetaAccessProvider runtime, Assumptions assumptions) {
+        public void inline(MetaAccessProvider runtime, Assumptions assumptions, Replacements replacements) {
             // receiver null check must be the first node
             InliningUtil.receiverNullCheck(invoke);
             if (hasSingleMethod()) {
                 inlineSingleMethod(graph(), runtime, assumptions);
             } else {
-                inlineMultipleMethods(graph(), runtime, assumptions);
+                inlineMultipleMethods(graph(), runtime, assumptions, replacements);
             }
         }
 
@@ -578,7 +578,7 @@
             return notRecordedTypeProbability > 0;
         }
 
-        private void inlineMultipleMethods(StructuredGraph graph, MetaAccessProvider runtime, Assumptions assumptions) {
+        private void inlineMultipleMethods(StructuredGraph graph, MetaAccessProvider runtime, Assumptions assumptions, Replacements replacements) {
             int numberOfMethods = concretes.size();
             FixedNode continuation = invoke.next();
 
@@ -685,14 +685,11 @@
                     current = ((FixedWithNextNode) current).next();
                 } while (current instanceof FixedWithNextNode);
 
-                // TEMP:
-// if (opportunities > 0) {
-// metricInliningTailDuplication.increment();
-// Debug.log("MultiTypeGuardInlineInfo starting tail duplication (%d opportunities)",
-// opportunities);
-// TailDuplicationPhase.tailDuplicate(returnMerge, TailDuplicationPhase.TRUE_DECISION,
-// replacementNodes, new HighTierContext(runtime, assumptions, replacements));
-// }
+                if (opportunities > 0) {
+                    metricInliningTailDuplication.increment();
+                    Debug.log("MultiTypeGuardInlineInfo starting tail duplication (%d opportunities)", opportunities);
+                    TailDuplicationPhase.tailDuplicate(returnMerge, TailDuplicationPhase.TRUE_DECISION, replacementNodes, new HighTierContext(runtime, assumptions, replacements));
+                }
             }
         }
 
@@ -990,9 +987,9 @@
         }
 
         @Override
-        public void inline(MetaAccessProvider runtime, Assumptions assumptions) {
+        public void inline(MetaAccessProvider runtime, Assumptions assumptions, Replacements replacements) {
             assumptions.record(takenAssumption);
-            super.inline(runtime, assumptions);
+            super.inline(runtime, assumptions, replacements);
         }
 
         @Override
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java	Mon May 13 17:43:42 2013 +0200
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java	Tue May 14 10:17:06 2013 +0200
@@ -58,12 +58,9 @@
     public static boolean IterativeInlining                  = ____;
 
     public static int     TrivialInliningSize                = 10;
-    public static int     MaximumInliningSize                = 180;
-    public static int     SmallCompiledHighLevelGraphSize    = 0;
-    public static int     SmallCompiledMidLevelGraphSize     = 0;
-    public static int     SmallCompiledLowLevelGraphSize     = 250;
+    public static int     MaximumInliningSize                = 300;
+    public static int     SmallCompiledLowLevelGraphSize     = 300;
     public static double  LimitInlinedInvokes                = 10.0;
-    public static boolean PropagateArgumentsDuringInlining   = true;
 
     // escape analysis settings
     public static boolean PartialEscapeAnalysis              = true;