Skip to content

Commit e38a854

Browse files
committed
Replace profiling with loop count reporting.
1 parent af9fa66 commit e38a854

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
import com.oracle.truffle.api.dsl.Specialization;
109109
import com.oracle.truffle.api.dsl.TypeSystemReference;
110110
import com.oracle.truffle.api.frame.VirtualFrame;
111+
import com.oracle.truffle.api.nodes.LoopNode;
111112
import com.oracle.truffle.api.nodes.Node;
112113
import com.oracle.truffle.api.profiles.InlinedConditionProfile;
113114
import com.oracle.truffle.api.profiles.InlinedLoopConditionProfile;
@@ -874,18 +875,20 @@ static double doIt(VirtualFrame frame, Object iterable,
874875
@Cached PyObjectGetIter getIter,
875876
@Cached PyIterNextNode nextNode,
876877
@Cached PyFloatAsDoubleNode asDoubleNode,
877-
@Cached InlinedLoopConditionProfile loopProfile,
878878
@Cached PRaiseNode raiseNode) {
879879
Object iterator = getIter.execute(frame, inliningTarget, iterable);
880880

881-
boolean exhausted = false;
882881
var acc = new XSum.SmallAccumulator();
883-
while (loopProfile.profile(inliningTarget, !exhausted)) {
882+
int nbrIter = 0;
883+
while (true) {
884884
try {
885885
Object next = nextNode.execute(frame, inliningTarget, iterator);
886+
nbrIter++;
886887
acc.add(asDoubleNode.execute(frame, inliningTarget, next));
887888
} catch (IteratorExhausted e) {
888-
exhausted = true;
889+
break;
890+
} finally {
891+
LoopNode.reportLoopCount(inliningTarget, nbrIter);
889892
}
890893
}
891894

0 commit comments

Comments
 (0)