|
108 | 108 | import com.oracle.truffle.api.dsl.Specialization; |
109 | 109 | import com.oracle.truffle.api.dsl.TypeSystemReference; |
110 | 110 | import com.oracle.truffle.api.frame.VirtualFrame; |
| 111 | +import com.oracle.truffle.api.nodes.LoopNode; |
111 | 112 | import com.oracle.truffle.api.nodes.Node; |
112 | 113 | import com.oracle.truffle.api.profiles.InlinedConditionProfile; |
113 | 114 | import com.oracle.truffle.api.profiles.InlinedLoopConditionProfile; |
@@ -874,18 +875,20 @@ static double doIt(VirtualFrame frame, Object iterable, |
874 | 875 | @Cached PyObjectGetIter getIter, |
875 | 876 | @Cached PyIterNextNode nextNode, |
876 | 877 | @Cached PyFloatAsDoubleNode asDoubleNode, |
877 | | - @Cached InlinedLoopConditionProfile loopProfile, |
878 | 878 | @Cached PRaiseNode raiseNode) { |
879 | 879 | Object iterator = getIter.execute(frame, inliningTarget, iterable); |
880 | 880 |
|
881 | | - boolean exhausted = false; |
882 | 881 | var acc = new XSum.SmallAccumulator(); |
883 | | - while (loopProfile.profile(inliningTarget, !exhausted)) { |
| 882 | + int nbrIter = 0; |
| 883 | + while (true) { |
884 | 884 | try { |
885 | 885 | Object next = nextNode.execute(frame, inliningTarget, iterator); |
| 886 | + nbrIter++; |
886 | 887 | acc.add(asDoubleNode.execute(frame, inliningTarget, next)); |
887 | 888 | } catch (IteratorExhausted e) { |
888 | | - exhausted = true; |
| 889 | + break; |
| 890 | + } finally { |
| 891 | + LoopNode.reportLoopCount(inliningTarget, nbrIter); |
889 | 892 | } |
890 | 893 | } |
891 | 894 |
|
|
0 commit comments