@@ -156,8 +156,7 @@ type_watcher_callback(PyTypeObject* type)
156156}
157157
158158static PyObject *
159- convert_global_to_const (_PyUOpInstruction * inst , PyObject * obj ,
160- uint16_t immortal_op , uint16_t mortal_op )
159+ convert_global_to_const (_PyUOpInstruction * inst , PyObject * obj )
161160{
162161 assert (inst -> opcode == _LOAD_GLOBAL_MODULE || inst -> opcode == _LOAD_GLOBAL_BUILTINS || inst -> opcode == _LOAD_ATTR_MODULE );
163162 assert (PyDict_CheckExact (obj ));
@@ -178,15 +177,9 @@ convert_global_to_const(_PyUOpInstruction *inst, PyObject *obj,
178177 return NULL ;
179178 }
180179 if (_Py_IsImmortal (res )) {
181- inst -> opcode = immortal_op ;
180+ inst -> opcode = _LOAD_CONST_INLINE_BORROW ;
182181 } else {
183- inst -> opcode = mortal_op ;
184- }
185- if (inst -> opcode == _LOAD_CONST_INLINE_BORROW || inst -> opcode == _LOAD_CONST_INLINE ) {
186- if (inst -> oparg & 1 ) {
187- assert (inst [1 ].opcode == _PUSH_NULL_CONDITIONAL );
188- assert (inst [1 ].oparg & 1 );
189- }
182+ inst -> opcode = _LOAD_CONST_INLINE ;
190183 }
191184 inst -> operand0 = (uint64_t )res ;
192185 return res ;
@@ -326,7 +319,7 @@ optimize_to_bool(
326319 JitOptContext * ctx ,
327320 JitOptRef value ,
328321 JitOptRef * result_ptr ,
329- uint16_t prefix , uint16_t load_op )
322+ uint16_t prefix , uint16_t suffix )
330323{
331324 if (sym_matches_type (value , & PyBool_Type )) {
332325 ADD_OP (_NOP , 0 , 0 );
@@ -339,7 +332,10 @@ optimize_to_bool(
339332 if (prefix != _NOP ) {
340333 ADD_OP (prefix , 0 , 0 );
341334 }
342- ADD_OP (load_op , 0 , (uintptr_t )load );
335+ ADD_OP (_LOAD_CONST_INLINE_BORROW , 0 , (uintptr_t )load );
336+ if (suffix != _NOP ) {
337+ ADD_OP (suffix , 2 , 0 );
338+ }
343339 * result_ptr = sym_new_const (ctx , load );
344340 return 1 ;
345341 }
@@ -386,7 +382,7 @@ eliminate_pop_guard(_PyUOpInstruction *this_instr, JitOptContext *ctx, bool exit
386382static JitOptRef
387383lookup_attr (JitOptContext * ctx , _PyBloomFilter * dependencies , _PyUOpInstruction * this_instr ,
388384 PyTypeObject * type , PyObject * name ,
389- uint16_t prefix , uint16_t immortal_op , uint16_t mortal_op )
385+ uint16_t prefix , uint16_t suffix )
390386{
391387 // The cached value may be dead, so we need to do the lookup again... :(
392388 if (type && PyType_Check (type )) {
@@ -396,7 +392,11 @@ lookup_attr(JitOptContext *ctx, _PyBloomFilter *dependencies, _PyUOpInstruction
396392 if (prefix != _NOP ) {
397393 ADD_OP (prefix , 0 , 0 );
398394 }
399- ADD_OP (immortal ? immortal_op : mortal_op , 0 , (uintptr_t )lookup );
395+ ADD_OP (immortal ? _LOAD_CONST_INLINE_BORROW : _LOAD_CONST_INLINE ,
396+ 0 , (uintptr_t )lookup );
397+ if (suffix != _NOP ) {
398+ ADD_OP (suffix , 2 , 0 );
399+ }
400400 PyType_Watch (TYPE_WATCHER_ID , (PyObject * )type );
401401 _Py_BloomFilter_Add (dependencies , type );
402402 return sym_new_const (ctx , lookup );
@@ -411,7 +411,8 @@ static JitOptRef
411411lookup_super_attr (JitOptContext * ctx , _PyBloomFilter * dependencies ,
412412 _PyUOpInstruction * this_instr ,
413413 PyTypeObject * su_type , PyTypeObject * obj_type ,
414- PyObject * name , uint16_t immortal , uint16_t mortal )
414+ PyObject * name ,
415+ uint16_t immortal , uint16_t mortal , uint16_t suffix )
415416{
416417 if (su_type == NULL || obj_type == NULL ) {
417418 return sym_new_not_null (ctx );
@@ -439,6 +440,9 @@ lookup_super_attr(JitOptContext *ctx, _PyBloomFilter *dependencies,
439440 ADD_OP (_POP_TOP , 0 , 0 );
440441 ADD_OP (_POP_TOP , 0 , 0 );
441442 ADD_OP (opcode , 0 , (uintptr_t )lookup );
443+ if (suffix != _NOP ) {
444+ ADD_OP (suffix , 2 , 0 );
445+ }
442446 PyType_Watch (TYPE_WATCHER_ID , (PyObject * )su_type );
443447 _Py_BloomFilter_Add (dependencies , su_type );
444448 PyType_Watch (TYPE_WATCHER_ID , (PyObject * )obj_type );
@@ -647,8 +651,6 @@ const uint16_t op_without_push[MAX_UOP_ID + 1] = {
647651 [_COPY ] = _NOP ,
648652 [_LOAD_CONST_INLINE ] = _NOP ,
649653 [_LOAD_CONST_INLINE_BORROW ] = _NOP ,
650- [_INSERT_1_LOAD_CONST_INLINE ] = _POP_TOP_LOAD_CONST_INLINE ,
651- [_INSERT_1_LOAD_CONST_INLINE_BORROW ] = _POP_TOP_LOAD_CONST_INLINE_BORROW ,
652654 [_LOAD_FAST ] = _NOP ,
653655 [_LOAD_FAST_BORROW ] = _NOP ,
654656 [_LOAD_SMALL_INT ] = _NOP ,
0 commit comments