Skip to content

Commit bceb24a

Browse files
committed
Fixed loop profiling for doObject in all/any implementations
Signed-off-by: Octave Larose <[email protected]>
1 parent 522e6ed commit bceb24a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,16 +424,20 @@ boolean doObject(VirtualFrame frame,
424424
@Cached IsBuiltinClassProfile errorProfile,
425425
@Cached PyObjectIsTrueNode isTrueNode) {
426426
Object iterator = getIter.execute(frame, object);
427+
int nbrIter = 0;
428+
427429
while (true) {
428430
try {
429-
LoopNode.reportLoopCount(this, 1);
430431
Object next = nextNode.execute(frame, iterator);
432+
nbrIter++;
431433
if (!isTrueNode.execute(frame, next)) {
432434
return false;
433435
}
434436
} catch (PException e) {
435437
e.expectStopIteration(errorProfile);
436438
break;
439+
} finally {
440+
LoopNode.reportLoopCount(this, nbrIter);
437441
}
438442
}
439443

@@ -477,16 +481,20 @@ boolean doObject(VirtualFrame frame,
477481
@Cached IsBuiltinClassProfile errorProfile,
478482
@Cached PyObjectIsTrueNode isTrueNode) {
479483
Object iterator = getIter.execute(frame, object);
484+
int nbrIter = 0;
485+
480486
while (true) {
481487
try {
482-
LoopNode.reportLoopCount(this, 1);
483488
Object next = nextNode.execute(frame, iterator);
489+
nbrIter++;
484490
if (isTrueNode.execute(frame, next)) {
485491
return true;
486492
}
487493
} catch (PException e) {
488494
e.expectStopIteration(errorProfile);
489495
break;
496+
} finally {
497+
LoopNode.reportLoopCount(this, nbrIter);
490498
}
491499
}
492500

0 commit comments

Comments
 (0)