mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
GH-103082: Filter LINE events in VM, to simplify tool implementation. (GH-104387)
When monitoring LINE events, instrument all instructions that can have a predecessor on a different line. Then check that the a new line has been hit in the instrumentation code. This brings the behavior closer to that of 3.11, simplifying implementation and porting of tools.
This commit is contained in:
parent
19ee53d52e
commit
45f5aa8fc7
16 changed files with 255 additions and 161 deletions
|
@ -775,6 +775,41 @@ handle_eval_breaker:
|
|||
|
||||
#include "generated_cases.c.h"
|
||||
|
||||
/* INSTRUMENTED_LINE has to be here, rather than in bytecodes.c,
|
||||
* because it needs to capture frame->prev_instr before it is updated,
|
||||
* as happens in the standard instruction prologue.
|
||||
*/
|
||||
#if USE_COMPUTED_GOTOS
|
||||
TARGET_INSTRUMENTED_LINE:
|
||||
#else
|
||||
case INSTRUMENTED_LINE:
|
||||
#endif
|
||||
{
|
||||
_Py_CODEUNIT *prev = frame->prev_instr;
|
||||
_Py_CODEUNIT *here = frame->prev_instr = next_instr;
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
int original_opcode = _Py_call_instrumentation_line(
|
||||
tstate, frame, here, prev);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
if (original_opcode < 0) {
|
||||
next_instr = here+1;
|
||||
goto error;
|
||||
}
|
||||
next_instr = frame->prev_instr;
|
||||
if (next_instr != here) {
|
||||
DISPATCH();
|
||||
}
|
||||
if (_PyOpcode_Caches[original_opcode]) {
|
||||
_PyBinaryOpCache *cache = (_PyBinaryOpCache *)(next_instr+1);
|
||||
/* Prevent the underlying instruction from specializing
|
||||
* and overwriting the instrumentation. */
|
||||
INCREMENT_ADAPTIVE_COUNTER(cache->counter);
|
||||
}
|
||||
opcode = original_opcode;
|
||||
DISPATCH_GOTO();
|
||||
}
|
||||
|
||||
|
||||
#if USE_COMPUTED_GOTOS
|
||||
_unknown_opcode:
|
||||
#else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue