mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
[3.9] bpo-40514: Remove --with-experimental-isolated-subinterpreters in 3.9 (GH-20228)
Remove --with-experimental-isolated-subinterpreters configure option in Python 3.9: the experiment continues in the master branch, but it's no longer needed in 3.9.
This commit is contained in:
parent
b008445a7b
commit
9512ad74b0
21 changed files with 7 additions and 236 deletions
|
@ -50,11 +50,7 @@ extern PyObject *_PyEval_EvalCode(
|
||||||
PyObject *kwdefs, PyObject *closure,
|
PyObject *kwdefs, PyObject *closure,
|
||||||
PyObject *name, PyObject *qualname);
|
PyObject *name, PyObject *qualname);
|
||||||
|
|
||||||
#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(PyThreadState *tstate);
|
extern void _PyEval_FiniGIL(PyThreadState *tstate);
|
||||||
|
|
||||||
|
|
|
@ -46,9 +46,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
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* fs_codec.encoding is initialized to NULL.
|
/* fs_codec.encoding is initialized to NULL.
|
||||||
|
|
|
@ -49,18 +49,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.
|
||||||
|
@ -75,11 +67,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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Redefine PyThreadState_GET() as an alias to _PyThreadState_GET() */
|
/* Redefine PyThreadState_GET() as an alias to _PyThreadState_GET() */
|
||||||
|
|
|
@ -19,9 +19,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 */
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
Remove ``--with-experimental-isolated-subinterpreters`` configure option in
|
||||||
|
Python 3.9: the experiment continues in the master branch, but it's no
|
||||||
|
longer needed in 3.9.
|
|
@ -1939,20 +1939,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()) {
|
||||||
|
@ -1970,7 +1956,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) {
|
||||||
|
|
|
@ -1181,14 +1181,6 @@ collect(PyThreadState *tstate, int generation,
|
||||||
_PyTime_t t1 = 0; /* initialize to prevent a compiler warning */
|
_PyTime_t t1 = 0; /* initialize to prevent a compiler warning */
|
||||||
GCState *gcstate = &tstate->interp->gc;
|
GCState *gcstate = &tstate->interp->gc;
|
||||||
|
|
||||||
#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);
|
||||||
|
|
|
@ -251,12 +251,6 @@ static uint64_t pydict_global_version = 0;
|
||||||
#define PyDict_MAXFREELIST 80
|
#define PyDict_MAXFREELIST 80
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* bpo-40521: dict free lists are shared by all interpreters. */
|
|
||||||
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
|
|
||||||
# undef PyDict_MAXFREELIST
|
|
||||||
# define PyDict_MAXFREELIST 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if PyDict_MAXFREELIST > 0
|
#if PyDict_MAXFREELIST > 0
|
||||||
static PyDictObject *free_list[PyDict_MAXFREELIST];
|
static PyDictObject *free_list[PyDict_MAXFREELIST];
|
||||||
static int numfree = 0;
|
static int numfree = 0;
|
||||||
|
|
|
@ -559,12 +559,6 @@ static PyGetSetDef frame_getsetlist[] = {
|
||||||
/* max value for numfree */
|
/* max value for numfree */
|
||||||
#define PyFrame_MAXFREELIST 200
|
#define PyFrame_MAXFREELIST 200
|
||||||
|
|
||||||
/* bpo-40521: frame free lists are shared by all interpreters. */
|
|
||||||
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
|
|
||||||
# undef PyFrame_MAXFREELIST
|
|
||||||
# define PyFrame_MAXFREELIST 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if PyFrame_MAXFREELIST > 0
|
#if PyFrame_MAXFREELIST > 0
|
||||||
static PyFrameObject *free_list = NULL;
|
static PyFrameObject *free_list = NULL;
|
||||||
static int numfree = 0; /* number of frames currently in free_list */
|
static int numfree = 0; /* number of frames currently in free_list */
|
||||||
|
|
|
@ -101,12 +101,6 @@ list_preallocate_exact(PyListObject *self, Py_ssize_t size)
|
||||||
# define PyList_MAXFREELIST 80
|
# define PyList_MAXFREELIST 80
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* bpo-40521: list free lists are shared by all interpreters. */
|
|
||||||
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
|
|
||||||
# undef PyList_MAXFREELIST
|
|
||||||
# define PyList_MAXFREELIST 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static PyListObject *free_list[PyList_MAXFREELIST];
|
static PyListObject *free_list[PyList_MAXFREELIST];
|
||||||
static int numfree = 0;
|
static int numfree = 0;
|
||||||
|
|
||||||
|
|
|
@ -22,12 +22,6 @@ class tuple "PyTupleObject *" "&PyTuple_Type"
|
||||||
#define PyTuple_MAXFREELIST 2000 /* Maximum number of tuples of each size to save */
|
#define PyTuple_MAXFREELIST 2000 /* Maximum number of tuples of each size to save */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* bpo-40521: tuple free lists are shared by all interpreters. */
|
|
||||||
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
|
|
||||||
# undef PyTuple_MAXSAVESIZE
|
|
||||||
# define PyTuple_MAXSAVESIZE 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if PyTuple_MAXSAVESIZE > 0
|
#if PyTuple_MAXSAVESIZE > 0
|
||||||
/* Entries 1 up to PyTuple_MAXSAVESIZE are free lists, entry 0 is the empty
|
/* Entries 1 up to PyTuple_MAXSAVESIZE are free lists, entry 0 is the empty
|
||||||
tuple () of which at most one instance will be allocated.
|
tuple () of which at most one instance will be allocated.
|
||||||
|
|
|
@ -19,10 +19,7 @@ class object "PyObject *" "&PyBaseObject_Type"
|
||||||
|
|
||||||
#include "clinic/typeobject.c.h"
|
#include "clinic/typeobject.c.h"
|
||||||
|
|
||||||
/* bpo-40521: Type method cache is shared by all subinterpreters */
|
#define MCACHE
|
||||||
#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
|
|
||||||
# define MCACHE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef MCACHE
|
#ifdef MCACHE
|
||||||
/* Support type attribute cache */
|
/* Support type attribute cache */
|
||||||
|
@ -63,10 +60,7 @@ static size_t method_cache_misses = 0;
|
||||||
static size_t method_cache_collisions = 0;
|
static size_t method_cache_collisions = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* bpo-40521: Interned strings are shared by all subinterpreters */
|
#define INTERN_NAME_STRINGS
|
||||||
#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
|
|
||||||
# define INTERN_NAME_STRINGS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* alphabetical order */
|
/* alphabetical order */
|
||||||
_Py_IDENTIFIER(__abstractmethods__);
|
_Py_IDENTIFIER(__abstractmethods__);
|
||||||
|
|
|
@ -198,10 +198,7 @@ extern "C" {
|
||||||
# define OVERALLOCATE_FACTOR 4
|
# define OVERALLOCATE_FACTOR 4
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* bpo-40521: Interned strings are shared by all interpreters. */
|
#define INTERNED_STRINGS
|
||||||
#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.
|
||||||
|
@ -288,10 +285,7 @@ unicode_decode_utf8(const char *s, Py_ssize_t size,
|
||||||
/* List of static strings. */
|
/* List of static strings. */
|
||||||
static _Py_Identifier *static_strings = NULL;
|
static _Py_Identifier *static_strings = NULL;
|
||||||
|
|
||||||
/* bpo-40521: Latin1 singletons are shared by all interpreters. */
|
#define LATIN1_SINGLETONS
|
||||||
#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
|
|
||||||
# define LATIN1_SINGLETONS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef LATIN1_SINGLETONS
|
#ifdef LATIN1_SINGLETONS
|
||||||
/* Single character Unicode strings in the Latin-1 range are being
|
/* Single character Unicode strings in the Latin-1 range are being
|
||||||
|
|
|
@ -250,21 +250,6 @@ ensure_tstate_not_null(const char *func, PyThreadState *tstate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#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)
|
||||||
{
|
{
|
||||||
|
@ -277,25 +262,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)) {
|
if (!_Py_IsMainInterpreter(tstate)) {
|
||||||
/* 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();
|
||||||
|
@ -310,20 +288,14 @@ _PyEval_InitGIL(PyThreadState *tstate)
|
||||||
void
|
void
|
||||||
_PyEval_FiniGIL(PyThreadState *tstate)
|
_PyEval_FiniGIL(PyThreadState *tstate)
|
||||||
{
|
{
|
||||||
#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
|
|
||||||
if (!_Py_IsMainInterpreter(tstate)) {
|
if (!_Py_IsMainInterpreter(tstate)) {
|
||||||
/* 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 = &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
|
|
||||||
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. */
|
||||||
|
@ -408,13 +380,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
|
||||||
|
@ -444,11 +412,7 @@ _PyEval_ReInitThreads(_PyRuntimeState *runtime)
|
||||||
PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
|
PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
|
||||||
ensure_tstate_not_null(__func__, tstate);
|
ensure_tstate_not_null(__func__, tstate);
|
||||||
|
|
||||||
#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;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -480,21 +444,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
|
|
||||||
ensure_tstate_not_null(__func__, tstate);
|
ensure_tstate_not_null(__func__, 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;
|
||||||
}
|
}
|
||||||
|
@ -753,9 +708,7 @@ void
|
||||||
_PyEval_InitRuntimeState(struct _ceval_runtime_state *ceval)
|
_PyEval_InitRuntimeState(struct _ceval_runtime_state *ceval)
|
||||||
{
|
{
|
||||||
_Py_CheckRecursionLimit = Py_DEFAULT_RECURSION_LIMIT;
|
_Py_CheckRecursionLimit = Py_DEFAULT_RECURSION_LIMIT;
|
||||||
#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
|
|
||||||
_gil_initialize(&ceval->gil);
|
_gil_initialize(&ceval->gil);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -771,10 +724,6 @@ _PyEval_InitState(struct _ceval_state *ceval)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
|
|
||||||
_gil_initialize(&ceval->gil);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -919,13 +868,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. */
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -291,17 +291,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
|
||||||
|
|
|
@ -1561,12 +1561,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();
|
||||||
|
|
|
@ -956,14 +956,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)
|
||||||
{
|
{
|
||||||
|
@ -983,11 +975,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
|
||||||
|
@ -1005,9 +993,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;
|
||||||
}
|
}
|
||||||
|
@ -1378,9 +1363,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);
|
||||||
|
|
29
configure
vendored
29
configure
vendored
|
@ -848,7 +848,6 @@ with_ensurepip
|
||||||
with_openssl
|
with_openssl
|
||||||
with_ssl_default_suites
|
with_ssl_default_suites
|
||||||
with_builtin_hashlib_hashes
|
with_builtin_hashlib_hashes
|
||||||
with_experimental_isolated_subinterpreters
|
|
||||||
'
|
'
|
||||||
ac_precious_vars='build_alias
|
ac_precious_vars='build_alias
|
||||||
host_alias
|
host_alias
|
||||||
|
@ -1585,9 +1584,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:
|
||||||
MACHDEP name for machine-dependent library files
|
MACHDEP name for machine-dependent library files
|
||||||
|
@ -17581,31 +17577,6 @@ _ACEOF
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# generate output files
|
# generate output files
|
||||||
ac_config_files="$ac_config_files Makefile.pre Misc/python.pc Misc/python-embed.pc Misc/python-config.sh"
|
ac_config_files="$ac_config_files Makefile.pre Misc/python.pc Misc/python-embed.pc Misc/python-config.sh"
|
||||||
|
|
||||||
|
|
18
configure.ac
18
configure.ac
|
@ -5779,24 +5779,6 @@ AC_MSG_RESULT($default_hashlib_hashes);
|
||||||
AC_DEFINE_UNQUOTED(PY_BUILTIN_HASHLIB_HASHES, "$default_hashlib_hashes")
|
AC_DEFINE_UNQUOTED(PY_BUILTIN_HASHLIB_HASHES, "$default_hashlib_hashes")
|
||||||
])
|
])
|
||||||
|
|
||||||
# --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)])
|
|
||||||
|
|
||||||
|
|
||||||
# generate output files
|
# generate output files
|
||||||
AC_CONFIG_FILES(Makefile.pre Misc/python.pc Misc/python-embed.pc Misc/python-config.sh)
|
AC_CONFIG_FILES(Makefile.pre Misc/python.pc Misc/python-embed.pc Misc/python-config.sh)
|
||||||
AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
|
AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
|
||||||
|
|
|
@ -38,9 +38,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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue