Skip to content

Commit

Permalink
work with GCC -O3
Browse files Browse the repository at this point in the history
  • Loading branch information
Fidget-Spinner committed Jan 12, 2025
1 parent d26ef11 commit 851dc7a
Show file tree
Hide file tree
Showing 6 changed files with 10,881 additions and 7,006 deletions.
1 change: 1 addition & 0 deletions Include/Python.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "pyconfig.h"
#include "pymacconfig.h"

#define Py_TAIL_CALL_INTERP 1

// Include standard header files
#include <assert.h> // assert()
Expand Down
24 changes: 12 additions & 12 deletions Python/ceval_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@
#endif

#ifdef Py_TAIL_CALL_INTERP
# define Py_MUSTTAIL __attribute__((musttail))
# define Py_PRESERVE_NONE_CC __attribute__((preserve_none))
# define Py_MUSTTAIL [[clang::musttail]]
# define Py_PRESERVE_NONE_CC
Py_PRESERVE_NONE_CC
typedef PyObject* (*py_tail_call_funcptr)(TAIL_CALL_PARAMS);
# define DISPATCH_GOTO() do { \
Expand Down Expand Up @@ -328,18 +328,12 @@ GETITEM(PyObject *v, Py_ssize_t i) {
GETLOCAL(i) = value; \
PyStackRef_XCLOSE(tmp); } while (0)
#ifdef Py_TAIL_CALL_INTERP
#ifdef LLTRACE
#define GO_TO_INSTRUCTION(op) do { \
Py_MUSTTAIL \
return (INSTRUCTION_TABLE[op])(frame, stack_pointer, tstate, next_instr - 1 - _PyOpcode_Caches[_PyOpcode_Deopt[op]], opcode, oparg, lltrace); \
next_instr = next_instr - 1 - _PyOpcode_Caches[_PyOpcode_Deopt[op]]; \
Py_MUSTTAIL \
return (INSTRUCTION_TABLE[op])(TAIL_CALL_ARGS); \
} while (0)
#else
#define GO_TO_INSTRUCTION(op) do { \
Py_MUSTTAIL \
return (INSTRUCTION_TABLE[op])(frame, stack_pointer, tstate, next_instr - 1 - _PyOpcode_Caches[_PyOpcode_Deopt[op]], opcode, oparg); \
} while (0)
#endif
#else
#define GO_TO_INSTRUCTION(op) goto PREDICT_ID(op)
#endif

Expand All @@ -357,14 +351,20 @@ GETITEM(PyObject *v, Py_ssize_t i) {
#define UPDATE_MISS_STATS(INSTNAME) ((void)0)
#endif

#ifdef Py_TAIL_CALL_INTERP
#define DEOPT_IF(COND, INSTNAME) \
if ((COND)) { \
goto INSTNAME##_deopt; \
}
#else
#define DEOPT_IF(COND, INSTNAME) \
if ((COND)) { \
/* This is only a single jump on release builds! */ \
UPDATE_MISS_STATS((INSTNAME)); \
assert(_PyOpcode_Deopt[opcode] == (INSTNAME)); \
GO_TO_INSTRUCTION(INSTNAME); \
}

#endif

// Try to lock an object in the free threading build, if it's not already
// locked. Use with a DEOPT_IF() to deopt if the object is already locked.
Expand Down
Loading

0 comments on commit 851dc7a

Please sign in to comment.