27
27
package com .oracle .graal .python .builtins .objects .bytes ;
28
28
29
29
import static com .oracle .graal .python .nodes .BuiltinNames .J_APPEND ;
30
+ import static com .oracle .graal .python .nodes .BuiltinNames .J_BYTEARRAY ;
30
31
import static com .oracle .graal .python .nodes .BuiltinNames .J_EXTEND ;
31
32
import static com .oracle .graal .python .nodes .SpecialAttributeNames .T___DICT__ ;
32
33
import static com .oracle .graal .python .nodes .SpecialMethodNames .J___DELITEM__ ;
78
79
import com .oracle .graal .python .builtins .objects .slice .SliceNodes ;
79
80
import com .oracle .graal .python .builtins .objects .type .TypeNodes ;
80
81
import com .oracle .graal .python .builtins .objects .type .TypeNodes .InlinedIsSameTypeNode ;
82
+ import com .oracle .graal .python .lib .PyByteArrayCheckNode ;
81
83
import com .oracle .graal .python .lib .PyIndexCheckNode ;
82
84
import com .oracle .graal .python .lib .PyNumberAsSizeNode ;
83
85
import com .oracle .graal .python .lib .PyObjectLookupAttr ;
@@ -799,24 +801,22 @@ public Object reduce(VirtualFrame frame, PByteArray self,
799
801
abstract static class AbstractComparisonNode extends BytesNodes .AbstractComparisonBaseNode {
800
802
@ Specialization
801
803
@ SuppressWarnings ("truffle-static-method" )
802
- boolean cmp (PBytesLike self , PBytesLike other ,
804
+ boolean cmp (PByteArray self , PBytesLike other ,
803
805
@ Shared @ Cached GetInternalByteArrayNode getArray ) {
804
806
SequenceStorage selfStorage = self .getSequenceStorage ();
805
807
SequenceStorage otherStorage = other .getSequenceStorage ();
806
808
return doCmp (getArray .execute (selfStorage ), selfStorage .length (), getArray .execute (otherStorage ), otherStorage .length ());
807
809
}
808
810
809
- @ Specialization
811
+ @ Specialization ( guards = { "check.execute(inliningTarget, self)" , "acquireLib.hasBuffer(other)" }, limit = "3" )
810
812
@ SuppressWarnings ("truffle-static-method" )
811
813
Object cmp (VirtualFrame frame , Object self , Object other ,
812
814
@ Bind ("this" ) Node inliningTarget ,
815
+ @ SuppressWarnings ("unused" ) @ Cached PyByteArrayCheckNode check ,
813
816
@ Cached GetBytesStorage getBytesStorage ,
814
817
@ Shared @ Cached GetInternalByteArrayNode getArray ,
815
- @ CachedLibrary (limit = "3 " ) PythonBufferAcquireLibrary acquireLib ,
818
+ @ CachedLibrary ("other " ) PythonBufferAcquireLibrary acquireLib ,
816
819
@ CachedLibrary (limit = "3" ) PythonBufferAccessLibrary bufferLib ) {
817
- if (!acquireLib .hasBuffer (other )) {
818
- return PNotImplemented .NOT_IMPLEMENTED ;
819
- }
820
820
SequenceStorage selfStorage = getBytesStorage .execute (inliningTarget , self );
821
821
Object otherBuffer = acquireLib .acquireReadonly (other , frame , this );
822
822
try {
@@ -826,6 +826,23 @@ Object cmp(VirtualFrame frame, Object self, Object other,
826
826
bufferLib .release (otherBuffer );
827
827
}
828
828
}
829
+
830
+ @ Specialization (guards = {"check.execute(inliningTarget, self)" , "!acquireLib.hasBuffer(other)" }, limit = "1" )
831
+ @ SuppressWarnings ("unused" )
832
+ static Object cmp (VirtualFrame frame , Object self , Object other ,
833
+ @ Bind ("this" ) Node inliningTarget ,
834
+ @ Cached PyByteArrayCheckNode check ,
835
+ @ CachedLibrary (limit = "3" ) PythonBufferAcquireLibrary acquireLib ) {
836
+ return PNotImplemented .NOT_IMPLEMENTED ;
837
+ }
838
+
839
+ @ Specialization (guards = "!check.execute(inliningTarget, self)" , limit = "1" )
840
+ @ SuppressWarnings ({"truffle-static-method" , "unused" })
841
+ Object error (VirtualFrame frame , Object self , Object other ,
842
+ @ Bind ("this" ) Node inliningTarget ,
843
+ @ Cached PyByteArrayCheckNode check ) {
844
+ throw raise (TypeError , ErrorMessages .DESCRIPTOR_REQUIRES_OBJ , J___EQ__ , J_BYTEARRAY , self );
845
+ }
829
846
}
830
847
831
848
@ Builtin (name = J___EQ__ , minNumOfPositionalArgs = 2 )
0 commit comments