diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2022-11-11 23:30:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-11 23:30:46 (GMT) |
commit | 67807cfc87135fdce4992d38d2ffe3e44747e73b (patch) | |
tree | c6723686f91afa7963e1ac72729a417f2067f7f9 /Python | |
parent | 55c96e8053689c29ae28a9d2117ae37934eace68 (diff) | |
download | cpython-67807cfc87135fdce4992d38d2ffe3e44747e73b.zip cpython-67807cfc87135fdce4992d38d2ffe3e44747e73b.tar.gz cpython-67807cfc87135fdce4992d38d2ffe3e44747e73b.tar.bz2 |
gh-81057: Move the Allocators to _PyRuntimeState (gh-99217)
The global allocators were stored in 3 static global variables: _PyMem_Raw, _PyMem, and _PyObject. State for the "small block" allocator was stored in another 13. That makes a total of 16 global variables. We are moving all 16 to the _PyRuntimeState struct as part of the work for gh-81057. (If PEP 684 is accepted then we will follow up by moving them all to PyInterpreterState.)
https://github.com/python/cpython/issues/81057
Diffstat (limited to 'Python')
-rw-r--r-- | Python/pylifecycle.c | 2 | ||||
-rw-r--r-- | Python/pystate.c | 7 |
2 files changed, 6 insertions, 3 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 3991089..39e54c1 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -104,7 +104,7 @@ _PyRuntimeState _PyRuntime #if defined(__linux__) && (defined(__GNUC__) || defined(__clang__)) __attribute__ ((section (".PyRuntime"))) #endif -= _PyRuntimeState_INIT; += _PyRuntimeState_INIT(_PyRuntime); _Py_COMP_DIAG_POP static int runtime_initialized = 0; diff --git a/Python/pystate.c b/Python/pystate.c index 04db1fb4..5d1814f 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -51,8 +51,11 @@ static void _PyThreadState_Delete(PyThreadState *tstate, int check_current); _Py_COMP_DIAG_PUSH _Py_COMP_DIAG_IGNORE_DEPR_DECLS /* We use "initial" if the runtime gets re-used - (e.g. Py_Finalize() followed by Py_Initialize(). */ -static const _PyRuntimeState initial = _PyRuntimeState_INIT; + (e.g. Py_Finalize() followed by Py_Initialize(). + Note that we initialize "initial" relative to _PyRuntime, + to ensure pre-initialized pointers point to the active + runtime state (and not "initial"). */ +static const _PyRuntimeState initial = _PyRuntimeState_INIT(_PyRuntime); _Py_COMP_DIAG_POP static int |