Mercurial > hg > truffle
changeset 16554:f3c1b2d999da
clone nodes without adding to a graph
author | Lukas Stadler <lukas.stadler@oracle.com> |
---|---|
date | Thu, 17 Jul 2014 14:29:05 +0200 |
parents | c9d3d0964adb |
children | 29c5fd119afa |
files | graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java |
diffstat | 2 files changed, 16 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java Thu Jul 17 14:28:35 2014 +0200 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java Thu Jul 17 14:29:05 2014 +0200 @@ -806,12 +806,18 @@ } public final Node copyWithInputs() { - Node newNode = clone(graph); + return copyWithInputs(true); + } + + public final Node copyWithInputs(boolean addToGraph) { + Node newNode = clone(addToGraph ? graph : null); NodeClass clazz = getNodeClass(); clazz.copyInputs(this, newNode); - for (Node input : inputs()) { - if (input.recordsUsages()) { - input.addUsage(newNode); + if (addToGraph) { + for (Node input : inputs()) { + if (input.recordsUsages()) { + input.addUsage(newNode); + } } } return newNode; @@ -834,7 +840,7 @@ final Node clone(Graph into, boolean clearInputsAndSuccessors) { NodeClass nodeClass = getNodeClass(); - if (nodeClass.valueNumberable() && nodeClass.isLeafNode()) { + if (into != null && nodeClass.valueNumberable() && nodeClass.isLeafNode()) { Node otherNode = into.findNodeInCache(this); if (otherNode != null) { return otherNode; @@ -854,13 +860,15 @@ newNode.graph = into; newNode.typeCacheNext = null; newNode.id = INITIAL_ID; - into.register(newNode); + if (into != null) { + into.register(newNode); + } newNode.usage0 = null; newNode.usage1 = null; newNode.extraUsages = NO_NODES; newNode.predecessor = null; - if (nodeClass.valueNumberable() && nodeClass.isLeafNode()) { + if (into != null && nodeClass.valueNumberable() && nodeClass.isLeafNode()) { into.putNodeIntoCache(newNode); } newNode.afterClone(this);
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java Thu Jul 17 14:28:35 2014 +0200 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java Thu Jul 17 14:29:05 2014 +0200 @@ -397,7 +397,7 @@ node.getNodeClass().set(node, this, value); } - void initialize(Node node, Node value) { + public void initialize(Node node, Node value) { node.getNodeClass().initializePosition(node, this, value); }