@@ -709,98 +709,96 @@ dummy_func(
709709 _GUARD_TOS_INT + _GUARD_NOS_INT + unused /5 + _BINARY_OP_SUBTRACT_INT + _POP_TOP_INT + _POP_TOP_INT ;
710710
711711 // Inplace compact int ops: mutate the uniquely-referenced operand
712- // when possible. If TARGET is immortal (small int) or the result
713- // is a small int or overflows, fall back to _PyCompactLong_*.
714- // On mutation success, DUP the target so POP_TOP_INT can safely
715- // decref the original. Tier 2 only.
712+ // when possible. The op handles decref of TARGET internally so
713+ // the following _POP_TOP_INT becomes _POP_TOP_NOP. Tier 2 only.
716714 tier2 op (_BINARY_OP_ADD_INT_INPLACE , (left , right -- res , l , r )) {
717- INT_INPLACE_OP (left , right , left , + );
715+ INT_INPLACE_OP (left , right , left , + , _PyCompactLong_Add );
716+ r = right ;
717+ DEAD (right );
718+ EXIT_IF (!_int_inplace_ok && PyStackRef_IsNull (_int_inplace_res ));
718719 if (_int_inplace_ok ) {
719720 res = PyStackRef_DUP (left );
720721 }
721722 else {
722- res = _PyCompactLong_Add ((PyLongObject * )PyStackRef_AsPyObjectBorrow (left ),
723- (PyLongObject * )PyStackRef_AsPyObjectBorrow (right ));
724- EXIT_IF (PyStackRef_IsNull (res ));
723+ res = _int_inplace_res ;
725724 }
726725 l = left ;
727- r = right ;
728- INPUTS_DEAD ();
726+ DEAD (left );
729727 }
730728
731729 tier2 op (_BINARY_OP_SUBTRACT_INT_INPLACE , (left , right -- res , l , r )) {
732- INT_INPLACE_OP (left , right , left , - );
730+ INT_INPLACE_OP (left , right , left , - , _PyCompactLong_Subtract );
731+ r = right ;
732+ DEAD (right );
733+ EXIT_IF (!_int_inplace_ok && PyStackRef_IsNull (_int_inplace_res ));
733734 if (_int_inplace_ok ) {
734735 res = PyStackRef_DUP (left );
735736 }
736737 else {
737- res = _PyCompactLong_Subtract ((PyLongObject * )PyStackRef_AsPyObjectBorrow (left ),
738- (PyLongObject * )PyStackRef_AsPyObjectBorrow (right ));
739- EXIT_IF (PyStackRef_IsNull (res ));
738+ res = _int_inplace_res ;
740739 }
741740 l = left ;
742- r = right ;
743- INPUTS_DEAD ();
741+ DEAD (left );
744742 }
745743
746744 tier2 op (_BINARY_OP_MULTIPLY_INT_INPLACE , (left , right -- res , l , r )) {
747- INT_INPLACE_OP (left , right , left , * );
745+ INT_INPLACE_OP (left , right , left , * , _PyCompactLong_Multiply );
746+ r = right ;
747+ DEAD (right );
748+ EXIT_IF (!_int_inplace_ok && PyStackRef_IsNull (_int_inplace_res ));
748749 if (_int_inplace_ok ) {
749750 res = PyStackRef_DUP (left );
750751 }
751752 else {
752- res = _PyCompactLong_Multiply ((PyLongObject * )PyStackRef_AsPyObjectBorrow (left ),
753- (PyLongObject * )PyStackRef_AsPyObjectBorrow (right ));
754- EXIT_IF (PyStackRef_IsNull (res ));
753+ res = _int_inplace_res ;
755754 }
756755 l = left ;
757- r = right ;
758- INPUTS_DEAD ();
756+ DEAD (left );
759757 }
760758
761759 tier2 op (_BINARY_OP_ADD_INT_INPLACE_RIGHT , (left , right -- res , l , r )) {
762- INT_INPLACE_OP (left , right , right , + );
760+ INT_INPLACE_OP (left , right , right , + , _PyCompactLong_Add );
761+ l = left ;
762+ DEAD (left );
763+ EXIT_IF (!_int_inplace_ok && PyStackRef_IsNull (_int_inplace_res ));
763764 if (_int_inplace_ok ) {
764765 res = PyStackRef_DUP (right );
765766 }
766767 else {
767- res = _PyCompactLong_Add ((PyLongObject * )PyStackRef_AsPyObjectBorrow (left ),
768- (PyLongObject * )PyStackRef_AsPyObjectBorrow (right ));
769- EXIT_IF (PyStackRef_IsNull (res ));
768+ res = _int_inplace_res ;
770769 }
771- l = left ;
772770 r = right ;
773- INPUTS_DEAD ( );
771+ DEAD ( right );
774772 }
775773
776774 tier2 op (_BINARY_OP_SUBTRACT_INT_INPLACE_RIGHT , (left , right -- res , l , r )) {
777- INT_INPLACE_OP (left , right , right , - );
775+ INT_INPLACE_OP (left , right , right , - , _PyCompactLong_Subtract );
776+ l = left ;
777+ DEAD (left );
778+ EXIT_IF (!_int_inplace_ok && PyStackRef_IsNull (_int_inplace_res ));
778779 if (_int_inplace_ok ) {
779780 res = PyStackRef_DUP (right );
780781 }
781782 else {
782- res = _PyCompactLong_Subtract ((PyLongObject * )PyStackRef_AsPyObjectBorrow (left ),
783- (PyLongObject * )PyStackRef_AsPyObjectBorrow (right ));
784- EXIT_IF (PyStackRef_IsNull (res ));
783+ res = _int_inplace_res ;
785784 }
786- l = left ;
787785 r = right ;
788- INPUTS_DEAD ( );
786+ DEAD ( right );
789787 }
790788
791789 tier2 op (_BINARY_OP_MULTIPLY_INT_INPLACE_RIGHT , (left , right -- res , l , r )) {
792- INT_INPLACE_OP (left , right , right , * );
790+ INT_INPLACE_OP (left , right , right , * , _PyCompactLong_Multiply );
791+ l = left ;
792+ DEAD (left );
793+ EXIT_IF (!_int_inplace_ok && PyStackRef_IsNull (_int_inplace_res ));
793794 if (_int_inplace_ok ) {
794795 res = PyStackRef_DUP (right );
795796 }
796797 else {
797- res = _PyCompactLong_Multiply ((PyLongObject * )PyStackRef_AsPyObjectBorrow (left ),
798- (PyLongObject * )PyStackRef_AsPyObjectBorrow (right ));
799- EXIT_IF (PyStackRef_IsNull (res ));
798+ res = _int_inplace_res ;
800799 }
801- l = left ;
802800 r = right ;
803- INPUTS_DEAD ( );
801+ DEAD ( right );
804802 }
805803
806804 op (_GUARD_NOS_FLOAT , (left , unused -- left , unused )) {
0 commit comments