@@ -143,70 +143,76 @@ is_tstate_valid(PyThreadState *tstate)
143143 the GIL eventually anyway. */
144144static inline void
145145COMPUTE_EVAL_BREAKER (PyInterpreterState * interp ,
146- struct _ceval_state * ceval )
146+ struct _ceval_runtime_state * ceval ,
147+ struct _ceval_state * ceval2 )
147148{
148- _Py_atomic_store_relaxed (& ceval -> eval_breaker ,
149- _Py_atomic_load_relaxed (& ceval -> gil_drop_request )
149+ _Py_atomic_store_relaxed (& ceval2 -> eval_breaker ,
150+ _Py_atomic_load_relaxed (& ceval2 -> gil_drop_request )
150151 | (_Py_atomic_load_relaxed (& ceval -> signals_pending )
151152 && _Py_ThreadCanHandleSignals (interp ))
152- | (_Py_atomic_load_relaxed (& ceval -> pending .calls_to_do )
153+ | (_Py_atomic_load_relaxed (& ceval2 -> pending .calls_to_do )
153154 && _Py_ThreadCanHandlePendingCalls ())
154- | ceval -> pending .async_exc );
155+ | ceval2 -> pending .async_exc );
155156}
156157
157158
158159static inline void
159160SET_GIL_DROP_REQUEST (PyInterpreterState * interp )
160161{
161- struct _ceval_state * ceval = & interp -> ceval ;
162- _Py_atomic_store_relaxed (& ceval -> gil_drop_request , 1 );
163- _Py_atomic_store_relaxed (& ceval -> eval_breaker , 1 );
162+ struct _ceval_state * ceval2 = & interp -> ceval ;
163+ _Py_atomic_store_relaxed (& ceval2 -> gil_drop_request , 1 );
164+ _Py_atomic_store_relaxed (& ceval2 -> eval_breaker , 1 );
164165}
165166
166167
167168static inline void
168169RESET_GIL_DROP_REQUEST (PyInterpreterState * interp )
169170{
170- struct _ceval_state * ceval = & interp -> ceval ;
171- _Py_atomic_store_relaxed (& ceval -> gil_drop_request , 0 );
172- COMPUTE_EVAL_BREAKER (interp , ceval );
171+ struct _ceval_runtime_state * ceval = & interp -> runtime -> ceval ;
172+ struct _ceval_state * ceval2 = & interp -> ceval ;
173+ _Py_atomic_store_relaxed (& ceval2 -> gil_drop_request , 0 );
174+ COMPUTE_EVAL_BREAKER (interp , ceval , ceval2 );
173175}
174176
175177
176178static inline void
177179SIGNAL_PENDING_CALLS (PyInterpreterState * interp )
178180{
179- struct _ceval_state * ceval = & interp -> ceval ;
180- _Py_atomic_store_relaxed (& ceval -> pending .calls_to_do , 1 );
181- COMPUTE_EVAL_BREAKER (interp , ceval );
181+ struct _ceval_runtime_state * ceval = & interp -> runtime -> ceval ;
182+ struct _ceval_state * ceval2 = & interp -> ceval ;
183+ _Py_atomic_store_relaxed (& ceval2 -> pending .calls_to_do , 1 );
184+ COMPUTE_EVAL_BREAKER (interp , ceval , ceval2 );
182185}
183186
184187
185188static inline void
186189UNSIGNAL_PENDING_CALLS (PyInterpreterState * interp )
187190{
188- struct _ceval_state * ceval = & interp -> ceval ;
189- _Py_atomic_store_relaxed (& ceval -> pending .calls_to_do , 0 );
190- COMPUTE_EVAL_BREAKER (interp , ceval );
191+ struct _ceval_runtime_state * ceval = & interp -> runtime -> ceval ;
192+ struct _ceval_state * ceval2 = & interp -> ceval ;
193+ _Py_atomic_store_relaxed (& ceval2 -> pending .calls_to_do , 0 );
194+ COMPUTE_EVAL_BREAKER (interp , ceval , ceval2 );
191195}
192196
193197
194198static inline void
195199SIGNAL_PENDING_SIGNALS (PyInterpreterState * interp )
196200{
197- struct _ceval_state * ceval = & interp -> ceval ;
201+ struct _ceval_runtime_state * ceval = & interp -> runtime -> ceval ;
202+ struct _ceval_state * ceval2 = & interp -> ceval ;
198203 _Py_atomic_store_relaxed (& ceval -> signals_pending , 1 );
199204 /* eval_breaker is not set to 1 if thread_can_handle_signals() is false */
200- COMPUTE_EVAL_BREAKER (interp , ceval );
205+ COMPUTE_EVAL_BREAKER (interp , ceval , ceval2 );
201206}
202207
203208
204209static inline void
205210UNSIGNAL_PENDING_SIGNALS (PyInterpreterState * interp )
206211{
207- struct _ceval_state * ceval = & interp -> ceval ;
212+ struct _ceval_runtime_state * ceval = & interp -> runtime -> ceval ;
213+ struct _ceval_state * ceval2 = & interp -> ceval ;
208214 _Py_atomic_store_relaxed (& ceval -> signals_pending , 0 );
209- COMPUTE_EVAL_BREAKER (interp , ceval );
215+ COMPUTE_EVAL_BREAKER (interp , ceval , ceval2 );
210216}
211217
212218
@@ -222,9 +228,10 @@ SIGNAL_ASYNC_EXC(PyInterpreterState *interp)
222228static inline void
223229UNSIGNAL_ASYNC_EXC (PyInterpreterState * interp )
224230{
225- struct _ceval_state * ceval = & interp -> ceval ;
226- ceval -> pending .async_exc = 0 ;
227- COMPUTE_EVAL_BREAKER (interp , ceval );
231+ struct _ceval_runtime_state * ceval = & interp -> runtime -> ceval ;
232+ struct _ceval_state * ceval2 = & interp -> ceval ;
233+ ceval2 -> pending .async_exc = 0 ;
234+ COMPUTE_EVAL_BREAKER (interp , ceval , ceval2 );
228235}
229236
230237
@@ -349,11 +356,12 @@ PyEval_ReleaseLock(void)
349356{
350357 _PyRuntimeState * runtime = & _PyRuntime ;
351358 PyThreadState * tstate = _PyRuntimeState_GetThreadState (runtime );
352- struct _ceval_state * ceval2 = & tstate -> interp -> ceval ;
353359 /* This function must succeed when the current thread state is NULL.
354360 We therefore avoid PyThreadState_Get() which dumps a fatal error
355361 in debug mode. */
356- drop_gil (& runtime -> ceval , ceval2 , tstate );
362+ struct _ceval_runtime_state * ceval = & runtime -> ceval ;
363+ struct _ceval_state * ceval2 = & tstate -> interp -> ceval ;
364+ drop_gil (ceval , ceval2 , tstate );
357365}
358366
359367void
@@ -435,7 +443,6 @@ PyThreadState *
435443PyEval_SaveThread (void )
436444{
437445 _PyRuntimeState * runtime = & _PyRuntime ;
438-
439446 PyThreadState * tstate = _PyThreadState_Swap (& runtime -> gilstate , NULL );
440447 ensure_tstate_not_null (__func__ , tstate );
441448
@@ -831,16 +838,16 @@ eval_frame_handle_pending(PyThreadState *tstate)
831838{
832839 _PyRuntimeState * const runtime = & _PyRuntime ;
833840 struct _ceval_runtime_state * ceval = & runtime -> ceval ;
834- struct _ceval_state * ceval2 = & tstate -> interp -> ceval ;
835841
836842 /* Pending signals */
837- if (_Py_atomic_load_relaxed (& ceval2 -> signals_pending )) {
843+ if (_Py_atomic_load_relaxed (& ceval -> signals_pending )) {
838844 if (handle_signals (tstate ) != 0 ) {
839845 return -1 ;
840846 }
841847 }
842848
843849 /* Pending calls */
850+ struct _ceval_state * ceval2 = & tstate -> interp -> ceval ;
844851 if (_Py_atomic_load_relaxed (& ceval2 -> pending .calls_to_do )) {
845852 if (make_pending_calls (tstate ) != 0 ) {
846853 return -1 ;
0 commit comments