# HG changeset patch # User Andreas Woess # Date 1395267106 -3600 # Node ID a08b8694f55640c0c3aa403506f20005767b6dd2 # Parent 46c020971d9c58de137bc86195b2c0437a44a232 Truffle: Node API changes deprecate adoptChild, no longer needed in constructor add Node#insert for inserting new nodes into the tree (previously adoptChild) add Node#adoptChildren() helper method that adopts all (direct and indirect) children of a node, automatically called in TruffleRuntime#createCallTarget diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/ControlFlowExceptionPartialEvaluationTest.java --- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/ControlFlowExceptionPartialEvaluationTest.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/ControlFlowExceptionPartialEvaluationTest.java Wed Mar 19 23:11:46 2014 +0100 @@ -62,7 +62,7 @@ @Child private AbstractTestNode child; public CatchControlFlowExceptionTestNode(AbstractTestNode child) { - this.child = adoptChild(child); + this.child = child; } @Override @@ -80,7 +80,7 @@ @Child private AbstractTestNode child; public CatchSlowPathAndControlFlowExceptionTestNode(AbstractTestNode child) { - this.child = adoptChild(child); + this.child = child; } @Override diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/nodes/AddTestNode.java --- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/nodes/AddTestNode.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/nodes/AddTestNode.java Wed Mar 19 23:11:46 2014 +0100 @@ -30,8 +30,8 @@ @Child private AbstractTestNode right; public AddTestNode(AbstractTestNode left, AbstractTestNode right) { - this.left = adoptChild(left); - this.right = adoptChild(right); + this.left = left; + this.right = right; } @Override diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/nodes/BlockTestNode.java --- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/nodes/BlockTestNode.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/nodes/BlockTestNode.java Wed Mar 19 23:11:46 2014 +0100 @@ -30,7 +30,7 @@ @Children private final AbstractTestNode[] statements; public BlockTestNode(AbstractTestNode[] statements) { - this.statements = adoptChildren(statements); + this.statements = statements; } @ExplodeLoop diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/nodes/LoopTestNode.java --- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/nodes/LoopTestNode.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/nodes/LoopTestNode.java Wed Mar 19 23:11:46 2014 +0100 @@ -31,7 +31,7 @@ public LoopTestNode(int numberOfIterations, AbstractTestNode child) { this.numberOfIterations = numberOfIterations; - this.child = adoptChild(child); + this.child = child; } @Override diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeSystemTest.java --- a/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeSystemTest.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeSystemTest.java Wed Mar 19 23:11:46 2014 +0100 @@ -100,7 +100,7 @@ public TestRootNode(E node) { super(null); - this.node = adoptChild(node); + this.node = node; } @Override diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ArgumentsTest.java --- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ArgumentsTest.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ArgumentsTest.java Wed Mar 19 23:11:46 2014 +0100 @@ -61,7 +61,7 @@ Assert.assertEquals(42, result); } - class TestArguments extends Arguments { + private static class TestArguments extends Arguments { final int[] values; @@ -70,13 +70,13 @@ } } - class TestRootNode extends RootNode { + private static class TestRootNode extends RootNode { - @Children private TestArgumentNode[] children; + @Children private final TestArgumentNode[] children; TestRootNode(TestArgumentNode[] children) { super(null); - this.children = adoptChildren(children); + this.children = children; } @Override @@ -89,7 +89,7 @@ } } - class TestArgumentNode extends Node { + private static class TestArgumentNode extends Node { private final int index; diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ChildNodeTest.java --- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ChildNodeTest.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ChildNodeTest.java Wed Mar 19 23:11:46 2014 +0100 @@ -61,13 +61,13 @@ TestChildNode leftChild = new TestChildNode(); TestChildNode rightChild = new TestChildNode(); TestRootNode rootNode = new TestRootNode(leftChild, rightChild); + CallTarget target = runtime.createCallTarget(rootNode); Assert.assertEquals(rootNode, leftChild.getParent()); Assert.assertEquals(rootNode, rightChild.getParent()); Iterator iterator = rootNode.getChildren().iterator(); Assert.assertEquals(leftChild, iterator.next()); Assert.assertEquals(rightChild, iterator.next()); Assert.assertFalse(iterator.hasNext()); - CallTarget target = runtime.createCallTarget(rootNode); Object result = target.call(); Assert.assertEquals(42, result); } @@ -79,8 +79,8 @@ public TestRootNode(TestChildNode left, TestChildNode right) { super(null); - this.left = adoptChild(left); - this.right = adoptChild(right); + this.left = left; + this.right = right; } @Override diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ChildrenNodesTest.java --- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ChildrenNodesTest.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ChildrenNodesTest.java Wed Mar 19 23:11:46 2014 +0100 @@ -55,13 +55,13 @@ TestChildNode firstChild = new TestChildNode(); TestChildNode secondChild = new TestChildNode(); TestRootNode rootNode = new TestRootNode(new TestChildNode[]{firstChild, secondChild}); + CallTarget target = runtime.createCallTarget(rootNode); Assert.assertEquals(rootNode, firstChild.getParent()); Assert.assertEquals(rootNode, secondChild.getParent()); Iterator iterator = rootNode.getChildren().iterator(); Assert.assertEquals(firstChild, iterator.next()); Assert.assertEquals(secondChild, iterator.next()); Assert.assertFalse(iterator.hasNext()); - CallTarget target = runtime.createCallTarget(rootNode); Object result = target.call(); Assert.assertEquals(42, result); } @@ -72,7 +72,7 @@ public TestRootNode(TestChildNode[] children) { super(null); - this.children = adoptChildren(children); + this.children = children; } @Override diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FinalFieldTest.java --- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FinalFieldTest.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FinalFieldTest.java Wed Mar 19 23:11:46 2014 +0100 @@ -60,13 +60,13 @@ Assert.assertEquals(42, result); } - class TestRootNode extends RootNode { + private static class TestRootNode extends RootNode { - @Children TestChildNode[] children; + @Children private final TestChildNode[] children; public TestRootNode(TestChildNode[] children) { super(null); - this.children = adoptChildren(children); + this.children = children; } @Override @@ -79,7 +79,7 @@ } } - class TestChildNode extends Node { + private static class TestChildNode extends Node { private final int value; diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameSlotTypeSpecializationTest.java --- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameSlotTypeSpecializationTest.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameSlotTypeSpecializationTest.java Wed Mar 19 23:11:46 2014 +0100 @@ -64,8 +64,8 @@ public TestRootNode(FrameDescriptor descriptor, TestChildNode left, TestChildNode right) { super(null, descriptor); - this.left = adoptChild(left); - this.right = adoptChild(right); + this.left = left; + this.right = right; } @Override @@ -108,7 +108,7 @@ IntAssignLocal(FrameSlot slot, TestChildNode value) { super(slot); - this.value = adoptChild(value); + this.value = value; } @Override @@ -130,7 +130,7 @@ ObjectAssignLocal(FrameSlot slot, TestChildNode value) { super(slot); - this.value = adoptChild(value); + this.value = value; } @Override diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameTest.java --- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameTest.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameTest.java Wed Mar 19 23:11:46 2014 +0100 @@ -88,8 +88,8 @@ public TestRootNode(FrameDescriptor descriptor, TestChildNode left, TestChildNode right) { super(null, descriptor); - this.left = adoptChild(left); - this.right = adoptChild(right); + this.left = left; + this.right = right; } @Override diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReplaceTest.java --- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReplaceTest.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReplaceTest.java Wed Mar 19 23:11:46 2014 +0100 @@ -59,13 +59,13 @@ UnresolvedNode leftChild = new UnresolvedNode("20"); UnresolvedNode rightChild = new UnresolvedNode("22"); TestRootNode rootNode = new TestRootNode(new ValueNode[]{leftChild, rightChild}); + CallTarget target = runtime.createCallTarget(rootNode); assertEquals(rootNode, leftChild.getParent()); assertEquals(rootNode, rightChild.getParent()); Iterator iterator = rootNode.getChildren().iterator(); Assert.assertEquals(leftChild, iterator.next()); Assert.assertEquals(rightChild, iterator.next()); Assert.assertFalse(iterator.hasNext()); - CallTarget target = runtime.createCallTarget(rootNode); Object result = target.call(); assertEquals(42, result); assertEquals(42, target.call()); @@ -85,7 +85,7 @@ public TestRootNode(ValueNode[] children) { super(null); - this.children = adoptChildren(children); + this.children = children; } @Override diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReturnTypeSpecializationTest.java --- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReturnTypeSpecializationTest.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReturnTypeSpecializationTest.java Wed Mar 19 23:11:46 2014 +0100 @@ -63,8 +63,8 @@ public TestRootNode(FrameDescriptor descriptor, TestChildNode left, TestChildNode right) { super(null, descriptor); - this.left = adoptChild(left); - this.right = adoptChild(right); + this.left = left; + this.right = right; } @Override @@ -115,7 +115,7 @@ IntAssignLocal(FrameSlot slot, TestChildNode value) { super(slot); - this.value = adoptChild(value); + this.value = value; } @Override @@ -137,7 +137,7 @@ ObjectAssignLocal(FrameSlot slot, TestChildNode value) { super(slot); - this.value = adoptChild(value); + this.value = value; } @Override diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/nodes/serial/TestNodes.java --- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/nodes/serial/TestNodes.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/nodes/serial/TestNodes.java Wed Mar 19 23:11:46 2014 +0100 @@ -84,7 +84,7 @@ @Child Node child; public NodeWithOneChild(Node child) { - this.child = adoptChild(child); + this.child = child; } } @@ -95,8 +95,8 @@ @Child Node child2; public NodeWithTwoChilds(Node child1, Node child2) { - this.child1 = adoptChild(child1); - this.child2 = adoptChild(child2); + this.child1 = child1; + this.child2 = child2; } } @@ -108,9 +108,9 @@ @Child Node child3; public NodeWithThreeChilds(Node child1, Node child2, Node child3) { - this.child1 = adoptChild(child1); - this.child2 = adoptChild(child2); - this.child3 = adoptChild(child3); + this.child1 = child1; + this.child2 = child2; + this.child3 = child3; } } @@ -120,7 +120,7 @@ @Children private final Node[] childNodes; NodeWithArray(Node[] children) { - this.childNodes = adoptChildren(children); + this.childNodes = children; } Node[] getChildNodes() { @@ -134,8 +134,8 @@ @Children private final Node[] childNodes2; NodeWithTwoArray(Node[] childs1, Node[] childs2) { - this.childNodes1 = adoptChildren(childs1); - this.childNodes2 = adoptChildren(childs2); + this.childNodes1 = childs1; + this.childNodes2 = childs2; } Node[] getChildNodes1() { diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/RootCallTarget.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/RootCallTarget.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/RootCallTarget.java Wed Mar 19 23:11:46 2014 +0100 @@ -37,6 +37,7 @@ public RootCallTarget(RootNode function) { this.rootNode = function; this.rootNode.setCallTarget(this); + this.rootNode.adoptChildren(); } @Override diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java Wed Mar 19 23:11:46 2014 +0100 @@ -133,11 +133,36 @@ * @param newChildren the array of new children whose parent should be updated * @return the array of new children */ - protected final T[] adoptChildren(T[] newChildren) { - if (newChildren != null) { - for (T n : newChildren) { - adoptChild(n); - } + @SuppressWarnings("static-method") + @Deprecated + protected final T[] adoptChildren(final T[] newChildren) { + return newChildren; + } + + /** + * Method that updates the link to the parent in the specified new child node to this node. + * + * @param newChild the new child whose parent should be updated + * @return the new child + */ + @SuppressWarnings("static-method") + @Deprecated + protected final T adoptChild(final T newChild) { + return newChild; + } + + /** + * Method that updates the link to the parent in the array of specified new child nodes to this + * node. + * + * @param newChildren the array of new children whose parent should be updated + * @return the array of new children + */ + protected final T[] insert(final T[] newChildren) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + assert newChildren != null; + for (Node newChild : newChildren) { + adoptHelper(newChild); } return newChildren; } @@ -148,14 +173,52 @@ * @param newChild the new child whose parent should be updated * @return the new child */ - protected final T adoptChild(T newChild) { - if (newChild != null) { - if (newChild == this) { - throw new IllegalStateException("The parent of a node can never be the node itself."); + protected final T insert(final T newChild) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + assert newChild != null; + adoptHelper(newChild); + return newChild; + } + + public final void adoptChildren() { + CompilerDirectives.transferToInterpreterAndInvalidate(); + adoptHelper(); + } + + private void adoptHelper(final Node newChild) { + assert newChild != null; + if (newChild == this) { + throw new IllegalStateException("The parent of a node can never be the node itself."); + } + newChild.parent = this; + newChild.adoptHelper(); + } + + private void adoptHelper() { + Iterable children = this.getChildren(); + for (Node child : children) { + if (child != null && child.getParent() != this) { + this.adoptHelper(child); } - ((Node) newChild).parent = this; + } + } + + private void adoptUnadoptedHelper(final Node newChild) { + assert newChild != null; + if (newChild == this) { + throw new IllegalStateException("The parent of a node can never be the node itself."); } - return newChild; + newChild.parent = this; + newChild.adoptUnadoptedHelper(); + } + + private void adoptUnadoptedHelper() { + Iterable children = this.getChildren(); + for (Node child : children) { + if (child != null && child.getParent() == null) { + this.adoptUnadoptedHelper(child); + } + } } /** @@ -186,54 +249,13 @@ * @param reason a description of the reason for the replacement * @return the new node */ - public final T replace(T newNode, CharSequence reason) { + public final T replace(final T newNode, final CharSequence reason) { CompilerDirectives.transferToInterpreterAndInvalidate(); - if (this.getParent() == null) { - throw new IllegalStateException("This node cannot be replaced, because it does not yet have a parent."); - } - if (sourceSection != null && newNode.getSourceSection() == null) { - // Pass on the source section to the new node. - newNode.assignSourceSection(sourceSection); - } - onReplace(newNode, reason); - ((Node) newNode).parent = this.parent; - if (!NodeUtil.replaceChild(this.parent, this, newNode)) { - fixupTree(); - } - reportReplace(this, newNode, reason); + replaceHelper(newNode, reason); return newNode; } /** - * Rewrite has failed; the tree is likely inconsistent, so fix any stale parent references. - * - * This is a rather expensive operation but rare to occur. - */ - private void fixupTree() { - Node rootNode = getRootNode(); - if (rootNode == null) { - throw new UnsupportedOperationException("Tree does not have a root node."); - } - int fixCount = rootNode.fixupChildren(); - assert fixCount != 0 : "sanity check failed: missing @Child[ren] or adoptChild?"; - // if nothing had to be fixed, rewrite failed due to node not being a proper child. - } - - private int fixupChildren() { - int fixCount = 0; - for (Node child : getChildren()) { - if (child != null) { - if (child.parent != this) { - child.parent = this; - fixCount++; - } - fixCount += child.fixupChildren(); - } - } - return fixCount; - } - - /** * Replaces this node with another node. If there is a source section (see * {@link #getSourceSection()}) associated with this node, it is transferred to the new node. * @@ -244,6 +266,27 @@ return replace(newNode, ""); } + private void replaceHelper(Node newNode, CharSequence reason) { + CompilerAsserts.neverPartOfCompilation(); + if (this.getParent() == null) { + throw new IllegalStateException("This node cannot be replaced, because it does not yet have a parent."); + } + if (sourceSection != null && newNode.getSourceSection() == null) { + // Pass on the source section to the new node. + newNode.assignSourceSection(sourceSection); + } + // (aw) need to set parent *before* replace, so that (unsynchronized) getRootNode() + // will always find the root node + newNode.parent = this.parent; + if (NodeUtil.replaceChild(this.parent, this, newNode)) { + this.parent.adoptHelper(newNode); + } else { + this.parent.adoptUnadoptedHelper(newNode); + } + reportReplace(this, newNode, reason); + onReplace(newNode, reason); + } + /** * Checks if this node is properly adopted by a parent and can be replaced. * diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/instrument/InstrumentationProbeNode.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/instrument/InstrumentationProbeNode.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/instrument/InstrumentationProbeNode.java Wed Mar 19 23:11:46 2014 +0100 @@ -62,7 +62,7 @@ */ protected void internalAppendProbe(InstrumentationProbeNode newProbeNode) { if (next == null) { - this.next = adoptChild(newProbeNode); + this.next = newProbeNode; } else { next.internalAppendProbe(newProbeNode); } @@ -75,7 +75,7 @@ if (oldProbeNode.next == null) { this.next = null; } else { - this.next = adoptChild(oldProbeNode.next); + this.next = oldProbeNode.next; oldProbeNode.next = null; } } else { diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java --- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java Wed Mar 19 23:11:46 2014 +0100 @@ -931,7 +931,7 @@ CodeExecutableElement setter = new CodeExecutableElement(modifiers(PROTECTED), context.getType(void.class), "setNext0"); setter.getParameters().add(new CodeVariableElement(clazz.asType(), "next0")); CodeTreeBuilder builder = setter.createBuilder(); - builder.statement("this.next0 = adoptChild(next0)"); + builder.statement("this.next0 = insert(next0)"); clazz.add(setter); CodeExecutableElement genericCachedExecute = createCachedExecute(node, node.getPolymorphicSpecialization()); @@ -1210,7 +1210,6 @@ String fieldName = var.getSimpleName().toString(); CodeTree init = createStaticCast(builder, child, fieldName); - init = createAdoptChild(builder, var.asType(), init); builder.string("this.").string(fieldName).string(" = ").tree(init); builder.end(); @@ -1229,18 +1228,6 @@ return CodeTreeBuilder.singleString(fieldName); } - private CodeTree createAdoptChild(CodeTreeBuilder parent, TypeMirror type, CodeTree value) { - CodeTreeBuilder builder = new CodeTreeBuilder(parent); - if (Utils.isAssignable(getContext(), type, getContext().getTruffleTypes().getNode())) { - builder.string("adoptChild(").tree(value).string(")"); - } else if (Utils.isAssignable(getContext(), type, getContext().getTruffleTypes().getNodeArray())) { - builder.string("adoptChildren(").tree(value).string(")"); - } else { - builder.tree(value); - } - return builder.getRoot(); - } - private CodeExecutableElement createCopyConstructor(CodeTypeElement type, ExecutableElement superConstructor, ExecutableElement sourceSectionConstructor) { CodeExecutableElement method = new CodeExecutableElement(null, type.getSimpleName().toString()); CodeTreeBuilder builder = method.createBuilder(); @@ -1261,7 +1248,7 @@ if (Utils.isAssignable(getContext(), varType, getContext().getTruffleTypes().getNodeArray())) { copyAccess += ".clone()"; } - CodeTree init = createAdoptChild(builder, varType, CodeTreeBuilder.singleString(copyAccess)); + CodeTree init = CodeTreeBuilder.singleString(copyAccess); builder.startStatement().string("this.").string(varName).string(" = ").tree(init).end(); } @@ -2644,7 +2631,7 @@ if (node.isPolymorphic()) { if (specialization.isSpecialized() || specialization.isPolymorphic()) { - builder.statement("this.next0 = adoptChild(copy.next0)"); + builder.statement("this.next0 = copy.next0"); } } if (superConstructor != null) { diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLRootNode.java --- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLRootNode.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLRootNode.java Wed Mar 19 23:11:46 2014 +0100 @@ -52,7 +52,7 @@ super(null, frameDescriptor); /* Deep copy the body before any specialization occurs during execution. */ this.uninitializedBodyNode = NodeUtil.cloneNode(bodyNode); - this.bodyNode = adoptChild(bodyNode); + this.bodyNode = bodyNode; this.name = name; } diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLDirectDispatchNode.java --- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLDirectDispatchNode.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLDirectDispatchNode.java Wed Mar 19 23:11:46 2014 +0100 @@ -53,9 +53,9 @@ protected SLDirectDispatchNode(SLAbstractDispatchNode next, SLFunction cachedFunction) { this.cachedFunction = cachedFunction; - this.callCachedTargetNode = adoptChild(Truffle.getRuntime().createCallNode(cachedFunction.getCallTarget())); + this.callCachedTargetNode = Truffle.getRuntime().createCallNode(cachedFunction.getCallTarget()); this.cachedTargetStable = cachedFunction.getCallTargetStable(); - this.nextNode = adoptChild(next); + this.nextNode = next; } /** diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLInvokeNode.java --- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLInvokeNode.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLInvokeNode.java Wed Mar 19 23:11:46 2014 +0100 @@ -48,9 +48,9 @@ @Child protected SLAbstractDispatchNode dispatchNode; private SLInvokeNode(SLExpressionNode functionNode, SLExpressionNode[] argumentNodes, SLAbstractDispatchNode dispatchNode) { - this.functionNode = adoptChild(functionNode); - this.argumentNodes = adoptChildren(argumentNodes); - this.dispatchNode = adoptChild(dispatchNode); + this.functionNode = functionNode; + this.argumentNodes = argumentNodes; + this.dispatchNode = dispatchNode; } @Override diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLBlockNode.java --- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLBlockNode.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLBlockNode.java Wed Mar 19 23:11:46 2014 +0100 @@ -45,7 +45,7 @@ * It is a Truffle requirement to call adoptChildren(), which performs all the necessary * steps to add the new children to the node tree. */ - this.bodyNodes = adoptChildren(bodyNodes); + this.bodyNodes = bodyNodes; } /** diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLFunctionBodyNode.java --- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLFunctionBodyNode.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLFunctionBodyNode.java Wed Mar 19 23:11:46 2014 +0100 @@ -54,7 +54,7 @@ * It is a Truffle requirement to call adoptChild(), which performs all the necessary steps * to add the new child to the node tree. */ - this.bodyNode = adoptChild(bodyNode); + this.bodyNode = bodyNode; } @Override diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java --- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java Wed Mar 19 23:11:46 2014 +0100 @@ -57,9 +57,9 @@ * It is a Truffle requirement to call adoptChild(), which performs all the necessary steps * to add the new child to the node tree. */ - this.conditionNode = adoptChild(conditionNode); - this.thenPartNode = adoptChild(thenPartNode); - this.elsePartNode = adoptChild(elsePartNode); + this.conditionNode = conditionNode; + this.thenPartNode = thenPartNode; + this.elsePartNode = elsePartNode; } @Override diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLReturnNode.java --- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLReturnNode.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLReturnNode.java Wed Mar 19 23:11:46 2014 +0100 @@ -40,7 +40,7 @@ @Child private SLExpressionNode valueNode; public SLReturnNode(SLExpressionNode valueNode) { - this.valueNode = adoptChild(valueNode); + this.valueNode = valueNode; } @Override diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLWhileNode.java --- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLWhileNode.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLWhileNode.java Wed Mar 19 23:11:46 2014 +0100 @@ -55,8 +55,8 @@ * It is a Truffle requirement to call adoptChild(), which performs all the necessary steps * to add the new child to the node tree. */ - this.conditionNode = adoptChild(conditionNode); - this.bodyNode = adoptChild(bodyNode); + this.conditionNode = conditionNode; + this.bodyNode = bodyNode; } @Override diff -r 46c020971d9c -r a08b8694f556 graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/demo/SLAddWithoutSpecializationNode.java --- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/demo/SLAddWithoutSpecializationNode.java Thu Mar 20 00:16:39 2014 +0100 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/demo/SLAddWithoutSpecializationNode.java Wed Mar 19 23:11:46 2014 +0100 @@ -42,8 +42,8 @@ @Child private SLExpressionNode rightNode; public SLAddWithoutSpecializationNode(SLExpressionNode leftNode, SLExpressionNode rightNode) { - this.leftNode = adoptChild(leftNode); - this.rightNode = adoptChild(rightNode); + this.leftNode = leftNode; + this.rightNode = rightNode; } @Override