Skip to content

Commit 928ec91

Browse files
committed
remove obsolete java iterable handling in ForNode
1 parent 6aa1d92 commit 928ec91

File tree

1 file changed

+0
-81
lines changed
  • com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/control

1 file changed

+0
-81
lines changed

com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/control/ForNode.java

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,11 @@
2929
import com.oracle.truffle.api.dsl.NodeChild;
3030
import com.oracle.truffle.api.dsl.Specialization;
3131
import com.oracle.truffle.api.frame.VirtualFrame;
32-
import com.oracle.truffle.api.interop.ArityException;
3332
import com.oracle.truffle.api.interop.ForeignAccess;
3433
import com.oracle.truffle.api.interop.Message;
3534
import com.oracle.truffle.api.interop.TruffleObject;
3635
import com.oracle.truffle.api.interop.UnknownIdentifierException;
3736
import com.oracle.truffle.api.interop.UnsupportedMessageException;
38-
import com.oracle.truffle.api.interop.UnsupportedTypeException;
3937
import com.oracle.truffle.api.nodes.LoopNode;
4038
import com.oracle.truffle.api.nodes.Node;
4139
import com.oracle.truffle.api.nodes.UnexpectedResultException;
@@ -172,10 +170,6 @@ protected WriteVariableNode createWriteVariable(String name) {
172170
return WriteVariableNode.createAnonymous(name, Mode.REGULAR, null);
173171
}
174172

175-
protected LoopNode createForIterableLoopNode(String iteratorName) {
176-
return createLoopNode(new ForIterableRepeatingNode(this, var.getIdentifier(), RASTUtils.cloneNode(body), iteratorName));
177-
}
178-
179173
protected LoopNode createForKeysLoopNode(String indexName, String positionName, String lengthName, String rangeName, String keysName) {
180174
return createLoopNode(new ForKeysRepeatingNode(this, var.getIdentifier(), RASTUtils.cloneNode(body), indexName, positionName, lengthName, rangeName, keysName));
181175
}
@@ -320,81 +314,6 @@ protected void writePosition(VirtualFrame frame, int index) {
320314
}
321315
}
322316

323-
private static final class ForIterableRepeatingNode extends AbstractRepeatingNode {
324-
325-
private final ConditionProfile conditionProfile = ConditionProfile.createBinaryProfile();
326-
private final BranchProfile breakBlock = BranchProfile.create();
327-
private final BranchProfile nextBlock = BranchProfile.create();
328-
329-
@Child private WriteVariableNode writeElementNode;
330-
@Child private LocalReadVariableNode readIteratorNode;
331-
332-
@Child private Node readForeignNode;
333-
@Child private Node executeForeignNode;
334-
335-
// only used for toString
336-
private final ForNode forNode;
337-
338-
ForIterableRepeatingNode(ForNode forNode, String var, RNode body, String iteratorName) {
339-
super(body);
340-
this.forNode = forNode;
341-
this.writeElementNode = WriteVariableNode.createAnonymous(var, Mode.REGULAR, createNextLoad(iteratorName), false);
342-
343-
this.readIteratorNode = LocalReadVariableNode.create(iteratorName, true);
344-
345-
this.executeForeignNode = Message.EXECUTE.createNode();
346-
this.readForeignNode = Message.READ.createNode();
347-
348-
// pre-initialize the profile so that loop exits to not deoptimize
349-
conditionProfile.profile(false);
350-
}
351-
352-
private static RNode createNextLoad(String iteratorName) {
353-
RCodeBuilder<RSyntaxNode> builder = RContext.getASTBuilder();
354-
RSyntaxNode receiver = builder.lookup(RSyntaxNode.INTERNAL, iteratorName, false);
355-
RSyntaxNode next = builder.lookup(RSyntaxNode.INTERNAL, "next", true);
356-
RSyntaxNode access = builder.lookup(RSyntaxNode.INTERNAL, "$", true);
357-
RSyntaxNode nextCall = builder.call(RSyntaxNode.INTERNAL, access, receiver, next);
358-
return builder.call(RSyntaxNode.INTERNAL, nextCall).asRNode();
359-
}
360-
361-
@Override
362-
public boolean executeRepeating(VirtualFrame frame) {
363-
try {
364-
TruffleObject iterator = (TruffleObject) readIteratorNode.execute(frame);
365-
assert iterator != null;
366-
367-
if (conditionProfile.profile(hasNext(iterator))) {
368-
writeElementNode.voidExecute(frame);
369-
body.voidExecute(frame);
370-
return true;
371-
}
372-
return false;
373-
} catch (BreakException e) {
374-
breakBlock.enter();
375-
return false;
376-
} catch (NextException e) {
377-
nextBlock.enter();
378-
return true;
379-
}
380-
}
381-
382-
private boolean hasNext(TruffleObject iterator) {
383-
try {
384-
TruffleObject hasNextFun = (TruffleObject) ForeignAccess.sendRead(readForeignNode, iterator, "hasNext");
385-
return (boolean) ForeignAccess.sendExecute(executeForeignNode, hasNextFun);
386-
} catch (UnknownIdentifierException | UnsupportedMessageException | UnsupportedTypeException | ArityException ex) {
387-
throw RInternalError.shouldNotReachHere(ex, "Could not retrieve hasNext function");
388-
}
389-
}
390-
391-
@Override
392-
public String toString() {
393-
return forNode.toString();
394-
}
395-
396-
}
397-
398317
@Override
399318
public RSyntaxElement[] getSyntaxArguments() {
400319
return new RSyntaxElement[]{var, getRange().asRSyntaxNode(), body.asRSyntaxNode()};

0 commit comments

Comments
 (0)