diff options
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 9f4b436..ee13fd1 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -191,7 +191,8 @@ static size_t opcache_global_misses = 0; int PyEval_ThreadsInitialized(void) { - return gil_created(&_PyRuntime.ceval.gil); + _PyRuntimeState *runtime = &_PyRuntime; + return gil_created(&runtime->ceval.gil); } void @@ -235,8 +236,9 @@ _PyEval_FiniThreads(struct _ceval_runtime_state *ceval) } static inline void -exit_thread_if_finalizing(_PyRuntimeState *runtime, PyThreadState *tstate) +exit_thread_if_finalizing(PyThreadState *tstate) { + _PyRuntimeState *runtime = tstate->interp->runtime; /* _Py_Finalizing is protected by the GIL */ if (runtime->finalizing != NULL && !_Py_CURRENTLY_FINALIZING(runtime, tstate)) { drop_gil(&runtime->ceval, tstate); @@ -283,7 +285,7 @@ PyEval_AcquireLock(void) Py_FatalError("PyEval_AcquireLock: current thread state is NULL"); } take_gil(ceval, tstate); - exit_thread_if_finalizing(runtime, tstate); + exit_thread_if_finalizing(tstate); } void @@ -305,13 +307,13 @@ PyEval_AcquireThread(PyThreadState *tstate) Py_FatalError("PyEval_AcquireThread: NULL new thread state"); } - _PyRuntimeState *runtime = &_PyRuntime; + _PyRuntimeState *runtime = tstate->interp->runtime; struct _ceval_runtime_state *ceval = &runtime->ceval; /* Check someone has called PyEval_InitThreads() to create the lock */ assert(gil_created(&ceval->gil)); take_gil(ceval, tstate); - exit_thread_if_finalizing(runtime, tstate); + exit_thread_if_finalizing(tstate); if (_PyThreadState_Swap(&runtime->gilstate, tstate) != NULL) { Py_FatalError("PyEval_AcquireThread: non-NULL old thread state"); } @@ -324,7 +326,7 @@ PyEval_ReleaseThread(PyThreadState *tstate) Py_FatalError("PyEval_ReleaseThread: NULL thread state"); } - _PyRuntimeState *runtime = &_PyRuntime; + _PyRuntimeState *runtime = tstate->interp->runtime; PyThreadState *new_tstate = _PyThreadState_Swap(&runtime->gilstate, NULL); if (new_tstate != tstate) { Py_FatalError("PyEval_ReleaseThread: wrong thread state"); @@ -384,7 +386,7 @@ PyEval_SaveThread(void) void PyEval_RestoreThread(PyThreadState *tstate) { - _PyRuntimeState *runtime = &_PyRuntime; + _PyRuntimeState *runtime = tstate->interp->runtime; struct _ceval_runtime_state *ceval = &runtime->ceval; if (tstate == NULL) { @@ -394,7 +396,7 @@ PyEval_RestoreThread(PyThreadState *tstate) int err = errno; take_gil(ceval, tstate); - exit_thread_if_finalizing(runtime, tstate); + exit_thread_if_finalizing(tstate); errno = err; _PyThreadState_Swap(&runtime->gilstate, tstate); @@ -649,7 +651,8 @@ _PyEval_Initialize(struct _ceval_runtime_state *state) int Py_GetRecursionLimit(void) { - return _PyRuntime.ceval.recursion_limit; + struct _ceval_runtime_state *ceval = &_PyRuntime.ceval; + return ceval->recursion_limit; } void @@ -668,7 +671,7 @@ Py_SetRecursionLimit(int new_limit) int _Py_CheckRecursiveCall(PyThreadState *tstate, const char *where) { - _PyRuntimeState *runtime = &_PyRuntime; + _PyRuntimeState *runtime = tstate->interp->runtime; int recursion_limit = runtime->ceval.recursion_limit; #ifdef USE_STACKCHECK @@ -1245,7 +1248,7 @@ main_loop: take_gil(ceval, tstate); /* Check if we should make a quick exit. */ - exit_thread_if_finalizing(runtime, tstate); + exit_thread_if_finalizing(tstate); if (_PyThreadState_Swap(&runtime->gilstate, tstate) != NULL) { Py_FatalError("ceval: orphan tstate"); @@ -4806,7 +4809,8 @@ _PyEval_GetAsyncGenFinalizer(void) static PyFrameObject * _PyEval_GetFrame(PyThreadState *tstate) { - return _PyRuntime.gilstate.getframe(tstate); + _PyRuntimeState *runtime = tstate->interp->runtime; + return runtime->gilstate.getframe(tstate); } PyFrameObject * |