# HG changeset patch # User Christian Haeubl # Date 1368456399 -7200 # Node ID 57113d21ce3619a6432888f777227a01cd269b9b # Parent 907f1124b4274f17f867f301cef7a28eec4a5c7c Added some tunable parameters to the inlining phase. diff -r 907f1124b427 -r 57113d21ce36 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Mon May 13 13:55:41 2013 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Mon May 13 16:46:39 2013 +0200 @@ -133,12 +133,12 @@ new IterativeConditionalEliminationPhase().apply(graph, highTierContext); } } - InliningPhase.saveGraphStatistics(graph); + InliningPhase.storeHighLevelStatistics(graph); } plan.runPhases(PhasePosition.HIGH_LEVEL, graph); - Suites.DEFAULT.getHighTier().apply(graph, highTierContext); + InliningPhase.storeMidLevelStatistics(graph); MidTierContext midTierContext = new MidTierContext(runtime, assumptions, replacements, target); Suites.DEFAULT.getMidTier().apply(graph, midTierContext); @@ -147,6 +147,7 @@ LowTierContext lowTierContext = new LowTierContext(runtime, assumptions, replacements, target); Suites.DEFAULT.getLowTier().apply(graph, lowTierContext); + InliningPhase.storeLowLevelStatistics(graph); final SchedulePhase schedule = new SchedulePhase(); schedule.apply(graph); diff -r 907f1124b427 -r 57113d21ce36 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java Mon May 13 13:55:41 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java Mon May 13 16:46:39 2013 +0200 @@ -89,13 +89,23 @@ return inliningCount; } - public static void saveGraphStatistics(StructuredGraph graph) { + public static void storeHighLevelStatistics(StructuredGraph graph) { CompiledMethodInfo info = compiledMethodInfo(graph.method()); double summedUpProbabilityOfRemainingInvokes = sumUpInvokeProbabilities(graph); info.setSummedUpProbabilityOfRemainingInvokes(summedUpProbabilityOfRemainingInvokes); info.setHighLevelNodeCount(graph.getNodeCount()); } + public static void storeMidLevelStatistics(StructuredGraph graph) { + CompiledMethodInfo info = compiledMethodInfo(graph.method()); + info.setMidLevelNodeCount(graph.getNodeCount()); + } + + public static void storeLowLevelStatistics(StructuredGraph graph) { + CompiledMethodInfo info = compiledMethodInfo(graph.method()); + info.setLowLevelNodeCount(graph.getNodeCount()); + } + @Override protected void run(final StructuredGraph graph) { InliningData data = new InliningData(); @@ -368,10 +378,26 @@ return true; } - protected static int previousHIRSize(InlineInfo info) { + protected static int previousHighLevelGraphSize(InlineInfo info) { int size = 0; for (int i = 0; i < info.numberOfMethods(); i++) { - size += compiledMethodInfo(info.methodAt(i)).highLevelNodes(); + 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++) { + size += compiledMethodInfo(info.methodAt(i)).lowLevelNodeCount(); } return size; } @@ -432,9 +458,19 @@ double inliningBonus = getInliningBonus(info); - int hirSize = previousHIRSize(info); - if (hirSize > GraalOptions.SmallCompiledGraphSize * inliningBonus) { - return InliningUtil.logNotInlinedMethod(info, "too large HIR graph: %s", hirSize); + 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); } /* @@ -445,7 +481,7 @@ */ int nodes = determineNodeCount(info); - if (nodes < GraalOptions.TrivialHighLevelGraphSize * inliningBonus) { + if (nodes < GraalOptions.TrivialInliningSize * inliningBonus) { return InliningUtil.logInlinedMethod(info, fullyProcessed, "trivial (nodes=%d)", nodes); } @@ -454,7 +490,7 @@ return InliningUtil.logNotInlinedMethod(info, "invoke probability is too high (%f)", invokes); } - double maximumNodes = computeMaximumSize(relevance, (int) (GraalOptions.NormalHighLevelGraphSize * inliningBonus)); + double maximumNodes = computeMaximumSize(relevance, (int) (GraalOptions.MaximumInliningSize * inliningBonus)); if (nodes < maximumNodes) { return InliningUtil.logInlinedMethod(info, fullyProcessed, "relevance-based (relevance=%f, nodes=%d)", relevance, nodes); } @@ -766,19 +802,21 @@ } public double invokeRelevance(Invoke invoke) { - return relevance * nodeRelevance.get(invoke.asNode()); + return Math.min(GraalOptions.CapInheritedRelevance, relevance) * nodeRelevance.get(invoke.asNode()); } } private static class CompiledMethodInfo { private int highLevelNodes; + private int midLevelNodes; + private int lowLevelNodes; private double summedUpProbabilityOfRemainingInvokes; public CompiledMethodInfo() { } - public int highLevelNodes() { + public int highLevelNodeCount() { return highLevelNodes; } @@ -786,6 +824,22 @@ this.highLevelNodes = highLevelNodes; } + public int midLevelNodeCount() { + return midLevelNodes; + } + + public void setMidLevelNodeCount(int midLevelNodes) { + this.midLevelNodes = midLevelNodes; + } + + public int lowLevelNodeCount() { + return lowLevelNodes; + } + + public void setLowLevelNodeCount(int lowLevelNodes) { + this.lowLevelNodes = lowLevelNodes; + } + public double summedUpProbabilityOfRemainingInvokes() { return summedUpProbabilityOfRemainingInvokes; } diff -r 907f1124b427 -r 57113d21ce36 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java Mon May 13 13:55:41 2013 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java Mon May 13 16:46:39 2013 +0200 @@ -49,11 +49,14 @@ public static int MaximumRecursiveInlining = 1; public static float BoostInliningForEscapeAnalysis = 2f; public static float RelevanceCapForInlining = 1f; + public static float CapInheritedRelevance = 1f; public static boolean IterativeInlining = ____; - public static int TrivialHighLevelGraphSize = 10; - public static int NormalHighLevelGraphSize = 300; - public static int SmallCompiledGraphSize = 300; + 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 double LimitInlinedInvokes = 10.0; public static boolean PropagateArgumentsDuringInlining = true;