summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2022-05-27 23:38:01 (GMT)
committerGitHub <noreply@github.com>2022-05-27 23:38:01 (GMT)
commitcaa279d6fd5f151e57f891cd4f6ba51b532501c6 (patch)
treec19c87efdefab0b4e4a5291896cfb86e37ec90f2 /Python
parente6a57678cafe18ca132ee9510252168fcc392a8d (diff)
downloadcpython-caa279d6fd5f151e57f891cd4f6ba51b532501c6.zip
cpython-caa279d6fd5f151e57f891cd4f6ba51b532501c6.tar.gz
cpython-caa279d6fd5f151e57f891cd4f6ba51b532501c6.tar.bz2
bpo-40514: Drop EXPERIMENTAL_ISOLATED_SUBINTERPRETERS (gh-93185)
This was added for bpo-40514 (gh-84694) to test out a per-interpreter GIL. However, it has since proven unnecessary to keep the experiment in the repo. (It can be done as a branch in a fork like normal.) So here we are removing: * the configure option * the macro * the code enabled by the macro
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c55
-rw-r--r--Python/ceval_gil.h18
-rw-r--r--Python/preconfig.c10
-rw-r--r--Python/pylifecycle.c2
-rw-r--r--Python/pystate.c17
5 files changed, 0 insertions, 102 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 6158524..fdbf0d4 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -352,21 +352,6 @@ _Py_FatalError_TstateNULL(const char *func)
"(the current Python thread state is NULL)");
}
-#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
-int
-_PyEval_ThreadsInitialized(PyInterpreterState *interp)
-{
- return gil_created(&interp->ceval.gil);
-}
-
-int
-PyEval_ThreadsInitialized(void)
-{
- // Fatal error if there is no current interpreter
- PyInterpreterState *interp = PyInterpreterState_Get();
- return _PyEval_ThreadsInitialized(interp);
-}
-#else
int
_PyEval_ThreadsInitialized(_PyRuntimeState *runtime)
{
@@ -379,25 +364,18 @@ PyEval_ThreadsInitialized(void)
_PyRuntimeState *runtime = &_PyRuntime;
return _PyEval_ThreadsInitialized(runtime);
}
-#endif
PyStatus
_PyEval_InitGIL(PyThreadState *tstate)
{
-#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
if (!_Py_IsMainInterpreter(tstate->interp)) {
/* Currently, the GIL is shared by all interpreters,
and only the main interpreter is responsible to create
and destroy it. */
return _PyStatus_OK();
}
-#endif
-#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
- struct _gil_runtime_state *gil = &tstate->interp->ceval.gil;
-#else
struct _gil_runtime_state *gil = &tstate->interp->runtime->ceval.gil;
-#endif
assert(!gil_created(gil));
PyThread_init_thread();
@@ -412,20 +390,14 @@ _PyEval_InitGIL(PyThreadState *tstate)
void
_PyEval_FiniGIL(PyInterpreterState *interp)
{
-#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
if (!_Py_IsMainInterpreter(interp)) {
/* Currently, the GIL is shared by all interpreters,
and only the main interpreter is responsible to create
and destroy it. */
return;
}
-#endif
-#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
- struct _gil_runtime_state *gil = &interp->ceval.gil;
-#else
struct _gil_runtime_state *gil = &interp->runtime->ceval.gil;
-#endif
if (!gil_created(gil)) {
/* First Py_InitializeFromConfig() call: the GIL doesn't exist
yet: do nothing. */
@@ -489,13 +461,9 @@ PyEval_AcquireThread(PyThreadState *tstate)
take_gil(tstate);
struct _gilstate_runtime_state *gilstate = &tstate->interp->runtime->gilstate;
-#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
- (void)_PyThreadState_Swap(gilstate, tstate);
-#else
if (_PyThreadState_Swap(gilstate, tstate) != NULL) {
Py_FatalError("non-NULL old thread state");
}
-#endif
}
void
@@ -522,11 +490,7 @@ _PyEval_ReInitThreads(PyThreadState *tstate)
{
_PyRuntimeState *runtime = tstate->interp->runtime;
-#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
- struct _gil_runtime_state *gil = &tstate->interp->ceval.gil;
-#else
struct _gil_runtime_state *gil = &runtime->ceval.gil;
-#endif
if (!gil_created(gil)) {
return _PyStatus_OK();
}
@@ -558,21 +522,12 @@ PyThreadState *
PyEval_SaveThread(void)
{
_PyRuntimeState *runtime = &_PyRuntime;
-#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
- PyThreadState *old_tstate = _PyThreadState_GET();
- PyThreadState *tstate = _PyThreadState_Swap(&runtime->gilstate, old_tstate);
-#else
PyThreadState *tstate = _PyThreadState_Swap(&runtime->gilstate, NULL);
-#endif
_Py_EnsureTstateNotNULL(tstate);
struct _ceval_runtime_state *ceval = &runtime->ceval;
struct _ceval_state *ceval2 = &tstate->interp->ceval;
-#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
- assert(gil_created(&ceval2->gil));
-#else
assert(gil_created(&ceval->gil));
-#endif
drop_gil(ceval, ceval2, tstate);
return tstate;
}
@@ -836,9 +791,7 @@ Py_MakePendingCalls(void)
void
_PyEval_InitRuntimeState(struct _ceval_runtime_state *ceval)
{
-#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
_gil_initialize(&ceval->gil);
-#endif
}
void
@@ -848,10 +801,6 @@ _PyEval_InitState(struct _ceval_state *ceval, PyThread_type_lock pending_lock)
assert(pending->lock == NULL);
pending->lock = pending_lock;
-
-#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
- _gil_initialize(&ceval->gil);
-#endif
}
void
@@ -1267,13 +1216,9 @@ eval_frame_handle_pending(PyThreadState *tstate)
take_gil(tstate);
-#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
- (void)_PyThreadState_Swap(&runtime->gilstate, tstate);
-#else
if (_PyThreadState_Swap(&runtime->gilstate, tstate) != NULL) {
Py_FatalError("orphan tstate");
}
-#endif
}
/* Check for asynchronous exception. */
diff --git a/Python/ceval_gil.h b/Python/ceval_gil.h
index 9b8b432..1b2dc7f 100644
--- a/Python/ceval_gil.h
+++ b/Python/ceval_gil.h
@@ -144,11 +144,7 @@ static void
drop_gil(struct _ceval_runtime_state *ceval, struct _ceval_state *ceval2,
PyThreadState *tstate)
{
-#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
- struct _gil_runtime_state *gil = &ceval2->gil;
-#else
struct _gil_runtime_state *gil = &ceval->gil;
-#endif
if (!_Py_atomic_load_relaxed(&gil->locked)) {
Py_FatalError("drop_gil: GIL is not locked");
}
@@ -232,11 +228,7 @@ take_gil(PyThreadState *tstate)
PyInterpreterState *interp = tstate->interp;
struct _ceval_runtime_state *ceval = &interp->runtime->ceval;
struct _ceval_state *ceval2 = &interp->ceval;
-#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
- struct _gil_runtime_state *gil = &ceval2->gil;
-#else
struct _gil_runtime_state *gil = &ceval->gil;
-#endif
/* Check that _PyEval_InitThreads() was called to create the lock */
assert(gil_created(gil));
@@ -328,22 +320,12 @@ _ready:
void _PyEval_SetSwitchInterval(unsigned long microseconds)
{
-#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
- PyInterpreterState *interp = PyInterpreterState_Get();
- struct _gil_runtime_state *gil = &interp->ceval.gil;
-#else
struct _gil_runtime_state *gil = &_PyRuntime.ceval.gil;
-#endif
gil->interval = microseconds;
}
unsigned long _PyEval_GetSwitchInterval()
{
-#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
- PyInterpreterState *interp = PyInterpreterState_Get();
- struct _gil_runtime_state *gil = &interp->ceval.gil;
-#else
struct _gil_runtime_state *gil = &_PyRuntime.ceval.gil;
-#endif
return gil->interval;
}
diff --git a/Python/preconfig.c b/Python/preconfig.c
index e7125cd..c30c758 100644
--- a/Python/preconfig.c
+++ b/Python/preconfig.c
@@ -294,17 +294,7 @@ _PyPreConfig_InitCompatConfig(PyPreConfig *config)
config->coerce_c_locale_warn = 0;
config->dev_mode = -1;
-#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
- /* bpo-40512: pymalloc is not compatible with subinterpreters,
- force usage of libc malloc() which is thread-safe. */
-#ifdef Py_DEBUG
- config->allocator = PYMEM_ALLOCATOR_MALLOC_DEBUG;
-#else
- config->allocator = PYMEM_ALLOCATOR_MALLOC;
-#endif
-#else
config->allocator = PYMEM_ALLOCATOR_NOT_SET;
-#endif
#ifdef MS_WINDOWS
config->legacy_windows_fs_encoding = -1;
#endif
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 42a0581..31a358f 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -1981,12 +1981,10 @@ new_interpreter(PyThreadState **tstate_p, int isolated_subinterpreter)
/* Copy the current interpreter config into the new interpreter */
const PyConfig *config;
-#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
if (save_tstate != NULL) {
config = _PyInterpreterState_GetConfig(save_tstate->interp);
}
else
-#endif
{
/* No current thread state, copy from the main interpreter */
PyInterpreterState *main_interp = _PyInterpreterState_Main();
diff --git a/Python/pystate.c b/Python/pystate.c
index 3e28a6a..df56c05 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -1165,14 +1165,6 @@ _PyThreadState_DeleteExcept(_PyRuntimeState *runtime, PyThreadState *tstate)
}
-#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
-PyThreadState*
-_PyThreadState_GetTSS(void) {
- return PyThread_tss_get(&_PyRuntime.gilstate.autoTSSkey);
-}
-#endif
-
-
PyThreadState *
_PyThreadState_UncheckedGet(void)
{
@@ -1192,11 +1184,7 @@ PyThreadState_Get(void)
PyThreadState *
_PyThreadState_Swap(struct _gilstate_runtime_state *gilstate, PyThreadState *newts)
{
-#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
- PyThreadState *oldts = _PyThreadState_GetTSS();
-#else
PyThreadState *oldts = _PyRuntimeGILState_GetThreadState(gilstate);
-#endif
_PyRuntimeGILState_SetThreadState(gilstate, newts);
/* It should not be possible for more than one thread state
@@ -1215,9 +1203,6 @@ _PyThreadState_Swap(struct _gilstate_runtime_state *gilstate, PyThreadState *new
errno = err;
}
#endif
-#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
- PyThread_tss_set(&gilstate->autoTSSkey, newts);
-#endif
return oldts;
}
@@ -1665,9 +1650,7 @@ PyGILState_Ensure(void)
/* Ensure that _PyEval_InitThreads() and _PyGILState_Init() have been
called by Py_Initialize() */
-#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
assert(_PyEval_ThreadsInitialized(runtime));
-#endif
assert(gilstate->autoInterpreterState);
PyThreadState *tcur = (PyThreadState *)PyThread_tss_get(&gilstate->autoTSSkey);