From 36383f6213adbcdc44ec5c54b07e0a9010710b65 Mon Sep 17 00:00:00 2001 From: Iason Krommydas Date: Wed, 11 Nov 2026 22:04:55 +0100 Subject: [PATCH] gh-161827: Mark _PyEval_EvalFrameDefault as Py_NO_INLINE Signed-off-by: Iason Krommydas --- .../2026-11-11-21-52-02.gh-issue-161827.3PD3RK.rst | 4 ++++ Python/ceval.c | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2026-11-11-21-52-02.gh-issue-161827.3PD3RK.rst diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-11-11-21-52-02.gh-issue-161827.3PD3RK.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-11-11-21-52-02.gh-issue-161827.3PD3RK.rst new file mode 100644 index 00000000000000..2ae6517db14f15 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-11-11-21-52-02.gh-issue-161827.3PD3RK.rst @@ -0,0 +1,4 @@ +Keep ``_PyEval_EvalFrameDefault`` as a separate frame in the C call stack +when Python is built with the tail-calling interpreter +(:option:`--with-tail-call-interp`), so that stack unwinders, profilers and +other tools that walk the stack can find the interpreter loop. diff --git a/Python/ceval.c b/Python/ceval.c index 0d053cdc7a63e3..ccc0edca2fc794 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1200,7 +1200,13 @@ dtrace_function_return(_PyInterpreterFrame *frame) } #endif -PyObject* _Py_HOT_FUNCTION DONT_SLP_VECTORIZE +/* + * _PyEval_EvalFrameDefault must remain a separate frame in the C call stack: + * stack unwinders, profilers and other tools that walk the stack use it to + * find the interpreter loop. With the tail-calling interpreter it is small + * enough to be inlined into its callers, e.g. by Clang with PGO. + */ +Py_NO_INLINE PyObject* _Py_HOT_FUNCTION DONT_SLP_VECTORIZE _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int throwflag) { _Py_EnsureTstateNotNULL(tstate);