summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/Include/cpython/code.h
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/tools/python3/Include/cpython/code.h')
-rw-r--r--contrib/tools/python3/Include/cpython/code.h73
1 files changed, 21 insertions, 52 deletions
diff --git a/contrib/tools/python3/Include/cpython/code.h b/contrib/tools/python3/Include/cpython/code.h
index 81741c547b7..bd8afab8f93 100644
--- a/contrib/tools/python3/Include/cpython/code.h
+++ b/contrib/tools/python3/Include/cpython/code.h
@@ -16,57 +16,14 @@ extern "C" {
#define _PY_MONITORING_EVENTS 17
/* Tables of which tools are active for each monitored event. */
-/* For 3.12 ABI compatibility this is over sized */
typedef struct _Py_LocalMonitors {
- /* Only _PY_MONITORING_LOCAL_EVENTS of these are used */
- uint8_t tools[_PY_MONITORING_UNGROUPED_EVENTS];
+ uint8_t tools[_PY_MONITORING_LOCAL_EVENTS];
} _Py_LocalMonitors;
typedef struct _Py_GlobalMonitors {
uint8_t tools[_PY_MONITORING_UNGROUPED_EVENTS];
} _Py_GlobalMonitors;
-/* 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_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;
@@ -76,13 +33,21 @@ typedef struct {
} _PyCoCached;
/* Ancillary data structure used for instrumentation.
- Line instrumentation creates an array of
- these. One entry per code unit.*/
+ Line instrumentation creates this with sufficient
+ space for one entry per code unit. The total size
+ of the data will be `bytes_per_entry * Py_SIZE(code)` */
typedef struct {
- uint8_t original_opcode;
- int8_t line_delta;
+ uint8_t bytes_per_entry;
+ uint8_t data[1];
} _PyCoLineInstrumentationData;
+
+typedef struct {
+ int size;
+ int capacity;
+ struct _PyExecutorObject *executors[1];
+} _PyExecutorArray;
+
/* Main data structure used for instrumentation.
* This is allocated when needed for instrumentation
*/
@@ -160,8 +125,9 @@ typedef struct {
PyObject *co_qualname; /* unicode (qualname, for reference) */ \
PyObject *co_linetable; /* bytes object that holds location info */ \
PyObject *co_weakreflist; /* to support weakrefs to code objects */ \
+ _PyExecutorArray *co_executors; /* executors from optimizer */ \
_PyCoCached *_co_cached; /* cached co_* attributes */ \
- uint64_t _co_instrumentation_version; /* current instrumentation version */ \
+ uintptr_t _co_instrumentation_version; /* current instrumentation version */ \
_PyCoMonitoringData *_co_monitoring; /* Monitoring data */ \
int _co_firsttraceable; /* index of first traceable instruction */ \
/* Scratch space for extra data relating to the code object. \
@@ -202,6 +168,8 @@ struct PyCodeObject _PyCode_DEF(1);
#define CO_FUTURE_GENERATOR_STOP 0x800000
#define CO_FUTURE_ANNOTATIONS 0x1000000
+#define CO_NO_MONITORING_EVENTS 0x2000000
+
/* This should be defined if a future statement modifies the syntax.
For example, when a keyword is added.
*/
@@ -218,13 +186,14 @@ static inline Py_ssize_t PyCode_GetNumFree(PyCodeObject *op) {
return op->co_nfreevars;
}
-static inline int PyCode_GetFirstFree(PyCodeObject *op) {
+static inline int PyUnstable_Code_GetFirstFree(PyCodeObject *op) {
assert(PyCode_Check(op));
return op->co_nlocalsplus - op->co_nfreevars;
}
-#define _PyCode_CODE(CO) _Py_RVALUE((_Py_CODEUNIT *)(CO)->co_code_adaptive)
-#define _PyCode_NBYTES(CO) (Py_SIZE(CO) * (Py_ssize_t)sizeof(_Py_CODEUNIT))
+Py_DEPRECATED(3.13) static inline int PyCode_GetFirstFree(PyCodeObject *op) {
+ return PyUnstable_Code_GetFirstFree(op);
+}
/* Unstable public interface */
PyAPI_FUNC(PyCodeObject *) PyUnstable_Code_New(