mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-112529: Use GC heaps for GC allocations in free-threaded builds (gh-114157)
* gh-112529: Use GC heaps for GC allocations in free-threaded builds The free-threaded build's garbage collector implementation will need to find GC objects by traversing mimalloc heaps. This hooks up the allocation calls with the correct heaps by using a thread-local "current_obj_heap" variable. * Refactor out setting heap based on type
This commit is contained in:
parent
b1ad5a5d44
commit
1d6d5e854c
6 changed files with 85 additions and 7 deletions
|
@ -11,6 +11,7 @@
|
|||
#include "pycore_modsupport.h" // _PyArg_NoKwnames()
|
||||
#include "pycore_moduleobject.h" // _PyModule_GetDef()
|
||||
#include "pycore_object.h" // _PyType_HasFeature()
|
||||
#include "pycore_object_alloc.h" // _PyObject_MallocWithType()
|
||||
#include "pycore_pyerrors.h" // _PyErr_Occurred()
|
||||
#include "pycore_pystate.h" // _PyThreadState_GET()
|
||||
#include "pycore_symtable.h" // _Py_Mangle()
|
||||
|
@ -1729,7 +1730,7 @@ _PyType_AllocNoTrack(PyTypeObject *type, Py_ssize_t nitems)
|
|||
const size_t size = _PyObject_VAR_SIZE(type, nitems+1);
|
||||
|
||||
const size_t presize = _PyType_PreHeaderSize(type);
|
||||
char *alloc = PyObject_Malloc(size + presize);
|
||||
char *alloc = _PyObject_MallocWithType(type, size + presize);
|
||||
if (alloc == NULL) {
|
||||
return PyErr_NoMemory();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue