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:
Eric Snow 2022-11-11 16:30:46 -07:00 committed by GitHub
parent 55c96e8053
commit 67807cfc87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 1129 additions and 925 deletions

View file

@ -13,6 +13,8 @@ extern "C" {
#include "pycore_global_objects.h" // struct _Py_global_objects
#include "pycore_import.h" // struct _import_runtime_state
#include "pycore_interp.h" // PyInterpreterState
#include "pycore_pymem.h" // struct _pymem_allocators
#include "pycore_obmalloc.h" // struct obmalloc_state
#include "pycore_unicodeobject.h" // struct _Py_unicode_runtime_ids
struct _getargs_runtime_state {
@ -86,6 +88,9 @@ typedef struct pyruntimestate {
to access it, don't access it directly. */
_Py_atomic_address _finalizing;
struct _pymem_allocators allocators;
struct _obmalloc_state obmalloc;
struct pyinterpreters {
PyThread_type_lock mutex;
/* The linked list of interpreters, newest first. */