@@ -83,9 +83,7 @@ dummy_func(void) {
8383 op (_LOAD_FAST , (-- value )) {
8484 value = GETLOCAL (oparg );
8585 if (sym_is_const (value )) {
86- PyObject * val = sym_get_const (value );
87- int opcode = _Py_IsImmortal (val ) ? _LOAD_CONST_INLINE_BORROW : _LOAD_CONST_INLINE ;
88- REPLACE_OP (this_instr , opcode , 0 , (uintptr_t )val );
86+ REPLACE_OP_WITH_LOAD_CONST (this_instr , sym_get_const (value ));
8987 }
9088 }
9189
@@ -199,20 +197,15 @@ dummy_func(void) {
199197 assert (PyLong_CheckExact (sym_get_const (right )));
200198 PyObject * temp = _PyLong_Add ((PyLongObject * )sym_get_const (left ),
201199 (PyLongObject * )sym_get_const (right ));
202- if (temp == NULL ) {
200+ if (temp == NULL || _PyList_AppendTakeRef (( PyListObject * ) new_refs , temp ) ) {
203201 goto error ;
204202 }
205203 assert (this_instr [-2 ].opcode == _NOP );
206204 assert (this_instr [-1 ].opcode == _NOP );
207- REPLACE_OP (& this_instr [-2 ], _POP_TOP , 0 , 0 );
208- REPLACE_OP (& this_instr [-1 ], _POP_TOP , 0 , 0 );
209- if (PyList_Append (new_refs , temp )) {
210- goto error ;
211- }
212- int opcode = _Py_IsImmortal (temp ) ? _LOAD_CONST_INLINE_BORROW : _LOAD_CONST_INLINE ;
213- REPLACE_OP (this_instr , opcode , 0 , (uintptr_t )temp );
205+ REPLACE_OP (this_instr - 2 , _POP_TOP , 0 , 0 );
206+ REPLACE_OP (this_instr - 1 , _POP_TOP , 0 , 0 );
207+ REPLACE_OP_WITH_LOAD_CONST (this_instr , temp );
214208 res = sym_new_const (ctx , temp );
215- Py_DECREF (temp );
216209 }
217210 else {
218211 res = sym_new_type (ctx , & PyLong_Type );
@@ -227,20 +220,15 @@ dummy_func(void) {
227220 assert (PyLong_CheckExact (sym_get_const (right )));
228221 PyObject * temp = _PyLong_Subtract ((PyLongObject * )sym_get_const (left ),
229222 (PyLongObject * )sym_get_const (right ));
230- if (temp == NULL ) {
223+ if (temp == NULL || _PyList_AppendTakeRef (( PyListObject * ) new_refs , temp ) ) {
231224 goto error ;
232225 }
233226 assert (this_instr [-2 ].opcode == _NOP );
234227 assert (this_instr [-1 ].opcode == _NOP );
235- REPLACE_OP (& this_instr [-2 ], _POP_TOP , 0 , 0 );
236- REPLACE_OP (& this_instr [-1 ], _POP_TOP , 0 , 0 );
237- if (PyList_Append (new_refs , temp )) {
238- goto error ;
239- }
240- int opcode = _Py_IsImmortal (temp ) ? _LOAD_CONST_INLINE_BORROW : _LOAD_CONST_INLINE ;
241- REPLACE_OP (this_instr , opcode , 0 , (uintptr_t )temp );
228+ REPLACE_OP (this_instr - 2 , _POP_TOP , 0 , 0 );
229+ REPLACE_OP (this_instr - 1 , _POP_TOP , 0 , 0 );
230+ REPLACE_OP_WITH_LOAD_CONST (this_instr , temp );
242231 res = sym_new_const (ctx , temp );
243- Py_DECREF (temp );
244232 }
245233 else {
246234 res = sym_new_type (ctx , & PyLong_Type );
@@ -255,20 +243,15 @@ dummy_func(void) {
255243 assert (PyLong_CheckExact (sym_get_const (right )));
256244 PyObject * temp = _PyLong_Multiply ((PyLongObject * )sym_get_const (left ),
257245 (PyLongObject * )sym_get_const (right ));
258- if (temp == NULL ) {
246+ if (temp == NULL || _PyList_AppendTakeRef (( PyListObject * ) new_refs , temp ) ) {
259247 goto error ;
260248 }
261249 assert (this_instr [-2 ].opcode == _NOP );
262250 assert (this_instr [-1 ].opcode == _NOP );
263- REPLACE_OP (& this_instr [-2 ], _POP_TOP , 0 , 0 );
264- REPLACE_OP (& this_instr [-1 ], _POP_TOP , 0 , 0 );
265- if (PyList_Append (new_refs , temp )) {
266- goto error ;
267- }
268- int opcode = _Py_IsImmortal (temp ) ? _LOAD_CONST_INLINE_BORROW : _LOAD_CONST_INLINE ;
269- REPLACE_OP (this_instr , opcode , 0 , (uintptr_t )temp );
251+ REPLACE_OP (this_instr - 2 , _POP_TOP , 0 , 0 );
252+ REPLACE_OP (this_instr - 1 , _POP_TOP , 0 , 0 );
253+ REPLACE_OP_WITH_LOAD_CONST (this_instr , temp );
270254 res = sym_new_const (ctx , temp );
271- Py_DECREF (temp );
272255 }
273256 else {
274257 res = sym_new_type (ctx , & PyLong_Type );
@@ -284,20 +267,15 @@ dummy_func(void) {
284267 PyObject * temp = PyFloat_FromDouble (
285268 PyFloat_AS_DOUBLE (sym_get_const (left )) +
286269 PyFloat_AS_DOUBLE (sym_get_const (right )));
287- if (temp == NULL ) {
270+ if (temp == NULL || _PyList_AppendTakeRef (( PyListObject * ) new_refs , temp ) ) {
288271 goto error ;
289272 }
290273 assert (this_instr [-2 ].opcode == _NOP );
291274 assert (this_instr [-1 ].opcode == _NOP );
292- REPLACE_OP (& this_instr [-2 ], _POP_TOP , 0 , 0 );
293- REPLACE_OP (& this_instr [-1 ], _POP_TOP , 0 , 0 );
294- if (PyList_Append (new_refs , temp )) {
295- goto error ;
296- }
297- int opcode = _Py_IsImmortal (temp ) ? _LOAD_CONST_INLINE_BORROW : _LOAD_CONST_INLINE ;
298- REPLACE_OP (this_instr , opcode , 0 , (uintptr_t )temp );
275+ REPLACE_OP (this_instr - 2 , _POP_TOP , 0 , 0 );
276+ REPLACE_OP (this_instr - 1 , _POP_TOP , 0 , 0 );
277+ REPLACE_OP_WITH_LOAD_CONST (this_instr , temp );
299278 res = sym_new_const (ctx , temp );
300- Py_DECREF (temp );
301279 }
302280 else {
303281 res = sym_new_type (ctx , & PyFloat_Type );
@@ -313,20 +291,15 @@ dummy_func(void) {
313291 PyObject * temp = PyFloat_FromDouble (
314292 PyFloat_AS_DOUBLE (sym_get_const (left )) -
315293 PyFloat_AS_DOUBLE (sym_get_const (right )));
316- if (temp == NULL ) {
294+ if (temp == NULL || _PyList_AppendTakeRef (( PyListObject * ) new_refs , temp ) ) {
317295 goto error ;
318296 }
319297 assert (this_instr [-2 ].opcode == _NOP );
320298 assert (this_instr [-1 ].opcode == _NOP );
321- REPLACE_OP (& this_instr [-2 ], _POP_TOP , 0 , 0 );
322- REPLACE_OP (& this_instr [-1 ], _POP_TOP , 0 , 0 );
323- if (PyList_Append (new_refs , temp )) {
324- goto error ;
325- }
326- int opcode = _Py_IsImmortal (temp ) ? _LOAD_CONST_INLINE_BORROW : _LOAD_CONST_INLINE ;
327- REPLACE_OP (this_instr , opcode , 0 , (uintptr_t )temp );
299+ REPLACE_OP (this_instr - 2 , _POP_TOP , 0 , 0 );
300+ REPLACE_OP (this_instr - 1 , _POP_TOP , 0 , 0 );
301+ REPLACE_OP_WITH_LOAD_CONST (this_instr , temp );
328302 res = sym_new_const (ctx , temp );
329- Py_DECREF (temp );
330303 }
331304 else {
332305 res = sym_new_type (ctx , & PyFloat_Type );
@@ -342,20 +315,15 @@ dummy_func(void) {
342315 PyObject * temp = PyFloat_FromDouble (
343316 PyFloat_AS_DOUBLE (sym_get_const (left )) *
344317 PyFloat_AS_DOUBLE (sym_get_const (right )));
345- if (temp == NULL ) {
318+ if (temp == NULL || _PyList_AppendTakeRef (( PyListObject * ) new_refs , temp ) ) {
346319 goto error ;
347320 }
348321 assert (this_instr [-2 ].opcode == _NOP );
349322 assert (this_instr [-1 ].opcode == _NOP );
350- REPLACE_OP (& this_instr [-2 ], _POP_TOP , 0 , 0 );
351- REPLACE_OP (& this_instr [-1 ], _POP_TOP , 0 , 0 );
352- if (PyList_Append (new_refs , temp )) {
353- goto error ;
354- }
355- int opcode = _Py_IsImmortal (temp ) ? _LOAD_CONST_INLINE_BORROW : _LOAD_CONST_INLINE ;
356- REPLACE_OP (this_instr , opcode , 0 , (uintptr_t )temp );
323+ REPLACE_OP (this_instr - 2 , _POP_TOP , 0 , 0 );
324+ REPLACE_OP (this_instr - 1 , _POP_TOP , 0 , 0 );
325+ REPLACE_OP_WITH_LOAD_CONST (this_instr , temp );
357326 res = sym_new_const (ctx , temp );
358- Py_DECREF (temp );
359327 }
360328 else {
361329 res = sym_new_type (ctx , & PyFloat_Type );
@@ -366,20 +334,15 @@ dummy_func(void) {
366334 if (sym_is_const (left ) && sym_is_const (right ) &&
367335 sym_matches_type (left , & PyUnicode_Type ) && sym_matches_type (right , & PyUnicode_Type )) {
368336 PyObject * temp = PyUnicode_Concat (sym_get_const (left ), sym_get_const (right ));
369- if (temp == NULL ) {
337+ if (temp == NULL || _PyList_AppendTakeRef (( PyListObject * ) new_refs , temp ) ) {
370338 goto error ;
371339 }
372340 assert (this_instr [-2 ].opcode == _NOP );
373341 assert (this_instr [-1 ].opcode == _NOP );
374- REPLACE_OP (& this_instr [-2 ], _POP_TOP , 0 , 0 );
375- REPLACE_OP (& this_instr [-1 ], _POP_TOP , 0 , 0 );
376- if (PyList_Append (new_refs , temp )) {
377- goto error ;
378- }
379- int opcode = _Py_IsImmortal (temp ) ? _LOAD_CONST_INLINE_BORROW : _LOAD_CONST_INLINE ;
380- REPLACE_OP (this_instr , opcode , 0 , (uintptr_t )temp );
342+ REPLACE_OP (this_instr - 2 , _POP_TOP , 0 , 0 );
343+ REPLACE_OP (this_instr - 1 , _POP_TOP , 0 , 0 );
344+ REPLACE_OP_WITH_LOAD_CONST (this_instr , temp );
381345 res = sym_new_const (ctx , temp );
382- Py_DECREF (temp );
383346 }
384347 else {
385348 res = sym_new_type (ctx , & PyUnicode_Type );
@@ -391,22 +354,17 @@ dummy_func(void) {
391354 if (sym_is_const (left ) && sym_is_const (right ) &&
392355 sym_matches_type (left , & PyUnicode_Type ) && sym_matches_type (right , & PyUnicode_Type )) {
393356 PyObject * temp = PyUnicode_Concat (sym_get_const (left ), sym_get_const (right ));
394- if (temp == NULL ) {
357+ if (temp == NULL || _PyList_AppendTakeRef (( PyListObject * ) new_refs , temp ) ) {
395358 goto error ;
396359 }
397360 assert (this_instr [-3 ].opcode == _NOP );
398361 assert (this_instr [-2 ].opcode == _NOP );
399362 assert (this_instr [-1 ].opcode == _NOP );
400- REPLACE_OP (& this_instr [-3 ], _POP_TOP , 0 , 0 );
401- REPLACE_OP (& this_instr [-2 ], _POP_TOP , 0 , 0 );
402- if (PyList_Append (new_refs , temp )) {
403- goto error ;
404- }
405- int opcode = _Py_IsImmortal (temp ) ? _LOAD_CONST_INLINE_BORROW : _LOAD_CONST_INLINE ;
406- REPLACE_OP (& this_instr [-1 ], opcode , 0 , (uintptr_t )temp );
407- res = sym_new_const (ctx , temp );
408- Py_DECREF (temp );
363+ REPLACE_OP (this_instr - 3 , _POP_TOP , 0 , 0 );
364+ REPLACE_OP (this_instr - 2 , _POP_TOP , 0 , 0 );
365+ REPLACE_OP_WITH_LOAD_CONST (this_instr - 1 , temp );
409366 REPLACE_OP (this_instr , _STORE_FAST , this_instr -> operand , 0 );
367+ res = sym_new_const (ctx , temp );
410368 }
411369 else {
412370 res = sym_new_type (ctx , & PyUnicode_Type );
@@ -505,8 +463,7 @@ dummy_func(void) {
505463
506464 op (_LOAD_CONST , (-- value )) {
507465 PyObject * val = PyTuple_GET_ITEM (co -> co_consts , this_instr -> oparg );
508- int opcode = _Py_IsImmortal (val ) ? _LOAD_CONST_INLINE_BORROW : _LOAD_CONST_INLINE ;
509- REPLACE_OP (this_instr , opcode , 0 , (uintptr_t )val );
466+ REPLACE_OP_WITH_LOAD_CONST (this_instr , val );
510467 value = sym_new_const (ctx , val );
511468 }
512469
@@ -530,9 +487,7 @@ dummy_func(void) {
530487
531488 op (_COPY , (bottom , unused [oparg - 1 ] -- bottom , unused [oparg - 1 ], top )) {
532489 if (sym_is_const (bottom )) {
533- PyObject * value = sym_get_const (bottom );
534- int opcode = _Py_IsImmortal (value ) ? _LOAD_CONST_INLINE_BORROW : _LOAD_CONST_INLINE ;
535- REPLACE_OP (this_instr , opcode , 0 , (uintptr_t )value );
490+ REPLACE_OP_WITH_LOAD_CONST (this_instr , sym_get_const (bottom ));
536491 }
537492 assert (oparg > 0 );
538493 top = bottom ;
0 commit comments