@@ -83,9 +83,7 @@ dummy_func(void) {
83
83
op (_LOAD_FAST , (-- value )) {
84
84
value = GETLOCAL (oparg );
85
85
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 ));
89
87
}
90
88
}
91
89
@@ -199,20 +197,15 @@ dummy_func(void) {
199
197
assert (PyLong_CheckExact (sym_get_const (right )));
200
198
PyObject * temp = _PyLong_Add ((PyLongObject * )sym_get_const (left ),
201
199
(PyLongObject * )sym_get_const (right ));
202
- if (temp == NULL ) {
200
+ if (temp == NULL || _PyList_AppendTakeRef (( PyListObject * ) new_refs , temp ) ) {
203
201
goto error ;
204
202
}
205
203
assert (this_instr [-2 ].opcode == _NOP );
206
204
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 );
214
208
res = sym_new_const (ctx , temp );
215
- Py_DECREF (temp );
216
209
}
217
210
else {
218
211
res = sym_new_type (ctx , & PyLong_Type );
@@ -227,20 +220,15 @@ dummy_func(void) {
227
220
assert (PyLong_CheckExact (sym_get_const (right )));
228
221
PyObject * temp = _PyLong_Subtract ((PyLongObject * )sym_get_const (left ),
229
222
(PyLongObject * )sym_get_const (right ));
230
- if (temp == NULL ) {
223
+ if (temp == NULL || _PyList_AppendTakeRef (( PyListObject * ) new_refs , temp ) ) {
231
224
goto error ;
232
225
}
233
226
assert (this_instr [-2 ].opcode == _NOP );
234
227
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 );
242
231
res = sym_new_const (ctx , temp );
243
- Py_DECREF (temp );
244
232
}
245
233
else {
246
234
res = sym_new_type (ctx , & PyLong_Type );
@@ -255,20 +243,15 @@ dummy_func(void) {
255
243
assert (PyLong_CheckExact (sym_get_const (right )));
256
244
PyObject * temp = _PyLong_Multiply ((PyLongObject * )sym_get_const (left ),
257
245
(PyLongObject * )sym_get_const (right ));
258
- if (temp == NULL ) {
246
+ if (temp == NULL || _PyList_AppendTakeRef (( PyListObject * ) new_refs , temp ) ) {
259
247
goto error ;
260
248
}
261
249
assert (this_instr [-2 ].opcode == _NOP );
262
250
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 );
270
254
res = sym_new_const (ctx , temp );
271
- Py_DECREF (temp );
272
255
}
273
256
else {
274
257
res = sym_new_type (ctx , & PyLong_Type );
@@ -284,20 +267,15 @@ dummy_func(void) {
284
267
PyObject * temp = PyFloat_FromDouble (
285
268
PyFloat_AS_DOUBLE (sym_get_const (left )) +
286
269
PyFloat_AS_DOUBLE (sym_get_const (right )));
287
- if (temp == NULL ) {
270
+ if (temp == NULL || _PyList_AppendTakeRef (( PyListObject * ) new_refs , temp ) ) {
288
271
goto error ;
289
272
}
290
273
assert (this_instr [-2 ].opcode == _NOP );
291
274
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 );
299
278
res = sym_new_const (ctx , temp );
300
- Py_DECREF (temp );
301
279
}
302
280
else {
303
281
res = sym_new_type (ctx , & PyFloat_Type );
@@ -313,20 +291,15 @@ dummy_func(void) {
313
291
PyObject * temp = PyFloat_FromDouble (
314
292
PyFloat_AS_DOUBLE (sym_get_const (left )) -
315
293
PyFloat_AS_DOUBLE (sym_get_const (right )));
316
- if (temp == NULL ) {
294
+ if (temp == NULL || _PyList_AppendTakeRef (( PyListObject * ) new_refs , temp ) ) {
317
295
goto error ;
318
296
}
319
297
assert (this_instr [-2 ].opcode == _NOP );
320
298
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 );
328
302
res = sym_new_const (ctx , temp );
329
- Py_DECREF (temp );
330
303
}
331
304
else {
332
305
res = sym_new_type (ctx , & PyFloat_Type );
@@ -342,20 +315,15 @@ dummy_func(void) {
342
315
PyObject * temp = PyFloat_FromDouble (
343
316
PyFloat_AS_DOUBLE (sym_get_const (left )) *
344
317
PyFloat_AS_DOUBLE (sym_get_const (right )));
345
- if (temp == NULL ) {
318
+ if (temp == NULL || _PyList_AppendTakeRef (( PyListObject * ) new_refs , temp ) ) {
346
319
goto error ;
347
320
}
348
321
assert (this_instr [-2 ].opcode == _NOP );
349
322
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 );
357
326
res = sym_new_const (ctx , temp );
358
- Py_DECREF (temp );
359
327
}
360
328
else {
361
329
res = sym_new_type (ctx , & PyFloat_Type );
@@ -366,20 +334,15 @@ dummy_func(void) {
366
334
if (sym_is_const (left ) && sym_is_const (right ) &&
367
335
sym_matches_type (left , & PyUnicode_Type ) && sym_matches_type (right , & PyUnicode_Type )) {
368
336
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 ) ) {
370
338
goto error ;
371
339
}
372
340
assert (this_instr [-2 ].opcode == _NOP );
373
341
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 );
381
345
res = sym_new_const (ctx , temp );
382
- Py_DECREF (temp );
383
346
}
384
347
else {
385
348
res = sym_new_type (ctx , & PyUnicode_Type );
@@ -391,22 +354,17 @@ dummy_func(void) {
391
354
if (sym_is_const (left ) && sym_is_const (right ) &&
392
355
sym_matches_type (left , & PyUnicode_Type ) && sym_matches_type (right , & PyUnicode_Type )) {
393
356
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 ) ) {
395
358
goto error ;
396
359
}
397
360
assert (this_instr [-3 ].opcode == _NOP );
398
361
assert (this_instr [-2 ].opcode == _NOP );
399
362
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 );
409
366
REPLACE_OP (this_instr , _STORE_FAST , this_instr -> operand , 0 );
367
+ res = sym_new_const (ctx , temp );
410
368
}
411
369
else {
412
370
res = sym_new_type (ctx , & PyUnicode_Type );
@@ -505,8 +463,7 @@ dummy_func(void) {
505
463
506
464
op (_LOAD_CONST , (-- value )) {
507
465
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 );
510
467
value = sym_new_const (ctx , val );
511
468
}
512
469
@@ -530,9 +487,7 @@ dummy_func(void) {
530
487
531
488
op (_COPY , (bottom , unused [oparg - 1 ] -- bottom , unused [oparg - 1 ], top )) {
532
489
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 ));
536
491
}
537
492
assert (oparg > 0 );
538
493
top = bottom ;
0 commit comments