Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-119676: remove several pseudo instructions which are use only in codegen #119677

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 8 additions & 24 deletions Include/internal/pycore_opcode_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 5 additions & 9 deletions Include/opcode_ids.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 5 additions & 9 deletions Lib/_opcode_metadata.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 0 additions & 16 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1812,18 +1812,6 @@ dummy_func(

macro(LOAD_SUPER_ATTR) = _SPECIALIZE_LOAD_SUPER_ATTR + _LOAD_SUPER_ATTR;

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 -- attr, unused if (0))) {
assert(!(oparg & 1));
DEOPT_IF(global_super != (PyObject *)&PySuper_Type);
Expand Down Expand Up @@ -1925,10 +1913,6 @@ dummy_func(
unused/8 +
_LOAD_ATTR;

pseudo(LOAD_METHOD) = {
LOAD_ATTR,
};

op(_GUARD_TYPE_VERSION, (type_version/2, owner -- owner)) {
PyTypeObject *tp = Py_TYPE(owner);
assert(type_version != 0);
Expand Down
18 changes: 5 additions & 13 deletions Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,9 +723,6 @@ stack_effect(int opcode, int oparg, int jump)
case JUMP_NO_INTERRUPT:
return 0;

case EXIT_INIT_CHECK:
return -1;

/* Exception handling pseudo-instructions */
case SETUP_FINALLY:
/* 0 in the normal flow.
Expand All @@ -746,12 +743,6 @@ stack_effect(int opcode, int oparg, int jump)
return -1;
case LOAD_CLOSURE:
return 1;
case LOAD_METHOD:
return 1;
case LOAD_SUPER_METHOD:
case LOAD_ZERO_SUPER_METHOD:
case LOAD_ZERO_SUPER_ATTR:
return -1;
default:
return PY_INVALID_STACK_EFFECT;
}
Expand Down Expand Up @@ -997,6 +988,11 @@ compiler_addop_o(struct compiler_unit *u, location loc,
return codegen_addop_i(u->u_instr_sequence, opcode, arg, loc);
}

#define LOAD_METHOD -1
#define LOAD_SUPER_METHOD -2
#define LOAD_ZERO_SUPER_ATTR -3
#define LOAD_ZERO_SUPER_METHOD -4

static int
compiler_addop_name(struct compiler_unit *u, location loc,
int opcode, PyObject *dict, PyObject *o)
Expand All @@ -1014,7 +1010,6 @@ compiler_addop_name(struct compiler_unit *u, location loc,
arg <<= 1;
}
if (opcode == LOAD_METHOD) {
assert(is_pseudo_target(LOAD_METHOD, LOAD_ATTR));
opcode = LOAD_ATTR;
arg <<= 1;
arg |= 1;
Expand All @@ -1024,18 +1019,15 @@ compiler_addop_name(struct compiler_unit *u, location loc,
arg |= 2;
}
if (opcode == LOAD_SUPER_METHOD) {
assert(is_pseudo_target(LOAD_SUPER_METHOD, LOAD_SUPER_ATTR));
opcode = LOAD_SUPER_ATTR;
arg <<= 2;
arg |= 3;
}
if (opcode == LOAD_ZERO_SUPER_ATTR) {
assert(is_pseudo_target(LOAD_ZERO_SUPER_ATTR, LOAD_SUPER_ATTR));
opcode = LOAD_SUPER_ATTR;
arg <<= 2;
}
if (opcode == LOAD_ZERO_SUPER_METHOD) {
assert(is_pseudo_target(LOAD_ZERO_SUPER_METHOD, LOAD_SUPER_ATTR));
opcode = LOAD_SUPER_ATTR;
arg <<= 2;
arg |= 1;
Expand Down
Loading