mirror of
https://github.com/python/cpython
synced 2026-09-29 10:50:29 +03:00
GH-113860: All executors are now defined in terms of micro ops. Convert counter executor to use uops. (GH-113864)
This commit is contained in:
parent
93930eaf0a
commit
a0c9cf9456
9 changed files with 125 additions and 139 deletions
|
|
@ -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);
|
||||
|
|
|
|||
2
Include/internal/pycore_opcode_metadata.h
generated
2
Include/internal/pycore_opcode_metadata.h
generated
|
|
@ -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 },
|
||||
|
|
|
|||
4
Include/internal/pycore_uop_ids.h
generated
4
Include/internal/pycore_uop_ids.h
generated
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -24,11 +24,6 @@ typedef struct {
|
|||
_PyUOpInstruction trace[1];
|
||||
} _PyUOpExecutorObject;
|
||||
|
||||
_Py_CODEUNIT *_PyUOpExecute(
|
||||
_PyExecutorObject *executor,
|
||||
_PyInterpreterFrame *frame,
|
||||
PyObject **stack_pointer);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue