97
97
import com .oracle .graal .python .lib .PyObjectRichCompare ;
98
98
import com .oracle .graal .python .lib .PyObjectRichCompareBool ;
99
99
import com .oracle .graal .python .lib .PyObjectSizeNode ;
100
+ import com .oracle .graal .python .lib .RichCmpOp ;
100
101
import com .oracle .graal .python .nodes .ErrorMessages ;
101
102
import com .oracle .graal .python .nodes .PGuards ;
102
103
import com .oracle .graal .python .nodes .PRaiseNode ;
@@ -280,7 +281,7 @@ static Object concat(PArray self, int value,
280
281
abstract static class ArrayRichCmpNode extends TpSlotRichCompare .RichCmpBuiltinNode {
281
282
282
283
@ Specialization (guards = "!isFloatingPoint(left.getFormat()) || (left.getFormat() != right.getFormat())" )
283
- static Object cmpItems (VirtualFrame frame , PArray left , PArray right , TpSlotRichCompare . RichCmpOp op ,
284
+ static Object cmpItems (VirtualFrame frame , PArray left , PArray right , RichCmpOp op ,
284
285
@ Bind Node inliningTarget ,
285
286
@ Exclusive @ Cached InlinedBranchProfile fullCmpProfile ,
286
287
@ Exclusive @ Cached PyObjectRichCompareBool richCmpEqNode ,
@@ -290,18 +291,18 @@ static Object cmpItems(VirtualFrame frame, PArray left, PArray right, TpSlotRich
290
291
@ Exclusive @ Cached InlinedLoopConditionProfile loopProfile ) {
291
292
if (left .getLength () != right .getLength () && op .isEqOrNe ()) {
292
293
// the same fast-path as CPython
293
- return op == TpSlotRichCompare . RichCmpOp .Py_NE ;
294
+ return op == RichCmpOp .Py_NE ;
294
295
}
295
296
fullCmpProfile .enter (inliningTarget );
296
297
int commonLength = Math .min (left .getLength (), right .getLength ());
297
298
loopProfile .profileCounted (inliningTarget , commonLength ); // ignoring the early exit
298
299
for (int i = 0 ; loopProfile .inject (inliningTarget , i < commonLength ); i ++) {
299
300
Object leftValue = getLeft .execute (inliningTarget , left , i );
300
301
Object rightValue = getRight .execute (inliningTarget , right , i );
301
- if (!richCmpEqNode .execute (frame , inliningTarget , leftValue , rightValue , TpSlotRichCompare . RichCmpOp .Py_EQ )) {
302
- if (op == TpSlotRichCompare . RichCmpOp .Py_EQ ) {
302
+ if (!richCmpEqNode .execute (frame , inliningTarget , leftValue , rightValue , RichCmpOp .Py_EQ )) {
303
+ if (op == RichCmpOp .Py_EQ ) {
303
304
return false ;
304
- } else if (op == TpSlotRichCompare . RichCmpOp .Py_NE ) {
305
+ } else if (op == RichCmpOp .Py_NE ) {
305
306
return true ;
306
307
}
307
308
return richCmpOpNode .execute (frame , inliningTarget , leftValue , rightValue , op );
@@ -322,15 +323,15 @@ static Object cmpItems(VirtualFrame frame, PArray left, PArray right, TpSlotRich
322
323
// be preserved, so here we know for sure that if we see two NaNs, PyObjectRichCompareBool
323
324
// would return false on CPython, and so we do the same. This is tested in CPython tests.
324
325
@ Specialization (guards = {"isFloatingPoint(left.getFormat())" , "left.getFormat() == right.getFormat()" })
325
- static boolean cmpDoubles (VirtualFrame frame , PArray left , PArray right , TpSlotRichCompare . RichCmpOp op ,
326
+ static boolean cmpDoubles (VirtualFrame frame , PArray left , PArray right , RichCmpOp op ,
326
327
@ Bind ("$node" ) Node inliningTarget ,
327
328
@ Exclusive @ Cached InlinedBranchProfile fullCmpProfile ,
328
329
@ Exclusive @ Cached ArrayNodes .GetValueNode getLeft ,
329
330
@ Exclusive @ Cached ArrayNodes .GetValueNode getRight ,
330
331
@ Exclusive @ Cached InlinedLoopConditionProfile loopProfile ) {
331
332
if (left .getLength () != right .getLength () && op .isEqOrNe ()) {
332
333
// the same fast-path as CPython
333
- return op == TpSlotRichCompare . RichCmpOp .Py_NE ;
334
+ return op == RichCmpOp .Py_NE ;
334
335
}
335
336
fullCmpProfile .enter (inliningTarget );
336
337
int commonLength = Math .min (left .getLength (), right .getLength ());
@@ -350,13 +351,13 @@ static boolean cmpDoubles(VirtualFrame frame, PArray left, PArray right, TpSlotR
350
351
351
352
@ Specialization (guards = "!isArray(right)" )
352
353
@ SuppressWarnings ("unused" )
353
- static Object cmp (PArray left , Object right , TpSlotRichCompare . RichCmpOp op ) {
354
+ static Object cmp (PArray left , Object right , RichCmpOp op ) {
354
355
return PNotImplemented .NOT_IMPLEMENTED ;
355
356
}
356
357
357
358
@ Specialization (guards = "!isArray(left)" )
358
359
@ SuppressWarnings ("unused" )
359
- static Object error (Object left , Object right , TpSlotRichCompare . RichCmpOp op ,
360
+ static Object error (Object left , Object right , RichCmpOp op ,
360
361
@ Bind ("this" ) Node inliningTarget ) {
361
362
throw PRaiseNode .raiseStatic (inliningTarget , PythonErrorType .TypeError , ErrorMessages .DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P , op .getPythonName (), J_ARRAY + "." + J_ARRAY , left );
362
363
}
@@ -371,7 +372,7 @@ static boolean contains(VirtualFrame frame, PArray self, Object value,
371
372
@ Cached PyObjectRichCompareBool eqNode ,
372
373
@ Cached ArrayNodes .GetValueNode getValueNode ) {
373
374
for (int i = 0 ; i < self .getLength (); i ++) {
374
- if (eqNode .execute (frame , inliningTarget , getValueNode .execute (inliningTarget , self , i ), value , TpSlotRichCompare . RichCmpOp .Py_EQ )) {
375
+ if (eqNode .execute (frame , inliningTarget , getValueNode .execute (inliningTarget , self , i ), value , RichCmpOp .Py_EQ )) {
375
376
return true ;
376
377
}
377
378
}
@@ -927,7 +928,7 @@ static Object remove(VirtualFrame frame, PArray self, Object value,
927
928
@ Cached PRaiseNode raiseNode ) {
928
929
for (int i = 0 ; i < self .getLength (); i ++) {
929
930
Object item = getValueNode .execute (inliningTarget , self , i );
930
- if (eqNode .execute (frame , inliningTarget , item , value , TpSlotRichCompare . RichCmpOp .Py_EQ )) {
931
+ if (eqNode .execute (frame , inliningTarget , item , value , RichCmpOp .Py_EQ )) {
931
932
self .checkCanResize (inliningTarget , raiseNode );
932
933
deleteSliceNode .execute (inliningTarget , self , i , 1 );
933
934
return PNone .NONE ;
@@ -1274,7 +1275,7 @@ static int index(VirtualFrame frame, PArray self, Object value, int start, int s
1274
1275
stop += length ;
1275
1276
}
1276
1277
for (int i = start ; i < stop && i < length ; i ++) {
1277
- if (eqNode .execute (frame , inliningTarget , getValueNode .execute (inliningTarget , self , i ), value , TpSlotRichCompare . RichCmpOp .Py_EQ )) {
1278
+ if (eqNode .execute (frame , inliningTarget , getValueNode .execute (inliningTarget , self , i ), value , RichCmpOp .Py_EQ )) {
1278
1279
return i ;
1279
1280
}
1280
1281
}
@@ -1297,7 +1298,7 @@ static int count(VirtualFrame frame, PArray self, Object value,
1297
1298
@ Cached ArrayNodes .GetValueNode getValueNode ) {
1298
1299
int count = 0 ;
1299
1300
for (int i = 0 ; i < self .getLength (); i ++) {
1300
- if (eqNode .execute (frame , inliningTarget , getValueNode .execute (inliningTarget , self , i ), value , TpSlotRichCompare . RichCmpOp .Py_EQ )) {
1301
+ if (eqNode .execute (frame , inliningTarget , getValueNode .execute (inliningTarget , self , i ), value , RichCmpOp .Py_EQ )) {
1301
1302
count ++;
1302
1303
}
1303
1304
}
0 commit comments