@@ -376,7 +376,7 @@ dummy_func(
376
376
377
377
pure inst (UNARY_NOT , (value -- res )) {
378
378
assert (PyStackRef_BoolCheck (value ));
379
- res = PyStackRef_Is (value , PyStackRef_False )
379
+ res = PyStackRef_IsExactly (value , PyStackRef_False )
380
380
? PyStackRef_True : PyStackRef_False ;
381
381
DEAD (value );
382
382
}
@@ -441,7 +441,7 @@ dummy_func(
441
441
442
442
inst (TO_BOOL_NONE , (unused /1 , unused /2 , value -- res )) {
443
443
// This one is a bit weird, because we expect *some* failures:
444
- EXIT_IF (!PyStackRef_Is (value , PyStackRef_None ));
444
+ EXIT_IF (!PyStackRef_IsNone (value ));
445
445
DEAD (value );
446
446
STAT_INC (TO_BOOL , hit );
447
447
res = PyStackRef_False ;
@@ -651,9 +651,7 @@ dummy_func(
651
651
// specializations, but there is no output.
652
652
// At the end we just skip over the STORE_FAST.
653
653
op (_BINARY_OP_INPLACE_ADD_UNICODE , (left , right -- )) {
654
- #ifndef NDEBUG
655
654
PyObject * left_o = PyStackRef_AsPyObjectBorrow (left );
656
- #endif
657
655
PyObject * right_o = PyStackRef_AsPyObjectBorrow (right );
658
656
659
657
int next_oparg ;
@@ -664,7 +662,7 @@ dummy_func(
664
662
next_oparg = CURRENT_OPERAND0 ();
665
663
#endif
666
664
_PyStackRef * target_local = & GETLOCAL (next_oparg );
667
- DEOPT_IF (! PyStackRef_Is (* target_local , left ) );
665
+ DEOPT_IF (PyStackRef_AsPyObjectBorrow (* target_local ) != left_o );
668
666
STAT_INC (BINARY_OP , hit );
669
667
/* Handle `left = left + right` or `left += right` for str.
670
668
*
@@ -1141,7 +1139,7 @@ dummy_func(
1141
1139
gen_frame -> previous = frame ;
1142
1140
DISPATCH_INLINED (gen_frame );
1143
1141
}
1144
- if (PyStackRef_Is ( v , PyStackRef_None ) && PyIter_Check (receiver_o )) {
1142
+ if (PyStackRef_IsNone ( v ) && PyIter_Check (receiver_o )) {
1145
1143
retval_o = Py_TYPE (receiver_o )-> tp_iternext (receiver_o );
1146
1144
}
1147
1145
else {
@@ -1249,7 +1247,7 @@ dummy_func(
1249
1247
inst (POP_EXCEPT , (exc_value -- )) {
1250
1248
_PyErr_StackItem * exc_info = tstate -> exc_info ;
1251
1249
Py_XSETREF (exc_info -> exc_value ,
1252
- PyStackRef_Is (exc_value , PyStackRef_None )
1250
+ PyStackRef_IsNone (exc_value )
1253
1251
? NULL : PyStackRef_AsPyObjectSteal (exc_value ));
1254
1252
}
1255
1253
@@ -2408,6 +2406,14 @@ dummy_func(
2408
2406
}
2409
2407
else {
2410
2408
res = PyStackRef_FromPyObjectSteal (res_o );
2409
+ #ifdef Py_GIL_DISABLED
2410
+ // Ensure that Py_TAG_DEFERRED is set for Py_True and Py_False
2411
+ // so that ops like _POP_JUMP_IF_FALSE can use the faster
2412
+ // PyStackRef_IsExactly() check.
2413
+ if (_Py_IsImmortal (res_o )) {
2414
+ res .bits |= Py_TAG_DEFERRED ;
2415
+ }
2416
+ #endif
2411
2417
}
2412
2418
}
2413
2419
@@ -2481,13 +2487,7 @@ dummy_func(
2481
2487
}
2482
2488
2483
2489
inst (IS_OP , (left , right -- b )) {
2484
- #ifdef Py_GIL_DISABLED
2485
- // On free-threaded builds, objects are conditionally immortalized.
2486
- // So their bits don't always compare equally.
2487
2490
int res = Py_Is (PyStackRef_AsPyObjectBorrow (left ), PyStackRef_AsPyObjectBorrow (right )) ^ oparg ;
2488
- #else
2489
- int res = PyStackRef_Is (left , right ) ^ oparg ;
2490
- #endif
2491
2491
DECREF_INPUTS ();
2492
2492
b = res ? PyStackRef_True : PyStackRef_False ;
2493
2493
}
@@ -2693,22 +2693,22 @@ dummy_func(
2693
2693
2694
2694
replaced op (_POP_JUMP_IF_FALSE , (cond -- )) {
2695
2695
assert (PyStackRef_BoolCheck (cond ));
2696
- int flag = PyStackRef_Is (cond , PyStackRef_False );
2696
+ int flag = PyStackRef_IsExactly (cond , PyStackRef_False );
2697
2697
DEAD (cond );
2698
2698
RECORD_BRANCH_TAKEN (this_instr [1 ].cache , flag );
2699
2699
JUMPBY (oparg * flag );
2700
2700
}
2701
2701
2702
2702
replaced op (_POP_JUMP_IF_TRUE , (cond -- )) {
2703
2703
assert (PyStackRef_BoolCheck (cond ));
2704
- int flag = PyStackRef_Is (cond , PyStackRef_True );
2704
+ int flag = PyStackRef_IsExactly (cond , PyStackRef_True );
2705
2705
DEAD (cond );
2706
2706
RECORD_BRANCH_TAKEN (this_instr [1 ].cache , flag );
2707
2707
JUMPBY (oparg * flag );
2708
2708
}
2709
2709
2710
2710
op (_IS_NONE , (value -- b )) {
2711
- if (PyStackRef_Is (value , PyStackRef_None )) {
2711
+ if (PyStackRef_IsNone (value )) {
2712
2712
b = PyStackRef_True ;
2713
2713
DEAD (value );
2714
2714
}
@@ -3752,7 +3752,7 @@ dummy_func(
3752
3752
3753
3753
inst (EXIT_INIT_CHECK , (should_be_none -- )) {
3754
3754
assert (STACK_LEVEL () == 2 );
3755
- if (!PyStackRef_Is (should_be_none , PyStackRef_None )) {
3755
+ if (!PyStackRef_IsNone (should_be_none )) {
3756
3756
PyErr_Format (PyExc_TypeError ,
3757
3757
"__init__() should return None, not '%.200s'" ,
3758
3758
Py_TYPE (PyStackRef_AsPyObjectBorrow (should_be_none ))-> tp_name );
@@ -4712,7 +4712,7 @@ dummy_func(
4712
4712
inst (INSTRUMENTED_POP_JUMP_IF_TRUE , (unused /1 -- )) {
4713
4713
_PyStackRef cond = POP ();
4714
4714
assert (PyStackRef_BoolCheck (cond ));
4715
- int flag = PyStackRef_Is (cond , PyStackRef_True );
4715
+ int flag = PyStackRef_IsExactly (cond , PyStackRef_True );
4716
4716
int offset = flag * oparg ;
4717
4717
RECORD_BRANCH_TAKEN (this_instr [1 ].cache , flag );
4718
4718
INSTRUMENTED_JUMP (this_instr , next_instr + offset , PY_MONITORING_EVENT_BRANCH );
@@ -4721,15 +4721,15 @@ dummy_func(
4721
4721
inst (INSTRUMENTED_POP_JUMP_IF_FALSE , (unused /1 -- )) {
4722
4722
_PyStackRef cond = POP ();
4723
4723
assert (PyStackRef_BoolCheck (cond ));
4724
- int flag = PyStackRef_Is (cond , PyStackRef_False );
4724
+ int flag = PyStackRef_IsExactly (cond , PyStackRef_False );
4725
4725
int offset = flag * oparg ;
4726
4726
RECORD_BRANCH_TAKEN (this_instr [1 ].cache , flag );
4727
4727
INSTRUMENTED_JUMP (this_instr , next_instr + offset , PY_MONITORING_EVENT_BRANCH );
4728
4728
}
4729
4729
4730
4730
inst (INSTRUMENTED_POP_JUMP_IF_NONE , (unused /1 -- )) {
4731
4731
_PyStackRef value_stackref = POP ();
4732
- int flag = PyStackRef_Is (value_stackref , PyStackRef_None );
4732
+ int flag = PyStackRef_IsNone (value_stackref );
4733
4733
int offset ;
4734
4734
if (flag ) {
4735
4735
offset = oparg ;
@@ -4745,7 +4745,7 @@ dummy_func(
4745
4745
inst (INSTRUMENTED_POP_JUMP_IF_NOT_NONE , (unused /1 -- )) {
4746
4746
_PyStackRef value_stackref = POP ();
4747
4747
int offset ;
4748
- int nflag = PyStackRef_Is (value_stackref , PyStackRef_None );
4748
+ int nflag = PyStackRef_IsNone (value_stackref );
4749
4749
if (nflag ) {
4750
4750
offset = 0 ;
4751
4751
}
@@ -4780,21 +4780,21 @@ dummy_func(
4780
4780
///////// Tier-2 only opcodes /////////
4781
4781
4782
4782
op (_GUARD_IS_TRUE_POP , (flag -- )) {
4783
- int is_true = PyStackRef_Is (flag , PyStackRef_True );
4783
+ int is_true = PyStackRef_IsTrue (flag );
4784
4784
DEAD (flag );
4785
4785
SYNC_SP ();
4786
4786
EXIT_IF (!is_true );
4787
4787
}
4788
4788
4789
4789
op (_GUARD_IS_FALSE_POP , (flag -- )) {
4790
- int is_false = PyStackRef_Is (flag , PyStackRef_False );
4790
+ int is_false = PyStackRef_IsFalse (flag );
4791
4791
DEAD (flag );
4792
4792
SYNC_SP ();
4793
4793
EXIT_IF (!is_false );
4794
4794
}
4795
4795
4796
4796
op (_GUARD_IS_NONE_POP , (val -- )) {
4797
- int is_none = PyStackRef_Is (val , PyStackRef_None );
4797
+ int is_none = PyStackRef_IsNone (val );
4798
4798
if (!is_none ) {
4799
4799
PyStackRef_CLOSE (val );
4800
4800
SYNC_SP ();
@@ -4804,7 +4804,7 @@ dummy_func(
4804
4804
}
4805
4805
4806
4806
op (_GUARD_IS_NOT_NONE_POP , (val -- )) {
4807
- int is_none = PyStackRef_Is (val , PyStackRef_None );
4807
+ int is_none = PyStackRef_IsNone (val );
4808
4808
PyStackRef_CLOSE (val );
4809
4809
SYNC_SP ();
4810
4810
EXIT_IF (is_none );
0 commit comments