Mercurial > hg > truffle
changeset 18203:b1607c3ebe4f
Truffle: refactor TraceTruffleCompilationCallTree into a separate class.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 27 Oct 2014 15:40:31 +0100 |
parents | b3f6b210f723 |
children | a1873eefea65 |
files | graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTargetLog.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/debug/TraceCompilationCallTreeListener.java |
diffstat | 4 files changed, 59 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java Mon Oct 27 15:30:53 2014 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java Mon Oct 27 15:40:31 2014 +0100 @@ -60,6 +60,7 @@ TraceCompilationFailureListener.install(this); TraceCompilationListener.install(this); TraceCompilationPolymorphismListener.install(this); + TraceCompilationCallTreeListener.install(this); TraceInliningListener.install(this); PrintCallTargetProfiling.install(this); }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTargetLog.java Mon Oct 27 15:30:53 2014 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTargetLog.java Mon Oct 27 15:40:31 2014 +0100 @@ -28,8 +28,6 @@ import java.util.*; import com.oracle.graal.debug.*; -import com.oracle.graal.truffle.TruffleInlining.CallTreeNodeVisitor; -import com.oracle.truffle.api.nodes.*; public final class OptimizedCallTargetLog { @@ -38,40 +36,6 @@ private OptimizedCallTargetLog() { } - public static void logTruffleCallTree(OptimizedCallTarget compilable) { - CallTreeNodeVisitor visitor = new CallTreeNodeVisitor() { - - public boolean visit(List<TruffleInlining> decisionStack, Node node) { - if (node instanceof OptimizedDirectCallNode) { - OptimizedDirectCallNode callNode = ((OptimizedDirectCallNode) node); - int depth = decisionStack == null ? 0 : decisionStack.size() - 1; - TruffleInliningDecision inlining = CallTreeNodeVisitor.getCurrentInliningDecision(decisionStack); - String dispatched = "<dispatched>"; - if (inlining != null && inlining.isInline()) { - dispatched = ""; - } - Map<String, Object> properties = new LinkedHashMap<>(); - addASTSizeProperty(callNode.getCurrentCallTarget(), properties); - properties.putAll(callNode.getCurrentCallTarget().getDebugProperties()); - properties.put("Stamp", callNode.getCurrentCallTarget().getArgumentStamp()); - log((depth * 2), "opt call tree", callNode.getCurrentCallTarget().toString() + dispatched, properties); - } else if (node instanceof OptimizedIndirectCallNode) { - int depth = decisionStack == null ? 0 : decisionStack.size() - 1; - log((depth * 2), "opt call tree", "<indirect>", new LinkedHashMap<String, Object>()); - } - return true; - } - - }; - - TruffleInlining inlining = compilable.getInlining(); - if (inlining == null) { - compilable.getRootNode().accept(visitor); - } else { - inlining.accept(compilable, visitor); - } - } - private static int splitCount = 0; static void logSplit(OptimizedDirectCallNode callNode, OptimizedCallTarget target, OptimizedCallTarget newTarget) {
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Mon Oct 27 15:30:53 2014 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Mon Oct 27 15:40:31 2014 +0100 @@ -129,10 +129,6 @@ if (TraceTruffleCompilationAST.getValue()) { OptimizedCallUtils.printCompactTree(OptimizedCallTarget.OUT, compilable); } - if (TraceTruffleCompilationCallTree.getValue()) { - OptimizedCallTargetLog.log(0, "opt call tree", compilable.toString(), compilable.getDebugProperties()); - OptimizedCallTargetLog.logTruffleCallTree(compilable); - } compilationNotify.notifyCompilationSuccess(compilable, graph, compilationResult); } catch (Throwable t) { compilationNotify.notifyCompilationFailed(compilable, graph, t);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/debug/TraceCompilationCallTreeListener.java Mon Oct 27 15:40:31 2014 +0100 @@ -0,0 +1,58 @@ +package com.oracle.graal.truffle.debug; + +import static com.oracle.graal.truffle.TruffleCompilerOptions.*; + +import java.util.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.nodes.*; +import com.oracle.graal.truffle.*; +import com.oracle.graal.truffle.TruffleInlining.*; +import com.oracle.truffle.api.nodes.*; + +public class TraceCompilationCallTreeListener extends AbstractDebugCompilationListener { + + private TraceCompilationCallTreeListener() { + } + + public static void install(GraalTruffleRuntime runtime) { + if (TraceTruffleCompilationCallTree.getValue()) { + runtime.addCompilationListener(new TraceCompilationCallTreeListener()); + } + } + + @Override + public void notifyCompilationSuccess(OptimizedCallTarget target, StructuredGraph graph, CompilationResult result) { + log(0, "opt call tree", target.toString(), target.getDebugProperties()); + logTruffleCallTree(target); + } + + private static void logTruffleCallTree(OptimizedCallTarget compilable) { + CallTreeNodeVisitor visitor = new CallTreeNodeVisitor() { + + public boolean visit(List<TruffleInlining> decisionStack, Node node) { + if (node instanceof OptimizedDirectCallNode) { + OptimizedDirectCallNode callNode = ((OptimizedDirectCallNode) node); + int depth = decisionStack == null ? 0 : decisionStack.size() - 1; + TruffleInliningDecision inlining = CallTreeNodeVisitor.getCurrentInliningDecision(decisionStack); + String dispatched = "<dispatched>"; + if (inlining != null && inlining.isInline()) { + dispatched = ""; + } + Map<String, Object> properties = new LinkedHashMap<>(); + addASTSizeProperty(callNode.getCurrentCallTarget(), properties); + properties.putAll(callNode.getCurrentCallTarget().getDebugProperties()); + properties.put("Stamp", callNode.getCurrentCallTarget().getArgumentStamp()); + log((depth * 2), "opt call tree", callNode.getCurrentCallTarget().toString() + dispatched, properties); + } else if (node instanceof OptimizedIndirectCallNode) { + int depth = decisionStack == null ? 0 : decisionStack.size() - 1; + log((depth * 2), "opt call tree", "<indirect>", new LinkedHashMap<String, Object>()); + } + return true; + } + + }; + compilable.accept(visitor, true); + } + +}