@@ -34,7 +34,7 @@ typedef struct _Py_UOpsAbstractFrame _Py_UOpsAbstractFrame;
3434#define sym_new_tuple _Py_uop_sym_new_tuple
3535#define sym_tuple_getitem _Py_uop_sym_tuple_getitem
3636#define sym_tuple_length _Py_uop_sym_tuple_length
37- #define sym_is_immortal _Py_uop_sym_is_immortal
37+ #define sym_is_immortal _Py_uop_symbol_is_immortal
3838#define sym_new_compact_int _Py_uop_sym_new_compact_int
3939#define sym_is_compact_int _Py_uop_sym_is_compact_int
4040#define sym_new_truthiness _Py_uop_sym_new_truthiness
@@ -318,7 +318,7 @@ dummy_func(void) {
318318 }
319319 }
320320
321- op (_BINARY_OP_ADD_UNICODE , (left , right -- res )) {
321+ op (_BINARY_OP_ADD_UNICODE , (left , right -- res , l , r )) {
322322 if (sym_is_const (ctx , left ) && sym_is_const (ctx , right )) {
323323 assert (PyUnicode_CheckExact (sym_get_const (ctx , left )));
324324 assert (PyUnicode_CheckExact (sym_get_const (ctx , right )));
@@ -327,10 +327,14 @@ dummy_func(void) {
327327 goto error ;
328328 }
329329 res = sym_new_const (ctx , temp );
330+ l = left ;
331+ r = right ;
330332 Py_DECREF (temp );
331333 }
332334 else {
333335 res = sym_new_type (ctx , & PyUnicode_Type );
336+ l = left ;
337+ r = right ;
334338 }
335339 }
336340
@@ -561,11 +565,39 @@ dummy_func(void) {
561565 value = PyJitRef_Borrow (sym_new_const (ctx , ptr ));
562566 }
563567
568+ op (_POP_TOP_UNICODE , (value -- )) {
569+ if (PyJitRef_IsBorrowed (value ) ||
570+ sym_is_immortal (PyJitRef_Unwrap (value ))) {
571+ REPLACE_OP (this_instr , _POP_TOP_NOP , 0 , 0 );
572+ }
573+ }
574+
564575 op (_COPY , (bottom , unused [oparg - 1 ] -- bottom , unused [oparg - 1 ], top )) {
565576 assert (oparg > 0 );
566577 top = bottom ;
567578 }
568579
580+ op (_POP_TOP , (value -- )) {
581+ PyTypeObject * typ = sym_get_type (value );
582+ PyObject * const_val = sym_get_const (ctx , value );
583+ if (PyJitRef_IsBorrowed (value ) ||
584+ (const_val != NULL && _Py_IsImmortal (const_val ))) {
585+ REPLACE_OP (this_instr , _POP_TOP_NOP , 0 , 0 );
586+ }
587+ else if (typ == & PyLong_Type ) {
588+ REPLACE_OP (this_instr , _POP_TOP_INT , 0 , 0 );
589+ }
590+ else if (typ == & PyFloat_Type ) {
591+ REPLACE_OP (this_instr , _POP_TOP_FLOAT , 0 , 0 );
592+ }
593+ else if (typ == & PyUnicode_Type ) {
594+ REPLACE_OP (this_instr , _POP_TOP_UNICODE , 0 , 0 );
595+ }
596+ else if (typ == & PyBool_Type ) {
597+ REPLACE_OP (this_instr , _POP_TOP_NOP , 0 , 0 );
598+ }
599+ }
600+
569601 op (_SWAP , (bottom , unused [oparg - 2 ], top -- bottom , unused [oparg - 2 ], top )) {
570602 JitOptRef temp = bottom ;
571603 bottom = top ;
@@ -803,7 +835,7 @@ dummy_func(void) {
803835 }
804836
805837 op (_RETURN_VALUE , (retval -- res )) {
806- JitOptRef temp = retval ;
838+ JitOptRef temp = PyJitRef_Wrap ( PyJitRef_Unwrap ( retval )) ;
807839 DEAD (retval );
808840 SAVE_STACK ();
809841 ctx -> frame -> stack_pointer = stack_pointer ;
0 commit comments