summaryrefslogtreecommitdiffstats
path: root/Python/optimizer_bytecodes.c
diff options
context:
space:
mode:
authorKen Jin <kenjin@python.org>2025-09-03 18:05:06 (GMT)
committerGitHub <noreply@github.com>2025-09-03 18:05:06 (GMT)
commit2402f84665df41732c94db2ccd6f90dd13479fa8 (patch)
tree3d4c8a6dd243c18a5a5b287021681669f8cbdb98 /Python/optimizer_bytecodes.c
parent0d1f4e163990cb7e08b21d1fd88ff54bac5b0699 (diff)
downloadcpython-2402f84665df41732c94db2ccd6f90dd13479fa8.zip
cpython-2402f84665df41732c94db2ccd6f90dd13479fa8.tar.gz
cpython-2402f84665df41732c94db2ccd6f90dd13479fa8.tar.bz2
gh-138431: JIT Optimizer --- Fix round-tripping references for str and tuple (GH-138458)
Co-authored-by: Mark Shannon <9448417+markshannon@users.noreply.github.com>
Diffstat (limited to 'Python/optimizer_bytecodes.c')
-rw-r--r--Python/optimizer_bytecodes.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/Python/optimizer_bytecodes.c b/Python/optimizer_bytecodes.c
index 781296d..eccbddf 100644
--- a/Python/optimizer_bytecodes.c
+++ b/Python/optimizer_bytecodes.c
@@ -762,9 +762,8 @@ dummy_func(void) {
}
op(_RETURN_VALUE, (retval -- res)) {
- // We wrap and unwrap the value to mimic PyStackRef_MakeHeapSafe
- // in bytecodes.c
- JitOptRef temp = PyJitRef_Wrap(PyJitRef_Unwrap(retval));
+ // Mimics PyStackRef_MakeHeapSafe in the interpreter.
+ JitOptRef temp = PyJitRef_StripReferenceInfo(retval);
DEAD(retval);
SAVE_STACK();
ctx->frame->stack_pointer = stack_pointer;
@@ -925,7 +924,9 @@ dummy_func(void) {
op(_CALL_STR_1, (unused, unused, arg -- res)) {
if (sym_matches_type(arg, &PyUnicode_Type)) {
// e.g. str('foo') or str(foo) where foo is known to be a string
- res = arg;
+ // Note: we must strip the reference information because it goes
+ // through str() which strips the reference information from it.
+ res = PyJitRef_StripReferenceInfo(arg);
}
else {
res = sym_new_type(ctx, &PyUnicode_Type);
@@ -1065,7 +1066,9 @@ dummy_func(void) {
op(_CALL_TUPLE_1, (callable, null, arg -- res)) {
if (sym_matches_type(arg, &PyTuple_Type)) {
// e.g. tuple((1, 2)) or tuple(foo) where foo is known to be a tuple
- res = arg;
+ // Note: we must strip the reference information because it goes
+ // through tuple() which strips the reference information from it.
+ res = PyJitRef_StripReferenceInfo(arg);
}
else {
res = sym_new_type(ctx, &PyTuple_Type);