Mercurial > hg > graal-compiler
changeset 12495:b7c8b843dc7b
Truffle: add sanity check.
author | Andreas Woess <andreas.woess@jku.at> |
---|---|
date | Sun, 20 Oct 2013 03:50:51 +0200 |
parents | 57b8a41c0e18 |
children | c82ed607fada d00c31d8394f 0806a46dced5 e47f373499ec |
files | graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java |
diffstat | 1 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java Sun Oct 20 03:26:03 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java Sun Oct 20 03:50:51 2013 +0200 @@ -171,6 +171,7 @@ * @return the new node */ public final <T extends Node> T replace(T newNode, String reason) { + CompilerDirectives.transferToInterpreter(); if (this.getParent() == null) { throw new IllegalStateException("This node cannot be replaced, because it does not yet have a parent."); } @@ -196,18 +197,23 @@ if (rootNode == null) { throw new UnsupportedOperationException("Tree does not have a root node."); } - rootNode.fixupChildren(); + 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 void fixupChildren() { + private int fixupChildren() { + int fixCount = 0; for (Node child : getChildren()) { if (child != null) { if (child.parent != this) { child.parent = this; + fixCount++; } - child.fixupChildren(); + fixCount += child.fixupChildren(); } } + return fixCount; } /**