summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2023-09-07 17:23:11 (GMT)
committerGitHub <noreply@github.com>2023-09-07 17:23:11 (GMT)
commit96396962ce7a83c09bac5061121c779ca6b25ef5 (patch)
treebc1d4bbd691a159bf5255a886e4dacbba8821c14 /Python
parent403ab1306a6e9860197bce57eadcb83418966f21 (diff)
downloadcpython-96396962ce7a83c09bac5061121c779ca6b25ef5.zip
cpython-96396962ce7a83c09bac5061121c779ca6b25ef5.tar.gz
cpython-96396962ce7a83c09bac5061121c779ca6b25ef5.tar.bz2
gh-109094: remove unnecessary updates of frame->prev_instr in instrumentation functions (#109076)
Diffstat (limited to 'Python')
-rw-r--r--Python/instrumentation.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/Python/instrumentation.c b/Python/instrumentation.c
index acc3278..74c3adf 100644
--- a/Python/instrumentation.c
+++ b/Python/instrumentation.c
@@ -1057,8 +1057,6 @@ _Py_call_instrumentation_jump(
assert(event == PY_MONITORING_EVENT_JUMP ||
event == PY_MONITORING_EVENT_BRANCH);
assert(frame->prev_instr == instr);
- /* Event should occur after the jump */
- frame->prev_instr = target;
PyCodeObject *code = _PyFrame_GetCode(frame);
int to = (int)(target - _PyCode_CODE(code));
PyObject *to_obj = PyLong_FromLong(to * (int)sizeof(_Py_CODEUNIT));
@@ -1071,12 +1069,10 @@ _Py_call_instrumentation_jump(
if (err) {
return NULL;
}
- if (frame->prev_instr != target) {
+ if (frame->prev_instr != instr) {
/* The callback has caused a jump (by setting the line number) */
return frame->prev_instr;
}
- /* Reset prev_instr for INSTRUMENTED_LINE */
- frame->prev_instr = instr;
return target;
}
@@ -1125,7 +1121,7 @@ _Py_Instrumentation_GetLine(PyCodeObject *code, int index)
int
_Py_call_instrumentation_line(PyThreadState *tstate, _PyInterpreterFrame* frame, _Py_CODEUNIT *instr, _Py_CODEUNIT *prev)
{
- frame->prev_instr = instr;
+ assert(frame->prev_instr == instr);
PyCodeObject *code = _PyFrame_GetCode(frame);
assert(is_version_up_to_date(code, tstate->interp));
assert(instrumentation_cross_checks(tstate->interp, code));