Skip to content

Commit 0645b3b

Browse files
committed
Use ConditionProfile in ForIter nodes
1 parent 018891c commit 0645b3b

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ForIterINode.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
import com.oracle.truffle.api.dsl.Specialization;
5959
import com.oracle.truffle.api.frame.Frame;
6060
import com.oracle.truffle.api.frame.VirtualFrame;
61-
import com.oracle.truffle.api.profiles.LoopConditionProfile;
61+
import com.oracle.truffle.api.profiles.ConditionProfile;
6262

6363
/**
6464
* Obtains the next value of an iterator. When the iterator is exhausted it returns {@code null}. It
@@ -70,7 +70,11 @@ public abstract class ForIterINode extends PNodeWithContext {
7070

7171
@Specialization
7272
boolean doIntRange(VirtualFrame frame, PIntRangeIterator iterator, int stackTop,
73-
@Cached("createCountingProfile()") LoopConditionProfile conditionProfile) {
73+
/*
74+
* Not using LoopConditionProfile because when OSR-compiled, we might never
75+
* register the condition being false
76+
*/
77+
@Cached("createCountingProfile()") ConditionProfile conditionProfile) {
7478
if (conditionProfile.profile(iterator.hasNextInt())) {
7579
frame.setInt(stackTop, iterator.nextInt());
7680
return true;

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ForIterONode.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
import com.oracle.truffle.api.dsl.Specialization;
5757
import com.oracle.truffle.api.frame.Frame;
5858
import com.oracle.truffle.api.frame.VirtualFrame;
59-
import com.oracle.truffle.api.profiles.LoopConditionProfile;
59+
import com.oracle.truffle.api.profiles.ConditionProfile;
6060

6161
/**
6262
* Obtains the next value of an iterator. When the iterator is exhausted it returns {@code null}. It
@@ -68,7 +68,11 @@ public abstract class ForIterONode extends PNodeWithContext {
6868

6969
@Specialization
7070
boolean doIntRange(VirtualFrame frame, PIntRangeIterator iterator, int stackTop,
71-
@Cached("createCountingProfile()") LoopConditionProfile conditionProfile) {
71+
/*
72+
* Not using LoopConditionProfile because when OSR-compiled, we might never
73+
* register the condition being false
74+
*/
75+
@Cached("createCountingProfile()") ConditionProfile conditionProfile) {
7276
if (conditionProfile.profile(iterator.hasNextInt())) {
7377
frame.setObject(stackTop, iterator.nextInt());
7478
return true;

0 commit comments

Comments
 (0)