Skip to content

Commit 66661b4

Browse files
committed
loopConditionProfile.profileCounted() calls instead of just profile()
Signed-off-by: Octave Larose <[email protected]>
1 parent bceb24a commit 66661b4

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,10 @@ boolean doBoolSequence(VirtualFrame frame,
317317
BoolSequenceStorage sequenceStorage,
318318
NodeType nodeType) {
319319
boolean[] internalArray = sequenceStorage.getInternalBoolArray();
320+
int seqLength = sequenceStorage.length();
320321

321-
for (int i = 0; loopConditionProfile.profile(i < sequenceStorage.length()); i++) {
322+
loopConditionProfile.profileCounted(seqLength);
323+
for (int i = 0; loopConditionProfile.inject(i < seqLength); i++) {
322324
if (nodeType == NodeType.ALL && !isTrueNode.execute(frame, internalArray[i])) {
323325
return false;
324326
} else if (nodeType == NodeType.ANY && isTrueNode.execute(frame, internalArray[i])) {
@@ -335,8 +337,10 @@ boolean doIntSequence(VirtualFrame frame,
335337
IntSequenceStorage sequenceStorage,
336338
NodeType nodeType) {
337339
int[] internalArray = sequenceStorage.getInternalIntArray();
340+
int seqLength = sequenceStorage.length();
338341

339-
for (int i = 0; loopConditionProfile.profile(i < sequenceStorage.length()); i++) {
342+
loopConditionProfile.profileCounted(seqLength);
343+
for (int i = 0; loopConditionProfile.inject(i < seqLength); i++) {
340344
if (nodeType == NodeType.ALL && !isTrueNode.execute(frame, internalArray[i])) {
341345
return false;
342346
} else if (nodeType == NodeType.ANY && isTrueNode.execute(frame, internalArray[i])) {
@@ -355,7 +359,8 @@ boolean doGenericSequence(VirtualFrame frame,
355359
Object[] internalArray = sequenceStorage.getInternalArray();
356360
int seqLength = lenNode.execute(sequenceStorage);
357361

358-
for (int i = 0; loopConditionProfile.profile(i < seqLength); i++) {
362+
loopConditionProfile.profileCounted(seqLength);
363+
for (int i = 0; loopConditionProfile.inject(i < seqLength); i++) {
359364
if (nodeType == NodeType.ALL && !isTrueNode.execute(frame, internalArray[i])) {
360365
return false;
361366
} else if (nodeType == NodeType.ANY && isTrueNode.execute(frame, internalArray[i])) {
@@ -372,8 +377,10 @@ protected boolean doHashStorage(VirtualFrame frame,
372377
NodeType nodeType,
373378
@CachedLibrary("hashingStorage") HashingStorageLibrary hlib) {
374379
HashingStorageLibrary.HashingStorageIterator<Object> keysIter = hlib.keys(hashingStorage).iterator();
380+
int seqLength = hlib.length(hashingStorage);
375381

376-
for (int i = 0; loopConditionProfile.profile(i < hlib.length(hashingStorage)); i++) {
382+
loopConditionProfile.profileCounted(seqLength);
383+
for (int i = 0; loopConditionProfile.inject(i < seqLength); i++) {
377384
Object key = keysIter.next();
378385
if (nodeType == NodeType.ALL) {
379386
if (!isTrueNode.execute(frame, key)) {

0 commit comments

Comments
 (0)