@@ -630,21 +630,26 @@ static void
630
630
de_instrument_per_instruction (PyCodeObject * code , int i )
631
631
{
632
632
_Py_CODEUNIT * instr = & _PyCode_CODE (code )[i ];
633
- uint8_t * opcode_ptr = & instr -> op .code ;
634
- int opcode = * opcode_ptr ;
633
+ int opcode = instr -> op .code ;
635
634
if (opcode == INSTRUMENTED_LINE ) {
636
- opcode_ptr = & code -> _co_monitoring -> lines [i ].original_opcode ;
637
- opcode = * opcode_ptr ;
638
- }
639
- if (opcode != INSTRUMENTED_INSTRUCTION ) {
640
- return ;
641
- }
642
- int original_opcode = code -> _co_monitoring -> per_instruction_opcodes [i ];
643
- CHECK (original_opcode != 0 );
644
- CHECK (original_opcode == _PyOpcode_Deopt [original_opcode ]);
645
- instr -> op .code = original_opcode ;
646
- if (_PyOpcode_Caches [original_opcode ]) {
647
- instr [1 ].cache = adaptive_counter_warmup ();
635
+ // We need to keep INSTRUMENTED_LINE when deinstrumenting INSTRUCTION
636
+ opcode = code -> _co_monitoring -> lines [i ].original_opcode ;
637
+ if (opcode != INSTRUMENTED_INSTRUCTION ) {
638
+ return ;
639
+ }
640
+ code -> _co_monitoring -> lines [i ].original_opcode =
641
+ code -> _co_monitoring -> per_instruction_opcodes [i ];
642
+ } else {
643
+ if (opcode != INSTRUMENTED_INSTRUCTION ) {
644
+ return ;
645
+ }
646
+ int original_opcode = code -> _co_monitoring -> per_instruction_opcodes [i ];
647
+ CHECK (original_opcode != 0 );
648
+ CHECK (original_opcode == _PyOpcode_Deopt [original_opcode ]);
649
+ instr -> op .code = original_opcode ;
650
+ if (_PyOpcode_Caches [original_opcode ]) {
651
+ instr [1 ].cache = adaptive_counter_warmup ();
652
+ }
648
653
}
649
654
assert (instr -> op .code != INSTRUMENTED_INSTRUCTION );
650
655
/* Keep things clean for sanity check */
0 commit comments