gh-134584: JIT: Borrow references for immortal promoted globals (GH-142921)

JIT: Borrow references for immortal promoted globals
This commit is contained in:
Ken Jin 2025-12-20 03:06:34 +08:00 committed by GitHub
parent 6a4f10325d
commit 6b4bc6e6a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 62 additions and 4 deletions

View file

@ -1376,7 +1376,12 @@ dummy_func(void) {
res = sym_new_not_null(ctx);
}
else {
res = sym_new_const(ctx, cnst);
if (_Py_IsImmortal(cnst)) {
res = PyJitRef_Borrow(sym_new_const(ctx, cnst));
}
else {
res = sym_new_const(ctx, cnst);
}
}
}
@ -1411,7 +1416,12 @@ dummy_func(void) {
res = sym_new_not_null(ctx);
}
else {
res = sym_new_const(ctx, cnst);
if (_Py_IsImmortal(cnst)) {
res = PyJitRef_Borrow(sym_new_const(ctx, cnst));
}
else {
res = sym_new_const(ctx, cnst);
}
}
}

View file

@ -1330,7 +1330,12 @@
res = sym_new_not_null(ctx);
}
else {
res = sym_new_const(ctx, cnst);
if (_Py_IsImmortal(cnst)) {
res = PyJitRef_Borrow(sym_new_const(ctx, cnst));
}
else {
res = sym_new_const(ctx, cnst);
}
}
CHECK_STACK_BOUNDS(1);
stack_pointer[0] = res;
@ -1367,7 +1372,12 @@
res = sym_new_not_null(ctx);
}
else {
res = sym_new_const(ctx, cnst);
if (_Py_IsImmortal(cnst)) {
res = PyJitRef_Borrow(sym_new_const(ctx, cnst));
}
else {
res = sym_new_const(ctx, cnst);
}
}
CHECK_STACK_BOUNDS(1);
stack_pointer[0] = res;