@@ -191,7 +191,8 @@ static size_t opcache_global_misses = 0;
191191int
192192PyEval_ThreadsInitialized (void )
193193{
194- return gil_created (& _PyRuntime .ceval .gil );
194+ _PyRuntimeState * runtime = & _PyRuntime ;
195+ return gil_created (& runtime -> ceval .gil );
195196}
196197
197198void
@@ -235,8 +236,9 @@ _PyEval_FiniThreads(struct _ceval_runtime_state *ceval)
235236}
236237
237238static inline void
238- exit_thread_if_finalizing (_PyRuntimeState * runtime , PyThreadState * tstate )
239+ exit_thread_if_finalizing (PyThreadState * tstate )
239240{
241+ _PyRuntimeState * runtime = tstate -> interp -> runtime ;
240242 /* _Py_Finalizing is protected by the GIL */
241243 if (runtime -> finalizing != NULL && !_Py_CURRENTLY_FINALIZING (runtime , tstate )) {
242244 drop_gil (& runtime -> ceval , tstate );
@@ -283,7 +285,7 @@ PyEval_AcquireLock(void)
283285 Py_FatalError ("PyEval_AcquireLock: current thread state is NULL" );
284286 }
285287 take_gil (ceval , tstate );
286- exit_thread_if_finalizing (runtime , tstate );
288+ exit_thread_if_finalizing (tstate );
287289}
288290
289291void
@@ -305,13 +307,13 @@ PyEval_AcquireThread(PyThreadState *tstate)
305307 Py_FatalError ("PyEval_AcquireThread: NULL new thread state" );
306308 }
307309
308- _PyRuntimeState * runtime = & _PyRuntime ;
310+ _PyRuntimeState * runtime = tstate -> interp -> runtime ;
309311 struct _ceval_runtime_state * ceval = & runtime -> ceval ;
310312
311313 /* Check someone has called PyEval_InitThreads() to create the lock */
312314 assert (gil_created (& ceval -> gil ));
313315 take_gil (ceval , tstate );
314- exit_thread_if_finalizing (runtime , tstate );
316+ exit_thread_if_finalizing (tstate );
315317 if (_PyThreadState_Swap (& runtime -> gilstate , tstate ) != NULL ) {
316318 Py_FatalError ("PyEval_AcquireThread: non-NULL old thread state" );
317319 }
@@ -324,7 +326,7 @@ PyEval_ReleaseThread(PyThreadState *tstate)
324326 Py_FatalError ("PyEval_ReleaseThread: NULL thread state" );
325327 }
326328
327- _PyRuntimeState * runtime = & _PyRuntime ;
329+ _PyRuntimeState * runtime = tstate -> interp -> runtime ;
328330 PyThreadState * new_tstate = _PyThreadState_Swap (& runtime -> gilstate , NULL );
329331 if (new_tstate != tstate ) {
330332 Py_FatalError ("PyEval_ReleaseThread: wrong thread state" );
@@ -384,7 +386,7 @@ PyEval_SaveThread(void)
384386void
385387PyEval_RestoreThread (PyThreadState * tstate )
386388{
387- _PyRuntimeState * runtime = & _PyRuntime ;
389+ _PyRuntimeState * runtime = tstate -> interp -> runtime ;
388390 struct _ceval_runtime_state * ceval = & runtime -> ceval ;
389391
390392 if (tstate == NULL ) {
@@ -394,7 +396,7 @@ PyEval_RestoreThread(PyThreadState *tstate)
394396
395397 int err = errno ;
396398 take_gil (ceval , tstate );
397- exit_thread_if_finalizing (runtime , tstate );
399+ exit_thread_if_finalizing (tstate );
398400 errno = err ;
399401
400402 _PyThreadState_Swap (& runtime -> gilstate , tstate );
@@ -649,7 +651,8 @@ _PyEval_Initialize(struct _ceval_runtime_state *state)
649651int
650652Py_GetRecursionLimit (void )
651653{
652- return _PyRuntime .ceval .recursion_limit ;
654+ struct _ceval_runtime_state * ceval = & _PyRuntime .ceval ;
655+ return ceval -> recursion_limit ;
653656}
654657
655658void
@@ -668,7 +671,7 @@ Py_SetRecursionLimit(int new_limit)
668671int
669672_Py_CheckRecursiveCall (PyThreadState * tstate , const char * where )
670673{
671- _PyRuntimeState * runtime = & _PyRuntime ;
674+ _PyRuntimeState * runtime = tstate -> interp -> runtime ;
672675 int recursion_limit = runtime -> ceval .recursion_limit ;
673676
674677#ifdef USE_STACKCHECK
@@ -1245,7 +1248,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
12451248 take_gil (ceval , tstate );
12461249
12471250 /* Check if we should make a quick exit. */
1248- exit_thread_if_finalizing (runtime , tstate );
1251+ exit_thread_if_finalizing (tstate );
12491252
12501253 if (_PyThreadState_Swap (& runtime -> gilstate , tstate ) != NULL ) {
12511254 Py_FatalError ("ceval: orphan tstate" );
@@ -4806,7 +4809,8 @@ _PyEval_GetAsyncGenFinalizer(void)
48064809static PyFrameObject *
48074810_PyEval_GetFrame (PyThreadState * tstate )
48084811{
4809- return _PyRuntime .gilstate .getframe (tstate );
4812+ _PyRuntimeState * runtime = tstate -> interp -> runtime ;
4813+ return runtime -> gilstate .getframe (tstate );
48104814}
48114815
48124816PyFrameObject *
0 commit comments