File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99# error "pycore_mimalloc.h must be included before mimalloc.h"
1010#endif
1111
12- typedef enum {
13- _Py_MIMALLOC_HEAP_MEM = 0 , // PyMem_Malloc() and friends
14- _Py_MIMALLOC_HEAP_OBJECT = 1 , // non-GC objects
15- _Py_MIMALLOC_HEAP_GC = 2 , // GC objects without pre-header
16- _Py_MIMALLOC_HEAP_GC_PRE = 3 , // GC objects with pre-header
17- _Py_MIMALLOC_HEAP_COUNT
18- } _Py_mimalloc_heap_id ;
19-
12+ #include "pycore_mimalloc_structs.h"
2013#include "pycore_pymem.h"
2114
2215#ifdef WITH_MIMALLOC
@@ -77,19 +70,4 @@ extern "C++" {
7770
7871#endif
7972
80- #ifdef Py_GIL_DISABLED
81- struct _mimalloc_interp_state {
82- mi_heap_t * heaps [_Py_MIMALLOC_HEAP_COUNT ];
83- };
84-
85- struct _mimalloc_thread_state {
86- mi_theap_t * current_object_heap ;
87- mi_theap_t * heaps [_Py_MIMALLOC_HEAP_COUNT ];
88- int initialized ;
89- };
90-
91- extern int _PyMem_InitMimalloc (PyInterpreterState * interp );
92- extern void _PyMem_FiniMimalloc (PyInterpreterState * interp );
93- #endif
94-
9573#endif // Py_INTERNAL_MIMALLOC_H
Original file line number Diff line number Diff line change 1+ #ifndef Py_INTERNAL_MIMALLOC_STRUCTS_H
2+ #define Py_INTERNAL_MIMALLOC_STRUCTS_H
3+
4+ #ifndef Py_BUILD_CORE
5+ # error "this header requires Py_BUILD_CORE define"
6+ #endif
7+
8+ // mimalloc state embedded in the interpreter and thread states. This header
9+ // does not include mimalloc itself; use pycore_mimalloc.h to call into it.
10+
11+ #include "pycore_pymem.h" // previously exposed via pycore_tstate.h
12+
13+ typedef enum {
14+ _Py_MIMALLOC_HEAP_MEM = 0 , // PyMem_Malloc() and friends
15+ _Py_MIMALLOC_HEAP_OBJECT = 1 , // non-GC objects
16+ _Py_MIMALLOC_HEAP_GC = 2 , // GC objects without pre-header
17+ _Py_MIMALLOC_HEAP_GC_PRE = 3 , // GC objects with pre-header
18+ _Py_MIMALLOC_HEAP_COUNT
19+ } _Py_mimalloc_heap_id ;
20+
21+ #ifdef WITH_MIMALLOC
22+ // Defined by mimalloc as mi_heap_t and mi_theap_t
23+ struct mi_heap_s ;
24+ struct mi_theap_s ;
25+
26+ extern void _mi_fork_child (void );
27+ #endif
28+
29+ #ifdef Py_GIL_DISABLED
30+ struct _mimalloc_interp_state {
31+ struct mi_heap_s * heaps [_Py_MIMALLOC_HEAP_COUNT ];
32+ };
33+
34+ struct _mimalloc_thread_state {
35+ struct mi_theap_s * current_object_heap ;
36+ struct mi_theap_s * heaps [_Py_MIMALLOC_HEAP_COUNT ];
37+ int initialized ;
38+ };
39+
40+ extern int _PyMem_InitMimalloc (PyInterpreterState * interp );
41+ extern void _PyMem_FiniMimalloc (PyInterpreterState * interp );
42+ #endif
43+
44+ #endif // Py_INTERNAL_MIMALLOC_STRUCTS_H
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ extern "C" {
1414#endif
1515
1616#ifdef Py_GIL_DISABLED
17- static inline mi_theap_t *
17+ static inline struct mi_theap_s *
1818_PyObject_GetAllocationHeap (_PyThreadStateImpl * tstate , PyTypeObject * tp )
1919{
2020 struct _mimalloc_thread_state * m = & tstate -> mimalloc ;
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ extern "C" {
1111#include "pycore_brc.h" // struct _brc_thread_state
1212#include "pycore_freelist_state.h" // struct _Py_freelists
1313#include "pycore_interpframe_structs.h" // _PyInterpreterFrame
14- #include "pycore_mimalloc .h" // struct _mimalloc_thread_state
14+ #include "pycore_mimalloc_structs .h" // struct _mimalloc_thread_state
1515#include "pycore_qsbr.h" // struct qsbr
1616#include "pycore_uop.h" // struct _PyUOpInstruction
1717#include "pycore_structs.h"
Original file line number Diff line number Diff line change @@ -1367,6 +1367,7 @@ PYTHON_HEADERS= \
13671367 $(srcdir)/Include/internal/pycore_long.h \
13681368 $(srcdir)/Include/internal/pycore_memoryobject.h \
13691369 $(srcdir)/Include/internal/pycore_mimalloc.h \
1370+ $(srcdir)/Include/internal/pycore_mimalloc_structs.h \
13701371 $(srcdir)/Include/internal/pycore_mmap.h \
13711372 $(srcdir)/Include/internal/pycore_modsupport.h \
13721373 $(srcdir)/Include/internal/pycore_moduleobject.h \
Original file line number Diff line number Diff line change 284284 <ClInclude Include =" ..\Include\internal\pycore_llist.h" />
285285 <ClInclude Include =" ..\Include\internal\pycore_lock.h" />
286286 <ClInclude Include =" ..\Include\internal\pycore_long.h" />
287+ <ClInclude Include =" ..\Include\internal\pycore_mimalloc_structs.h" />
287288 <ClInclude Include =" ..\Include\internal\pycore_mmap.h" />
288289 <ClInclude Include =" ..\Include\internal\pycore_modsupport.h" />
289290 <ClInclude Include =" ..\Include\internal\pycore_moduleobject.h" />
Original file line number Diff line number Diff line change 765765 <ClInclude Include =" ..\Include\internal\pycore_lazyimportobject.h" >
766766 <Filter >Include\internal</Filter >
767767 </ClInclude >
768+ <ClInclude Include =" ..\Include\internal\pycore_mimalloc_structs.h" >
769+ <Filter >Include\internal</Filter >
770+ </ClInclude >
768771 <ClInclude Include =" ..\Include\internal\pycore_mmap.h" >
769772 <Filter >Include\internal</Filter >
770773 </ClInclude >
Original file line number Diff line number Diff line change 1010#include "pycore_interp.h" // PyInterpreterState.gc
1111#include "pycore_interpframe.h" // _PyFrame_GetLocalsArray()
1212#include "pycore_list.h" // _PyList_GetItemRef()
13+ #ifdef Py_GIL_DISABLED
14+ # include "pycore_mimalloc.h" // mi_heap_visit_blocks()
15+ #endif
1316#include "pycore_object_alloc.h" // _PyObject_MallocWithType()
1417#include "pycore_pystate.h" // _PyThreadState_GET()
1518#include "pycore_tstate.h" // _PyThreadStateImpl
Original file line number Diff line number Diff line change 1212#include "pycore_freelist.h" // _PyObject_ClearFreeLists()
1313#include "pycore_initconfig.h" // _PyStatus_OK()
1414#include "pycore_interpframe.h" // _PyThreadState_HasStackSpace()
15+ #ifdef Py_GIL_DISABLED
16+ # include "pycore_mimalloc.h" // mi_heap_theap()
17+ #endif
1518#include "pycore_object.h" // _Py_ClearImmortal()
1619#include "pycore_obmalloc.h" // _PyMem_obmalloc_state_on_heap()
1720#include "pycore_opcode_utils.h" // NUM_COMMON_CONSTANTS
You can’t perform that action at this time.
0 commit comments