# HG changeset patch # User Lukas Stadler # Date 1405600145 -7200 # Node ID f3c1b2d999da16629a33911aa04466d115a0f1fb # Parent c9d3d0964adb35ce7418f1ba3f9464ccca97c1d6 clone nodes without adding to a graph diff -r c9d3d0964adb -r f3c1b2d999da graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java --- 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); diff -r c9d3d0964adb -r f3c1b2d999da graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java --- 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); }