File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/control Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change 3333import com .oracle .truffle .api .nodes .Node ;
3434import com .oracle .truffle .api .nodes .NodeInfo ;
3535import com .oracle .truffle .api .nodes .RepeatingNode ;
36+ import com .oracle .truffle .api .profiles .LoopConditionProfile ;
3637
3738final class WhileRepeatingNode extends Node implements RepeatingNode {
3839
40+ private final LoopConditionProfile conditionProfile = LoopConditionProfile .createCountingProfile ();
41+
3942 @ Child CastToBooleanNode condition ;
4043 @ Child PNode body ;
41-
44+
4245 WhileRepeatingNode (CastToBooleanNode condition , PNode body ) {
4346 this .condition = condition ;
4447 this .body = body ;
4548 }
4649
4750 @ Override
4851 public boolean executeRepeating (VirtualFrame frame ) {
49- if (!condition .executeBoolean (frame )) {
50- return false ;
52+ if (conditionProfile .profile (condition .executeBoolean (frame ))) {
53+ body .executeVoid (frame );
54+ return true ;
5155 }
52- body .executeVoid (frame );
53- return true ;
56+ return false ;
5457 }
5558}
5659
You can’t perform that action at this time.
0 commit comments