# HG changeset patch # User Christian Wimmer # Date 1335553468 25200 # Node ID 8ac40aed34bf547c471cf6d2f7907890ddabf1c1 # Parent 8ab14908fb3c9f8a7c3a7181acfd39d72a0be73b Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions diff -r 8ab14908fb3c -r 8ac40aed34bf graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/InliningPhase.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/InliningPhase.java Fri Apr 27 13:12:39 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/InliningPhase.java Fri Apr 27 12:04:28 2012 -0700 @@ -80,7 +80,7 @@ @SuppressWarnings("unchecked") @Override - protected void run(StructuredGraph graph) { + protected void run(final StructuredGraph graph) { graph.createNodeMap(); if (hints != null) { @@ -91,8 +91,16 @@ } while (!inlineCandidates.isEmpty() && graph.getNodeCount() < GraalOptions.MaximumDesiredSize) { - InlineInfo info = inlineCandidates.remove(); - if (info.invoke.node().isAlive() && inliningPolicy.isWorthInlining(graph, info)) { + final InlineInfo info = inlineCandidates.remove(); + + boolean inline = Debug.scope("InliningDecisions", new Callable() { + @Override + public Boolean call() throws Exception { + return info.invoke.node().isAlive() && inliningPolicy.isWorthInlining(graph, info); + } + }); + + if (inline) { Iterable newNodes = null; try { info.inline(graph, runtime, this); @@ -124,24 +132,35 @@ } if (GraalOptions.Debug && graph.getNodeCount() >= GraalOptions.MaximumDesiredSize) { - Debug.log("inlining cut off by MaximumDesiredSize"); + Debug.scope("InliningDecisions", new Runnable() { + public void run() { + for (InlineInfo info : inlineCandidates) { + Debug.log("not inlining %s because inlining cut off by MaximumDesiredSize", InliningUtil.methodName(info)); + } + } + }); + metricInliningStoppedByMaxDesiredSize.increment(); } } - private void scanInvokes(Iterable newNodes, int level, StructuredGraph graph) { - graph.mark(); - for (Node node : newNodes) { - if (node != null) { - if (node instanceof Invoke) { - Invoke invoke = (Invoke) node; - scanInvoke(invoke, level); - } - for (Node usage : node.usages().filterInterface(Invoke.class).snapshot()) { - scanInvoke((Invoke) usage, level); + private void scanInvokes(final Iterable newNodes, final int level, final StructuredGraph graph) { + Debug.scope("InliningDecisions", new Runnable() { + public void run() { + graph.mark(); + for (Node node : newNodes) { + if (node != null) { + if (node instanceof Invoke) { + Invoke invoke = (Invoke) node; + scanInvoke(invoke, level); + } + for (Node usage : node.usages().filterInterface(Invoke.class).snapshot()) { + scanInvoke((Invoke) usage, level); + } + } } } - } + }); } private void scanInvoke(Invoke invoke, int level) { @@ -282,11 +301,11 @@ double penalty = Math.pow(GraalOptions.InliningSizePenaltyExp, callerGraph.getNodeCount() / (double) GraalOptions.MaximumDesiredSize) / GraalOptions.InliningSizePenaltyExp; if (info.weight > GraalOptions.MaximumInlineWeight / (1 + penalty * GraalOptions.InliningSizePenalty)) { - Debug.log("not inlining (cut off by weight %e): %s", info.weight, info); + Debug.log("not inlining %s (cut off by weight %e)", InliningUtil.methodName(info), info.weight); return false; } - Debug.log("inlining (weight %f): %s", info.weight, info); + Debug.log("inlining %s (weight %f): %s", InliningUtil.methodName(info), info.weight); return true; } } @@ -361,15 +380,15 @@ private static boolean decideSizeBasedInlining(InlineInfo info, double maxSize) { boolean success = info.weight <= maxSize; if (DebugScope.getInstance().isLogEnabled()) { - String formatterString = success ? "inlining invoke at %s@%d (size %f <= %f): %s" : "not inlining invoke at %s@%d (too large %f > %f): %s"; - Debug.log(formatterString, CiUtil.format("%H.%n(%p):%r", info.invoke.stateAfter().method()), info.invoke.bci(), info.weight, maxSize, info); + String formatterString = success ? "inlining %s (size %f <= %f)" : "not inlining %s (too large %f > %f)"; + Debug.log(formatterString, InliningUtil.methodName(info), info.weight, maxSize); } return success; } private static boolean checkCompiledCodeSize(InlineInfo info) { if (GraalOptions.SmallCompiledCodeSize >= 0 && info.compiledCodeSize() > GraalOptions.SmallCompiledCodeSize) { - Debug.log("not inlining invoke at %s@%d (CompiledCodeSize %d > %d): %s", CiUtil.format("%H.%n(%p):%r", info.invoke.stateAfter().method()), info.invoke.bci(), info.compiledCodeSize(), GraalOptions.SmallCompiledCodeSize, info); + Debug.log("not inlining %s (CompiledCodeSize %d > %d)", InliningUtil.methodName(info), info.compiledCodeSize(), GraalOptions.SmallCompiledCodeSize); return false; } return true; diff -r 8ab14908fb3c -r 8ac40aed34bf graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/util/InliningUtil.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/util/InliningUtil.java Fri Apr 27 13:12:39 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/util/InliningUtil.java Fri Apr 27 12:04:28 2012 -0700 @@ -51,21 +51,35 @@ void recordConcreteMethodAssumption(RiResolvedMethod method, RiResolvedType context, RiResolvedMethod impl); } - private static String methodName(RiResolvedMethod method, Invoke invoke) { - if (Debug.isLogEnabled()) { - if (invoke != null && invoke.stateAfter() != null) { - RiMethod parent = invoke.stateAfter().method(); - return parent.name() + "@" + invoke.bci() + ": " + methodNameAndCodeSize(method); - } else { - return methodNameAndCodeSize(method); - } + public static String methodName(RiResolvedMethod method, Invoke invoke) { + if (!Debug.isLogEnabled()) { + return null; + } else if (invoke != null && invoke.stateAfter() != null) { + return methodName(invoke.stateAfter(), invoke.bci()) + ": " + CiUtil.format("%H.%n(%p):%r", method) + " (" + method.codeSize() + " bytes)"; } else { - return null; + return CiUtil.format("%H.%n(%p):%r", method) + " (" + method.codeSize() + " bytes)"; } } - private static String methodNameAndCodeSize(RiResolvedMethod method) { - return CiUtil.format("%H.%n(%p):%r", method) + " (" + method.codeSize() + " bytes)"; + public static String methodName(InlineInfo info) { + if (!Debug.isLogEnabled()) { + return null; + } else if (info.invoke != null && info.invoke.stateAfter() != null) { + return methodName(info.invoke.stateAfter(), info.invoke.bci()) + ": " + info.toString(); + } else { + return info.toString(); + } + } + + private static String methodName(FrameState frameState, int bci) { + StringBuilder sb = new StringBuilder(); + if (frameState.outerFrameState() != null) { + sb.append(methodName(frameState.outerFrameState(), frameState.outerFrameState().bci)); + sb.append("->"); + } + sb.append(CiUtil.format("%h.%n", frameState.method())); + sb.append("@").append(bci); + return sb.toString(); } /**