@@ -571,10 +571,11 @@ const uint16_t op_without_pop[MAX_UOP_ID + 1] = {
571571 [_POP_CALL_ONE_LOAD_CONST_INLINE_BORROW ] = _POP_CALL_LOAD_CONST_INLINE_BORROW ,
572572 [_POP_CALL_TWO ] = _POP_CALL_ONE ,
573573 [_POP_CALL_ONE ] = _POP_CALL ,
574- // The following two instructions are handled separately in remove_unneeded_uops.
575- // The TOS for both is null so calling _POP_TOP (which closes the stackref) is not safe.
576- // [_POP_CALL] = _POP_TOP,
577- // [_POP_CALL_LOAD_CONST_INLINE_BORROW] = _POP_TOP_LOAD_CONST_INLINE_BORROW,
574+ };
575+
576+ const uint16_t op_without_pop_null [MAX_UOP_ID + 1 ] = {
577+ [_POP_CALL ] = _POP_TOP ,
578+ [_POP_CALL_LOAD_CONST_INLINE_BORROW ] = _POP_TOP_LOAD_CONST_INLINE_BORROW ,
578579};
579580
580581
@@ -611,9 +612,7 @@ remove_unneeded_uops(_PyUOpInstruction *buffer, int buffer_size)
611612 // _LOAD_FAST + _POP_TWO_LOAD_CONST_INLINE_BORROW + _POP_TOP
612613 // ...becomes:
613614 // _NOP + _POP_TOP + _NOP
614- while (op_without_pop [opcode ] ||
615- opcode == _POP_CALL ||
616- opcode == _POP_CALL_LOAD_CONST_INLINE_BORROW )
615+ while (op_without_pop [opcode ] || op_without_pop_null [opcode ])
617616 {
618617 _PyUOpInstruction * last = & buffer [pc - 1 ];
619618 while (op_skip [last -> opcode ]) {
@@ -632,12 +631,8 @@ remove_unneeded_uops(_PyUOpInstruction *buffer, int buffer_size)
632631 // This looks for a preceding _PUSH_NULL instruction and
633632 // simplifies to _POP_TOP(_LOAD_CONST_INLINE_BORROW).
634633 last -> opcode = _NOP ;
635- if (opcode == _POP_CALL ) {
636- opcode = buffer [pc ].opcode = _POP_TOP ;
637- }
638- else {
639- opcode = buffer [pc ].opcode = _POP_TOP_LOAD_CONST_INLINE_BORROW ;
640- }
634+ opcode = buffer [pc ].opcode = op_without_pop_null [opcode ];
635+ assert (opcode );
641636 }
642637 else {
643638 break ;
0 commit comments