summaryrefslogtreecommitdiffstats
path: root/Python/generated_cases.c.h
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2023-10-04 15:09:48 (GMT)
committerGitHub <noreply@github.com>2023-10-04 15:09:48 (GMT)
commitbf4bc36069ef1ed4be4be2ae70404f78bff056d9 (patch)
tree1921d692061fdc40d967f1f7b6defa6bb7a01bc4 /Python/generated_cases.c.h
parent7c149a76b2bf4c66bb7c8650ffb71acce12f5ea2 (diff)
downloadcpython-bf4bc36069ef1ed4be4be2ae70404f78bff056d9.zip
cpython-bf4bc36069ef1ed4be4be2ae70404f78bff056d9.tar.gz
cpython-bf4bc36069ef1ed4be4be2ae70404f78bff056d9.tar.bz2
GH-109369: Merge all eval-breaker flags and monitoring version into one word. (GH-109846)
Diffstat (limited to 'Python/generated_cases.c.h')
-rw-r--r--Python/generated_cases.c.h22
1 files changed, 13 insertions, 9 deletions
diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h
index 51e3937..221d477 100644
--- a/Python/generated_cases.c.h
+++ b/Python/generated_cases.c.h
@@ -12,7 +12,12 @@
static_assert(0 == 0, "incorrect cache size");
TIER_ONE_ONLY
assert(frame == tstate->current_frame);
- if (_PyFrame_GetCode(frame)->_co_instrumentation_version != tstate->interp->monitoring_version) {
+ uintptr_t global_version =
+ _Py_atomic_load_uintptr_relaxed(&tstate->interp->ceval.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--;
@@ -31,18 +36,17 @@
DEOPT_IF(_Py_emscripten_signal_clock == 0, RESUME);
_Py_emscripten_signal_clock -= Py_EMSCRIPTEN_SIGNAL_HANDLING;
#endif
- /* Possibly combine these two checks */
- DEOPT_IF(_PyFrame_GetCode(frame)->_co_instrumentation_version != tstate->interp->monitoring_version, RESUME);
- DEOPT_IF(_Py_atomic_load_relaxed_int32(&tstate->interp->ceval.eval_breaker), RESUME);
+ uintptr_t eval_breaker = _Py_atomic_load_uintptr_relaxed(&tstate->interp->ceval.eval_breaker);
+ uintptr_t version = _PyFrame_GetCode(frame)->_co_instrumentation_version;
+ assert((version & _PY_EVAL_EVENTS_MASK) == 0);
+ DEOPT_IF(eval_breaker != version, RESUME);
DISPATCH();
}
TARGET(INSTRUMENTED_RESUME) {
- /* Possible performance enhancement:
- * We need to check the eval breaker anyway, can we
- * combine the instrument verison check and the eval breaker test?
- */
- if (_PyFrame_GetCode(frame)->_co_instrumentation_version != tstate->interp->monitoring_version) {
+ uintptr_t global_version = _Py_atomic_load_uintptr_relaxed(&tstate->interp->ceval.eval_breaker) & ~_PY_EVAL_EVENTS_MASK;
+ uintptr_t code_version = _PyFrame_GetCode(frame)->_co_instrumentation_version;
+ if (code_version != global_version) {
if (_Py_Instrument(_PyFrame_GetCode(frame), tstate->interp)) {
goto error;
}