diff options
author | Victor Stinner <vstinner@python.org> | 2024-06-26 11:54:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-26 11:54:03 (GMT) |
commit | 9e4a81f00fef689c6e18a64245aa064eaadc7ac7 (patch) | |
tree | a0e7efaf59d8bb90911830b230909659b1176904 /Include/cpython/code.h | |
parent | 9e45fd9858a059950f7387b4fda2b00df0e8e537 (diff) | |
download | cpython-9e4a81f00fef689c6e18a64245aa064eaadc7ac7.zip cpython-9e4a81f00fef689c6e18a64245aa064eaadc7ac7.tar.gz cpython-9e4a81f00fef689c6e18a64245aa064eaadc7ac7.tar.bz2 |
gh-120642: Move private PyCode APIs to the internal C API (#120643)
* Move _Py_CODEUNIT and related functions to pycore_code.h.
* Move _Py_BackoffCounter to pycore_backoff.h.
* Move Include/cpython/optimizer.h content to pycore_optimizer.h.
* Remove Include/cpython/optimizer.h.
* Remove PyUnstable_Replace_Executor().
Rename functions:
* PyUnstable_GetExecutor() => _Py_GetExecutor()
* PyUnstable_GetOptimizer() => _Py_GetOptimizer()
* PyUnstable_SetOptimizer() => _Py_SetTier2Optimizer()
* PyUnstable_Optimizer_NewCounter() => _PyOptimizer_NewCounter()
* PyUnstable_Optimizer_NewUOpOptimizer() => _PyOptimizer_NewUOpOptimizer()
Diffstat (limited to 'Include/cpython/code.h')
-rw-r--r-- | Include/cpython/code.h | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/Include/cpython/code.h b/Include/cpython/code.h index ef8f930..07ed520 100644 --- a/Include/cpython/code.h +++ b/Include/cpython/code.h @@ -24,58 +24,6 @@ typedef struct _Py_GlobalMonitors { uint8_t tools[_PY_MONITORING_UNGROUPED_EVENTS]; } _Py_GlobalMonitors; -typedef struct { - union { - struct { - uint16_t backoff : 4; - uint16_t value : 12; - }; - uint16_t as_counter; // For printf("%#x", ...) - }; -} _Py_BackoffCounter; - -/* Each instruction in a code object is a fixed-width value, - * currently 2 bytes: 1-byte opcode + 1-byte oparg. The EXTENDED_ARG - * opcode allows for larger values but the current limit is 3 uses - * of EXTENDED_ARG (see Python/compile.c), for a maximum - * 32-bit value. This aligns with the note in Python/compile.c - * (compiler_addop_i_line) indicating that the max oparg value is - * 2**32 - 1, rather than INT_MAX. - */ - -typedef union { - uint16_t cache; - struct { - uint8_t code; - uint8_t arg; - } op; - _Py_BackoffCounter counter; // First cache entry of specializable op -} _Py_CODEUNIT; - - -/* These macros only remain defined for compatibility. */ -#define _Py_OPCODE(word) ((word).op.code) -#define _Py_OPARG(word) ((word).op.arg) - -static inline _Py_CODEUNIT -_py_make_codeunit(uint8_t opcode, uint8_t oparg) -{ - // No designated initialisers because of C++ compat - _Py_CODEUNIT word; - word.op.code = opcode; - word.op.arg = oparg; - return word; -} - -static inline void -_py_set_opcode(_Py_CODEUNIT *word, uint8_t opcode) -{ - word->op.code = opcode; -} - -#define _Py_MAKE_CODEUNIT(opcode, oparg) _py_make_codeunit((opcode), (oparg)) -#define _Py_SET_OPCODE(word, opcode) _py_set_opcode(&(word), (opcode)) - typedef struct { PyObject *_co_code; |