@@ -136,7 +136,12 @@ dummy_func(
136136 inst (RESUME , (-- )) {
137137 TIER_ONE_ONLY
138138 assert (frame == tstate -> current_frame );
139- if (_PyFrame_GetCode (frame )-> _co_instrumentation_version != tstate -> interp -> monitoring_version ) {
139+ uintptr_t global_version =
140+ _Py_atomic_load_uintptr_relaxed (& tstate -> interp -> ceval .eval_breaker ) &
141+ ~_PY_EVAL_EVENTS_MASK ;
142+ uintptr_t code_version = _PyFrame_GetCode (frame )-> _co_instrumentation_version ;
143+ assert ((code_version & 255 ) == 0 );
144+ if (code_version != global_version ) {
140145 int err = _Py_Instrument (_PyFrame_GetCode (frame ), tstate -> interp );
141146 ERROR_IF (err , error );
142147 next_instr -- ;
@@ -154,17 +159,16 @@ dummy_func(
154159 DEOPT_IF (_Py_emscripten_signal_clock == 0 );
155160 _Py_emscripten_signal_clock -= Py_EMSCRIPTEN_SIGNAL_HANDLING ;
156161#endif
157- /* Possibly combine these two checks */
158- DEOPT_IF (_PyFrame_GetCode (frame )-> _co_instrumentation_version != tstate -> interp -> monitoring_version );
159- DEOPT_IF (_Py_atomic_load_relaxed_int32 (& tstate -> interp -> ceval .eval_breaker ));
162+ uintptr_t eval_breaker = _Py_atomic_load_uintptr_relaxed (& tstate -> interp -> ceval .eval_breaker );
163+ uintptr_t version = _PyFrame_GetCode (frame )-> _co_instrumentation_version ;
164+ assert ((version & _PY_EVAL_EVENTS_MASK ) == 0 );
165+ DEOPT_IF (eval_breaker != version );
160166 }
161167
162168 inst (INSTRUMENTED_RESUME , (-- )) {
163- /* Possible performance enhancement:
164- * We need to check the eval breaker anyway, can we
165- * combine the instrument verison check and the eval breaker test?
166- */
167- if (_PyFrame_GetCode (frame )-> _co_instrumentation_version != tstate -> interp -> monitoring_version ) {
169+ uintptr_t global_version = _Py_atomic_load_uintptr_relaxed (& tstate -> interp -> ceval .eval_breaker ) & ~_PY_EVAL_EVENTS_MASK ;
170+ uintptr_t code_version = _PyFrame_GetCode (frame )-> _co_instrumentation_version ;
171+ if (code_version != global_version ) {
168172 if (_Py_Instrument (_PyFrame_GetCode (frame ), tstate -> interp )) {
169173 goto error ;
170174 }
0 commit comments