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

@ -2,6 +2,7 @@
#include "pycore_long.h"
#include "pycore_opcode_utils.h"
#include "pycore_optimizer.h"
#include "pycore_stackref.h"
#include "pycore_typeobject.h"
#include "pycore_uops.h"
#include "pycore_uop_ids.h"
@ -870,15 +871,11 @@ dummy_func(void) {
op(_LOAD_COMMON_CONSTANT, (-- value)) {
assert(oparg < NUM_COMMON_CONSTANTS);
PyObject *val = _PyInterpreterState_GET()->common_consts[oparg];
if (_Py_IsImmortal(val)) {
ADD_OP(_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)val);
value = PyJitRef_Borrow(sym_new_const(ctx, val));
}
else {
ADD_OP(_LOAD_CONST_INLINE, 0, (uintptr_t)val);
value = sym_new_const(ctx, val);
}
PyObject *val = PyStackRef_AsPyObjectBorrow(
_PyInterpreterState_GET()->common_consts[oparg]);
assert(_Py_IsImmortal(val));
ADD_OP(_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)val);
value = PyJitRef_Borrow(sym_new_const(ctx, val));
}
op(_LOAD_SMALL_INT, (-- value)) {