mirror of
https://github.com/python/cpython.git
synced 2025-10-17 04:08:28 +00:00
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
This commit is contained in:
parent
55c96e8053
commit
67807cfc87
14 changed files with 1129 additions and 925 deletions
|
@ -9,13 +9,15 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#include "pycore_object.h"
|
||||
#include "pycore_pymem_init.h"
|
||||
#include "pycore_obmalloc_init.h"
|
||||
|
||||
|
||||
/* The static initializers defined here should only be used
|
||||
in the runtime init code (in pystate.c and pylifecycle.c). */
|
||||
|
||||
|
||||
#define _PyRuntimeState_INIT \
|
||||
#define _PyRuntimeState_INIT(runtime) \
|
||||
{ \
|
||||
.gilstate = { \
|
||||
.check_enabled = 1, \
|
||||
|
@ -23,6 +25,12 @@ extern "C" {
|
|||
in accordance with the specification. */ \
|
||||
.autoTSSkey = Py_tss_NEEDS_INIT, \
|
||||
}, \
|
||||
.allocators = { \
|
||||
_pymem_allocators_standard_INIT(runtime), \
|
||||
_pymem_allocators_debug_INIT, \
|
||||
_pymem_allocators_obj_arena_INIT, \
|
||||
}, \
|
||||
.obmalloc = _obmalloc_state_INIT(runtime.obmalloc), \
|
||||
.interpreters = { \
|
||||
/* This prevents interpreters from getting created \
|
||||
until _PyInterpreterState_Enable() is called. */ \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue