summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2024-01-10 15:44:34 (GMT)
committerGitHub <noreply@github.com>2024-01-10 15:44:34 (GMT)
commita0c9cf9456c2ee7a89d9bd859c07afac8cf5e893 (patch)
treed89d0bcbd8850e29b68a262c9427c6e5288d65f7 /Include
parent93930eaf0acd64dc0d08d58321d2682cb019bc1a (diff)
downloadcpython-a0c9cf9456c2ee7a89d9bd859c07afac8cf5e893.zip
cpython-a0c9cf9456c2ee7a89d9bd859c07afac8cf5e893.tar.gz
cpython-a0c9cf9456c2ee7a89d9bd859c07afac8cf5e893.tar.bz2
GH-113860: All executors are now defined in terms of micro ops. Convert counter executor to use uops. (GH-113864)
Diffstat (limited to 'Include')
-rw-r--r--Include/cpython/optimizer.h8
-rw-r--r--Include/internal/pycore_opcode_metadata.h2
-rw-r--r--Include/internal/pycore_uop_ids.h4
-rw-r--r--Include/internal/pycore_uop_metadata.h4
-rw-r--r--Include/internal/pycore_uops.h5
5 files changed, 14 insertions, 9 deletions
diff --git a/Include/cpython/optimizer.h b/Include/cpython/optimizer.h
index d521eac..f077da7 100644
--- a/Include/cpython/optimizer.h
+++ b/Include/cpython/optimizer.h
@@ -31,8 +31,6 @@ typedef struct {
typedef struct _PyExecutorObject {
PyObject_VAR_HEAD
- /* WARNING: execute consumes a reference to self. This is necessary to allow executors to tail call into each other. */
- _Py_CODEUNIT *(*execute)(struct _PyExecutorObject *self, struct _PyInterpreterFrame *frame, PyObject **stack_pointer);
_PyVMData vm_data; /* Used by the VM, but opaque to the optimizer */
/* Data needed by the executor goes here, but is opaque to the VM */
} _PyExecutorObject;
@@ -52,6 +50,12 @@ typedef struct _PyOptimizerObject {
/* Data needed by the optimizer goes here, but is opaque to the VM */
} _PyOptimizerObject;
+/** Test support **/
+typedef struct {
+ _PyOptimizerObject base;
+ int64_t count;
+} _PyCounterOptimizerObject;
+
PyAPI_FUNC(int) PyUnstable_Replace_Executor(PyCodeObject *code, _Py_CODEUNIT *instr, _PyExecutorObject *executor);
PyAPI_FUNC(void) PyUnstable_SetOptimizer(_PyOptimizerObject* optimizer);
diff --git a/Include/internal/pycore_opcode_metadata.h b/Include/internal/pycore_opcode_metadata.h
index 7d39e4b..a9d698d 100644
--- a/Include/internal/pycore_opcode_metadata.h
+++ b/Include/internal/pycore_opcode_metadata.h
@@ -1009,7 +1009,7 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[268] = {
[END_ASYNC_FOR] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG },
[END_FOR] = { true, INSTR_FMT_IX, 0 },
[END_SEND] = { true, INSTR_FMT_IX, 0 },
- [ENTER_EXECUTOR] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG },
+ [ENTER_EXECUTOR] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG },
[EXIT_INIT_CHECK] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG },
[EXTENDED_ARG] = { true, INSTR_FMT_IB, HAS_ARG_FLAG },
[FORMAT_SIMPLE] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG | HAS_ESCAPES_FLAG },
diff --git a/Include/internal/pycore_uop_ids.h b/Include/internal/pycore_uop_ids.h
index 4a9a00b..b3b3632 100644
--- a/Include/internal/pycore_uop_ids.h
+++ b/Include/internal/pycore_uop_ids.h
@@ -231,7 +231,9 @@ extern "C" {
#define _SAVE_RETURN_OFFSET 378
#define _INSERT 379
#define _CHECK_VALIDITY 380
-#define MAX_UOP_ID 380
+#define _LOAD_CONST_INLINE_BORROW 381
+#define _INTERNAL_INCREMENT_OPT_COUNTER 382
+#define MAX_UOP_ID 382
#ifdef __cplusplus
}
diff --git a/Include/internal/pycore_uop_metadata.h b/Include/internal/pycore_uop_metadata.h
index 300bd3b..ab498e9 100644
--- a/Include/internal/pycore_uop_metadata.h
+++ b/Include/internal/pycore_uop_metadata.h
@@ -203,6 +203,8 @@ const uint16_t _PyUop_Flags[MAX_UOP_ID+1] = {
[_EXIT_TRACE] = HAS_DEOPT_FLAG,
[_INSERT] = HAS_ARG_FLAG,
[_CHECK_VALIDITY] = HAS_DEOPT_FLAG,
+ [_LOAD_CONST_INLINE_BORROW] = 0,
+ [_INTERNAL_INCREMENT_OPT_COUNTER] = 0,
};
const char *const _PyOpcode_uop_name[MAX_UOP_ID+1] = {
@@ -303,6 +305,7 @@ const char *const _PyOpcode_uop_name[MAX_UOP_ID+1] = {
[_INIT_CALL_BOUND_METHOD_EXACT_ARGS] = "_INIT_CALL_BOUND_METHOD_EXACT_ARGS",
[_INIT_CALL_PY_EXACT_ARGS] = "_INIT_CALL_PY_EXACT_ARGS",
[_INSERT] = "_INSERT",
+ [_INTERNAL_INCREMENT_OPT_COUNTER] = "_INTERNAL_INCREMENT_OPT_COUNTER",
[_IS_NONE] = "_IS_NONE",
[_IS_OP] = "_IS_OP",
[_ITER_CHECK_LIST] = "_ITER_CHECK_LIST",
@@ -328,6 +331,7 @@ const char *const _PyOpcode_uop_name[MAX_UOP_ID+1] = {
[_LOAD_ATTR_WITH_HINT] = "_LOAD_ATTR_WITH_HINT",
[_LOAD_BUILD_CLASS] = "_LOAD_BUILD_CLASS",
[_LOAD_CONST] = "_LOAD_CONST",
+ [_LOAD_CONST_INLINE_BORROW] = "_LOAD_CONST_INLINE_BORROW",
[_LOAD_DEREF] = "_LOAD_DEREF",
[_LOAD_FAST] = "_LOAD_FAST",
[_LOAD_FAST_AND_CLEAR] = "_LOAD_FAST_AND_CLEAR",
diff --git a/Include/internal/pycore_uops.h b/Include/internal/pycore_uops.h
index 153884f..eb10002 100644
--- a/Include/internal/pycore_uops.h
+++ b/Include/internal/pycore_uops.h
@@ -24,11 +24,6 @@ typedef struct {
_PyUOpInstruction trace[1];
} _PyUOpExecutorObject;
-_Py_CODEUNIT *_PyUOpExecute(
- _PyExecutorObject *executor,
- _PyInterpreterFrame *frame,
- PyObject **stack_pointer);
-
#ifdef __cplusplus
}
#endif