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
This commit is contained in:
Eric Snow 2022-05-27 17:38:01 -06:00 committed by GitHub
parent e6a57678ca
commit caa279d6fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 9 additions and 233 deletions

View File

@ -115,6 +115,10 @@ Removed
(Contributed by Erlend E. Aasland in :gh:`92548`) (Contributed by Erlend E. Aasland in :gh:`92548`)
* The ``--experimental-isolated-subinterpreters`` configure flag
(and corresponding ``EXPERIMENTAL_ISOLATED_SUBINTERPRETERS``)
have been removed.
Porting to Python 3.12 Porting to Python 3.12
====================== ======================

View File

@ -81,11 +81,7 @@ _PyEval_Vector(PyThreadState *tstate,
PyObject* const* args, size_t argcount, PyObject* const* args, size_t argcount,
PyObject *kwnames); PyObject *kwnames);
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
extern int _PyEval_ThreadsInitialized(PyInterpreterState *interp);
#else
extern int _PyEval_ThreadsInitialized(struct pyruntimestate *runtime); extern int _PyEval_ThreadsInitialized(struct pyruntimestate *runtime);
#endif
extern PyStatus _PyEval_InitGIL(PyThreadState *tstate); extern PyStatus _PyEval_InitGIL(PyThreadState *tstate);
extern void _PyEval_FiniGIL(PyInterpreterState *interp); extern void _PyEval_FiniGIL(PyInterpreterState *interp);

View File

@ -51,9 +51,6 @@ struct _ceval_state {
/* Request for dropping the GIL */ /* Request for dropping the GIL */
_Py_atomic_int gil_drop_request; _Py_atomic_int gil_drop_request;
struct _pending_calls pending; struct _pending_calls pending;
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
struct _gil_runtime_state gil;
#endif
}; };

View File

@ -64,18 +64,10 @@ _Py_ThreadCanHandlePendingCalls(void)
/* Variable and macro for in-line access to current thread /* Variable and macro for in-line access to current thread
and interpreter state */ and interpreter state */
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
PyAPI_FUNC(PyThreadState*) _PyThreadState_GetTSS(void);
#endif
static inline PyThreadState* static inline PyThreadState*
_PyRuntimeState_GetThreadState(_PyRuntimeState *runtime) _PyRuntimeState_GetThreadState(_PyRuntimeState *runtime)
{ {
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
return _PyThreadState_GetTSS();
#else
return (PyThreadState*)_Py_atomic_load_relaxed(&runtime->gilstate.tstate_current); return (PyThreadState*)_Py_atomic_load_relaxed(&runtime->gilstate.tstate_current);
#endif
} }
/* Get the current Python thread state. /* Get the current Python thread state.
@ -90,11 +82,7 @@ _PyRuntimeState_GetThreadState(_PyRuntimeState *runtime)
static inline PyThreadState* static inline PyThreadState*
_PyThreadState_GET(void) _PyThreadState_GET(void)
{ {
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
return _PyThreadState_GetTSS();
#else
return _PyRuntimeState_GetThreadState(&_PyRuntime); return _PyRuntimeState_GetThreadState(&_PyRuntime);
#endif
} }
PyAPI_FUNC(void) _Py_NO_RETURN _Py_FatalError_TstateNULL(const char *func); PyAPI_FUNC(void) _Py_NO_RETURN _Py_FatalError_TstateNULL(const char *func);

View File

@ -23,9 +23,7 @@ struct _ceval_runtime_state {
the main thread of the main interpreter can handle signals: see the main thread of the main interpreter can handle signals: see
_Py_ThreadCanHandleSignals(). */ _Py_ThreadCanHandleSignals(). */
_Py_atomic_int signals_pending; _Py_atomic_int signals_pending;
#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
struct _gil_runtime_state gil; struct _gil_runtime_state gil;
#endif
}; };
/* GIL state */ /* GIL state */

View File

@ -0,0 +1,2 @@
The ``--experimental-isolated-subinterpreters`` configure option and
``EXPERIMENTAL_ISOLATED_SUBINTERPRETERS`` macro have been removed.

View File

