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

Skip to content

Commit ae9140f

Browse files
authored
gh-119676: remove several pseudo instructions which are use only in codegen (#119677)
1 parent 6b240c2 commit ae9140f

File tree

5 files changed

+23
-71
lines changed

5 files changed

+23
-71
lines changed

Include/internal/pycore_opcode_metadata.h

Lines changed: 8 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/opcode_ids.h

Lines changed: 5 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/_opcode_metadata.py

Lines changed: 5 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/bytecodes.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,18 +1812,6 @@ dummy_func(
18121812

18131813
macro(LOAD_SUPER_ATTR) = _SPECIALIZE_LOAD_SUPER_ATTR + _LOAD_SUPER_ATTR;
18141814

1815-
pseudo(LOAD_SUPER_METHOD) = {
1816-
LOAD_SUPER_ATTR,
1817-
};
1818-
1819-
pseudo(LOAD_ZERO_SUPER_METHOD) = {
1820-
LOAD_SUPER_ATTR,
1821-
};
1822-
1823-
pseudo(LOAD_ZERO_SUPER_ATTR) = {
1824-
LOAD_SUPER_ATTR,
1825-
};
1826-
18271815
inst(LOAD_SUPER_ATTR_ATTR, (unused/1, global_super, class, self -- attr, unused if (0))) {
18281816
assert(!(oparg & 1));
18291817
DEOPT_IF(global_super != (PyObject *)&PySuper_Type);
@@ -1925,10 +1913,6 @@ dummy_func(
19251913
unused/8 +
19261914
_LOAD_ATTR;
19271915

1928-
pseudo(LOAD_METHOD) = {
1929-
LOAD_ATTR,
1930-
};
1931-
19321916
op(_GUARD_TYPE_VERSION, (type_version/2, owner -- owner)) {
19331917
PyTypeObject *tp = Py_TYPE(owner);
19341918
assert(type_version != 0);

Python/compile.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -723,9 +723,6 @@ stack_effect(int opcode, int oparg, int jump)
723723
case JUMP_NO_INTERRUPT:
724724
return 0;
725725

726-
case EXIT_INIT_CHECK:
727-
return -1;
728-
729726
/* Exception handling pseudo-instructions */
730727
case SETUP_FINALLY:
731728
/* 0 in the normal flow.
@@ -746,12 +743,6 @@ stack_effect(int opcode, int oparg, int jump)
746743
return -1;
747744
case LOAD_CLOSURE:
748745
return 1;
749-
case LOAD_METHOD:
750-
return 1;
751-
case LOAD_SUPER_METHOD:
752-
case LOAD_ZERO_SUPER_METHOD:
753-
case LOAD_ZERO_SUPER_ATTR:
754-
return -1;
755746
default:
756747
return PY_INVALID_STACK_EFFECT;
757748
}
@@ -997,6 +988,11 @@ compiler_addop_o(struct compiler_unit *u, location loc,
997988
return codegen_addop_i(u->u_instr_sequence, opcode, arg, loc);
998989
}
999990

991+
#define LOAD_METHOD -1
992+
#define LOAD_SUPER_METHOD -2
993+
#define LOAD_ZERO_SUPER_ATTR -3
994+
#define LOAD_ZERO_SUPER_METHOD -4
995+
1000996
static int
1001997
compiler_addop_name(struct compiler_unit *u, location loc,
1002998
int opcode, PyObject *dict, PyObject *o)
@@ -1014,7 +1010,6 @@ compiler_addop_name(struct compiler_unit *u, location loc,
10141010
arg <<= 1;
10151011
}
10161012
if (opcode == LOAD_METHOD) {
1017-
assert(is_pseudo_target(LOAD_METHOD, LOAD_ATTR));
10181013
opcode = LOAD_ATTR;
10191014
arg <<= 1;
10201015
arg |= 1;
@@ -1024,18 +1019,15 @@ compiler_addop_name(struct compiler_unit *u, location loc,
10241019
arg |= 2;
10251020
}
10261021
if (opcode == LOAD_SUPER_METHOD) {
1027-
assert(is_pseudo_target(LOAD_SUPER_METHOD, LOAD_SUPER_ATTR));
10281022
opcode = LOAD_SUPER_ATTR;
10291023
arg <<= 2;
10301024
arg |= 3;
10311025
}
10321026
if (opcode == LOAD_ZERO_SUPER_ATTR) {
1033-
assert(is_pseudo_target(LOAD_ZERO_SUPER_ATTR, LOAD_SUPER_ATTR));
10341027
opcode = LOAD_SUPER_ATTR;
10351028
arg <<= 2;
10361029
}
10371030
if (opcode == LOAD_ZERO_SUPER_METHOD) {
1038-
assert(is_pseudo_target(LOAD_ZERO_SUPER_METHOD, LOAD_SUPER_ATTR));
10391031
opcode = LOAD_SUPER_ATTR;
10401032
arg <<= 2;
10411033
arg |= 1;

0 commit comments

Comments
 (0)