@@ -762,9 +762,8 @@ dummy_func(void) {
762762 }
763763
764764 op (_RETURN_VALUE , (retval -- res )) {
765- // We wrap and unwrap the value to mimic PyStackRef_MakeHeapSafe
766- // in bytecodes.c
767- JitOptRef temp = PyJitRef_Wrap (PyJitRef_Unwrap (retval ));
765+ // Mimics PyStackRef_MakeHeapSafe in the interpreter.
766+ JitOptRef temp = PyJitRef_StripReferenceInfo (retval );
768767 DEAD (retval );
769768 SAVE_STACK ();
770769 ctx -> frame -> stack_pointer = stack_pointer ;
@@ -925,7 +924,9 @@ dummy_func(void) {
925924 op (_CALL_STR_1 , (unused , unused , arg -- res )) {
926925 if (sym_matches_type (arg , & PyUnicode_Type )) {
927926 // e.g. str('foo') or str(foo) where foo is known to be a string
928- res = arg ;
927+ // Note: we must strip the reference information because it goes
928+ // through str() which strips the reference information from it.
929+ res = PyJitRef_StripReferenceInfo (arg );
929930 }
930931 else {
931932 res = sym_new_type (ctx , & PyUnicode_Type );
@@ -1065,7 +1066,9 @@ dummy_func(void) {
10651066 op (_CALL_TUPLE_1 , (callable , null , arg -- res )) {
10661067 if (sym_matches_type (arg , & PyTuple_Type )) {
10671068 // e.g. tuple((1, 2)) or tuple(foo) where foo is known to be a tuple
1068- res = arg ;
1069+ // Note: we must strip the reference information because it goes
1070+ // through tuple() which strips the reference information from it.
1071+ res = PyJitRef_StripReferenceInfo (arg );
10691072 }
10701073 else {
10711074 res = sym_new_type (ctx , & PyTuple_Type );
0 commit comments