@@ -143,70 +143,76 @@ is_tstate_valid(PyThreadState *tstate)
143
143
the GIL eventually anyway. */
144
144
static inline void
145
145
COMPUTE_EVAL_BREAKER (PyInterpreterState * interp ,
146
- struct _ceval_state * ceval )
146
+ struct _ceval_runtime_state * ceval ,
147
+ struct _ceval_state * ceval2 )
147
148
{
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 )
150
151
| (_Py_atomic_load_relaxed (& ceval -> signals_pending )
151
152
&& _Py_ThreadCanHandleSignals (interp ))
152
- | (_Py_atomic_load_relaxed (& ceval -> pending .calls_to_do )
153
+ | (_Py_atomic_load_relaxed (& ceval2 -> pending .calls_to_do )
153
154
&& _Py_ThreadCanHandlePendingCalls ())
154
- | ceval -> pending .async_exc );
155
+ | ceval2 -> pending .async_exc );
155
156
}
156
157
157
158
158
159
static inline void
159
160
SET_GIL_DROP_REQUEST (PyInterpreterState * interp )
160
161
{
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 );
164
165
}
165
166
166
167
167
168
static inline void
168
169
RESET_GIL_DROP_REQUEST (PyInterpreterState * interp )
169
170
{
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 );
173
175
}
174
176
175
177
176
178
static inline void
177
179
SIGNAL_PENDING_CALLS (PyInterpreterState * interp )
178
180
{
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 );
182
185
}
183
186
184
187
185
188
static inline void
186
189
UNSIGNAL_PENDING_CALLS (PyInterpreterState * interp )
187
190
{
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 );
191
195
}
192
196
193
197
194
198
static inline void
195
199
SIGNAL_PENDING_SIGNALS (PyInterpreterState * interp )
196
200
{
197
- struct _ceval_state * ceval = & interp -> ceval ;
201
+ struct _ceval_runtime_state * ceval = & interp -> runtime -> ceval ;
202
+ struct _ceval_state * ceval2 = & interp -> ceval ;
198
203
_Py_atomic_store_relaxed (& ceval -> signals_pending , 1 );
199
204
/* 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 );
201
206
}
202
207
203
208
204
209
static inline void
205
210
UNSIGNAL_PENDING_SIGNALS (PyInterpreterState * interp )
206
211
{
207
- struct _ceval_state * ceval = & interp -> ceval ;
212
+ struct _ceval_runtime_state * ceval = & interp -> runtime -> ceval ;
213
+ struct _ceval_state * ceval2 = & interp -> ceval ;
208
214
_Py_atomic_store_relaxed (& ceval -> signals_pending , 0 );
209
- COMPUTE_EVAL_BREAKER (interp , ceval );
215
+ COMPUTE_EVAL_BREAKER (interp , ceval , ceval2 );
210
216
}
211
217
212
218
@@ -222,9 +228,10 @@ SIGNAL_ASYNC_EXC(PyInterpreterState *interp)
222
228
static inline void
223
229
UNSIGNAL_ASYNC_EXC (PyInterpreterState * interp )
224
230
{
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 );
228
235
}
229
236
230
237
@@ -349,11 +356,12 @@ PyEval_ReleaseLock(void)
349
356
{
350
357
_PyRuntimeState * runtime = & _PyRuntime ;
351
358
PyThreadState * tstate = _PyRuntimeState_GetThreadState (runtime );
352
- struct _ceval_state * ceval2 = & tstate -> interp -> ceval ;
353
359
/* This function must succeed when the current thread state is NULL.
354
360
We therefore avoid PyThreadState_Get() which dumps a fatal error
355
361
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 );
357
365
}
358
366
359
367
void
@@ -435,7 +443,6 @@ PyThreadState *
435
443
PyEval_SaveThread (void )
436
444
{
437
445
_PyRuntimeState * runtime = & _PyRuntime ;
438
-
439
446
PyThreadState * tstate = _PyThreadState_Swap (& runtime -> gilstate , NULL );
440
447
ensure_tstate_not_null (__func__ , tstate );
441
448
@@ -831,16 +838,16 @@ eval_frame_handle_pending(PyThreadState *tstate)
831
838
{
832
839
_PyRuntimeState * const runtime = & _PyRuntime ;
833
840
struct _ceval_runtime_state * ceval = & runtime -> ceval ;
834
- struct _ceval_state * ceval2 = & tstate -> interp -> ceval ;
835
841
836
842
/* Pending signals */
837
- if (_Py_atomic_load_relaxed (& ceval2 -> signals_pending )) {
843
+ if (_Py_atomic_load_relaxed (& ceval -> signals_pending )) {
838
844
if (handle_signals (tstate ) != 0 ) {
839
845
return -1 ;
840
846
}
841
847
}
842
848
843
849
/* Pending calls */
850
+ struct _ceval_state * ceval2 = & tstate -> interp -> ceval ;
844
851
if (_Py_atomic_load_relaxed (& ceval2 -> pending .calls_to_do )) {
845
852
if (make_pending_calls (tstate ) != 0 ) {
846
853
return -1 ;
0 commit comments