|
71 | 71 | #endif |
72 | 72 |
|
73 | 73 | #ifdef Py_STATS |
74 | | -# define TAIL_CALL_PARAMS _PyInterpreterFrame *frame, _PyStackRef *stack_pointer, PyThreadState *tstate, _Py_CODEUNIT *next_instr, int oparg, int lastopcode |
75 | | -# define TAIL_CALL_ARGS frame, stack_pointer, tstate, next_instr, oparg, lastopcode |
| 74 | +# define TAIL_CALL_PARAMS _PyInterpreterFrame *frame, _PyStackRef *stack_pointer, PyThreadState *tstate, _Py_CODEUNIT *next_instr, int oparg, PyObject **PYOBJECT_SCRATCH, int lastopcode |
| 75 | +# define TAIL_CALL_ARGS frame, stack_pointer, tstate, next_instr, oparg, PYOBJECT_SCRATCH, lastopcode |
76 | 76 | #else |
77 | | -# define TAIL_CALL_PARAMS _PyInterpreterFrame *frame, _PyStackRef *stack_pointer, PyThreadState *tstate, _Py_CODEUNIT *next_instr, int oparg |
78 | | -# define TAIL_CALL_ARGS frame, stack_pointer, tstate, next_instr, oparg |
| 77 | +# define TAIL_CALL_PARAMS _PyInterpreterFrame *frame, _PyStackRef *stack_pointer, PyThreadState *tstate, _Py_CODEUNIT *next_instr, int oparg, PyObject **PYOBJECT_SCRATCH |
| 78 | +# define TAIL_CALL_ARGS frame, stack_pointer, tstate, next_instr, oparg, PYOBJECT_SCRATCH |
79 | 79 | #endif |
80 | 80 |
|
| 81 | + |
81 | 82 | #if Py_TAIL_CALL_INTERP |
82 | 83 | # ifdef _MSC_VER |
83 | 84 | # define Py_MUSTTAIL [[msvc::musttail]] |
|
102 | 103 | # ifdef Py_STATS |
103 | 104 | # define JUMP_TO_PREDICTED(name) \ |
104 | 105 | do { \ |
105 | | - Py_MUSTTAIL return (_TAIL_CALL_##name)(frame, stack_pointer, tstate, this_instr, oparg, lastopcode); \ |
| 106 | + Py_MUSTTAIL return (_TAIL_CALL_##name)(frame, stack_pointer, tstate, this_instr, oparg, lastopcode, PYOBJECT_SCRATCH); \ |
106 | 107 | } while (0) |
107 | 108 | # else |
108 | 109 | # define JUMP_TO_PREDICTED(name) \ |
109 | 110 | do { \ |
110 | | - Py_MUSTTAIL return (_TAIL_CALL_##name)(frame, stack_pointer, tstate, this_instr, oparg); \ |
| 111 | + Py_MUSTTAIL return (_TAIL_CALL_##name)(frame, stack_pointer, tstate, this_instr, oparg, PYOBJECT_SCRATCH); \ |
111 | 112 | } while (0) |
112 | 113 | # endif |
113 | 114 | # define LABEL(name) TARGET(name) |
| 115 | +# define MSVC_TAILCALL_SCRATCH_ARG ,PYOBJECT_SCRATCH |
114 | 116 | #elif USE_COMPUTED_GOTOS |
115 | 117 | # define TARGET(op) TARGET_##op: |
116 | 118 | # define DISPATCH_GOTO() goto *opcode_targets[opcode] |
117 | 119 | # define JUMP_TO_LABEL(name) goto name; |
118 | 120 | # define JUMP_TO_PREDICTED(name) goto PREDICTED_##name; |
119 | 121 | # define LABEL(name) name: |
| 122 | +# define MSVC_TAILCALL_SCRATCH_ARG |
120 | 123 | #else |
121 | 124 | # define TARGET(op) case op: TARGET_##op: |
122 | 125 | # define DISPATCH_GOTO() goto dispatch_opcode |
123 | 126 | # define JUMP_TO_LABEL(name) goto name; |
124 | 127 | # define JUMP_TO_PREDICTED(name) goto PREDICTED_##name; |
125 | 128 | # define LABEL(name) name: |
| 129 | +# define MSVC_TAILCALL_SCRATCH_ARG |
126 | 130 | #endif |
127 | 131 |
|
128 | 132 | /* PRE_DISPATCH_GOTO() does lltrace if enabled. Normally a no-op */ |
@@ -421,10 +425,16 @@ do { \ |
421 | 425 | /* How much scratch space to give stackref to PyObject* conversion. */ |
422 | 426 | #define MAX_STACKREF_SCRATCH 10 |
423 | 427 |
|
| 428 | +#if Py_TAIL_CALL_INTERP |
424 | 429 | #define STACKREFS_TO_PYOBJECTS(ARGS, ARG_COUNT, NAME) \ |
425 | 430 | /* +1 because vectorcall might use -1 to write self */ \ |
426 | | - PyObject *NAME##_temp[MAX_STACKREF_SCRATCH+1]; \ |
| 431 | + PyObject **NAME##_temp = PYOBJECT_SCRATCH; \ |
| 432 | + PyObject **NAME = _PyObjectArray_FromStackRefArray(ARGS, ARG_COUNT, NAME##_temp + 1); |
| 433 | +#else |
| 434 | +#define STACKREFS_TO_PYOBJECTS(ARGS, ARG_COUNT, NAME) \ |
| 435 | + PyObject *NAME##_temp[MAX_STACKREF_SCRATCH + 1]; \ |
427 | 436 | PyObject **NAME = _PyObjectArray_FromStackRefArray(ARGS, ARG_COUNT, NAME##_temp + 1); |
| 437 | +#endif |
428 | 438 |
|
429 | 439 | #define STACKREFS_TO_PYOBJECTS_CLEANUP(NAME) \ |
430 | 440 | /* +1 because we +1 previously */ \ |
|
0 commit comments