diff options
author | Mark Shannon <mark@hotpy.org> | 2025-01-13 10:30:28 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-13 10:30:28 (GMT) |
commit | ddd959987c557beaf823b681bf5e5e573ad657ac (patch) | |
tree | e59574d3eb62f94e497f7aecd585bf656ebc984e /Python/optimizer_bytecodes.c | |
parent | 29fe8072cf404b891dde9c1d415095edddbe19de (diff) | |
download | cpython-ddd959987c557beaf823b681bf5e5e573ad657ac.zip cpython-ddd959987c557beaf823b681bf5e5e573ad657ac.tar.gz cpython-ddd959987c557beaf823b681bf5e5e573ad657ac.tar.bz2 |
GH-128685: Specialize (rather than quicken) LOAD_CONST into LOAD_CONST_[IM]MORTAL (GH-128708)
Diffstat (limited to 'Python/optimizer_bytecodes.c')
-rw-r--r-- | Python/optimizer_bytecodes.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Python/optimizer_bytecodes.c b/Python/optimizer_bytecodes.c index 8639448..788adec 100644 --- a/Python/optimizer_bytecodes.c +++ b/Python/optimizer_bytecodes.c @@ -479,6 +479,13 @@ dummy_func(void) { value = sym_new_const(ctx, val); } + op(_LOAD_CONST_MORTAL, (-- value)) { + PyObject *val = PyTuple_GET_ITEM(co->co_consts, this_instr->oparg); + int opcode = _Py_IsImmortal(val) ? _LOAD_CONST_INLINE_BORROW : _LOAD_CONST_INLINE; + REPLACE_OP(this_instr, opcode, 0, (uintptr_t)val); + value = sym_new_const(ctx, val); + } + op(_LOAD_CONST_IMMORTAL, (-- value)) { PyObject *val = PyTuple_GET_ITEM(co->co_consts, this_instr->oparg); REPLACE_OP(this_instr, _LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)val); |