diff options
author | Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com> | 2022-02-24 14:55:59 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-24 14:55:59 (GMT) |
commit | a52d2528a405c1e2bfeb6470cb3313a5338dc45f (patch) | |
tree | c7a8d9c23869de114ba3c5f09a7582e1185b30c4 /Python/specialize.c | |
parent | 4fccf910738d1442852cb900747e6dccb8fe03ef (diff) | |
download | cpython-a52d2528a405c1e2bfeb6470cb3313a5338dc45f.zip cpython-a52d2528a405c1e2bfeb6470cb3313a5338dc45f.tar.gz cpython-a52d2528a405c1e2bfeb6470cb3313a5338dc45f.tar.bz2 |
bpo-46823: Implement LOAD_FAST__LOAD_ATTR_INSTANCE_VALUE superinstruction (GH-31484)
Diffstat (limited to 'Python/specialize.c')
-rw-r--r-- | Python/specialize.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Python/specialize.c b/Python/specialize.c index 816cca1..1641766 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -889,6 +889,16 @@ _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name, Sp return -1; } if (err) { + if (_Py_OPCODE(instr[0]) == LOAD_ATTR_INSTANCE_VALUE) { + // Note: instr[-1] exists because there's something on the stack, + // and instr[-2] exists because there's at least a RESUME as well. + if (_Py_OPCODE(instr[-1]) == LOAD_FAST) { + instr[-1] = _Py_MAKECODEUNIT(LOAD_FAST__LOAD_ATTR_INSTANCE_VALUE, _Py_OPARG(instr[-1])); + if (_Py_OPCODE(instr[-2]) == LOAD_FAST__LOAD_FAST) { + instr[-2] = _Py_MAKECODEUNIT(LOAD_FAST, _Py_OPARG(instr[-2])); + } + } + } goto success; } fail: |