Skip to content

Commit 5bfcc32

Browse files
committed
always peel the first iteration (like PyPy)
1 parent b9d92f6 commit 5bfcc32

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/control/ForNode.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,10 @@ public void executeVoid(VirtualFrame frame) {
185185
}
186186
frame.setObject(iteratorSlot, iterator.execute(frame));
187187
try {
188-
loopNode.executeLoop(frame);
188+
if (((ForRepeatingNode) loopNode.getRepeatingNode()).executeRepeating(frame)) {
189+
// manually peel the first iteration
190+
loopNode.executeLoop(frame);
191+
}
189192
} finally {
190193
frame.setObject(iteratorSlot, null);
191194
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/control/WhileNode.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ public CastToBooleanNode getCondition() {
8181

8282
@Override
8383
public void executeVoid(VirtualFrame frame) {
84-
loopNode.executeLoop(frame);
84+
if (((WhileRepeatingNode) loopNode.getRepeatingNode()).executeRepeating(frame)) {
85+
// manually peel the first iteration
86+
loopNode.executeLoop(frame);
87+
}
8588
}
8689
}

0 commit comments

Comments
 (0)