Skip to content

GH-96177: Move GIL and some threading code out of ceval.c into gil.c. #96204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Include/internal/pycore_ceval.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ extern struct _PyInterpreterFrame* _PyEval_GetFrame(void);

extern PyObject* _Py_MakeCoro(PyFunctionObject *func);

extern int _Py_HandlePending(PyThreadState *tstate);


#ifdef __cplusplus
}
#endif
Expand Down
7 changes: 4 additions & 3 deletions Include/internal/pycore_pystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,14 @@ _PyThreadState_GET(void)
return _PyRuntimeState_GetThreadState(&_PyRuntime);
}

PyAPI_FUNC(void) _Py_NO_RETURN _Py_FatalError_TstateNULL(const char *func);

static inline void
_Py_EnsureFuncTstateNotNULL(const char *func, PyThreadState *tstate)
{
if (tstate == NULL) {
_Py_FatalError_TstateNULL(func);
_Py_FatalErrorFunc(func,
"the function must be called with the GIL held, "
"after Python initialization and before Python finalization, "
"but the GIL is released (the current Python thread state is NULL)");
}
}

Expand Down
4 changes: 2 additions & 2 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ PYTHON_OBJS= \
Python/getcopyright.o \
Python/getplatform.o \
Python/getversion.o \
Python/ceval_gil.o \
Python/hamt.o \
Python/hashtable.o \
Python/import.o \
Expand Down Expand Up @@ -1419,8 +1420,7 @@ regen-opcode-targets:
$(srcdir)/Python/opcode_targets.h.new
$(UPDATE_FILE) $(srcdir)/Python/opcode_targets.h $(srcdir)/Python/opcode_targets.h.new

Python/ceval.o: $(srcdir)/Python/opcode_targets.h $(srcdir)/Python/ceval_gil.h \
$(srcdir)/Python/condvar.h
Python/ceval.o: $(srcdir)/Python/opcode_targets.h $(srcdir)/Python/condvar.h

Python/frozen.o: $(FROZEN_FILES_OUT)

Expand Down
1 change: 1 addition & 0 deletions PCbuild/_freeze_module.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@
<ClCompile Include="..\Python\getopt.c" />
<ClCompile Include="..\Python\getplatform.c" />
<ClCompile Include="..\Python\getversion.c" />
<ClCompile Include="..\Python\ceval_gil.c" />
<ClCompile Include="..\Python\hamt.c" />
<ClCompile Include="..\Python\hashtable.c" />
<ClCompile Include="..\Python\import.c" />
Expand Down
3 changes: 3 additions & 0 deletions PCbuild/_freeze_module.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@
<ClCompile Include="..\Python\getversion.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\Python\ceval_gil.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\Python\hamt.c">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down
2 changes: 1 addition & 1 deletion PCbuild/pythoncore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@
<ClInclude Include="..\Parser\pegen.h" />
<ClInclude Include="..\PC\errmap.h" />
<ClInclude Include="..\PC\pyconfig.h" />
<ClInclude Include="..\Python\ceval_gil.h" />
<ClInclude Include="..\Python\condvar.h" />
<ClInclude Include="..\Python\importdl.h" />
<ClInclude Include="..\Python\stdlib_module_names.h" />
Expand Down Expand Up @@ -502,6 +501,7 @@
<ClCompile Include="..\Python\getopt.c" />
<ClCompile Include="..\Python\getplatform.c" />
<ClCompile Include="..\Python\getversion.c" />
<ClCompile Include="..\Python\ceval_gil.c" />
<ClCompile Include="..\Python\hamt.c" />
<ClCompile Include="..\Python\hashtable.c" />
<ClCompile Include="..\Python\import.c" />
Expand Down
6 changes: 3 additions & 3 deletions PCbuild/pythoncore.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,6 @@
<ClInclude Include="..\Python\condvar.h">
<Filter>Python</Filter>
</ClInclude>
<ClInclude Include="..\Python\ceval_gil.h">
<Filter>Python</Filter>
</ClInclude>
<ClInclude Include="..\Include\pyhash.h">
<Filter>Include</Filter>
</ClInclude>
Expand Down Expand Up @@ -1097,6 +1094,9 @@
<ClCompile Include="..\Python\getversion.c">
<Filter>Python</Filter>
</ClCompile>
<ClCompile Include="..\Python\ceval_gil.c">
<Filter>Python</Filter>
</ClCompile>
<ClCompile Include="..\Python\hashtable.c">
<Filter>Modules</Filter>
</ClCompile>
Expand Down
Loading