diff graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/GraphPrintVisitor.java @ 14982:1422f0bd55e3

Truffle: Truffle API changes for context sensitive inlining.
author Christian Humer <christian.humer@gmail.com>
date Thu, 03 Apr 2014 18:33:48 +0200
parents 5d1308c78ddc
children c0f71f81708a
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/GraphPrintVisitor.java	Thu Apr 03 18:32:39 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/GraphPrintVisitor.java	Thu Apr 03 18:33:48 2014 +0200
@@ -59,6 +59,8 @@
     private Element nodesElement;
     private Element edgesElement;
 
+    private ChildSupplier childSupplier;
+
     public GraphPrintVisitor() {
         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
         try {
@@ -73,6 +75,14 @@
         dom.appendChild(graphDocument);
     }
 
+    public void setChildSupplier(ChildSupplier callNodeVisitor) {
+        this.childSupplier = callNodeVisitor;
+    }
+
+    public ChildSupplier getChildSupplier() {
+        return childSupplier;
+    }
+
     public GraphPrintVisitor beginGroup(String groupName) {
         groupElement = dom.createElement("group");
         graphDocument.appendChild(groupElement);
@@ -328,6 +338,15 @@
             // default handler
             createElementForNode(node);
 
+            if (childSupplier != null) {
+                Object result = childSupplier.startNode(node);
+                if (result != null) {
+                    visit(result);
+                    connectNodes(node, result, "inlined");
+                }
+                childSupplier.endNode(node);
+            }
+
             if (node instanceof Node) {
                 for (Map.Entry<String, Node> child : findNamedNodeChildren((Node) node).entrySet()) {
                     visit(child.getValue());
@@ -343,13 +362,6 @@
         LinkedHashMap<String, Node> nodes = new LinkedHashMap<>();
         NodeClass nodeClass = NodeClass.get(node.getClass());
 
-        if (node instanceof CallNode) {
-            CallNode callNode = ((CallNode) node);
-            RootNode inlinedRoot = callNode.getCurrentRootNode();
-            if (inlinedRoot != null && callNode.isInlined()) {
-                nodes.put("inlinedRoot", inlinedRoot);
-            }
-        }
         for (NodeField field : nodeClass.getFields()) {
             NodeFieldKind kind = field.getKind();
             if (kind == NodeFieldKind.CHILD || kind == NodeFieldKind.CHILDREN) {
@@ -396,6 +408,15 @@
         void visit(Object node, GraphPrintAdapter gPrinter);
     }
 
+    public interface ChildSupplier {
+
+        /** Supplies an additional child if available. */
+        Object startNode(Object callNode);
+
+        void endNode(Object callNode);
+
+    }
+
     @Retention(RetentionPolicy.RUNTIME)
     @Target(ElementType.TYPE)
     public @interface CustomGraphPrintHandler {