gh-148871: make LOAD_COMMON_CONSTANT use immortal stackref borrows (GH-149625)

This commit is contained in:
Neko Asakura 2026-05-28 19:27:37 +08:00 committed by GitHub
parent 2531cd337b
commit 39bd44fc70
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 96 additions and 43 deletions

View file

@ -9396,7 +9396,7 @@
_PyStackRef value;
oparg = CURRENT_OPARG();
assert(oparg < NUM_COMMON_CONSTANTS);
value = PyStackRef_FromPyObjectNew(tstate->interp->common_consts[oparg]);
value = PyStackRef_DupImmortal(tstate->interp->common_consts[oparg]);
_tos_cache0 = value;
SET_CURRENT_CACHED_VALUES(1);
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
@ -9410,7 +9410,7 @@
_PyStackRef _stack_item_0 = _tos_cache0;
oparg = CURRENT_OPARG();
assert(oparg < NUM_COMMON_CONSTANTS);
value = PyStackRef_FromPyObjectNew(tstate->interp->common_consts[oparg]);
value = PyStackRef_DupImmortal(tstate->interp->common_consts[oparg]);
_tos_cache1 = value;
_tos_cache0 = _stack_item_0;
SET_CURRENT_CACHED_VALUES(2);
@ -9426,7 +9426,7 @@
_PyStackRef _stack_item_1 = _tos_cache1;
oparg = CURRENT_OPARG();
assert(oparg < NUM_COMMON_CONSTANTS);
value = PyStackRef_FromPyObjectNew(tstate->interp->common_consts[oparg]);
value = PyStackRef_DupImmortal(tstate->interp->common_consts[oparg]);
_tos_cache2 = value;
_tos_cache1 = _stack_item_1;
_tos_cache0 = _stack_item_0;