https://github.com/python/cpython/commit/6430c634da4332550744fe8f50b12c927b8382f6 commit: 6430c634da4332550744fe8f50b12c927b8382f6 branch: main author: Ken Jin <ken...@python.org> committer: Fidget-Spinner <kenjin4...@gmail.com> date: 2025-04-23T18:17:35+08:00 summary:
gh-132758: Fix tail call and pystats builds (GH-132759) files: A Misc/NEWS.d/next/Build/2025-04-20-20-07-44.gh-issue-132758.N2a3wp.rst M Python/ceval.c M Python/ceval_macros.h diff --git a/Misc/NEWS.d/next/Build/2025-04-20-20-07-44.gh-issue-132758.N2a3wp.rst b/Misc/NEWS.d/next/Build/2025-04-20-20-07-44.gh-issue-132758.N2a3wp.rst new file mode 100644 index 00000000000000..0645c35c18c133 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2025-04-20-20-07-44.gh-issue-132758.N2a3wp.rst @@ -0,0 +1 @@ +Fix building with tail call interpreter and pystats. diff --git a/Python/ceval.c b/Python/ceval.c index 17e28439872ba2..fb72fd49811e2d 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1071,7 +1071,11 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int monitor_throw(tstate, frame, next_instr); stack_pointer = _PyFrame_GetStackPointer(frame); #if Py_TAIL_CALL_INTERP - return _TAIL_CALL_error(frame, stack_pointer, tstate, next_instr, 0); +# if Py_STATS + return _TAIL_CALL_error(frame, stack_pointer, tstate, next_instr, 0, lastopcode); +# else + return _TAIL_CALL_error(frame, stack_pointer, tstate, next_instr, 0); +# endif #else goto error; #endif @@ -1083,7 +1087,11 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int const _PyUOpInstruction *next_uop = NULL; #endif #if Py_TAIL_CALL_INTERP - return _TAIL_CALL_start_frame(frame, NULL, tstate, NULL, 0); +# if Py_STATS + return _TAIL_CALL_start_frame(frame, NULL, tstate, NULL, 0, lastopcode); +# else + return _TAIL_CALL_start_frame(frame, NULL, tstate, NULL, 0); +# endif #else goto start_frame; # include "generated_cases.c.h" diff --git a/Python/ceval_macros.h b/Python/ceval_macros.h index 3dca4e46ee75e4..e1d2673848cc69 100644 --- a/Python/ceval_macros.h +++ b/Python/ceval_macros.h @@ -70,8 +70,13 @@ #define INSTRUCTION_STATS(op) ((void)0) #endif -#define TAIL_CALL_PARAMS _PyInterpreterFrame *frame, _PyStackRef *stack_pointer, PyThreadState *tstate, _Py_CODEUNIT *next_instr, int oparg -#define TAIL_CALL_ARGS frame, stack_pointer, tstate, next_instr, oparg +#ifdef Py_STATS +# define TAIL_CALL_PARAMS _PyInterpreterFrame *frame, _PyStackRef *stack_pointer, PyThreadState *tstate, _Py_CODEUNIT *next_instr, int oparg, int lastopcode +# define TAIL_CALL_ARGS frame, stack_pointer, tstate, next_instr, oparg, lastopcode +#else +# define TAIL_CALL_PARAMS _PyInterpreterFrame *frame, _PyStackRef *stack_pointer, PyThreadState *tstate, _Py_CODEUNIT *next_instr, int oparg +# define TAIL_CALL_ARGS frame, stack_pointer, tstate, next_instr, oparg +#endif #if Py_TAIL_CALL_INTERP // Note: [[clang::musttail]] works for GCC 15, but not __attribute__((musttail)) at the moment. @@ -88,10 +93,17 @@ do { \ Py_MUSTTAIL return (_TAIL_CALL_##name)(TAIL_CALL_ARGS); \ } while (0) -# define JUMP_TO_PREDICTED(name) \ - do { \ - Py_MUSTTAIL return (_TAIL_CALL_##name)(frame, stack_pointer, tstate, this_instr, oparg); \ - } while (0) +# ifdef Py_STATS +# define JUMP_TO_PREDICTED(name) \ + do { \ + Py_MUSTTAIL return (_TAIL_CALL_##name)(frame, stack_pointer, tstate, this_instr, oparg, lastopcode); \ + } while (0) +# else +# define JUMP_TO_PREDICTED(name) \ + do { \ + Py_MUSTTAIL return (_TAIL_CALL_##name)(frame, stack_pointer, tstate, this_instr, oparg); \ + } while (0) +# endif # define LABEL(name) TARGET(name) #elif USE_COMPUTED_GOTOS # define TARGET(op) TARGET_##op: _______________________________________________ Python-checkins mailing list -- python-checkins@python.org To unsubscribe send an email to python-checkins-le...@python.org https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: arch...@mail-archive.com