Mercurial > hg > truffle
diff graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java @ 14073:c5411233cdf8
Truffle: Now keeps track of all not just inlined call-sites called by CallNode. Deprecated some old API in NodeUtil.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Wed, 05 Mar 2014 23:33:25 +0100 |
parents | 655a4fd5038b |
children | 5d1308c78ddc |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java Wed Mar 05 21:37:50 2014 +0100 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java Wed Mar 05 23:33:25 2014 +0100 @@ -452,6 +452,10 @@ return null; } + /** + * @deprecated will be removed, exposed Truffle runtime specific functionality. + */ + @Deprecated public static List<CallTarget> findOutermostCallTargets(Node node) { RootNode root = node.getRootNode(); if (root == null) { @@ -459,19 +463,16 @@ } List<CallTarget> roots = new ArrayList<>(); roots.add(root.getCallTarget()); - for (CallNode callNode : root.getParentInlinedCalls()) { - roots.addAll(findOutermostCallTargets(callNode)); + for (CallNode callNode : root.getCachedCallNodes()) { + if (callNode.isInlined()) { + roots.addAll(findOutermostCallTargets(callNode)); + } } return roots; } /** - * Returns the outermost not inlined {@link RootNode} which is a parent of this node. - * - * @see RootNode#getParentInlinedCalls() - * @param node to search - * @return the outermost {@link RootNode} - * @deprecated use {@link #findOutermostCallTargets(Node)} + * @deprecated will be removed, exposed Truffle runtime specific functionality. */ @Deprecated public static RootNode findOutermostRootNode(Node node) { @@ -617,7 +618,7 @@ } public static int countNodes(Node root, Class<?> clazz, Kind nodeKind, boolean countInlinedCallNodes) { - NodeCountVisitor nodeCount = new NodeCountVisitor(root, clazz, nodeKind, countInlinedCallNodes); + NodeCountVisitor nodeCount = new NodeCountVisitor(clazz, nodeKind, countInlinedCallNodes); root.accept(nodeCount); return nodeCount.nodeCount; } @@ -628,14 +629,12 @@ private static final class NodeCountVisitor implements NodeVisitor { - private Node root; private final boolean inspectInlinedCalls; int nodeCount; private final Kind kind; private final Class<?> clazz; - private NodeCountVisitor(Node root, Class<?> clazz, Kind kind, boolean inspectInlinedCalls) { - this.root = root; + private NodeCountVisitor(Class<?> clazz, Kind kind, boolean inspectInlinedCalls) { this.clazz = clazz; this.kind = kind; this.inspectInlinedCalls = inspectInlinedCalls; @@ -643,10 +642,6 @@ @Override public boolean visit(Node node) { - if (node instanceof RootNode && node != root) { - return false; - } - if ((clazz == null || clazz.isInstance(node)) && (kind == null || isKind(node))) { nodeCount++; } @@ -654,7 +649,10 @@ if (inspectInlinedCalls && node instanceof CallNode) { CallNode call = (CallNode) node; if (call.isInlined()) { - call.getInlinedRoot().getChildren().iterator().next().accept(this); + Node target = ((RootCallTarget) call.getCurrentCallTarget()).getRootNode(); + if (target != null) { + target.accept(this); + } } } @@ -673,8 +671,9 @@ public boolean visit(Node node) { if (node instanceof CallNode) { - RootNode inlinedRoot = ((CallNode) node).getInlinedRoot(); - if (inlinedRoot != null) { + CallNode callNode = ((CallNode) node); + RootNode inlinedRoot = callNode.getCurrentRootNode(); + if (inlinedRoot != null && callNode.isInlined()) { depth++; printRootNode(stream, depth * 2, inlinedRoot); inlinedRoot.accept(this);