Skip to content

Commit 5bbc96e

Browse files
committed
Support tail-calling
1 parent 492df4e commit 5bbc96e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Python/ceval.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
10391039
monitor_throw(tstate, frame, next_instr);
10401040
stack_pointer = _PyFrame_GetStackPointer(frame);
10411041
#if Py_TAIL_CALL_INTERP
1042-
return _TAIL_CALL_error(frame, stack_pointer, tstate, next_instr, 0);
1042+
return _TAIL_CALL_error(frame, stack_pointer, tstate, next_instr, 0, PyStackRef_NULL);
10431043
#else
10441044
goto error;
10451045
#endif
@@ -1052,7 +1052,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
10521052
#endif
10531053
_PyStackRef _tos = PyStackRef_NULL;
10541054
#if Py_TAIL_CALL_INTERP
1055-
return _TAIL_CALL_start_frame(frame, NULL, tstate, NULL, 0);
1055+
return _TAIL_CALL_start_frame(frame, NULL, tstate, NULL, 0, _tos);
10561056
#else
10571057
goto start_frame;
10581058
# include "generated_cases.c.h"

Python/ceval_macros.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@
7070
#define INSTRUCTION_STATS(op) ((void)0)
7171
#endif
7272

73-
#define TAIL_CALL_PARAMS _PyInterpreterFrame *frame, _PyStackRef *stack_pointer, PyThreadState *tstate, _Py_CODEUNIT *next_instr, int oparg
74-
#define TAIL_CALL_ARGS frame, stack_pointer, tstate, next_instr, oparg
73+
#define TAIL_CALL_PARAMS _PyInterpreterFrame *frame, _PyStackRef *stack_pointer, PyThreadState *tstate, _Py_CODEUNIT *next_instr, int oparg, _PyStackRef _tos
74+
#define TAIL_CALL_ARGS frame, stack_pointer, tstate, next_instr, oparg, _tos
7575

7676
#if Py_TAIL_CALL_INTERP
7777
// Note: [[clang::musttail]] works for GCC 15, but not __attribute__((musttail)) at the moment.
@@ -90,7 +90,7 @@
9090
} while (0)
9191
# define JUMP_TO_PREDICTED(name) \
9292
do { \
93-
Py_MUSTTAIL return (_TAIL_CALL_##name)(frame, stack_pointer, tstate, this_instr, oparg); \
93+
Py_MUSTTAIL return (_TAIL_CALL_##name)(frame, stack_pointer, tstate, this_instr, oparg, _tos); \
9494
} while (0)
9595
# define LABEL(name) TARGET(name)
9696
#elif USE_COMPUTED_GOTOS

0 commit comments

Comments
 (0)