aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2024-10-07 14:56:39 +0100
committerGitHub <noreply@github.com>2024-10-07 14:56:39 +0100
commitda071fa3e8e01e0cacf13d632aae0835a2203eb2 (patch)
treeebd70c16c871dee470785be5aed0bccbb1e3cbaf /Python/ceval.c
parentcda3b5a576412a8671bbe4c68bb792ec14f1a4b1 (diff)
downloadcpython-da071fa3e8e01e0cacf13d632aae0835a2203eb2.tar.gz
cpython-da071fa3e8e01e0cacf13d632aae0835a2203eb2.zip
GH-119866: Spill the stack around escaping calls. (GH-124392)
* Spill the evaluation around escaping calls in the generated interpreter and JIT. * The code generator tracks live, cached values so they can be saved to memory when needed. * Spills the stack pointer around escaping calls, so that the exact stack is visible to the cycle GC.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 6e62939adb3..ba5c70b25f0 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -274,7 +274,6 @@ static void monitor_throw(PyThreadState *tstate,
_PyInterpreterFrame *frame,
_Py_CODEUNIT *instr);
-static int check_args_iterable(PyThreadState *, PyObject *func, PyObject *vararg);
static int get_exception_handler(PyCodeObject *, int, int*, int*, int*);
static _PyInterpreterFrame *
_PyEvalFramePushAndInit_Ex(PyThreadState *tstate, _PyStackRef func,
@@ -394,6 +393,13 @@ const _Py_SpecialMethod _Py_SpecialMethods[] = {
}
};
+const size_t _Py_FunctionAttributeOffsets[] = {
+ [MAKE_FUNCTION_CLOSURE] = offsetof(PyFunctionObject, func_closure),
+ [MAKE_FUNCTION_ANNOTATIONS] = offsetof(PyFunctionObject, func_annotations),
+ [MAKE_FUNCTION_KWDEFAULTS] = offsetof(PyFunctionObject, func_kwdefaults),
+ [MAKE_FUNCTION_DEFAULTS] = offsetof(PyFunctionObject, func_defaults),
+ [MAKE_FUNCTION_ANNOTATE] = offsetof(PyFunctionObject, func_annotate),
+};
// PEP 634: Structural Pattern Matching
@@ -1036,6 +1042,7 @@ tier2_dispatch:
uopcode = next_uop->opcode;
#ifdef Py_DEBUG
if (lltrace >= 3) {
+ dump_stack(frame, stack_pointer);
if (next_uop->opcode == _START_EXECUTOR) {
printf("%4d uop: ", 0);
}
@@ -1043,8 +1050,7 @@ tier2_dispatch:
printf("%4d uop: ", (int)(next_uop - current_executor->trace));
}
_PyUOpPrint(next_uop);
- printf(" stack_level=%d\n",
- (int)(stack_pointer - _PyFrame_Stackbase(frame)));
+ printf("\n");
}
#endif
next_uop++;
@@ -2920,11 +2926,11 @@ _PyEval_CheckExceptStarTypeValid(PyThreadState *tstate, PyObject* right)
return 0;
}
-static int
-check_args_iterable(PyThreadState *tstate, PyObject *func, PyObject *args)
+int
+_Py_Check_ArgsIterable(PyThreadState *tstate, PyObject *func, PyObject *args)
{
if (Py_TYPE(args)->tp_iter == NULL && !PySequence_Check(args)) {
- /* check_args_iterable() may be called with a live exception:
+ /* _Py_Check_ArgsIterable() may be called with a live exception:
* clear it to prevent calling _PyObject_FunctionStr() with an
* exception set. */
_PyErr_Clear(tstate);