aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/generated_cases.c.h
diff options
context:
space:
mode:
authorTian Gao <gaogaotiantian@hotmail.com>2024-02-28 07:21:42 -0800
committerGitHub <noreply@github.com>2024-02-28 15:21:42 +0000
commit0a61e237009bf6b833e13ac635299ee063377699 (patch)
tree3f4b945c0e65971740f7a0a3b4d38c2624bcd9a7 /Python/generated_cases.c.h
parent9578288a3e5a7f42d1f3bec139c0c85b87775c90 (diff)
downloadcpython-0a61e237009bf6b833e13ac635299ee063377699.tar.gz
cpython-0a61e237009bf6b833e13ac635299ee063377699.zip
gh-107674: Improve performance of `sys.settrace` (GH-114986)
Diffstat (limited to 'Python/generated_cases.c.h')
-rw-r--r--Python/generated_cases.c.h33
1 files changed, 17 insertions, 16 deletions
diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h
index 8b90e448a7b..bb26dac0e2b 100644
--- a/Python/generated_cases.c.h
+++ b/Python/generated_cases.c.h
@@ -3125,7 +3125,7 @@
INSTRUCTION_STATS(INSTRUMENTED_RESUME);
uintptr_t global_version = _Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker) & ~_PY_EVAL_EVENTS_MASK;
uintptr_t code_version = _PyFrame_GetCode(frame)->_co_instrumentation_version;
- if (code_version != global_version) {
+ if (code_version != global_version && tstate->tracing == 0) {
if (_Py_Instrument(_PyFrame_GetCode(frame), tstate->interp)) {
GOTO_ERROR(error);
}
@@ -4780,22 +4780,23 @@
PREDICTED(RESUME);
_Py_CODEUNIT *this_instr = next_instr - 1;
assert(frame == tstate->current_frame);
- uintptr_t global_version =
- _Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker) &
- ~_PY_EVAL_EVENTS_MASK;
- uintptr_t code_version = _PyFrame_GetCode(frame)->_co_instrumentation_version;
- assert((code_version & 255) == 0);
- if (code_version != global_version) {
- int err = _Py_Instrument(_PyFrame_GetCode(frame), tstate->interp);
- if (err) goto error;
- next_instr = this_instr;
- }
- else {
- if ((oparg & RESUME_OPARG_LOCATION_MASK) < RESUME_AFTER_YIELD_FROM) {
- CHECK_EVAL_BREAKER();
+ if (tstate->tracing == 0) {
+ uintptr_t global_version =
+ _Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker) &
+ ~_PY_EVAL_EVENTS_MASK;
+ uintptr_t code_version = _PyFrame_GetCode(frame)->_co_instrumentation_version;
+ assert((code_version & 255) == 0);
+ if (code_version != global_version) {
+ int err = _Py_Instrument(_PyFrame_GetCode(frame), tstate->interp);
+ if (err) goto error;
+ next_instr = this_instr;
+ DISPATCH();
}
- this_instr->op.code = RESUME_CHECK;
}
+ if ((oparg & RESUME_OPARG_LOCATION_MASK) < RESUME_AFTER_YIELD_FROM) {
+ CHECK_EVAL_BREAKER();
+ }
+ this_instr->op.code = RESUME_CHECK;
DISPATCH();
}
@@ -4811,7 +4812,7 @@
uintptr_t eval_breaker = _Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker);
uintptr_t version = _PyFrame_GetCode(frame)->_co_instrumentation_version;
assert((version & _PY_EVAL_EVENTS_MASK) == 0);
- DEOPT_IF(eval_breaker != version, RESUME);
+ DEOPT_IF(eval_breaker != version && tstate->tracing == 0, RESUME);
DISPATCH();
}