Lines Matching refs:tstate
45 static void _PyThreadState_Delete(PyThreadState *tstate, int check_current);
178 struct _gilstate_runtime_state *gilstate, PyThreadState* tstate);
209 PyThreadState *tstate = _PyThreadState_GET(); in PyInterpreterState_New() local
212 if (_PySys_Audit(tstate, "cpython.PyInterpreterState_New", NULL) < 0) { in PyInterpreterState_New()
249 if (tstate != NULL) { in PyInterpreterState_New()
250 _PyErr_SetString(tstate, PyExc_RuntimeError, in PyInterpreterState_New()
278 if (tstate != NULL) { in PyInterpreterState_New()
279 _PyErr_NoMemory(tstate); in PyInterpreterState_New()
288 interpreter_clear(PyInterpreterState *interp, PyThreadState *tstate) in interpreter_clear() argument
292 if (_PySys_Audit(tstate, "cpython.PyInterpreterState_Clear", NULL) < 0) { in interpreter_clear()
293 _PyErr_Clear(tstate); in interpreter_clear()
329 _PyGC_CollectNoFail(tstate); in interpreter_clear()
359 _PyInterpreterState_Clear(PyThreadState *tstate) in _PyInterpreterState_Clear() argument
361 interpreter_clear(tstate->interp, tstate); in _PyInterpreterState_Clear()
368 PyThreadState *tstate; in zapthreads() local
371 while ((tstate = interp->tstate_head) != NULL) { in zapthreads()
372 _PyThreadState_Delete(tstate, check_current); in zapthreads()
430 PyThreadState *tstate = _PyThreadState_Swap(gilstate, NULL); in _PyInterpreterState_DeleteExceptMain() local
431 if (tstate != NULL && tstate->interp != interpreters->main) { in _PyInterpreterState_DeleteExceptMain()
460 _PyThreadState_Swap(gilstate, tstate); in _PyInterpreterState_DeleteExceptMain()
469 PyThreadState *tstate = _PyThreadState_GET(); in PyInterpreterState_Get() local
470 _Py_EnsureTstateNotNULL(tstate); in PyInterpreterState_Get()
471 PyInterpreterState *interp = tstate->interp; in PyInterpreterState_Get()
570 PyThreadState *tstate = PyInterpreterState_ThreadHead(interp); in _PyInterpreterState_IDDecref() local
572 PyThreadState *save_tstate = _PyThreadState_Swap(gilstate, tstate); in _PyInterpreterState_IDDecref()
573 Py_EndInterpreter(tstate); in _PyInterpreterState_IDDecref()
617 PyThreadState *tstate = (PyThreadState *)PyMem_RawMalloc(sizeof(PyThreadState)); in new_threadstate() local
618 if (tstate == NULL) { in new_threadstate()
622 tstate->interp = interp; in new_threadstate()
624 tstate->frame = NULL; in new_threadstate()
625 tstate->recursion_depth = 0; in new_threadstate()
626 tstate->recursion_headroom = 0; in new_threadstate()
627 tstate->stackcheck_counter = 0; in new_threadstate()
628 tstate->tracing = 0; in new_threadstate()
629 tstate->root_cframe.use_tracing = 0; in new_threadstate()
630 tstate->cframe = &tstate->root_cframe; in new_threadstate()
631 tstate->gilstate_counter = 0; in new_threadstate()
632 tstate->async_exc = NULL; in new_threadstate()
633 tstate->thread_id = PyThread_get_thread_ident(); in new_threadstate()
635 tstate->dict = NULL; in new_threadstate()
637 tstate->curexc_type = NULL; in new_threadstate()
638 tstate->curexc_value = NULL; in new_threadstate()
639 tstate->curexc_traceback = NULL; in new_threadstate()
641 tstate->exc_state.exc_type = NULL; in new_threadstate()
642 tstate->exc_state.exc_value = NULL; in new_threadstate()
643 tstate->exc_state.exc_traceback = NULL; in new_threadstate()
644 tstate->exc_state.previous_item = NULL; in new_threadstate()
645 tstate->exc_info = &tstate->exc_state; in new_threadstate()
647 tstate->c_profilefunc = NULL; in new_threadstate()
648 tstate->c_tracefunc = NULL; in new_threadstate()
649 tstate->c_profileobj = NULL; in new_threadstate()
650 tstate->c_traceobj = NULL; in new_threadstate()
652 tstate->trash_delete_nesting = 0; in new_threadstate()
653 tstate->trash_delete_later = NULL; in new_threadstate()
654 tstate->on_delete = NULL; in new_threadstate()
655 tstate->on_delete_data = NULL; in new_threadstate()
657 tstate->coroutine_origin_tracking_depth = 0; in new_threadstate()
659 tstate->async_gen_firstiter = NULL; in new_threadstate()
660 tstate->async_gen_finalizer = NULL; in new_threadstate()
662 tstate->context = NULL; in new_threadstate()
663 tstate->context_ver = 1; in new_threadstate()
666 _PyThreadState_Init(tstate); in new_threadstate()
670 tstate->id = ++interp->tstate_next_unique_id; in new_threadstate()
671 tstate->prev = NULL; in new_threadstate()
672 tstate->next = interp->tstate_head; in new_threadstate()
673 if (tstate->next) in new_threadstate()
674 tstate->next->prev = tstate; in new_threadstate()
675 interp->tstate_head = tstate; in new_threadstate()
678 return tstate; in new_threadstate()
694 _PyThreadState_Init(PyThreadState *tstate) in _PyThreadState_Init() argument
696 _PyGILState_NoteThreadState(&tstate->interp->runtime->gilstate, tstate); in _PyThreadState_Init()
719 _PyState_AddModule(PyThreadState *tstate, PyObject* module, struct PyModuleDef* def) in _PyState_AddModule() argument
722 assert(_PyErr_Occurred(tstate)); in _PyState_AddModule()
726 _PyErr_SetString(tstate, in _PyState_AddModule()
732 PyInterpreterState *interp = tstate->interp; in _PyState_AddModule()
759 PyThreadState *tstate = _PyThreadState_GET(); in PyState_AddModule() local
760 PyInterpreterState *interp = tstate->interp; in PyState_AddModule()
769 return _PyState_AddModule(tstate, module, def); in PyState_AddModule()
775 PyThreadState *tstate = _PyThreadState_GET(); in PyState_RemoveModule() local
776 PyInterpreterState *interp = tstate->interp; in PyState_RemoveModule()
779 _PyErr_SetString(tstate, in PyState_RemoveModule()
830 PyThreadState_Clear(PyThreadState *tstate) in PyThreadState_Clear() argument
832 int verbose = _PyInterpreterState_GetConfig(tstate->interp)->verbose; in PyThreadState_Clear()
834 if (verbose && tstate->frame != NULL) { in PyThreadState_Clear()
848 Py_CLEAR(tstate->dict); in PyThreadState_Clear()
849 Py_CLEAR(tstate->async_exc); in PyThreadState_Clear()
851 Py_CLEAR(tstate->curexc_type); in PyThreadState_Clear()
852 Py_CLEAR(tstate->curexc_value); in PyThreadState_Clear()
853 Py_CLEAR(tstate->curexc_traceback); in PyThreadState_Clear()
855 Py_CLEAR(tstate->exc_state.exc_type); in PyThreadState_Clear()
856 Py_CLEAR(tstate->exc_state.exc_value); in PyThreadState_Clear()
857 Py_CLEAR(tstate->exc_state.exc_traceback); in PyThreadState_Clear()
860 if (verbose && tstate->exc_info != &tstate->exc_state) { in PyThreadState_Clear()
865 tstate->c_profilefunc = NULL; in PyThreadState_Clear()
866 tstate->c_tracefunc = NULL; in PyThreadState_Clear()
867 Py_CLEAR(tstate->c_profileobj); in PyThreadState_Clear()
868 Py_CLEAR(tstate->c_traceobj); in PyThreadState_Clear()
870 Py_CLEAR(tstate->async_gen_firstiter); in PyThreadState_Clear()
871 Py_CLEAR(tstate->async_gen_finalizer); in PyThreadState_Clear()
873 Py_CLEAR(tstate->context); in PyThreadState_Clear()
875 if (tstate->on_delete != NULL) { in PyThreadState_Clear()
876 tstate->on_delete(tstate->on_delete_data); in PyThreadState_Clear()
883 tstate_delete_common(PyThreadState *tstate, in tstate_delete_common() argument
886 _Py_EnsureTstateNotNULL(tstate); in tstate_delete_common()
887 PyInterpreterState *interp = tstate->interp; in tstate_delete_common()
894 if (tstate->prev) { in tstate_delete_common()
895 tstate->prev->next = tstate->next; in tstate_delete_common()
898 interp->tstate_head = tstate->next; in tstate_delete_common()
900 if (tstate->next) { in tstate_delete_common()
901 tstate->next->prev = tstate->prev; in tstate_delete_common()
906 PyThread_tss_get(&gilstate->autoTSSkey) == tstate) in tstate_delete_common()
914 _PyThreadState_Delete(PyThreadState *tstate, int check_current) in _PyThreadState_Delete() argument
916 struct _gilstate_runtime_state *gilstate = &tstate->interp->runtime->gilstate; in _PyThreadState_Delete()
918 if (tstate == _PyRuntimeGILState_GetThreadState(gilstate)) { in _PyThreadState_Delete()
919 _Py_FatalErrorFormat(__func__, "tstate %p is still current", tstate); in _PyThreadState_Delete()
922 tstate_delete_common(tstate, gilstate); in _PyThreadState_Delete()
923 PyMem_RawFree(tstate); in _PyThreadState_Delete()
928 PyThreadState_Delete(PyThreadState *tstate) in PyThreadState_Delete() argument
930 _PyThreadState_Delete(tstate, 1); in PyThreadState_Delete()
935 _PyThreadState_DeleteCurrent(PyThreadState *tstate) in _PyThreadState_DeleteCurrent() argument
937 _Py_EnsureTstateNotNULL(tstate); in _PyThreadState_DeleteCurrent()
938 struct _gilstate_runtime_state *gilstate = &tstate->interp->runtime->gilstate; in _PyThreadState_DeleteCurrent()
939 tstate_delete_common(tstate, gilstate); in _PyThreadState_DeleteCurrent()
941 _PyEval_ReleaseLock(tstate); in _PyThreadState_DeleteCurrent()
942 PyMem_RawFree(tstate); in _PyThreadState_DeleteCurrent()
949 PyThreadState *tstate = _PyRuntimeGILState_GetThreadState(gilstate); in PyThreadState_DeleteCurrent() local
950 _PyThreadState_DeleteCurrent(tstate); in PyThreadState_DeleteCurrent()
962 _PyThreadState_DeleteExcept(_PyRuntimeState *runtime, PyThreadState *tstate) in _PyThreadState_DeleteExcept() argument
964 PyInterpreterState *interp = tstate->interp; in _PyThreadState_DeleteExcept()
971 if (list == tstate) { in _PyThreadState_DeleteExcept()
972 list = tstate->next; in _PyThreadState_DeleteExcept()
974 if (tstate->prev) { in _PyThreadState_DeleteExcept()
975 tstate->prev->next = tstate->next; in _PyThreadState_DeleteExcept()
977 if (tstate->next) { in _PyThreadState_DeleteExcept()
978 tstate->next->prev = tstate->prev; in _PyThreadState_DeleteExcept()
980 tstate->prev = tstate->next = NULL; in _PyThreadState_DeleteExcept()
981 interp->tstate_head = tstate; in _PyThreadState_DeleteExcept()
1014 PyThreadState *tstate = _PyThreadState_GET(); in PyThreadState_Get() local
1015 _Py_EnsureTstateNotNULL(tstate); in PyThreadState_Get()
1016 return tstate; in PyThreadState_Get()
1065 _PyThreadState_GetDict(PyThreadState *tstate) in _PyThreadState_GetDict() argument
1067 assert(tstate != NULL); in _PyThreadState_GetDict()
1068 if (tstate->dict == NULL) { in _PyThreadState_GetDict()
1069 tstate->dict = PyDict_New(); in _PyThreadState_GetDict()
1070 if (tstate->dict == NULL) { in _PyThreadState_GetDict()
1071 _PyErr_Clear(tstate); in _PyThreadState_GetDict()
1074 return tstate->dict; in _PyThreadState_GetDict()
1081 PyThreadState *tstate = _PyThreadState_GET(); in PyThreadState_GetDict() local
1082 if (tstate == NULL) { in PyThreadState_GetDict()
1085 return _PyThreadState_GetDict(tstate); in PyThreadState_GetDict()
1090 PyThreadState_GetInterpreter(PyThreadState *tstate) in PyThreadState_GetInterpreter() argument
1092 assert(tstate != NULL); in PyThreadState_GetInterpreter()
1093 return tstate->interp; in PyThreadState_GetInterpreter()
1098 PyThreadState_GetFrame(PyThreadState *tstate) in PyThreadState_GetFrame() argument
1100 assert(tstate != NULL); in PyThreadState_GetFrame()
1101 PyFrameObject *frame = tstate->frame; in PyThreadState_GetFrame()
1108 PyThreadState_GetID(PyThreadState *tstate) in PyThreadState_GetID() argument
1110 assert(tstate != NULL); in PyThreadState_GetID()
1111 return tstate->id; in PyThreadState_GetID()
1136 for (PyThreadState *tstate = interp->tstate_head; tstate != NULL; tstate = tstate->next) { in PyThreadState_SetAsyncExc() local
1137 if (tstate->thread_id != id) { in PyThreadState_SetAsyncExc()
1148 PyObject *old_exc = tstate->async_exc; in PyThreadState_SetAsyncExc()
1150 tstate->async_exc = exc; in PyThreadState_SetAsyncExc()
1154 _PyEval_SignalAsyncExc(tstate->interp); in PyThreadState_SetAsyncExc()
1188 PyThreadState_Next(PyThreadState *tstate) { in PyThreadState_Next() argument
1189 return tstate->next; in PyThreadState_Next()
1200 PyThreadState *tstate = _PyThreadState_GET(); in _PyThread_CurrentFrames() local
1201 if (_PySys_Audit(tstate, "sys._current_frames", NULL) < 0) { in _PyThread_CurrentFrames()
1216 _PyRuntimeState *runtime = tstate->interp->runtime; in _PyThread_CurrentFrames()
1250 PyThreadState *tstate = _PyThreadState_GET(); in _PyThread_CurrentExceptions() local
1252 _Py_EnsureTstateNotNULL(tstate); in _PyThread_CurrentExceptions()
1254 if (_PySys_Audit(tstate, "sys._current_exceptions", NULL) < 0) { in _PyThread_CurrentExceptions()
1269 _PyRuntimeState *runtime = tstate->interp->runtime; in _PyThread_CurrentExceptions()
1321 PyThreadState_IsCurrent(PyThreadState *tstate) in PyThreadState_IsCurrent() argument
1325 assert(_PyGILState_GetThisThreadState(gilstate) == tstate); in PyThreadState_IsCurrent()
1326 return tstate == _PyRuntimeGILState_GetThreadState(gilstate); in PyThreadState_IsCurrent()
1347 _PyGILState_SetTstate(PyThreadState *tstate) in _PyGILState_SetTstate() argument
1349 if (!_Py_IsMainInterpreter(tstate->interp)) { in _PyGILState_SetTstate()
1356 assert(tstate != NULL); in _PyGILState_SetTstate()
1357 assert(tstate->interp != NULL); in _PyGILState_SetTstate()
1359 struct _gilstate_runtime_state *gilstate = &tstate->interp->runtime->gilstate; in _PyGILState_SetTstate()
1361 gilstate->autoInterpreterState = tstate->interp; in _PyGILState_SetTstate()
1363 assert(tstate->gilstate_counter == 0); in _PyGILState_SetTstate()
1365 _PyGILState_NoteThreadState(gilstate, tstate); in _PyGILState_SetTstate()
1392 PyThreadState *tstate = _PyGILState_GetThisThreadState(gilstate); in _PyGILState_Reinit() local
1401 if (tstate && in _PyGILState_Reinit()
1402 PyThread_tss_set(&gilstate->autoTSSkey, (void *)tstate) != 0) in _PyGILState_Reinit()
1416 _PyGILState_NoteThreadState(struct _gilstate_runtime_state *gilstate, PyThreadState* tstate) in _PyGILState_NoteThreadState() argument
1438 if ((PyThread_tss_set(&gilstate->autoTSSkey, (void *)tstate)) != 0) { in _PyGILState_NoteThreadState()
1444 tstate->gilstate_counter = 1; in _PyGILState_NoteThreadState()
1474 PyThreadState *tstate = _PyRuntimeGILState_GetThreadState(gilstate); in PyGILState_Check() local
1475 if (tstate == NULL) { in PyGILState_Check()
1479 return (tstate == _PyGILState_GetThisThreadState(gilstate)); in PyGILState_Check()
1536 PyThreadState *tstate = PyThread_tss_get(&runtime->gilstate.autoTSSkey); in PyGILState_Release() local
1537 if (tstate == NULL) { in PyGILState_Release()
1547 if (!PyThreadState_IsCurrent(tstate)) { in PyGILState_Release()
1550 tstate); in PyGILState_Release()
1552 assert(PyThreadState_IsCurrent(tstate)); in PyGILState_Release()
1553 --tstate->gilstate_counter; in PyGILState_Release()
1554 assert(tstate->gilstate_counter >= 0); /* illegal counter value */ in PyGILState_Release()
1559 if (tstate->gilstate_counter == 0) { in PyGILState_Release()
1562 PyThreadState_Clear(tstate); in PyGILState_Release()
1568 assert(_PyRuntimeGILState_GetThreadState(&runtime->gilstate) == tstate); in PyGILState_Release()
1569 _PyThreadState_DeleteCurrent(tstate); in PyGILState_Release()
1608 _check_xidata(PyThreadState *tstate, _PyCrossInterpreterData *data) in _check_xidata() argument
1615 _PyErr_SetString(tstate, PyExc_SystemError, "missing interp"); in _check_xidata()
1620 _PyErr_SetString(tstate, PyExc_SystemError, "missing new_object func"); in _check_xidata()
1633 PyThreadState *tstate = PyThreadState_Get(); in _PyObject_GetCrossInterpreterData() local
1634 PyInterpreterState *interp = tstate->interp; in _PyObject_GetCrossInterpreterData()
1655 if (_check_xidata(tstate, data) != 0) { in _PyObject_GetCrossInterpreterData()
1685 PyThreadState *tstate = PyInterpreterState_ThreadHead(interp); in _call_in_interpreter() local
1687 save_tstate = _PyThreadState_Swap(gilstate, tstate); in _call_in_interpreter()
1971 PyThreadState *tstate = _PyThreadState_GET(); in _Py_GetConfig() local
1972 return _PyInterpreterState_GetConfig(tstate->interp); in _Py_GetConfig()