Skip to content
Prev Previous commit
Next Next commit
Make sure IP is up to date when checing validity.
  • Loading branch information
markshannon committed Nov 4, 2023
commit 65b6e36a2cb210963552e5d45c8a7c7d12e3d3d0
9 changes: 2 additions & 7 deletions Lib/test/test_monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -1798,17 +1798,12 @@ def test_func(recorder):
set_events = sys.monitoring.set_events
line = E.LINE
i = 0
for i in range(601):
for i in range(551):
# Turn on events without branching once i reaches 500.
set_events(TEST_TOOL, line * int(i >= 500))
pass
pass
pass
pass
pass
pass
pass
pass

self.assertEqual(sys.monitoring._all_events(), {})
events = []
Expand All @@ -1819,4 +1814,4 @@ def test_func(recorder):
finally:
sys.monitoring.register_callback(TEST_TOOL, E.LINE, None)
sys.monitoring.set_events(TEST_TOOL, 0)
self.assertGreater(len(events), 1000)
self.assertGreater(len(events), 250)
2 changes: 1 addition & 1 deletion Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
deoptimize:
// On DEOPT_IF we just repeat the last instruction.
// This presumes nothing was popped from the stack (nor pushed).
DPRINTF(2, "DEOPT: [Opcode %d, operand %" PRIu64 "]\n", opcode, operand);
DPRINTF(2, "DEOPT: [Opcode %d, operand %" PRIu64 " @ %ld]\n", opcode, operand, next_uop-current_executor->trace-1);
OPT_HIST(trace_uop_execution_counter, trace_run_length_hist);
UOP_STAT_INC(opcode, miss);
frame->return_offset = 0; // Dispatch to frame->instr_ptr
Expand Down
2 changes: 2 additions & 0 deletions Python/optimizer_analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ remove_unneeded_uops(_PyUOpInstruction *buffer, int buffer_size)
}
else if (opcode == _CHECK_VALIDITY) {
if (maybe_invalid) {
/* Exiting the trace requires that IP is correct */
need_ip = true;
maybe_invalid = false;
}
else {
Expand Down