mirror of
https://github.com/microsoft/mimalloc.git
synced 2024-12-28 05:50:51 +08:00
improve inlining and codegen for mi_new
This commit is contained in:
parent
c04881ef8a
commit
cc019fd145
@ -760,83 +760,83 @@ static inline uintptr_t _mi_thread_id(void) mi_attr_noexcept {
|
||||
#endif
|
||||
|
||||
#define MI_ALLOC_API1(tp,name,tp0,arg0,tp1,arg1) \
|
||||
static inline tp mi_base_##name(tp0 arg0, tp1 arg1 MI_SOURCE_XPARAM) mi_attr_noexcept; \
|
||||
static tp mi_base_##name(tp0 arg0, tp1 arg1 MI_SOURCE_XPARAM) mi_attr_noexcept; \
|
||||
tp mi_##name(tp1 arg1) mi_attr_noexcept { return mi_base_##name(mi_get_default_heap(), arg1 MI_SOURCE_XRET()); } \
|
||||
tp mi_heap_##name(mi_heap_t* heap, tp1 arg1) mi_attr_noexcept { return mi_base_##name(heap, arg1 MI_SOURCE_XRET()); } \
|
||||
MI_DEBUG_ONLY(tp dbg_mi_##name(tp1 arg1, mi_source_t __mi_source) mi_attr_noexcept { (void)__mi_source; return mi_base_##name(mi_get_default_heap(), arg1 MI_SOURCE_XARG); }) \
|
||||
MI_DEBUG_ONLY(tp dbg_mi_heap_##name(mi_heap_t* heap, tp1 arg1, mi_source_t __mi_source) mi_attr_noexcept { (void)__mi_source; return mi_base_##name(heap, arg1 MI_SOURCE_XARG); }) \
|
||||
static inline tp mi_base_##name(tp0 arg0, tp1 arg1 MI_SOURCE_XPARAM) mi_attr_noexcept
|
||||
static tp mi_base_##name(tp0 arg0, tp1 arg1 MI_SOURCE_XPARAM) mi_attr_noexcept
|
||||
|
||||
#define MI_ALLOC_API2(tp,name,tp0,arg0,tp1,arg1,tp2,arg2) \
|
||||
static inline tp mi_base_##name(tp0 arg0, tp1 arg1, tp2 arg2 MI_SOURCE_XPARAM) mi_attr_noexcept; \
|
||||
static tp mi_base_##name(tp0 arg0, tp1 arg1, tp2 arg2 MI_SOURCE_XPARAM) mi_attr_noexcept; \
|
||||
tp mi_##name(tp1 arg1, tp2 arg2) mi_attr_noexcept { return mi_base_##name(mi_get_default_heap(), arg1, arg2 MI_SOURCE_XRET()); } \
|
||||
tp mi_heap_##name(mi_heap_t* heap, tp1 arg1, tp2 arg2) mi_attr_noexcept { return mi_base_##name(heap, arg1, arg2 MI_SOURCE_XRET()); } \
|
||||
MI_DEBUG_ONLY(tp dbg_mi_##name(tp1 arg1, tp2 arg2, mi_source_t __mi_source) mi_attr_noexcept { (void)__mi_source; return mi_base_##name(mi_get_default_heap(), arg1, arg2 MI_SOURCE_XARG); }) \
|
||||
MI_DEBUG_ONLY(tp dbg_mi_heap_##name(mi_heap_t* heap, tp1 arg1, tp2 arg2, mi_source_t __mi_source) mi_attr_noexcept { (void)__mi_source; return mi_base_##name(heap, arg1, arg2 MI_SOURCE_XARG); }) \
|
||||
static inline tp mi_base_##name(tp0 arg0, tp1 arg1, tp2 arg2 MI_SOURCE_XPARAM) mi_attr_noexcept
|
||||
static tp mi_base_##name(tp0 arg0, tp1 arg1, tp2 arg2 MI_SOURCE_XPARAM) mi_attr_noexcept
|
||||
|
||||
#define MI_ALLOC_API3(tp,name,tp0,arg0,tp1,arg1,tp2,arg2,tp3,arg3) \
|
||||
static inline tp mi_base_##name(tp0 arg0, tp1 arg1, tp2 arg2, tp3 arg3 MI_SOURCE_XPARAM) mi_attr_noexcept; \
|
||||
static tp mi_base_##name(tp0 arg0, tp1 arg1, tp2 arg2, tp3 arg3 MI_SOURCE_XPARAM) mi_attr_noexcept; \
|
||||
tp mi_##name(tp1 arg1, tp2 arg2, tp3 arg3) mi_attr_noexcept { return mi_base_##name(mi_get_default_heap(), arg1, arg2, arg3 MI_SOURCE_XRET()); } \
|
||||
tp mi_heap_##name(mi_heap_t* heap, tp1 arg1, tp2 arg2, tp3 arg3) mi_attr_noexcept { return mi_base_##name(heap, arg1, arg2, arg3 MI_SOURCE_XRET()); } \
|
||||
MI_DEBUG_ONLY(tp dbg_mi_##name(tp1 arg1, tp2 arg2, tp3 arg3, mi_source_t __mi_source) mi_attr_noexcept { (void)__mi_source; return mi_base_##name(mi_get_default_heap(), arg1, arg2, arg3 MI_SOURCE_XARG); }) \
|
||||
MI_DEBUG_ONLY(tp dbg_mi_heap_##name(mi_heap_t* heap, tp1 arg1, tp2 arg2, tp3 arg3, mi_source_t __mi_source) mi_attr_noexcept { (void)__mi_source; return mi_base_##name(heap, arg1, arg2, arg3 MI_SOURCE_XARG); }) \
|
||||
static inline tp mi_base_##name(tp0 arg0, tp1 arg1, tp2 arg2, tp3 arg3 MI_SOURCE_XPARAM) mi_attr_noexcept
|
||||
static tp mi_base_##name(tp0 arg0, tp1 arg1, tp2 arg2, tp3 arg3 MI_SOURCE_XPARAM) mi_attr_noexcept
|
||||
|
||||
#define MI_ALLOC_API4(tp,name,tp0,arg0,tp1,arg1,tp2,arg2,tp3,arg3,tp4,arg4) \
|
||||
static inline tp mi_base_##name(tp0 arg0, tp1 arg1, tp2 arg2, tp3 arg3, tp4 arg4 MI_SOURCE_XPARAM) mi_attr_noexcept; \
|
||||
static tp mi_base_##name(tp0 arg0, tp1 arg1, tp2 arg2, tp3 arg3, tp4 arg4 MI_SOURCE_XPARAM) mi_attr_noexcept; \
|
||||
tp mi_##name(tp1 arg1, tp2 arg2, tp3 arg3, tp4 arg4) mi_attr_noexcept { return mi_base_##name(mi_get_default_heap(), arg1, arg2, arg3, arg4 MI_SOURCE_XRET()); } \
|
||||
tp mi_heap_##name(mi_heap_t* heap, tp1 arg1, tp2 arg2, tp3 arg3, tp4 arg4) mi_attr_noexcept { return mi_base_##name(heap, arg1, arg2, arg3, arg4 MI_SOURCE_XRET()); } \
|
||||
MI_DEBUG_ONLY(tp dbg_mi_##name(tp1 arg1, tp2 arg2, tp3 arg3, tp4 arg4, mi_source_t __mi_source) mi_attr_noexcept { (void)__mi_source; return mi_base_##name(mi_get_default_heap(), arg1, arg2, arg3, arg4 MI_SOURCE_XARG); }) \
|
||||
MI_DEBUG_ONLY(tp dbg_mi_heap_##name(mi_heap_t* heap, tp1 arg1, tp2 arg2, tp3 arg3, tp4 arg4, mi_source_t __mi_source) mi_attr_noexcept { (void)__mi_source; return mi_base_##name(heap, arg1, arg2, arg3, arg4 MI_SOURCE_XARG); }) \
|
||||
static inline tp mi_base_##name(tp0 arg0, tp1 arg1, tp2 arg2, tp3 arg3, tp4 arg4 MI_SOURCE_XPARAM) mi_attr_noexcept
|
||||
static tp mi_base_##name(tp0 arg0, tp1 arg1, tp2 arg2, tp3 arg3, tp4 arg4 MI_SOURCE_XPARAM) mi_attr_noexcept
|
||||
|
||||
#define MI_ALLOC_API5(tp,name,tp0,arg0,tp1,arg1,tp2,arg2,tp3,arg3,tp4,arg4,tp5,arg5) \
|
||||
static inline tp mi_base_##name(tp0 arg0, tp1 arg1, tp2 arg2, tp3 arg3, tp4 arg4, tp5 arg5 MI_SOURCE_XPARAM) mi_attr_noexcept; \
|
||||
static tp mi_base_##name(tp0 arg0, tp1 arg1, tp2 arg2, tp3 arg3, tp4 arg4, tp5 arg5 MI_SOURCE_XPARAM) mi_attr_noexcept; \
|
||||
tp mi_##name(tp1 arg1, tp2 arg2, tp3 arg3, tp4 arg4, tp5 arg5) mi_attr_noexcept { return mi_base_##name(mi_get_default_heap(), arg1, arg2, arg3, arg4, arg5 MI_SOURCE_XRET()); } \
|
||||
tp mi_heap_##name(mi_heap_t* heap, tp1 arg1, tp2 arg2, tp3 arg3, tp4 arg4, tp5 arg5) mi_attr_noexcept { return mi_base_##name(heap, arg1, arg2, arg3, arg4, arg5 MI_SOURCE_XRET()); } \
|
||||
MI_DEBUG_ONLY(tp dbg_mi_##name(tp1 arg1, tp2 arg2, tp3 arg3, tp4 arg4, tp5 arg5, mi_source_t __mi_source) mi_attr_noexcept { (void)__mi_source; return mi_base_##name(mi_get_default_heap(), arg1, arg2, arg3, arg4, arg5 MI_SOURCE_XARG); }) \
|
||||
MI_DEBUG_ONLY(tp dbg_mi_heap_##name(mi_heap_t* heap, tp1 arg1, tp2 arg2, tp3 arg3, tp4 arg4, tp5 arg5, mi_source_t __mi_source) mi_attr_noexcept { (void)__mi_source; return mi_base_##name(heap, arg1, arg2, arg3, arg4, arg5 MI_SOURCE_XARG); } ) \
|
||||
static inline tp mi_base_##name(tp0 arg0, tp1 arg1, tp2 arg2, tp3 arg3, tp4 arg4, tp5 arg5 MI_SOURCE_XPARAM) mi_attr_noexcept
|
||||
static tp mi_base_##name(tp0 arg0, tp1 arg1, tp2 arg2, tp3 arg3, tp4 arg4, tp5 arg5 MI_SOURCE_XPARAM) mi_attr_noexcept
|
||||
|
||||
|
||||
#define MI_NEW_API1(tp,name,tp1,arg1) \
|
||||
static inline tp mi_base_##name(tp1 arg1 MI_SOURCE_XPARAM); \
|
||||
static tp mi_base_##name(tp1 arg1 MI_SOURCE_XPARAM); \
|
||||
tp mi_##name(tp1 arg1) { return mi_base_##name(arg1 MI_SOURCE_XRET()); } \
|
||||
MI_DEBUG_ONLY(tp dbg_mi_##name(tp1 arg1, mi_source_t __mi_source) { (void)__mi_source; return mi_base_##name(arg1 MI_SOURCE_XARG); }) \
|
||||
static inline tp mi_base_##name(tp1 arg1 MI_SOURCE_XPARAM)
|
||||
static tp mi_base_##name(tp1 arg1 MI_SOURCE_XPARAM)
|
||||
|
||||
#define MI_NEW_API2(tp,name,tp1,arg1,tp2,arg2) \
|
||||
static inline tp mi_base_##name(tp1 arg1, tp2 arg2 MI_SOURCE_XPARAM); \
|
||||
static tp mi_base_##name(tp1 arg1, tp2 arg2 MI_SOURCE_XPARAM); \
|
||||
tp mi_##name(tp1 arg1, tp2 arg2) { return mi_base_##name(arg1, arg2 MI_SOURCE_XRET()); } \
|
||||
MI_DEBUG_ONLY(tp dbg_mi_##name(tp1 arg1, tp2 arg2, mi_source_t __mi_source) { (void)__mi_source; return mi_base_##name(arg1, arg2 MI_SOURCE_XARG); }) \
|
||||
static inline tp mi_base_##name(tp1 arg1, tp2 arg2 MI_SOURCE_XPARAM)
|
||||
static tp mi_base_##name(tp1 arg1, tp2 arg2 MI_SOURCE_XPARAM)
|
||||
|
||||
#define MI_NEW_API3(tp,name,tp1,arg1,tp2,arg2,tp3,arg3) \
|
||||
static inline tp mi_base_##name(tp1 arg1, tp2 arg2, tp3 arg3 MI_SOURCE_XPARAM); \
|
||||
static tp mi_base_##name(tp1 arg1, tp2 arg2, tp3 arg3 MI_SOURCE_XPARAM); \
|
||||
tp mi_##name(tp1 arg1, tp2 arg2, tp3 arg3) { return mi_base_##name(arg1, arg2, arg3 MI_SOURCE_XRET()); } \
|
||||
MI_DEBUG_ONLY(tp dbg_mi_##name(tp1 arg1, tp2 arg2, tp3 arg3, mi_source_t __mi_source) { (void)__mi_source; return mi_base_##name(arg1, arg2, arg3 MI_SOURCE_XARG); }) \
|
||||
static inline tp mi_base_##name(tp1 arg1, tp2 arg2, tp3 arg3 MI_SOURCE_XPARAM)
|
||||
static tp mi_base_##name(tp1 arg1, tp2 arg2, tp3 arg3 MI_SOURCE_XPARAM)
|
||||
|
||||
|
||||
|
||||
#define MI_SOURCE_API1(tp,name,tp1,arg1) \
|
||||
static inline tp mi_base_##name(tp1 arg1 MI_SOURCE_XPARAM); \
|
||||
static tp mi_base_##name(tp1 arg1 MI_SOURCE_XPARAM); \
|
||||
tp mi_##name(tp1 arg1) mi_attr_noexcept { return mi_base_##name(arg1 MI_SOURCE_XRET()); } \
|
||||
MI_DEBUG_ONLY(tp dbg_mi_##name(tp1 arg1, mi_source_t __mi_source) mi_attr_noexcept { (void)__mi_source; return mi_base_##name(arg1 MI_SOURCE_XARG); }) \
|
||||
static inline tp mi_base_##name(tp1 arg1 MI_SOURCE_XPARAM)
|
||||
static tp mi_base_##name(tp1 arg1 MI_SOURCE_XPARAM)
|
||||
|
||||
#define MI_SOURCE_API2(tp,name,tp1,arg1,tp2,arg2) \
|
||||
static inline tp mi_base_##name(tp1 arg1, tp2 arg2 MI_SOURCE_XPARAM); \
|
||||
static tp mi_base_##name(tp1 arg1, tp2 arg2 MI_SOURCE_XPARAM); \
|
||||
tp mi_##name(tp1 arg1, tp2 arg2) mi_attr_noexcept { return mi_base_##name(arg1, arg2 MI_SOURCE_XRET()); } \
|
||||
MI_DEBUG_ONLY(tp dbg_mi_##name(tp1 arg1, tp2 arg2, mi_source_t __mi_source) mi_attr_noexcept { (void)__mi_source; return mi_base_##name(arg1, arg2 MI_SOURCE_XARG); }) \
|
||||
static inline tp mi_base_##name(tp1 arg1, tp2 arg2 MI_SOURCE_XPARAM)
|
||||
static tp mi_base_##name(tp1 arg1, tp2 arg2 MI_SOURCE_XPARAM)
|
||||
|
||||
#define MI_SOURCE_API3(tp,name,tp1,arg1,tp2,arg2,tp3,arg3) \
|
||||
static inline tp mi_base_##name(tp1 arg1, tp2 arg2, tp3 arg3 MI_SOURCE_XPARAM); \
|
||||
static tp mi_base_##name(tp1 arg1, tp2 arg2, tp3 arg3 MI_SOURCE_XPARAM); \
|
||||
tp mi_##name(tp1 arg1, tp2 arg2, tp3 arg3) mi_attr_noexcept { return mi_base_##name(arg1, arg2, arg3 MI_SOURCE_XRET()); } \
|
||||
MI_DEBUG_ONLY(tp dbg_mi_##name(tp1 arg1, tp2 arg2, tp3 arg3, mi_source_t __mi_source) mi_attr_noexcept { (void)__mi_source; return mi_base_##name(arg1, arg2, arg3 MI_SOURCE_XARG); }) \
|
||||
static inline tp mi_base_##name(tp1 arg1, tp2 arg2, tp3 arg3 MI_SOURCE_XPARAM)
|
||||
static tp mi_base_##name(tp1 arg1, tp2 arg2, tp3 arg3 MI_SOURCE_XPARAM)
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -528,18 +528,18 @@ template<class T1, class T2> bool operator!=(const mi_stl_allocator<T1>&, const
|
||||
#define mi_rezalloc_aligned_at(p,n,a,o) MI_SOURCE_LOC(mi_rezalloc_aligned_at,p,n,a,o)
|
||||
#define mi_recalloc_aligned_at(p,c,n,a,o) MI_SOURCE_LOC(mi_recalloc_aligned_at,p,c,n,a,o)
|
||||
|
||||
#define mi_heap_malloc(h,n) MI_SOURCE_LOC(mi_heap_malloc,h,n)
|
||||
#define mi_heap_calloc(h,c,n) MI_SOURCE_LOC(mi_heap_calloc,h,c,n)
|
||||
#define mi_heap_realloc(h,p,n) MI_SOURCE_LOC(mi_heap_realloc,h,p,n)
|
||||
#define mi_heap_strdup(h,s) MI_SOURCE_LOC(mi_heap_strdup,h,s)
|
||||
#define mi_heap_strndup(h,s,n) MI_SOURCE_LOC(mi_heap_strndup,h,s,n)
|
||||
#define mi_heap_realpath(h,f,n) MI_SOURCE_LOC(mi_heap_realpath,h,f,n)
|
||||
#define mi_heap_malloc_small(h,n) MI_SOURCE_LOC(mi_heap_malloc_small,h,n)
|
||||
#define mi_heap_zalloc_small(h,n) MI_SOURCE_LOC(mi_heap_zalloc_small,h,n)
|
||||
#define mi_heap_zalloc(h,n) MI_SOURCE_LOC(mi_heap_zalloc,h,n)
|
||||
#define mi_heap_mallocn(h,c,n) MI_SOURCE_LOC(mi_heap_mallocn,h,c,n)
|
||||
#define mi_heap_reallocn(h,p,c,n) MI_SOURCE_LOC(mi_heap_reallocn,h,p,c,n)
|
||||
#define mi_heap_reallocf(h,p,n) MI_SOURCE_LOC(mi_heap_reallocf,h,p,n)
|
||||
#define mi_heap_malloc(h,n) MI_SOURCE_LOC(mi_heap_malloc,h,n)
|
||||
#define mi_heap_calloc(h,c,n) MI_SOURCE_LOC(mi_heap_calloc,h,c,n)
|
||||
#define mi_heap_realloc(h,p,n) MI_SOURCE_LOC(mi_heap_realloc,h,p,n)
|
||||
#define mi_heap_strdup(h,s) MI_SOURCE_LOC(mi_heap_strdup,h,s)
|
||||
#define mi_heap_strndup(h,s,n) MI_SOURCE_LOC(mi_heap_strndup,h,s,n)
|
||||
#define mi_heap_realpath(h,f,n) MI_SOURCE_LOC(mi_heap_realpath,h,f,n)
|
||||
#define mi_heap_malloc_small(h,n) MI_SOURCE_LOC(mi_heap_malloc_small,h,n)
|
||||
#define mi_heap_zalloc_small(h,n) MI_SOURCE_LOC(mi_heap_zalloc_small,h,n)
|
||||
#define mi_heap_zalloc(h,n) MI_SOURCE_LOC(mi_heap_zalloc,h,n)
|
||||
#define mi_heap_mallocn(h,c,n) MI_SOURCE_LOC(mi_heap_mallocn,h,c,n)
|
||||
#define mi_heap_reallocn(h,p,c,n) MI_SOURCE_LOC(mi_heap_reallocn,h,p,c,n)
|
||||
#define mi_heap_reallocf(h,p,n) MI_SOURCE_LOC(mi_heap_reallocf,h,p,n)
|
||||
|
||||
#define mi_heap_malloc_aligned(h,n,a) MI_SOURCE_LOC(mi_heap_malloc_aligned,h,n,a)
|
||||
#define mi_heap_zalloc_aligned(h,n,a) MI_SOURCE_LOC(mi_heap_zalloc_aligned,h,n,a)
|
||||
|
@ -62,7 +62,7 @@ extern inline void* _mi_page_malloc(mi_heap_t* heap, mi_page_t* page, size_t siz
|
||||
}
|
||||
|
||||
// allocate a small block
|
||||
MI_ALLOC_API1(mi_decl_restrict void*, malloc_small, mi_heap_t*, heap, size_t, size)
|
||||
MI_ALLOC_API1(inline mi_decl_restrict void*, malloc_small, mi_heap_t*, heap, size_t, size)
|
||||
{
|
||||
mi_assert(heap!=NULL);
|
||||
mi_assert(heap->thread_id == 0 || heap->thread_id == _mi_thread_id()); // heaps are thread local
|
||||
@ -81,7 +81,7 @@ MI_ALLOC_API1(mi_decl_restrict void*, malloc_small, mi_heap_t*, heap, size_t, si
|
||||
|
||||
|
||||
// The main allocation function
|
||||
MI_ALLOC_API1(mi_decl_restrict void*, malloc, mi_heap_t*, heap, size_t, size)
|
||||
MI_ALLOC_API1(inline mi_decl_restrict void*, malloc, mi_heap_t*, heap, size_t, size)
|
||||
{
|
||||
if (mi_likely(size <= MI_SMALL_SIZE_MAX)) {
|
||||
return mi_base_malloc_small(heap, size MI_SOURCE_XARG);
|
||||
|
Loading…
x
Reference in New Issue
Block a user