changeset 22897:71c1991bb6f0

TruffleTreeDumpHandler: dump inlined trees to IGV
author Andreas Woess <andreas.woess@oracle.com>
date Wed, 28 Oct 2015 18:47:41 +0100
parents afe502521189
children f22b9506329a
files graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleTreeDumpHandler.java
diffstat 2 files changed, 29 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java	Wed Oct 28 18:47:22 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java	Wed Oct 28 18:47:41 2015 +0100
@@ -159,7 +159,7 @@
     @SuppressWarnings("try")
     public StructuredGraph createGraph(final OptimizedCallTarget callTarget, AllowAssumptions allowAssumptions) {
         try (Scope c = Debug.scope("TruffleTree")) {
-            Debug.dump(callTarget, "truffle tree");
+            Debug.dump(callTarget, callTarget.toString());
         } catch (Throwable e) {
             throw Debug.handle(e);
         }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleTreeDumpHandler.java	Wed Oct 28 18:47:22 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleTreeDumpHandler.java	Wed Oct 28 18:47:41 2015 +0100
@@ -23,33 +23,52 @@
 package com.oracle.graal.truffle;
 
 import com.oracle.graal.debug.DebugDumpHandler;
+import com.oracle.truffle.api.CallTarget;
 import com.oracle.truffle.api.RootCallTarget;
+import com.oracle.truffle.api.nodes.DirectCallNode;
 import com.oracle.truffle.api.nodes.GraphPrintVisitor;
+import com.oracle.truffle.api.nodes.NodeUtil;
 
 public class TruffleTreeDumpHandler implements DebugDumpHandler {
 
     @Override
     public void dump(Object object, final String message) {
         if (object instanceof RootCallTarget) {
-            RootCallTarget callTarget = (RootCallTarget) object;
-            dumpRootCallTarget(message, callTarget);
+            dumpRootCallTarget(message, (RootCallTarget) object);
         }
     }
 
     private static void dumpRootCallTarget(final String message, RootCallTarget callTarget) {
         if (callTarget.getRootNode() != null) {
-            final GraphPrintVisitor visitor = new GraphPrintVisitor();
+            final GraphPrintVisitor printer = new GraphPrintVisitor();
 
-            final OptimizedCallTarget oct = (OptimizedCallTarget) callTarget;
+            printer.beginGroup(callTarget.toString());
+            printer.beginGraph(message).visit(callTarget.getRootNode()).endGraph();
+            if (callTarget instanceof OptimizedCallTarget) {
+                TruffleInlining inlining = new TruffleInlining((OptimizedCallTarget) callTarget, new DefaultInliningPolicy());
+                if (inlining.countInlinedCalls() > 0) {
+                    dumpInlinedTrees(printer, (OptimizedCallTarget) callTarget, inlining);
+                }
+            }
+            printer.endGroup();
 
-            visitor.beginGroup(callTarget.toString());
-            dumpFullTree(visitor, message, oct);
-            visitor.printToNetwork(false);
+            printer.printToNetwork(false);
         }
     }
 
-    private static void dumpFullTree(final GraphPrintVisitor visitor, final String message, final OptimizedCallTarget oct) {
-        visitor.beginGraph(message).visit(oct.getRootNode());
+    private static void dumpInlinedTrees(final GraphPrintVisitor printer, final OptimizedCallTarget callTarget, TruffleInlining inlining) {
+        for (DirectCallNode callNode : NodeUtil.findAllNodeInstances(callTarget.getRootNode(), DirectCallNode.class)) {
+            CallTarget inlinedCallTarget = callNode.getCurrentCallTarget();
+            if (inlinedCallTarget instanceof OptimizedCallTarget && callNode instanceof OptimizedDirectCallNode) {
+                TruffleInliningDecision decision = inlining.findByCall((OptimizedDirectCallNode) callNode);
+                if (decision != null && decision.isInline()) {
+                    printer.beginGroup(inlinedCallTarget.toString());
+                    printer.beginGraph(inlinedCallTarget.toString()).visit(((RootCallTarget) inlinedCallTarget).getRootNode()).endGraph();
+                    dumpInlinedTrees(printer, (OptimizedCallTarget) inlinedCallTarget, decision);
+                    printer.endGroup();
+                }
+            }
+        }
     }
 
     public void close() {