Skip to content
Snippets Groups Projects
Commit 5fdc237d authored by Lukas Stadler's avatar Lukas Stadler
Browse files

do not store reference to WhileNode in WhileRepeatingNode

parent 9abc9048
No related branches found
No related tags found
No related merge requests found
......@@ -45,7 +45,7 @@ public final class WhileNode extends AbstractLoopNode implements RSyntaxNode, Vi
private final boolean isRepeat;
private WhileNode(RSyntaxNode condition, RSyntaxNode body, boolean isRepeat) {
this.loop = Truffle.getRuntime().createLoopNode(new WhileRepeatingNode(this, ConvertBooleanNode.create(condition), body.asRNode()));
this.loop = Truffle.getRuntime().createLoopNode(new WhileRepeatingNode(ConvertBooleanNode.create(condition), body.asRNode()));
this.isRepeat = isRepeat;
}
......@@ -122,11 +122,7 @@ public final class WhileNode extends AbstractLoopNode implements RSyntaxNode, Vi
private final BranchProfile breakBlock = BranchProfile.create();
private final BranchProfile nextBlock = BranchProfile.create();
// used as RSyntaxNode
private final WhileNode whileNode;
public WhileRepeatingNode(WhileNode whileNode, ConvertBooleanNode condition, RNode body) {
this.whileNode = whileNode;
public WhileRepeatingNode(ConvertBooleanNode condition, RNode body) {
this.condition = condition;
this.body = body;
// pre-initialize the profile so that loop exits to not deoptimize
......@@ -160,7 +156,11 @@ public final class WhileNode extends AbstractLoopNode implements RSyntaxNode, Vi
@Override
protected RSyntaxNode getRSyntaxNode() {
return whileNode;
Node current = this;
while (!(current instanceof WhileNode)) {
current = current.getParent();
}
return (WhileNode) current;
}
@Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment