Skip to content

Commit

Permalink
pythongh-119676: remove several pseudo instructions which are use onl…
Browse files Browse the repository at this point in the history
…y in codegen
  • Loading branch information
iritkatriel committed May 28, 2024
1 parent f912e5a commit 370779d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 68 deletions.
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
15 changes: 5 additions & 10 deletions Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -746,12 +746,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 +991,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 +1013,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 +1022,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

0 comments on commit 370779d

Please sign in to comment.