Mercurial > hg > truffle
changeset 19859:ba265a5410e0
Add utility Node#pushInputs(NodeStack).
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sun, 15 Mar 2015 13:40:28 +0100 |
parents | 1cbbdc29ab45 |
children | d4c45ab543c8 |
files | graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Edges.java graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java graal/com.oracle.graal.printer/src/com/oracle/graal/printer/BinaryGraphPrinter.java |
diffstat | 4 files changed, 57 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Edges.java Sat Mar 14 22:45:52 2015 +0100 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Edges.java Sun Mar 15 13:40:28 2015 +0100 @@ -528,22 +528,56 @@ } index++; } - int count = getCount(); + int count = curOffsets.length; while (index < count) { NodeList<Node> list = getNodeList(node, curOffsets, index); - if (list != null) { - for (int i = 0; i < list.size(); ++i) { - Node curNode = list.get(i); - if (curNode != null) { - consumer.accept(node, curNode); - } + acceptHelper(node, consumer, list); + index++; + } + } + + private static void acceptHelper(Node node, BiConsumer<Node, Node> consumer, NodeList<Node> list) { + if (list != null) { + for (int i = 0; i < list.size(); ++i) { + Node curNode = list.get(i); + if (curNode != null) { + consumer.accept(node, curNode); } } - index++; } } public long[] getOffsets() { return this.offsets; } + + public void pushAll(Node node, NodeStack stack) { + int index = 0; + int curDirectCount = this.directCount; + final long[] curOffsets = this.offsets; + while (index < curDirectCount) { + Node curNode = getNode(node, curOffsets, index); + if (curNode != null) { + stack.push(curNode); + } + index++; + } + int count = curOffsets.length; + while (index < count) { + NodeList<Node> list = getNodeList(node, curOffsets, index); + pushAllHelper(stack, list); + index++; + } + } + + private static void pushAllHelper(NodeStack stack, NodeList<Node> list) { + if (list != null) { + for (int i = 0; i < list.size(); ++i) { + Node curNode = list.get(i); + if (curNode != null) { + stack.push(curNode); + } + } + } + } }
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java Sat Mar 14 22:45:52 2015 +0100 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java Sun Mar 15 13:40:28 2015 +0100 @@ -1074,4 +1074,8 @@ public boolean valueEquals(Node other) { return getNodeClass().dataEquals(this, other); } + + public final void pushInputs(NodeStack stack) { + getNodeClass().getInputEdges().pushAll(this, stack); + } }
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java Sat Mar 14 22:45:52 2015 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java Sun Mar 15 13:40:28 2015 +0100 @@ -588,7 +588,7 @@ newList.add(n); } else { // This node was pulled up. - assert !(n instanceof FixedNode); + assert !(n instanceof FixedNode) : n; } } @@ -627,12 +627,16 @@ } } } else { - for (Node input : current.inputs()) { - if (current instanceof FrameState && input instanceof StateSplit && ((StateSplit) input).stateAfter() == current) { - // Ignore the cycle. - } else { - stack.push(input); + if (current instanceof FrameState) { + for (Node input : current.inputs()) { + if (input instanceof StateSplit && ((StateSplit) input).stateAfter() == current) { + // Ignore the cycle. + } else { + stack.push(input); + } } + } else { + current.pushInputs(stack); } } } else {
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/BinaryGraphPrinter.java Sat Mar 14 22:45:52 2015 +0100 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/BinaryGraphPrinter.java Sun Mar 15 13:40:28 2015 +0100 @@ -469,7 +469,7 @@ } private void writeBlocks(List<Block> blocks, BlockMap<List<Node>> blockToNodes) throws IOException { - if (blocks != null) { + if (blocks != null && blockToNodes != null) { for (Block block : blocks) { List<Node> nodes = blockToNodes.get(block); if (nodes == null) {