Mercurial > hg > truffle
changeset 10607:dd5a042811f6
enhanced debug context for inlining so that inlining hierarchy is correctly shown in IGV
added documentation and toString() implementation for inlining utility classes
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 04 Jul 2013 15:03:43 +0200 |
parents | a6c0ae38e05e |
children | eeb80dcd60d8 |
files | graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java |
diffstat | 1 files changed, 63 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java Thu Jul 04 14:53:28 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java Thu Jul 04 15:03:43 2013 +0200 @@ -33,6 +33,7 @@ import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.java.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; import com.oracle.graal.nodes.util.*; @@ -123,10 +124,10 @@ @Override protected void run(final StructuredGraph graph) { - InliningData data = new InliningData(graph, compilationAssumptions); + final InliningData data = new InliningData(graph, compilationAssumptions); while (data.hasUnprocessedGraphs()) { - MethodInvocation currentInvocation = data.currentInvocation(); + final MethodInvocation currentInvocation = data.currentInvocation(); GraphInfo graphInfo = data.currentGraph(); if (!currentInvocation.isRoot() && !inliningPolicy.isWorthInlining(currentInvocation.callee(), data.inliningDepth(), currentInvocation.probability(), currentInvocation.relevance(), false)) { int remainingGraphs = currentInvocation.totalGraphs() - currentInvocation.processedGraphs(); @@ -142,8 +143,15 @@ currentInvocation.incrementProcessedGraphs(); if (currentInvocation.processedGraphs() == currentInvocation.totalGraphs()) { data.popInvocation(); - MethodInvocation parentInvoke = data.currentInvocation(); - tryToInline(data.currentGraph(), currentInvocation, parentInvoke, data.inliningDepth() + 1); + final MethodInvocation parentInvoke = data.currentInvocation(); + Debug.scope("Inlining", data.inliningContext(), new Runnable() { + + @Override + public void run() { + tryToInline(data.currentGraph(), currentInvocation, parentInvoke, data.inliningDepth() + 1); + } + }); + } } } @@ -581,6 +589,9 @@ private static final GraphInfo DummyGraphInfo = new GraphInfo(null, new LinkedList<Invoke>(), 1.0, 1.0); + /** + * Call hierarchy from outer most call (i.e., compilation unit) to inner most callee. + */ private final ArrayDeque<GraphInfo> graphQueue; private final ArrayDeque<MethodInvocation> invocationQueue; @@ -632,6 +643,18 @@ } } + /** + * Gets the call hierarchy of this inling from outer most call to inner most callee. + */ + public Object[] inliningContext() { + Object[] result = new Object[graphQueue.size()]; + int i = 0; + for (GraphInfo g : graphQueue) { + result[i++] = g.graph.method(); + } + return result; + } + public MethodInvocation currentInvocation() { return invocationQueue.peek(); } @@ -670,10 +693,12 @@ StringBuilder result = new StringBuilder("Invocations: "); for (MethodInvocation invocation : invocationQueue) { - result.append(invocation.callee().numberOfMethods()); - result.append("x "); - result.append(invocation.callee().invoke()); - result.append("; "); + if (invocation.callee() != null) { + result.append(invocation.callee().numberOfMethods()); + result.append("x "); + result.append(invocation.callee().invoke()); + result.append("; "); + } } result.append("\nGraphs: "); @@ -754,8 +779,26 @@ public boolean isRoot() { return callee == null; } + + @Override + public String toString() { + if (isRoot()) { + return "<root>"; + } + CallTargetNode callTarget = callee.invoke().callTarget(); + if (callTarget instanceof MethodCallTargetNode) { + ResolvedJavaMethod calleeMethod = ((MethodCallTargetNode) callTarget).targetMethod(); + return MetaUtil.format("Invoke#%H.%n(%p)", calleeMethod); + } else { + return "Invoke#" + callTarget.targetName(); + } + } } + /** + * Information about a graph that will potentially be inlined. This includes tracking the + * invocations in graph that will subject to inlining themselves. + */ private static class GraphInfo { private final StructuredGraph graph; @@ -777,6 +820,10 @@ } } + /** + * Gets the method associated with the {@linkplain #graph() graph} represented by this + * object. + */ public ResolvedJavaMethod method() { return graph.method(); } @@ -785,6 +832,9 @@ return !remainingInvokes.isEmpty(); } + /** + * The graph about which this object contains inlining information. + */ public StructuredGraph graph() { return graph; } @@ -809,6 +859,11 @@ public double invokeRelevance(Invoke invoke) { return Math.min(CapInheritedRelevance.getValue(), relevance) * nodeRelevance.get(invoke.asNode()); } + + @Override + public String toString() { + return MetaUtil.format("%H.%n(%p)", method()) + remainingInvokes; + } } private static class CompiledMethodInfo {