Skip to content

Commit 7dafaf2

Browse files
committed
Fix all/any with native storage
1 parent 5b6efe0 commit 7dafaf2

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

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

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -365,18 +365,17 @@ abstract static class AllOrAnySequenceStorageNode extends PNodeWithContext {
365365
abstract boolean execute(VirtualFrame frame, Node inliningTarget, SequenceStorage storageObj, AnyOrAllNodeType nodeType);
366366

367367
@Specialization
368-
static boolean doBoolSequence(VirtualFrame frame, Node inliningTarget, BoolSequenceStorage sequenceStorage, AnyOrAllNodeType nodeType,
369-
@Shared @Cached InlinedLoopConditionProfile loopConditionProfile,
370-
@Shared @Cached InlinedCountingConditionProfile earlyExitProfile,
371-
@Shared @Cached PyObjectIsTrueNode isTrueNode) {
368+
static boolean doBoolSequence(Node inliningTarget, BoolSequenceStorage sequenceStorage, AnyOrAllNodeType nodeType,
369+
@Exclusive @Cached InlinedLoopConditionProfile loopConditionProfile,
370+
@Exclusive @Cached InlinedCountingConditionProfile earlyExitProfile) {
372371
boolean[] internalArray = sequenceStorage.getInternalBoolArray();
373372
int seqLength = sequenceStorage.length();
374373

375374
for (int i = 0; loopConditionProfile.profile(inliningTarget, i < seqLength); i++) {
376-
if (nodeType == AnyOrAllNodeType.ALL && earlyExitProfile.profile(inliningTarget, !isTrueNode.execute(frame, inliningTarget, internalArray[i]))) {
375+
if (nodeType == AnyOrAllNodeType.ALL && earlyExitProfile.profile(inliningTarget, !internalArray[i])) {
377376
LoopNode.reportLoopCount(inliningTarget, i);
378377
return false;
379-
} else if (nodeType == AnyOrAllNodeType.ANY && earlyExitProfile.profile(inliningTarget, isTrueNode.execute(frame, inliningTarget, internalArray[i]))) {
378+
} else if (nodeType == AnyOrAllNodeType.ANY && earlyExitProfile.profile(inliningTarget, internalArray[i])) {
380379
LoopNode.reportLoopCount(inliningTarget, i);
381380
return true;
382381
}
@@ -386,18 +385,17 @@ static boolean doBoolSequence(VirtualFrame frame, Node inliningTarget, BoolSeque
386385
}
387386

388387
@Specialization
389-
static boolean doIntSequence(VirtualFrame frame, Node inliningTarget, IntSequenceStorage sequenceStorage, AnyOrAllNodeType nodeType,
390-
@Shared @Cached InlinedLoopConditionProfile loopConditionProfile,
391-
@Shared @Cached InlinedCountingConditionProfile earlyExitProfile,
392-
@Shared @Cached PyObjectIsTrueNode isTrueNode) {
388+
static boolean doIntSequence(Node inliningTarget, IntSequenceStorage sequenceStorage, AnyOrAllNodeType nodeType,
389+
@Exclusive @Cached InlinedLoopConditionProfile loopConditionProfile,
390+
@Exclusive @Cached InlinedCountingConditionProfile earlyExitProfile) {
393391
int[] internalArray = sequenceStorage.getInternalIntArray();
394392
int seqLength = sequenceStorage.length();
395393

396394
for (int i = 0; loopConditionProfile.profile(inliningTarget, i < seqLength); i++) {
397-
if (nodeType == AnyOrAllNodeType.ALL && earlyExitProfile.profile(inliningTarget, !isTrueNode.execute(frame, inliningTarget, internalArray[i]))) {
395+
if (nodeType == AnyOrAllNodeType.ALL && earlyExitProfile.profile(inliningTarget, internalArray[i] == 0)) {
398396
LoopNode.reportLoopCount(inliningTarget, i);
399397
return false;
400-
} else if (nodeType == AnyOrAllNodeType.ANY && earlyExitProfile.profile(inliningTarget, isTrueNode.execute(frame, inliningTarget, internalArray[i]))) {
398+
} else if (nodeType == AnyOrAllNodeType.ANY && earlyExitProfile.profile(inliningTarget, internalArray[i] != 0)) {
401399
LoopNode.reportLoopCount(inliningTarget, i);
402400
return true;
403401
}
@@ -408,17 +406,19 @@ static boolean doIntSequence(VirtualFrame frame, Node inliningTarget, IntSequenc
408406

409407
@Specialization
410408
static boolean doGenericSequence(VirtualFrame frame, Node inliningTarget, SequenceStorage sequenceStorage, AnyOrAllNodeType nodeType,
411-
@Shared @Cached InlinedLoopConditionProfile loopConditionProfile,
412-
@Shared @Cached InlinedCountingConditionProfile earlyExitProfile,
413-
@Shared @Cached PyObjectIsTrueNode isTrueNode) {
414-
Object[] internalArray = sequenceStorage.getInternalArray();
409+
@Exclusive @Cached InlinedLoopConditionProfile loopConditionProfile,
410+
@Exclusive @Cached InlinedCountingConditionProfile earlyExitProfile,
411+
@Cached PyObjectIsTrueNode isTrueNode,
412+
@Cached SequenceStorageNodes.GetItemScalarNode getItem) {
415413
int seqLength = sequenceStorage.length();
416414

417415
for (int i = 0; loopConditionProfile.profile(inliningTarget, i < seqLength); i++) {
418-
if (nodeType == AnyOrAllNodeType.ALL && earlyExitProfile.profile(inliningTarget, !isTrueNode.execute(frame, inliningTarget, internalArray[i]))) {
416+
if (nodeType == AnyOrAllNodeType.ALL &&
417+
earlyExitProfile.profile(inliningTarget, !isTrueNode.execute(frame, inliningTarget, getItem.execute(inliningTarget, sequenceStorage, i)))) {
419418
LoopNode.reportLoopCount(inliningTarget, i);
420419
return false;
421-
} else if (nodeType == AnyOrAllNodeType.ANY && earlyExitProfile.profile(inliningTarget, isTrueNode.execute(frame, inliningTarget, internalArray[i]))) {
420+
} else if (nodeType == AnyOrAllNodeType.ANY &&
421+
earlyExitProfile.profile(inliningTarget, isTrueNode.execute(frame, inliningTarget, getItem.execute(inliningTarget, sequenceStorage, i)))) {
422422
LoopNode.reportLoopCount(inliningTarget, i);
423423
return true;
424424
}

0 commit comments

Comments
 (0)