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 33
33
import com .oracle .truffle .api .nodes .Node ;
34
34
import com .oracle .truffle .api .nodes .NodeInfo ;
35
35
import com .oracle .truffle .api .nodes .RepeatingNode ;
36
+ import com .oracle .truffle .api .profiles .LoopConditionProfile ;
36
37
37
38
final class WhileRepeatingNode extends Node implements RepeatingNode {
38
39
40
+ private final LoopConditionProfile conditionProfile = LoopConditionProfile .createCountingProfile ();
41
+
39
42
@ Child CastToBooleanNode condition ;
40
43
@ Child PNode body ;
41
-
44
+
42
45
WhileRepeatingNode (CastToBooleanNode condition , PNode body ) {
43
46
this .condition = condition ;
44
47
this .body = body ;
45
48
}
46
49
47
50
@ Override
48
51
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 ;
51
55
}
52
- body .executeVoid (frame );
53
- return true ;
56
+ return false ;
54
57
}
55
58
}
56
59
You can’t perform that action at this time.
0 commit comments