@@ -143,77 +143,70 @@ 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_runtime_state * ceval ,
147
- struct _ceval_state * ceval2 )
146
+ struct _ceval_state * ceval )
148
147
{
149
- _Py_atomic_store_relaxed (& ceval2 -> eval_breaker ,
148
+ _Py_atomic_store_relaxed (& ceval -> eval_breaker ,
150
149
_Py_atomic_load_relaxed (& ceval -> gil_drop_request )
151
- | (_Py_atomic_load_relaxed (& ceval2 -> signals_pending )
150
+ | (_Py_atomic_load_relaxed (& ceval -> signals_pending )
152
151
&& _Py_ThreadCanHandleSignals (interp ))
153
- | (_Py_atomic_load_relaxed (& ceval2 -> pending .calls_to_do )
152
+ | (_Py_atomic_load_relaxed (& ceval -> pending .calls_to_do )
154
153
&& _Py_ThreadCanHandlePendingCalls ())
155
- | ceval2 -> pending .async_exc );
154
+ | ceval -> pending .async_exc );
156
155
}
157
156
158
157
159
158
static inline void
160
159
SET_GIL_DROP_REQUEST (PyInterpreterState * interp )
161
160
{
162
- struct _ceval_runtime_state * ceval = & interp -> runtime -> ceval ;
163
- struct _ceval_state * ceval2 = & interp -> ceval ;
161
+ struct _ceval_state * ceval = & interp -> ceval ;
164
162
_Py_atomic_store_relaxed (& ceval -> gil_drop_request , 1 );
165
- _Py_atomic_store_relaxed (& ceval2 -> eval_breaker , 1 );
163
+ _Py_atomic_store_relaxed (& ceval -> eval_breaker , 1 );
166
164
}
167
165
168
166
169
167
static inline void
170
168
RESET_GIL_DROP_REQUEST (PyInterpreterState * interp )
171
169
{
172
- struct _ceval_runtime_state * ceval = & interp -> runtime -> ceval ;
173
- struct _ceval_state * ceval2 = & interp -> ceval ;
170
+ struct _ceval_state * ceval = & interp -> ceval ;
174
171
_Py_atomic_store_relaxed (& ceval -> gil_drop_request , 0 );
175
- COMPUTE_EVAL_BREAKER (interp , ceval , ceval2 );
172
+ COMPUTE_EVAL_BREAKER (interp , ceval );
176
173
}
177
174
178
175
179
176
static inline void
180
177
SIGNAL_PENDING_CALLS (PyInterpreterState * interp )
181
178
{
182
- struct _ceval_runtime_state * ceval = & interp -> runtime -> ceval ;
183
- struct _ceval_state * ceval2 = & interp -> ceval ;
184
- _Py_atomic_store_relaxed (& ceval2 -> pending .calls_to_do , 1 );
185
- COMPUTE_EVAL_BREAKER (interp , ceval , ceval2 );
179
+ struct _ceval_state * ceval = & interp -> ceval ;
180
+ _Py_atomic_store_relaxed (& ceval -> pending .calls_to_do , 1 );
181
+ COMPUTE_EVAL_BREAKER (interp , ceval );
186
182
}
187
183
188
184
189
185
static inline void
190
186
UNSIGNAL_PENDING_CALLS (PyInterpreterState * interp )
191
187
{
192
- struct _ceval_runtime_state * ceval = & interp -> runtime -> ceval ;
193
- struct _ceval_state * ceval2 = & interp -> ceval ;
194
- _Py_atomic_store_relaxed (& ceval2 -> pending .calls_to_do , 0 );
195
- COMPUTE_EVAL_BREAKER (interp , ceval , ceval2 );
188
+ struct _ceval_state * ceval = & interp -> ceval ;
189
+ _Py_atomic_store_relaxed (& ceval -> pending .calls_to_do , 0 );
190
+ COMPUTE_EVAL_BREAKER (interp , ceval );
196
191
}
197
192
198
193
199
194
static inline void
200
195
SIGNAL_PENDING_SIGNALS (PyInterpreterState * interp )
201
196
{
202
- struct _ceval_runtime_state * ceval = & interp -> runtime -> ceval ;
203
- struct _ceval_state * ceval2 = & interp -> ceval ;
204
- _Py_atomic_store_relaxed (& ceval2 -> signals_pending , 1 );
197
+ struct _ceval_state * ceval = & interp -> ceval ;
198
+ _Py_atomic_store_relaxed (& ceval -> signals_pending , 1 );
205
199
/* eval_breaker is not set to 1 if thread_can_handle_signals() is false */
206
- COMPUTE_EVAL_BREAKER (interp , ceval , ceval2 );
200
+ COMPUTE_EVAL_BREAKER (interp , ceval );
207
201
}
208
202
209
203
210
204
static inline void
211
205
UNSIGNAL_PENDING_SIGNALS (PyInterpreterState * interp )
212
206
{
213
- struct _ceval_runtime_state * ceval = & interp -> runtime -> ceval ;
214
- struct _ceval_state * ceval2 = & interp -> ceval ;
215
- _Py_atomic_store_relaxed (& ceval2 -> signals_pending , 0 );
216
- COMPUTE_EVAL_BREAKER (interp , ceval , ceval2 );
207
+ struct _ceval_state * ceval = & interp -> ceval ;
208
+ _Py_atomic_store_relaxed (& ceval -> signals_pending , 0 );
209
+ COMPUTE_EVAL_BREAKER (interp , ceval );
217
210
}
218
211
219
212
@@ -229,10 +222,9 @@ SIGNAL_ASYNC_EXC(PyInterpreterState *interp)
229
222
static inline void
230
223
UNSIGNAL_ASYNC_EXC (PyInterpreterState * interp )
231
224
{
232
- struct _ceval_runtime_state * ceval = & interp -> runtime -> ceval ;
233
- struct _ceval_state * ceval2 = & interp -> ceval ;
234
- ceval2 -> pending .async_exc = 0 ;
235
- COMPUTE_EVAL_BREAKER (interp , ceval , ceval2 );
225
+ struct _ceval_state * ceval = & interp -> ceval ;
226
+ ceval -> pending .async_exc = 0 ;
227
+ COMPUTE_EVAL_BREAKER (interp , ceval );
236
228
}
237
229
238
230
@@ -357,17 +349,19 @@ PyEval_ReleaseLock(void)
357
349
{
358
350
_PyRuntimeState * runtime = & _PyRuntime ;
359
351
PyThreadState * tstate = _PyRuntimeState_GetThreadState (runtime );
352
+ struct _ceval_state * ceval2 = & tstate -> interp -> ceval ;
360
353
/* This function must succeed when the current thread state is NULL.
361
354
We therefore avoid PyThreadState_Get() which dumps a fatal error
362
355
in debug mode. */
363
- drop_gil (& runtime -> ceval , tstate );
356
+ drop_gil (& runtime -> ceval , ceval2 , tstate );
364
357
}
365
358
366
359
void
367
360
_PyEval_ReleaseLock (PyThreadState * tstate )
368
361
{
369
362
struct _ceval_runtime_state * ceval = & tstate -> interp -> runtime -> ceval ;
370
- drop_gil (ceval , tstate );
363
+ struct _ceval_state * ceval2 = & tstate -> interp -> ceval ;
364
+ drop_gil (ceval , ceval2 , tstate );
371
365
}
372
366
373
367
void
@@ -393,7 +387,9 @@ PyEval_ReleaseThread(PyThreadState *tstate)
393
387
if (new_tstate != tstate ) {
394
388
Py_FatalError ("wrong thread state" );
395
389
}
396
- drop_gil (& runtime -> ceval , tstate );
390
+ struct _ceval_runtime_state * ceval = & runtime -> ceval ;
391
+ struct _ceval_state * ceval2 = & tstate -> interp -> ceval ;
392
+ drop_gil (ceval , ceval2 , tstate );
397
393
}
398
394
399
395
#ifdef HAVE_FORK
@@ -439,13 +435,14 @@ PyThreadState *
439
435
PyEval_SaveThread (void )
440
436
{
441
437
_PyRuntimeState * runtime = & _PyRuntime ;
442
- struct _ceval_runtime_state * ceval = & runtime -> ceval ;
443
438
444
439
PyThreadState * tstate = _PyThreadState_Swap (& runtime -> gilstate , NULL );
445
440
ensure_tstate_not_null (__func__ , tstate );
446
441
442
+ struct _ceval_runtime_state * ceval = & runtime -> ceval ;
443
+ struct _ceval_state * ceval2 = & tstate -> interp -> ceval ;
447
444
assert (gil_created (& ceval -> gil ));
448
- drop_gil (ceval , tstate );
445
+ drop_gil (ceval , ceval2 , tstate );
449
446
return tstate ;
450
447
}
451
448
@@ -847,12 +844,12 @@ eval_frame_handle_pending(PyThreadState *tstate)
847
844
}
848
845
849
846
/* GIL drop request */
850
- if (_Py_atomic_load_relaxed (& ceval -> gil_drop_request )) {
847
+ if (_Py_atomic_load_relaxed (& ceval2 -> gil_drop_request )) {
851
848
/* Give another thread a chance */
852
849
if (_PyThreadState_Swap (& runtime -> gilstate , NULL ) != tstate ) {
853
850
Py_FatalError ("tstate mix-up" );
854
851
}
855
- drop_gil (ceval , tstate );
852
+ drop_gil (ceval , ceval2 , tstate );
856
853
857
854
/* Other threads may run now */
858
855
0 commit comments