Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java @ 9703:57113d21ce36
Added some tunable parameters to the inlining phase.
author | Christian Haeubl <haeubl@ssw.jku.at> |
---|---|
date | Mon, 13 May 2013 16:46:39 +0200 |
parents | 907f1124b427 |
children | f9a65a0e626b |
line wrap: on
line diff
--- 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; }