diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2023-06-11 22:31:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-11 22:31:59 +0100 |
commit | 58f5227d7cdff803609a0bda6882997b3a5ec4bf (patch) | |
tree | 59cedf6d505015a2876a13da499894bcb8969f93 /Python/bytecodes.c | |
parent | 20a56d8becba1a5a958b167fdb43b1a1b9228095 (diff) | |
download | cpython-58f5227d7cdff803609a0bda6882997b3a5ec4bf.tar.gz cpython-58f5227d7cdff803609a0bda6882997b3a5ec4bf.zip |
gh-105481: add pseudo-instructions to the bytecodes DSL (#105506)
Diffstat (limited to 'Python/bytecodes.c')
-rw-r--r-- | Python/bytecodes.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c index e7f7c1a96f8..f0b2dc7976c 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -50,6 +50,7 @@ #define macro(name) static int MACRO_##name #define super(name) static int SUPER_##name #define family(name, ...) static int family_##name +#define pseudo(name) static int pseudo_##name // Dummy variables for stack effects. static PyObject *value, *value1, *value2, *left, *right, *res, *sum, *prod, *sub; @@ -218,6 +219,10 @@ dummy_func( SETLOCAL(oparg, value); } + pseudo(STORE_FAST_MAYBE_NULL) = { + STORE_FAST, + }; + inst(STORE_FAST_LOAD_FAST, (value1 -- value2)) { uint32_t oparg1 = oparg >> 4; uint32_t oparg2 = oparg & 15; @@ -1674,6 +1679,18 @@ dummy_func( ERROR_IF(res == NULL, error); } + pseudo(LOAD_SUPER_METHOD) = { + LOAD_SUPER_ATTR, + }; + + pseudo(LOAD_ZERO_SUPER_METHOD) = { + LOAD_SUPER_ATTR, + }; + + pseudo(LOAD_ZERO_SUPER_ATTR) = { + LOAD_SUPER_ATTR, + }; + inst(LOAD_SUPER_ATTR_ATTR, (unused/1, global_super, class, self -- res2 if (oparg & 1), res)) { assert(!(oparg & 1)); DEOPT_IF(global_super != (PyObject *)&PySuper_Type, LOAD_SUPER_ATTR); @@ -1772,6 +1789,10 @@ dummy_func( } } + pseudo(LOAD_METHOD) = { + LOAD_ATTR, + }; + inst(LOAD_ATTR_INSTANCE_VALUE, (unused/1, type_version/2, index/1, unused/5, owner -- res2 if (oparg & 1), res)) { PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); @@ -2142,6 +2163,16 @@ dummy_func( CHECK_EVAL_BREAKER(); } + pseudo(JUMP) = { + JUMP_FORWARD, + JUMP_BACKWARD, + }; + + pseudo(JUMP_NO_INTERRUPT) = { + JUMP_FORWARD, + JUMP_BACKWARD_NO_INTERRUPT, + }; + inst(ENTER_EXECUTOR, (--)) { _PyExecutorObject *executor = (_PyExecutorObject *)frame->f_code->co_executors->executors[oparg]; Py_INCREF(executor); @@ -2530,6 +2561,22 @@ dummy_func( ERROR_IF(res == NULL, error); } + pseudo(SETUP_FINALLY) = { + NOP, + }; + + pseudo(SETUP_CLEANUP) = { + NOP, + }; + + pseudo(SETUP_WITH) = { + NOP, + }; + + pseudo(POP_BLOCK) = { + NOP, + }; + inst(PUSH_EXC_INFO, (new_exc -- prev_exc, new_exc)) { _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { |