mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +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
64
Python/generated_cases.c.h
generated
64
Python/generated_cases.c.h
generated
|
@ -4568,32 +4568,8 @@
|
|||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(INSTRUMENTED_LINE) {
|
||||
#line 3292 "Python/bytecodes.c"
|
||||
_Py_CODEUNIT *here = next_instr-1;
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
int original_opcode = _Py_call_instrumentation_line(
|
||||
tstate, frame, here);
|
||||
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);
|
||||
INCREMENT_ADAPTIVE_COUNTER(cache->counter);
|
||||
}
|
||||
opcode = original_opcode;
|
||||
DISPATCH_GOTO();
|
||||
#line 4593 "Python/generated_cases.c.h"
|
||||
}
|
||||
|
||||
TARGET(INSTRUMENTED_INSTRUCTION) {
|
||||
#line 3314 "Python/bytecodes.c"
|
||||
#line 3292 "Python/bytecodes.c"
|
||||
int next_opcode = _Py_call_instrumentation_instruction(
|
||||
tstate, frame, next_instr-1);
|
||||
if (next_opcode < 0) goto error;
|
||||
|
@ -4605,26 +4581,26 @@
|
|||
assert(next_opcode > 0 && next_opcode < 256);
|
||||
opcode = next_opcode;
|
||||
DISPATCH_GOTO();
|
||||
#line 4609 "Python/generated_cases.c.h"
|
||||
#line 4585 "Python/generated_cases.c.h"
|
||||
}
|
||||
|
||||
TARGET(INSTRUMENTED_JUMP_FORWARD) {
|
||||
#line 3328 "Python/bytecodes.c"
|
||||
#line 3306 "Python/bytecodes.c"
|
||||
INSTRUMENTED_JUMP(next_instr-1, next_instr+oparg, PY_MONITORING_EVENT_JUMP);
|
||||
#line 4615 "Python/generated_cases.c.h"
|
||||
#line 4591 "Python/generated_cases.c.h"
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(INSTRUMENTED_JUMP_BACKWARD) {
|
||||
#line 3332 "Python/bytecodes.c"
|
||||
#line 3310 "Python/bytecodes.c"
|
||||
INSTRUMENTED_JUMP(next_instr-1, next_instr-oparg, PY_MONITORING_EVENT_JUMP);
|
||||
#line 4622 "Python/generated_cases.c.h"
|
||||
#line 4598 "Python/generated_cases.c.h"
|
||||
CHECK_EVAL_BREAKER();
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) {
|
||||
#line 3337 "Python/bytecodes.c"
|
||||
#line 3315 "Python/bytecodes.c"
|
||||
PyObject *cond = POP();
|
||||
int err = PyObject_IsTrue(cond);
|
||||
Py_DECREF(cond);
|
||||
|
@ -4633,12 +4609,12 @@
|
|||
assert(err == 0 || err == 1);
|
||||
int offset = err*oparg;
|
||||
INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
|
||||
#line 4637 "Python/generated_cases.c.h"
|
||||
#line 4613 "Python/generated_cases.c.h"
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) {
|
||||
#line 3348 "Python/bytecodes.c"
|
||||
#line 3326 "Python/bytecodes.c"
|
||||
PyObject *cond = POP();
|
||||
int err = PyObject_IsTrue(cond);
|
||||
Py_DECREF(cond);
|
||||
|
@ -4647,12 +4623,12 @@
|
|||
assert(err == 0 || err == 1);
|
||||
int offset = (1-err)*oparg;
|
||||
INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
|
||||
#line 4651 "Python/generated_cases.c.h"
|
||||
#line 4627 "Python/generated_cases.c.h"
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) {
|
||||
#line 3359 "Python/bytecodes.c"
|
||||
#line 3337 "Python/bytecodes.c"
|
||||
PyObject *value = POP();
|
||||
_Py_CODEUNIT *here = next_instr-1;
|
||||
int offset;
|
||||
|
@ -4665,12 +4641,12 @@
|
|||
offset = 0;
|
||||
}
|
||||
INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
|
||||
#line 4669 "Python/generated_cases.c.h"
|
||||
#line 4645 "Python/generated_cases.c.h"
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) {
|
||||
#line 3374 "Python/bytecodes.c"
|
||||
#line 3352 "Python/bytecodes.c"
|
||||
PyObject *value = POP();
|
||||
_Py_CODEUNIT *here = next_instr-1;
|
||||
int offset;
|
||||
|
@ -4683,30 +4659,30 @@
|
|||
offset = oparg;
|
||||
}
|
||||
INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH);
|
||||
#line 4687 "Python/generated_cases.c.h"
|
||||
#line 4663 "Python/generated_cases.c.h"
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(EXTENDED_ARG) {
|
||||
#line 3389 "Python/bytecodes.c"
|
||||
#line 3367 "Python/bytecodes.c"
|
||||
assert(oparg);
|
||||
opcode = next_instr->op.code;
|
||||
oparg = oparg << 8 | next_instr->op.arg;
|
||||
PRE_DISPATCH_GOTO();
|
||||
DISPATCH_GOTO();
|
||||
#line 4698 "Python/generated_cases.c.h"
|
||||
#line 4674 "Python/generated_cases.c.h"
|
||||
}
|
||||
|
||||
TARGET(CACHE) {
|
||||
#line 3397 "Python/bytecodes.c"
|
||||
#line 3375 "Python/bytecodes.c"
|
||||
assert(0 && "Executing a cache.");
|
||||
Py_UNREACHABLE();
|
||||
#line 4705 "Python/generated_cases.c.h"
|
||||
#line 4681 "Python/generated_cases.c.h"
|
||||
}
|
||||
|
||||
TARGET(RESERVED) {
|
||||
#line 3402 "Python/bytecodes.c"
|
||||
#line 3380 "Python/bytecodes.c"
|
||||
assert(0 && "Executing RESERVED instruction.");
|
||||
Py_UNREACHABLE();
|
||||
#line 4712 "Python/generated_cases.c.h"
|
||||
#line 4688 "Python/generated_cases.c.h"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue