aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/executor_cases.c.h
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2024-03-15 10:48:00 +0000
committerGitHub <noreply@github.com>2024-03-15 10:48:00 +0000
commit2cf18a44303b6d84faa8ecffaecc427b53ae121e (patch)
tree944935198b1935d61091b1e40681720de4177dd8 /Python/executor_cases.c.h
parenta50cf6c3d76b34e2ee9f92a248f1b0df24e407f6 (diff)
downloadcpython-2cf18a44303b6d84faa8ecffaecc427b53ae121e.tar.gz
cpython-2cf18a44303b6d84faa8ecffaecc427b53ae121e.zip
GH-116422: Modify a few uops so that they can be supported by tier 2 with hot/cold splitting (GH-116832)
Diffstat (limited to 'Python/executor_cases.c.h')
-rw-r--r--Python/executor_cases.c.h32
1 files changed, 15 insertions, 17 deletions
diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h
index 077499ebc01..bdc9c0b1501 100644
--- a/Python/executor_cases.c.h
+++ b/Python/executor_cases.c.h
@@ -3189,14 +3189,12 @@
if (total_args != 1) goto deoptimize;
if (!PyCFunction_CheckExact(callable)) goto deoptimize;
if (PyCFunction_GET_FLAGS(callable) != METH_O) goto deoptimize;
+ // CPython promises to check all non-vectorcall function calls.
+ if (tstate->c_recursion_remaining <= 0) goto deoptimize;
STAT_INC(CALL, hit);
PyCFunction cfunc = PyCFunction_GET_FUNCTION(callable);
- // This is slower but CPython promises to check all non-vectorcall
- // function calls.
- if (_Py_EnterRecursiveCallTstate(tstate, " while calling a Python object")) {
- GOTO_ERROR(error);
- }
PyObject *arg = args[0];
+ _Py_EnterRecursiveCallTstateUnchecked(tstate);
res = _PyCFunction_TrampolineCall(cfunc, PyCFunction_GET_SELF(callable), arg);
_Py_LeaveRecursiveCallTstate(tstate);
assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
@@ -3305,9 +3303,11 @@
}
res = PyLong_FromSsize_t(len_i);
assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
+ if (res == NULL) {
+ GOTO_ERROR(error);
+ }
Py_DECREF(callable);
Py_DECREF(arg);
- if (res == NULL) { stack_pointer += -2 - oparg; goto error_tier_two; }
stack_pointer[-2 - oparg] = res;
stack_pointer += -1 - oparg;
break;
@@ -3340,10 +3340,12 @@
}
res = PyBool_FromLong(retval);
assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
+ if (res == NULL) {
+ GOTO_ERROR(error);
+ }
Py_DECREF(inst);
Py_DECREF(cls);
Py_DECREF(callable);
- if (res == NULL) { stack_pointer += -2 - oparg; goto error_tier_two; }
stack_pointer[-2 - oparg] = res;
stack_pointer += -1 - oparg;
break;
@@ -3368,16 +3370,14 @@
if (!Py_IS_TYPE(method, &PyMethodDescr_Type)) goto deoptimize;
PyMethodDef *meth = method->d_method;
if (meth->ml_flags != METH_O) goto deoptimize;
+ // CPython promises to check all non-vectorcall function calls.
+ if (tstate->c_recursion_remaining <= 0) goto deoptimize;
PyObject *arg = args[1];
PyObject *self = args[0];
if (!Py_IS_TYPE(self, method->d_common.d_type)) goto deoptimize;
STAT_INC(CALL, hit);
PyCFunction cfunc = meth->ml_meth;
- // This is slower but CPython promises to check all non-vectorcall
- // function calls.
- if (_Py_EnterRecursiveCallTstate(tstate, " while calling a Python object")) {
- GOTO_ERROR(error);
- }
+ _Py_EnterRecursiveCallTstateUnchecked(tstate);
res = _PyCFunction_TrampolineCall(cfunc, self, arg);
_Py_LeaveRecursiveCallTstate(tstate);
assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));
@@ -3450,13 +3450,11 @@
PyObject *self = args[0];
if (!Py_IS_TYPE(self, method->d_common.d_type)) goto deoptimize;
if (meth->ml_flags != METH_NOARGS) goto deoptimize;
+ // CPython promises to check all non-vectorcall function calls.
+ if (tstate->c_recursion_remaining <= 0) goto deoptimize;
STAT_INC(CALL, hit);
PyCFunction cfunc = meth->ml_meth;
- // This is slower but CPython promises to check all non-vectorcall
- // function calls.
- if (_Py_EnterRecursiveCallTstate(tstate, " while calling a Python object")) {
- GOTO_ERROR(error);
- }
+ _Py_EnterRecursiveCallTstateUnchecked(tstate);
res = _PyCFunction_TrampolineCall(cfunc, self, NULL);
_Py_LeaveRecursiveCallTstate(tstate);
assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL));