@@ -3376,14 +3376,12 @@ dummy_func(
3376
3376
DEOPT_IF (total_args != 1 );
3377
3377
DEOPT_IF (!PyCFunction_CheckExact (callable ));
3378
3378
DEOPT_IF (PyCFunction_GET_FLAGS (callable ) != METH_O );
3379
+ // CPython promises to check all non-vectorcall function calls.
3380
+ DEOPT_IF (tstate -> c_recursion_remaining <= 0 );
3379
3381
STAT_INC (CALL , hit );
3380
3382
PyCFunction cfunc = PyCFunction_GET_FUNCTION (callable );
3381
- // This is slower but CPython promises to check all non-vectorcall
3382
- // function calls.
3383
- if (_Py_EnterRecursiveCallTstate (tstate , " while calling a Python object" )) {
3384
- GOTO_ERROR (error );
3385
- }
3386
3383
PyObject * arg = args [0 ];
3384
+ _Py_EnterRecursiveCallTstateUnchecked (tstate );
3387
3385
res = _PyCFunction_TrampolineCall (cfunc , PyCFunction_GET_SELF (callable ), arg );
3388
3386
_Py_LeaveRecursiveCallTstate (tstate );
3389
3387
assert ((res != NULL ) ^ (_PyErr_Occurred (tstate ) != NULL ));
@@ -3480,10 +3478,11 @@ dummy_func(
3480
3478
}
3481
3479
res = PyLong_FromSsize_t (len_i );
3482
3480
assert ((res != NULL ) ^ (_PyErr_Occurred (tstate ) != NULL ));
3483
-
3481
+ if (res == NULL ) {
3482
+ GOTO_ERROR (error );
3483
+ }
3484
3484
Py_DECREF (callable );
3485
3485
Py_DECREF (arg );
3486
- ERROR_IF (res == NULL , error );
3487
3486
}
3488
3487
3489
3488
inst (CALL_ISINSTANCE , (unused /1 , unused /2 , callable , self_or_null , args [oparg ] -- res )) {
@@ -3505,11 +3504,12 @@ dummy_func(
3505
3504
}
3506
3505
res = PyBool_FromLong (retval );
3507
3506
assert ((res != NULL ) ^ (_PyErr_Occurred (tstate ) != NULL ));
3508
-
3507
+ if (res == NULL ) {
3508
+ GOTO_ERROR (error );
3509
+ }
3509
3510
Py_DECREF (inst );
3510
3511
Py_DECREF (cls );
3511
3512
Py_DECREF (callable );
3512
- ERROR_IF (res == NULL , error );
3513
3513
}
3514
3514
3515
3515
// This is secretly a super-instruction
@@ -3543,16 +3543,14 @@ dummy_func(
3543
3543
DEOPT_IF (!Py_IS_TYPE (method , & PyMethodDescr_Type ));
3544
3544
PyMethodDef * meth = method -> d_method ;
3545
3545
DEOPT_IF (meth -> ml_flags != METH_O );
3546
+ // CPython promises to check all non-vectorcall function calls.
3547
+ DEOPT_IF (tstate -> c_recursion_remaining <= 0 );
3546
3548
PyObject * arg = args [1 ];
3547
3549
PyObject * self = args [0 ];
3548
3550
DEOPT_IF (!Py_IS_TYPE (self , method -> d_common .d_type ));
3549
3551
STAT_INC (CALL , hit );
3550
3552
PyCFunction cfunc = meth -> ml_meth ;
3551
- // This is slower but CPython promises to check all non-vectorcall
3552
- // function calls.
3553
- if (_Py_EnterRecursiveCallTstate (tstate , " while calling a Python object" )) {
3554
- GOTO_ERROR (error );
3555
- }
3553
+ _Py_EnterRecursiveCallTstateUnchecked (tstate );
3556
3554
res = _PyCFunction_TrampolineCall (cfunc , self , arg );
3557
3555
_Py_LeaveRecursiveCallTstate (tstate );
3558
3556
assert ((res != NULL ) ^ (_PyErr_Occurred (tstate ) != NULL ));
@@ -3616,13 +3614,11 @@ dummy_func(
3616
3614
PyObject * self = args [0 ];
3617
3615
DEOPT_IF (!Py_IS_TYPE (self , method -> d_common .d_type ));
3618
3616
DEOPT_IF (meth -> ml_flags != METH_NOARGS );
3617
+ // CPython promises to check all non-vectorcall function calls.
3618
+ DEOPT_IF (tstate -> c_recursion_remaining <= 0 );
3619
3619
STAT_INC (CALL , hit );
3620
3620
PyCFunction cfunc = meth -> ml_meth ;
3621
- // This is slower but CPython promises to check all non-vectorcall
3622
- // function calls.
3623
- if (_Py_EnterRecursiveCallTstate (tstate , " while calling a Python object" )) {
3624
- GOTO_ERROR (error );
3625
- }
3621
+ _Py_EnterRecursiveCallTstateUnchecked (tstate );
3626
3622
res = _PyCFunction_TrampolineCall (cfunc , self , NULL );
3627
3623
_Py_LeaveRecursiveCallTstate (tstate );
3628
3624
assert ((res != NULL ) ^ (_PyErr_Occurred (tstate ) != NULL ));
0 commit comments