# HG changeset patch # User Christian Humer # Date 1412868347 -7200 # Node ID c0f71f81708a820807189494d7584170cf41ffcf # Parent e3dd05527c2f117b93e0d956c1be8a1021cb5222 Truffle: fixes to the call tree logging. diff -r e3dd05527c2f -r c0f71f81708a graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTargetLog.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTargetLog.java Thu Oct 09 17:25:24 2014 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTargetLog.java Thu Oct 09 17:25:47 2014 +0200 @@ -76,14 +76,18 @@ } } - public static void logTruffleCalls(OptimizedCallTarget compilable) { + public static void logTruffleCallTree(OptimizedCallTarget compilable) { CallTreeNodeVisitor visitor = new CallTreeNodeVisitor() { public boolean visit(List decisionStack, Node node) { if (node instanceof OptimizedDirectCallNode) { + OptimizedDirectCallNode callNode = ((OptimizedDirectCallNode) node); int depth = decisionStack == null ? 0 : decisionStack.size(); - OptimizedDirectCallNode callNode = ((OptimizedDirectCallNode) node); - String dispatched = !callNode.isInlined() ? " " : ""; + TruffleInliningDecision inlining = CallTreeNodeVisitor.getCurrentInliningDecision(decisionStack); + String dispatched = ""; + if (inlining != null && inlining.isInline()) { + dispatched = ""; + } Map properties = new LinkedHashMap<>(); addASTSizeProperty(callNode.getCurrentCallTarget(), properties); properties.putAll(callNode.getCurrentCallTarget().getDebugProperties()); @@ -175,27 +179,15 @@ log(0, "opt done", target.toString(), properties); } if (TraceTruffleCompilationPolymorphism.getValue()) { - - target.getRootNode().accept(new NodeVisitor() { - public boolean visit(Node node) { - NodeCost kind = node.getCost(); - if (kind == NodeCost.POLYMORPHIC || kind == NodeCost.MEGAMORPHIC) { - Map props = new LinkedHashMap<>(); - props.put("simpleName", node.getClass().getSimpleName()); - props.put("subtree", "\n" + NodeUtil.printCompactTreeToString(node)); - String msg = kind == NodeCost.MEGAMORPHIC ? "megamorphic" : "polymorphic"; - log(0, msg, node.toString(), props); - } - if (node instanceof DirectCallNode) { - DirectCallNode callNode = (DirectCallNode) node; - if (callNode.isInlined()) { - callNode.getCurrentRootNode().accept(this); - } - } - return true; - } + target.nodeStream(true).filter(node -> node != null && (node.getCost() == NodeCost.MEGAMORPHIC || node.getCost() == NodeCost.POLYMORPHIC))// + .forEach(node -> { + NodeCost cost = node.getCost(); + Map props = new LinkedHashMap<>(); + props.put("simpleName", node.getClass().getSimpleName()); + props.put("subtree", "\n" + NodeUtil.printCompactTreeToString(node)); + String msg = cost == NodeCost.MEGAMORPHIC ? "megamorphic" : "polymorphic"; + log(0, msg, node.toString(), props); }); - } } diff -r e3dd05527c2f -r c0f71f81708a graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleInlining.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleInlining.java Thu Oct 09 17:25:24 2014 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleInlining.java Thu Oct 09 17:25:47 2014 +0200 @@ -190,6 +190,13 @@ return depth; } + static TruffleInliningDecision getCurrentInliningDecision(List decisionStack) { + if (decisionStack.size() <= 1) { + return null; + } + return (TruffleInliningDecision) decisionStack.get(decisionStack.size() - 1); + } + } /** diff -r e3dd05527c2f -r c0f71f81708a graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleTreeDumpHandler.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleTreeDumpHandler.java Thu Oct 09 17:25:24 2014 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleTreeDumpHandler.java Thu Oct 09 17:25:47 2014 +0200 @@ -25,7 +25,6 @@ import com.oracle.graal.debug.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.nodes.*; -import com.oracle.truffle.api.nodes.GraphPrintVisitor.ChildSupplier; public class TruffleTreeDumpHandler implements DebugDumpHandler { @@ -50,24 +49,7 @@ } private static void dumpFullTree(final GraphPrintVisitor visitor, final String message, final OptimizedCallTarget oct) { - - visitor.setChildSupplier(new ChildSupplier() { - - public Object startNode(Object callNode) { - if (callNode instanceof OptimizedDirectCallNode) { - if (((OptimizedDirectCallNode) callNode).isInlined()) { - return ((OptimizedDirectCallNode) callNode).getCurrentRootNode(); - } - } - return null; - } - - public void endNode(Object callNode) { - } - }); - visitor.beginGraph(message).visit(oct.getRootNode()); - visitor.setChildSupplier(null); } public void close() { diff -r e3dd05527c2f -r c0f71f81708a graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/GraphPrintVisitor.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/GraphPrintVisitor.java Thu Oct 09 17:25:24 2014 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/GraphPrintVisitor.java Thu Oct 09 17:25:47 2014 +0200 @@ -59,8 +59,6 @@ private Element nodesElement; private Element edgesElement; - private ChildSupplier childSupplier; - public GraphPrintVisitor() { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); try { @@ -75,14 +73,6 @@ 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); @@ -338,15 +328,6 @@ // 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 child : findNamedNodeChildren((Node) node).entrySet()) { visit(child.getValue());