@ -1932,20 +1932,6 @@ _run_script_in_interpreter(PyInterpreterState *interp, const char *codestr,
return -1; return -1;
} }
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
// Switch to interpreter.
PyThreadState *new_tstate = PyInterpreterState_ThreadHead(interp);
PyThreadState *save1 = PyEval_SaveThread();
(void)PyThreadState_Swap(new_tstate);
// Run the script.
_sharedexception *exc = NULL;
int result = _run_script(interp, codestr, shared, &exc);
// Switch back.
PyEval_RestoreThread(save1);
#else
// Switch to interpreter. // Switch to interpreter.
PyThreadState *save_tstate = NULL; PyThreadState *save_tstate = NULL;
if (interp != PyInterpreterState_Get()) { if (interp != PyInterpreterState_Get()) {
@ -1963,7 +1949,6 @@ _run_script_in_interpreter(PyInterpreterState *interp, const char *codestr,
if (save_tstate != NULL) { if (save_tstate != NULL) {
PyThreadState_Swap(save_tstate); PyThreadState_Swap(save_tstate);
} }
#endif
// Propagate any exception out to the caller. // Propagate any exception out to the caller.
if (exc != NULL) { if (exc != NULL) {

View File

@ -1195,14 +1195,6 @@ gc_collect_main(PyThreadState *tstate, int generation,
assert(gcstate->garbage != NULL); assert(gcstate->garbage != NULL);
assert(!_PyErr_Occurred(tstate)); assert(!_PyErr_Occurred(tstate));
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
if (tstate->interp->config._isolated_interpreter) {
// bpo-40533: The garbage collector must not be run on parallel on
// Python objects shared by multiple interpreters.
return 0;
}
#endif
if (gcstate->debug & DEBUG_STATS) { if (gcstate->debug & DEBUG_STATS) {
PySys_WriteStderr("gc: collecting generation %d...\n", generation); PySys_WriteStderr("gc: collecting generation %d...\n", generation);
show_stats_each_generations(gcstate); show_stats_each_generations(gcstate);

View File

@ -54,11 +54,6 @@ typedef struct PySlot_Offset {
} PySlot_Offset; } PySlot_Offset;
/* bpo-40521: Interned strings are shared by all subinterpreters */
#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
# define INTERN_NAME_STRINGS
#endif
static PyObject * static PyObject *
slot_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds); slot_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
@ -4027,7 +4022,7 @@ type_setattro(PyTypeObject *type, PyObject *name, PyObject *value)
if (name == NULL) if (name == NULL)
return -1; return -1;
} }
#ifdef INTERN_NAME_STRINGS /* bpo-40521: Interned strings are shared by all subinterpreters */
if (!PyUnicode_CHECK_INTERNED(name)) { if (!PyUnicode_CHECK_INTERNED(name)) {
PyUnicode_InternInPlace(&name); PyUnicode_InternInPlace(&name);
if (!PyUnicode_CHECK_INTERNED(name)) { if (!PyUnicode_CHECK_INTERNED(name)) {
@ -4037,7 +4032,6 @@ type_setattro(PyTypeObject *type, PyObject *name, PyObject *value)
return -1; return -1;
} }
} }
#endif
} }
else { else {
/* Will fail in _PyObject_GenericSetAttrWithDict. */ /* Will fail in _PyObject_GenericSetAttrWithDict. */
@ -8474,17 +8468,11 @@ _PyTypes_InitSlotDefs(void)
for (slotdef *p = slotdefs; p->name; p++) { for (slotdef *p = slotdefs; p->name; p++) {
/* Slots must be ordered by their offset in the PyHeapTypeObject. */ /* Slots must be ordered by their offset in the PyHeapTypeObject. */
assert(!p[1].name || p->offset <= p[1].offset); assert(!p[1].name || p->offset <= p[1].offset);
#ifdef INTERN_NAME_STRINGS /* bpo-40521: Interned strings are shared by all subinterpreters */
p->name_strobj = PyUnicode_InternFromString(p->name); p->name_strobj = PyUnicode_InternFromString(p->name);
if (!p->name_strobj || !PyUnicode_CHECK_INTERNED(p->name_strobj)) { if (!p->name_strobj || !PyUnicode_CHECK_INTERNED(p->name_strobj)) {
return _PyStatus_NO_MEMORY(); return _PyStatus_NO_MEMORY();
} }
#else
p->name_strobj = PyUnicode_FromString(p->name);
if (!p->name_strobj) {
return _PyStatus_NO_MEMORY();
}
#endif
} }
slotdefs_initialized = 1; slotdefs_initialized = 1;
return _PyStatus_OK(); return _PyStatus_OK();
@ -8509,24 +8497,17 @@ update_slot(PyTypeObject *type, PyObject *name)
int offset; int offset;
assert(PyUnicode_CheckExact(name)); assert(PyUnicode_CheckExact(name));
#ifdef INTERN_NAME_STRINGS
assert(PyUnicode_CHECK_INTERNED(name)); assert(PyUnicode_CHECK_INTERNED(name));
#endif
assert(slotdefs_initialized); assert(slotdefs_initialized);
pp = ptrs; pp = ptrs;
for (p = slotdefs; p->name; p++) { for (p = slotdefs; p->name; p++) {
assert(PyUnicode_CheckExact(p->name_strobj)); assert(PyUnicode_CheckExact(p->name_strobj));
assert(PyUnicode_CheckExact(name)); assert(PyUnicode_CheckExact(name));
#ifdef INTERN_NAME_STRINGS /* bpo-40521: Using interned strings. */
if (p->name_strobj == name) { if (p->name_strobj == name) {
*pp++ = p; *pp++ = p;
} }
#else
if (p->name_strobj == name || _PyUnicode_EQ(p->name_strobj, name)) {
*pp++ = p;
}
#endif
} }
*pp = NULL; *pp = NULL;
for (pp = ptrs; *pp; pp++) { for (pp = ptrs; *pp; pp++) {

View File

@ -190,11 +190,6 @@ extern "C" {
# define OVERALLOCATE_FACTOR 4 # define OVERALLOCATE_FACTOR 4
#endif #endif
/* bpo-40521: Interned strings are shared by all interpreters. */
#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
# define INTERNED_STRINGS
#endif
/* This dictionary holds all interned unicode strings. Note that references /* This dictionary holds all interned unicode strings. Note that references
to strings in this dictionary are *not* counted in the string's ob_refcnt. to strings in this dictionary are *not* counted in the string's ob_refcnt.
When the interned string reaches a refcnt of 0 the string deallocation When the interned string reaches a refcnt of 0 the string deallocation
@ -203,9 +198,7 @@ extern "C" {
Another way to look at this is that to say that the actual reference Another way to look at this is that to say that the actual reference
count of a string is: s->ob_refcnt + (s->state ? 2 : 0) count of a string is: s->ob_refcnt + (s->state ? 2 : 0)
*/ */
#ifdef INTERNED_STRINGS
static PyObject *interned = NULL; static PyObject *interned = NULL;
#endif
/* Forward declaration */ /* Forward declaration */
static inline int static inline int
@ -1530,7 +1523,6 @@ unicode_dealloc(PyObject *unicode)
} }
#endif #endif
#ifdef INTERNED_STRINGS
if (PyUnicode_CHECK_INTERNED(unicode)) { if (PyUnicode_CHECK_INTERNED(unicode)) {
/* Revive the dead object temporarily. PyDict_DelItem() removes two /* Revive the dead object temporarily. PyDict_DelItem() removes two
references (key and value) which were ignored by references (key and value) which were ignored by
@ -1546,7 +1538,6 @@ unicode_dealloc(PyObject *unicode)
assert(Py_REFCNT(unicode) == 1); assert(Py_REFCNT(unicode) == 1);
Py_SET_REFCNT(unicode, 0); Py_SET_REFCNT(unicode, 0);
} }
#endif
if (_PyUnicode_HAS_UTF8_MEMORY(unicode)) { if (_PyUnicode_HAS_UTF8_MEMORY(unicode)) {
PyObject_Free(_PyUnicode_UTF8(unicode)); PyObject_Free(_PyUnicode_UTF8(unicode));
@ -10568,13 +10559,11 @@ _PyUnicode_EqualToASCIIId(PyObject *left, _Py_Identifier *right)
if (PyUnicode_CHECK_INTERNED(left)) if (PyUnicode_CHECK_INTERNED(left))
return 0; return 0;
#ifdef INTERNED_STRINGS
assert(_PyUnicode_HASH(right_uni) != -1); assert(_PyUnicode_HASH(right_uni) != -1);
Py_hash_t hash = _PyUnicode_HASH(left); Py_hash_t hash = _PyUnicode_HASH(left);
if (hash != -1 && hash != _PyUnicode_HASH(right_uni)) { if (hash != -1 && hash != _PyUnicode_HASH(right_uni)) {
return 0; return 0;
} }
#endif
return unicode_compare_eq(left, right_uni); return unicode_compare_eq(left, right_uni);
} }
@ -14645,7 +14634,6 @@ PyUnicode_InternInPlace(PyObject **p)
return; return;
} }
#ifdef INTERNED_STRINGS
if (interned == NULL) { if (interned == NULL) {
interned = PyDict_New(); interned = PyDict_New();
if (interned == NULL) { if (interned == NULL) {
@ -14671,11 +14659,6 @@ PyUnicode_InternInPlace(PyObject **p)
this. */ this. */
Py_SET_REFCNT(s, Py_REFCNT(s) - 2); Py_SET_REFCNT(s, Py_REFCNT(s) - 2);
_PyUnicode_STATE(s).interned = 1; _PyUnicode_STATE(s).interned = 1;
#else
// PyDict expects that interned strings have their hash
// (PyASCIIObject.hash) already computed.
(void)unicode_hash(s);
#endif
} }
// Function kept for the stable ABI. // Function kept for the stable ABI.

View File

@ -352,21 +352,6 @@ _Py_FatalError_TstateNULL(const char *func)
"(the current Python thread state is NULL)"); "(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 int
_PyEval_ThreadsInitialized(_PyRuntimeState *runtime) _PyEval_ThreadsInitialized(_PyRuntimeState *runtime)
{ {
@ -379,25 +364,18 @@ PyEval_ThreadsInitialized(void)
_PyRuntimeState *runtime = &_PyRuntime; _PyRuntimeState *runtime = &_PyRuntime;
return _PyEval_ThreadsInitialized(runtime); return _PyEval_ThreadsInitialized(runtime);
} }
#endif
PyStatus PyStatus
_PyEval_InitGIL(PyThreadState *tstate) _PyEval_InitGIL(PyThreadState *tstate)
{ {
#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
if (!_Py_IsMainInterpreter(tstate->interp)) { if (!_Py_IsMainInterpreter(tstate->interp)) {
/* Currently, the GIL is shared by all interpreters, /* Currently, the GIL is shared by all interpreters,
and only the main interpreter is responsible to create and only the main interpreter is responsible to create
and destroy it. */ and destroy it. */
return _PyStatus_OK(); 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; struct _gil_runtime_state *gil = &tstate->interp->runtime->ceval.gil;
#endif
assert(!gil_created(gil)); assert(!gil_created(gil));
PyThread_init_thread(); PyThread_init_thread();
@ -412,20 +390,14 @@ _PyEval_InitGIL(PyThreadState *tstate)
void void
_PyEval_FiniGIL(PyInterpreterState *interp) _PyEval_FiniGIL(PyInterpreterState *interp)
{ {
#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
if (!_Py_IsMainInterpreter(interp)) { if (!_Py_IsMainInterpreter(interp)) {
/* Currently, the GIL is shared by all interpreters, /* Currently, the GIL is shared by all interpreters,
and only the main interpreter is responsible to create and only the main interpreter is responsible to create
and destroy it. */ and destroy it. */
return; return;
} }
#endif
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
struct _gil_runtime_state *gil = &interp->ceval.gil;
#else
struct _gil_runtime_state *gil = &interp->runtime->ceval.gil; struct _gil_runtime_state *gil = &interp->runtime->ceval.gil;
#endif
if (!gil_created(gil)) { if (!gil_created(gil)) {
/* First Py_InitializeFromConfig() call: the GIL doesn't exist /* First Py_InitializeFromConfig() call: the GIL doesn't exist
yet: do nothing. */ yet: do nothing. */
@ -489,13 +461,9 @@ PyEval_AcquireThread(PyThreadState *tstate)
take_gil(tstate); take_gil(tstate);
struct _gilstate_runtime_state *gilstate = &tstate->interp->runtime->gilstate; 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) { if (_PyThreadState_Swap(gilstate, tstate) != NULL) {
Py_FatalError("non-NULL old thread state"); Py_FatalError("non-NULL old thread state");
} }
#endif
} }
void void
@ -522,11 +490,7 @@ _PyEval_ReInitThreads(PyThreadState *tstate)
{ {
_PyRuntimeState *runtime = tstate->interp->runtime; _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; struct _gil_runtime_state *gil = &runtime->ceval.gil;
#endif
if (!gil_created(gil)) { if (!gil_created(gil)) {
return _PyStatus_OK(); return _PyStatus_OK();
} }
@ -558,21 +522,12 @@ PyThreadState *
PyEval_SaveThread(void) PyEval_SaveThread(void)
{ {
_PyRuntimeState *runtime = &_PyRuntime; _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); PyThreadState *tstate = _PyThreadState_Swap(&runtime->gilstate, NULL);
#endif
_Py_EnsureTstateNotNULL(tstate); _Py_EnsureTstateNotNULL(tstate);
struct _ceval_runtime_state *ceval = &runtime->ceval; struct _ceval_runtime_state *ceval = &runtime->ceval;
struct _ceval_state *ceval2 = &tstate->interp->ceval; struct _ceval_state *ceval2 = &tstate->interp->ceval;
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
assert(gil_created(&ceval2->gil));
#else
assert(gil_created(&ceval->gil)); assert(gil_created(&ceval->gil));
#endif
drop_gil(ceval, ceval2, tstate); drop_gil(ceval, ceval2, tstate);
return tstate; return tstate;
} }
@ -836,9 +791,7 @@ Py_MakePendingCalls(void)
void void
_PyEval_InitRuntimeState(struct _ceval_runtime_state *ceval) _PyEval_InitRuntimeState(struct _ceval_runtime_state *ceval)
{ {
#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
_gil_initialize(&ceval->gil); _gil_initialize(&ceval->gil);
#endif
} }
void void
@ -848,10 +801,6 @@ _PyEval_InitState(struct _ceval_state *ceval, PyThread_type_lock pending_lock)
assert(pending->lock == NULL); assert(pending->lock == NULL);
pending->lock = pending_lock; pending->lock = pending_lock;
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
_gil_initialize(&ceval->gil);
#endif
} }
void void
@ -1267,13 +1216,9 @@ eval_frame_handle_pending(PyThreadState *tstate)
take_gil(tstate); take_gil(tstate);
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
(void)_PyThreadState_Swap(&runtime->gilstate, tstate);
#else
if (_PyThreadState_Swap(&runtime->gilstate, tstate) != NULL) { if (_PyThreadState_Swap(&runtime->gilstate, tstate) != NULL) {
Py_FatalError("orphan tstate"); Py_FatalError("orphan tstate");
} }
#endif
} }
/* Check for asynchronous exception. */ /* Check for asynchronous exception. */

View File

@ -144,11 +144,7 @@ static void
drop_gil(struct _ceval_runtime_state *ceval, struct _ceval_state *ceval2, drop_gil(struct _ceval_runtime_state *ceval, struct _ceval_state *ceval2,
PyThreadState *tstate) PyThreadState *tstate)
{ {
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
struct _gil_runtime_state *gil = &ceval2->gil;
#else
struct _gil_runtime_state *gil = &ceval->gil; struct _gil_runtime_state *gil = &ceval->gil;
#endif
if (!_Py_atomic_load_relaxed(&gil->locked)) { if (!_Py_atomic_load_relaxed(&gil->locked)) {
Py_FatalError("drop_gil: GIL is not locked"); Py_FatalError("drop_gil: GIL is not locked");
} }
@ -232,11 +228,7 @@ take_gil(PyThreadState *tstate)
PyInterpreterState *interp = tstate->interp; PyInterpreterState *interp = tstate->interp;
struct _ceval_runtime_state *ceval = &interp->runtime->ceval; struct _ceval_runtime_state *ceval = &interp->runtime->ceval;
struct _ceval_state *ceval2 = &interp->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; struct _gil_runtime_state *gil = &ceval->gil;
#endif
/* Check that _PyEval_InitThreads() was called to create the lock */ /* Check that _PyEval_InitThreads() was called to create the lock */
assert(gil_created(gil)); assert(gil_created(gil));
@ -328,22 +320,12 @@ _ready:
void _PyEval_SetSwitchInterval(unsigned long microseconds) 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; struct _gil_runtime_state *gil = &_PyRuntime.ceval.gil;
#endif
gil->interval = microseconds; gil->interval = microseconds;
} }
unsigned long _PyEval_GetSwitchInterval() 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; struct _gil_runtime_state *gil = &_PyRuntime.ceval.gil;
#endif
return gil->interval; return gil->interval;
} }

View File

@ -294,17 +294,7 @@ _PyPreConfig_InitCompatConfig(PyPreConfig *config)
config->coerce_c_locale_warn = 0; config->coerce_c_locale_warn = 0;
config->dev_mode = -1; 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; config->allocator = PYMEM_ALLOCATOR_NOT_SET;
#endif
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
config->legacy_windows_fs_encoding = -1; config->legacy_windows_fs_encoding = -1;
#endif #endif

View File

@ -1981,12 +1981,10 @@ new_interpreter(PyThreadState **tstate_p, int isolated_subinterpreter)
/* Copy the current interpreter config into the new interpreter */ /* Copy the current interpreter config into the new interpreter */
const PyConfig *config; const PyConfig *config;
#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
if (save_tstate != NULL) { if (save_tstate != NULL) {
config = _PyInterpreterState_GetConfig(save_tstate->interp); config = _PyInterpreterState_GetConfig(save_tstate->interp);
} }
else else
#endif
{ {
/* No current thread state, copy from the main interpreter */ /* No current thread state, copy from the main interpreter */
PyInterpreterState *main_interp = _PyInterpreterState_Main(); PyInterpreterState *main_interp = _PyInterpreterState_Main();

View File

@ -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 *
_PyThreadState_UncheckedGet(void) _PyThreadState_UncheckedGet(void)
{ {
@ -1192,11 +1184,7 @@ PyThreadState_Get(void)
PyThreadState * PyThreadState *
_PyThreadState_Swap(struct _gilstate_runtime_state *gilstate, PyThreadState *newts) _PyThreadState_Swap(struct _gilstate_runtime_state *gilstate, PyThreadState *newts)
{ {
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
PyThreadState *oldts = _PyThreadState_GetTSS();
#else
PyThreadState *oldts = _PyRuntimeGILState_GetThreadState(gilstate); PyThreadState *oldts = _PyRuntimeGILState_GetThreadState(gilstate);
#endif
_PyRuntimeGILState_SetThreadState(gilstate, newts); _PyRuntimeGILState_SetThreadState(gilstate, newts);
/* It should not be possible for more than one thread state /* It should not be possible for more than one thread state
@ -1214,9 +1202,6 @@ _PyThreadState_Swap(struct _gilstate_runtime_state *gilstate, PyThreadState *new
Py_FatalError("Invalid thread state for this thread"); Py_FatalError("Invalid thread state for this thread");
errno = err; errno = err;
} }
#endif
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
PyThread_tss_set(&gilstate->autoTSSkey, newts);
#endif #endif
return oldts; return oldts;
} }
@ -1665,9 +1650,7 @@ PyGILState_Ensure(void)
/* Ensure that _PyEval_InitThreads() and _PyGILState_Init() have been /* Ensure that _PyEval_InitThreads() and _PyGILState_Init() have been
called by Py_Initialize() */ called by Py_Initialize() */
#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
assert(_PyEval_ThreadsInitialized(runtime)); assert(_PyEval_ThreadsInitialized(runtime));
#endif
assert(gilstate->autoInterpreterState); assert(gilstate->autoInterpreterState);
PyThreadState *tcur = (PyThreadState *)PyThread_tss_get(&gilstate->autoTSSkey); PyThreadState *tcur = (PyThreadState *)PyThread_tss_get(&gilstate->autoTSSkey);

28
configure generated vendored
View File

@ -1061,7 +1061,6 @@ with_openssl
with_openssl_rpath with_openssl_rpath
with_ssl_default_suites with_ssl_default_suites
with_builtin_hashlib_hashes with_builtin_hashlib_hashes
with_experimental_isolated_subinterpreters
enable_test_modules enable_test_modules
' '
ac_precious_vars='build_alias ac_precious_vars='build_alias
@ -1861,9 +1860,6 @@ Optional Packages:
--with-builtin-hashlib-hashes=md5,sha1,sha256,sha512,sha3,blake2 --with-builtin-hashlib-hashes=md5,sha1,sha256,sha512,sha3,blake2
builtin hash modules, md5, sha1, sha256, sha512, builtin hash modules, md5, sha1, sha256, sha512,
sha3 (with shake), blake2 sha3 (with shake), blake2
--with-experimental-isolated-subinterpreters
better isolate subinterpreters, experimental build
mode (default is no)
Some influential environment variables: Some influential environment variables:
PKG_CONFIG path to pkg-config utility PKG_CONFIG path to pkg-config utility
@ -22363,30 +22359,6 @@ fi
fi fi
# --with-experimental-isolated-subinterpreters
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-experimental-isolated-subinterpreters" >&5
$as_echo_n "checking for --with-experimental-isolated-subinterpreters... " >&6; }
# Check whether --with-experimental-isolated-subinterpreters was given.
if test "${with_experimental_isolated_subinterpreters+set}" = set; then :
withval=$with_experimental_isolated_subinterpreters;
if test "$withval" != no
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; };
$as_echo "#define EXPERIMENTAL_ISOLATED_SUBINTERPRETERS 1" >>confdefs.h
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; };
fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
# Check whether to disable test modules. Once set, setup.py will not build # Check whether to disable test modules. Once set, setup.py will not build
# test extension modules and "make install" will not install test suites. # test extension modules and "make install" will not install test suites.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --disable-test-modules" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --disable-test-modules" >&5

View File

@ -6540,23 +6540,6 @@ AS_VAR_IF([with_builtin_blake2], [yes], [
], [have_libb2=no]) ], [have_libb2=no])
]) ])
# --with-experimental-isolated-subinterpreters
AH_TEMPLATE(EXPERIMENTAL_ISOLATED_SUBINTERPRETERS,
[Better isolate subinterpreters, experimental build mode.])
AC_MSG_CHECKING(for --with-experimental-isolated-subinterpreters)
AC_ARG_WITH(experimental-isolated-subinterpreters,
AS_HELP_STRING([--with-experimental-isolated-subinterpreters],
[better isolate subinterpreters, experimental build mode (default is no)]),
[
if test "$withval" != no
then
AC_MSG_RESULT(yes);
AC_DEFINE(EXPERIMENTAL_ISOLATED_SUBINTERPRETERS)
else
AC_MSG_RESULT(no);
fi],
[AC_MSG_RESULT(no)])
# Check whether to disable test modules. Once set, setup.py will not build # Check whether to disable test modules. Once set, setup.py will not build
# test extension modules and "make install" will not install test suites. # test extension modules and "make install" will not install test suites.
AC_MSG_CHECKING([for --disable-test-modules]) AC_MSG_CHECKING([for --disable-test-modules])

View File

@ -44,9 +44,6 @@
/* Define if --enable-ipv6 is specified */ /* Define if --enable-ipv6 is specified */
#undef ENABLE_IPV6 #undef ENABLE_IPV6
/* Better isolate subinterpreters, experimental build mode. */
#undef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
/* Define to 1 if your system stores words within floats with the most /* Define to 1 if your system stores words within floats with the most
significant word first */ significant word first */
#undef FLOAT_WORDS_BIGENDIAN #undef FLOAT_WORDS_BIGENDIAN