Skip to content

Commit fc91ac8

Browse files
cleanup macros
1 parent 16db128 commit fc91ac8

File tree

1 file changed

+23
-30
lines changed

1 file changed

+23
-30
lines changed

Python/ceval_macros.h

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -71,32 +71,25 @@
7171
#endif
7272

7373
#ifdef Py_TAIL_CALL_INTERP
74-
#ifdef LLTRACE
75-
__attribute__((preserve_none))
76-
typedef PyObject* (*py_tail_call_funcptr)(_PyInterpreterFrame *, _PyStackRef *, PyThreadState *tstate, _Py_CODEUNIT *, int, _PyInterpreterFrame *, int);
77-
#else
78-
__attribute__((preserve_none))
79-
typedef PyObject* (*py_tail_call_funcptr)(_PyInterpreterFrame *, _PyStackRef *, PyThreadState *tstate, _Py_CODEUNIT *, int, _PyInterpreterFrame *);
80-
#endif
81-
#ifdef LLTRACE
82-
#define DISPATCH_GOTO() do { \
83-
__attribute__((musttail)) \
84-
return (INSTRUCTION_TABLE[opcode])(frame, stack_pointer, tstate, next_instr, oparg, entry_frame, lltrace); \
74+
# define Py_MUSTTAIL __attribute__((musttail))
75+
# define Py_PRESERVE_NONE_CC __attribute__((preserve_none))
76+
# ifdef LLTRACE
77+
Py_PRESERVE_NONE_CC
78+
typedef PyObject* (*py_tail_call_funcptr)(_PyInterpreterFrame *, _PyStackRef *, PyThreadState *tstate, _Py_CODEUNIT *, int, _PyInterpreterFrame *, int);
79+
# define TAIL_CALL_ARGS frame, stack_pointer, tstate, next_instr, oparg, entry_frame, lltrace
80+
# else
81+
Py_PRESERVE_NONE_CC
82+
typedef PyObject* (*py_tail_call_funcptr)(_PyInterpreterFrame *, _PyStackRef *, PyThreadState *tstate, _Py_CODEUNIT *, int, _PyInterpreterFrame *);
83+
# define TAIL_CALL_ARGS frame, stack_pointer, tstate, next_instr, oparg, entry_frame
84+
# endif
85+
# define DISPATCH_GOTO() do { \
86+
Py_MUSTTAIL \
87+
return (INSTRUCTION_TABLE[opcode])(TAIL_CALL_ARGS); \
8588
} while (0)
86-
#define CEVAL_GOTO(name) do { \
87-
__attribute__((musttail)) \
88-
return (_TAIL_CALL_##name)(frame, stack_pointer, tstate, next_instr, oparg, entry_frame, lltrace); \
89+
# define CEVAL_GOTO(name) do { \
90+
Py_MUSTTAIL \
91+
return (_TAIL_CALL_##name)(TAIL_CALL_ARGS); \
8992
} while (0)
90-
#else
91-
#define DISPATCH_GOTO() do { \
92-
__attribute__((musttail)) \
93-
return (INSTRUCTION_TABLE[opcode])(frame, stack_pointer, tstate, next_instr, oparg, entry_frame); \
94-
} while (0)
95-
#define CEVAL_GOTO(name) do { \
96-
__attribute__((musttail)) \
97-
return (_TAIL_CALL_##name)(frame, stack_pointer, tstate, next_instr, oparg, entry_frame); \
98-
} while (0)
99-
#endif
10093
#elif USE_COMPUTED_GOTOS
10194
# define TARGET(op) TARGET_##op:
10295
# define DISPATCH_GOTO() goto *opcode_targets[opcode]
@@ -170,8 +163,8 @@ do { \
170163
CEVAL_GOTO(exit_unwind); \
171164
} \
172165
NEXTOPARG(); \
173-
__attribute__((musttail)) \
174-
return (INSTRUCTION_TABLE[opcode])(frame, stack_pointer, tstate, next_instr, oparg, entry_frame, lltrace); \
166+
Py_MUSTTAIL \
167+
return (INSTRUCTION_TABLE[opcode])(TAIL_CALL_ARGS); \
175168
} while (0)
176169
#else
177170
#define DISPATCH_INLINED(NEW_FRAME) \
@@ -187,8 +180,8 @@ do { \
187180
next_instr = frame->instr_ptr; \
188181
stack_pointer = _PyFrame_GetStackPointer(frame); \
189182
NEXTOPARG(); \
190-
__attribute__((musttail)) \
191-
return (INSTRUCTION_TABLE[opcode])(frame, stack_pointer, tstate, next_instr, oparg, entry_frame); \
183+
Py_MUSTTAIL \
184+
return (INSTRUCTION_TABLE[opcode])(TAIL_CALL_ARGS); \
192185
} while (0)
193186
#endif
194187
#else
@@ -333,12 +326,12 @@ GETITEM(PyObject *v, Py_ssize_t i) {
333326
#ifdef Py_TAIL_CALL_INTERP
334327
#ifdef LLTRACE
335328
#define GO_TO_INSTRUCTION(op) do { \
336-
__attribute__((musttail)) \
329+
Py_MUSTTAIL \
337330
return (INSTRUCTION_TABLE[op])(frame, stack_pointer, tstate, next_instr - 1 - _PyOpcode_Caches[_PyOpcode_Deopt[op]], oparg, entry_frame, lltrace); \
338331
} while (0)
339332
#else
340333
#define GO_TO_INSTRUCTION(op) do { \
341-
__attribute__((musttail)) \
334+
Py_MUSTTAIL \
342335
return (INSTRUCTION_TABLE[op])(frame, stack_pointer, tstate, next_instr - 1 - _PyOpcode_Caches[_PyOpcode_Deopt[op]], oparg, entry_frame); \
343336
} while (0)
344337
#endif

0 commit comments

Comments
 (0)