From b19da8e362acae8944c60a40cf5c40c8f5ebeb44 Mon Sep 17 00:00:00 2001 From: Daan Date: Tue, 6 Apr 2021 11:05:43 -0700 Subject: [PATCH 1/2] update readme for 1.7.1 and 2.0.1 --- readme.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 00c6fbd1..e3662368 100644 --- a/readme.md +++ b/readme.md @@ -12,8 +12,8 @@ is a general purpose allocator with excellent [performance](#performance) charac Initially developed by Daan Leijen for the run-time systems of the [Koka](https://koka-lang.github.io) and [Lean](https://github.com/leanprover/lean) languages. -Latest release tag: `v2.0.0` (beta, 2021-01-31). -Latest stable tag: `v1.7.0` (2021-01-31). +Latest release tag: `v2.0.1` (beta, 2021-04-06). +Latest stable tag: `v1.7.1` (2021-04-06). mimalloc is a drop-in replacement for `malloc` and can be used in other programs without code changes, for example, on dynamically linked ELF-based systems (Linux, BSD, etc.) you can use it as: @@ -71,8 +71,10 @@ Enjoy! * `dev`: development branch for mimalloc v1. * `dev-slice`: development branch for mimalloc v2 with a new algorithm for managing internal mimalloc pages. -### Release +### Releases +* 2021-04-06, `v1.7.1`, `v2.0.1` (beta): fix bug in arena allocation for huge pages, improved aslr on large allocations, improved M1 support (still experimental). + * 2021-01-31, `v2.0.0`: beta release 2.0: new algorithm for managing internal mimalloc pages that tends to use reduce memory usage and fragmentation compared to mimalloc v1 (especially for large workloads). Should otherwise have similar performance (see [below](#performance)); please report if you observe any significant performance regression. From 3402c6cc3f439e8be04ff99afea2c810f27af035 Mon Sep 17 00:00:00 2001 From: Jim Huang Date: Mon, 19 Apr 2021 01:02:13 +0800 Subject: [PATCH 2/2] Revise the use of macOS predefined macro Quoted from "Porting UNIX/Linux Applications to OS X,"[1] * macro __MACH__ is defined if Mach system calls are supported; * macro __APPLE__ is defined in any Apple computer. __MACH__ is not specific to macOS since GNU/Hurd runs on a Mach-based microkernel (gnumach) [2]. __MACH__ is defined by the compiler, leading to potential confusions. The solution is just changing the checked identifier (i.e. __APPLE__), so it is really used only on macOS. [1] https://developer.apple.com/library/archive/documentation/Porting/Conceptual/PortingUnix/compiling/compiling.html [2] https://www.gnu.org/software/hurd/microkernel/mach/gnumach.html --- include/mimalloc-internal.h | 6 +++--- src/alloc-override.c | 8 ++++---- src/options.c | 4 ++-- src/stats.c | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/mimalloc-internal.h b/include/mimalloc-internal.h index 7160bc47..5655cd48 100644 --- a/include/mimalloc-internal.h +++ b/include/mimalloc-internal.h @@ -293,7 +293,7 @@ extern bool _mi_process_is_initialized; mi_heap_t* _mi_heap_main_get(void); // statically allocated main backing heap #if defined(MI_MALLOC_OVERRIDE) -#if defined(__MACH__) // OSX +#if defined(__APPLE__) // macOS #define MI_TLS_SLOT 89 // seems unused? // other possible unused ones are 9, 29, __PTK_FRAMEWORK_JAVASCRIPTCORE_KEY4 (94), __PTK_FRAMEWORK_GC_KEY9 (112) and __PTK_FRAMEWORK_OLDGC_KEY9 (89) // see @@ -699,7 +699,7 @@ static inline void* mi_tls_slot(size_t slot) mi_attr_noexcept { const size_t ofs = (slot*sizeof(void*)); #if defined(__i386__) __asm__("movl %%gs:%1, %0" : "=r" (res) : "m" (*((void**)ofs)) : ); // 32-bit always uses GS -#elif defined(__MACH__) && defined(__x86_64__) +#elif defined(__APPLE__) && defined(__x86_64__) __asm__("movq %%gs:%1, %0" : "=r" (res) : "m" (*((void**)ofs)) : ); // x86_64 macOSX uses GS #elif defined(__x86_64__) && (MI_INTPTR_SIZE==4) __asm__("movl %%fs:%1, %0" : "=r" (res) : "m" (*((void**)ofs)) : ); // x32 ABI @@ -726,7 +726,7 @@ static inline void mi_tls_slot_set(size_t slot, void* value) mi_attr_noexcept { const size_t ofs = (slot*sizeof(void*)); #if defined(__i386__) __asm__("movl %1,%%gs:%0" : "=m" (*((void**)ofs)) : "rn" (value) : ); // 32-bit always uses GS -#elif defined(__MACH__) && defined(__x86_64__) +#elif defined(__APPLE__) && defined(__x86_64__) __asm__("movq %1,%%gs:%0" : "=m" (*((void**)ofs)) : "rn" (value) : ); // x86_64 macOSX uses GS #elif defined(__x86_64__) && (MI_INTPTR_SIZE==4) __asm__("movl %1,%%fs:%1" : "=m" (*((void**)ofs)) : "rn" (value) : ); // x32 ABI diff --git a/src/alloc-override.c b/src/alloc-override.c index 5906bd20..b4a661b8 100644 --- a/src/alloc-override.c +++ b/src/alloc-override.c @@ -13,13 +13,13 @@ terms of the MIT license. A copy of the license can be found in the file #error "It is only possible to override "malloc" on Windows when building as a DLL (and linking the C runtime as a DLL)" #endif -#if defined(MI_MALLOC_OVERRIDE) && !(defined(_WIN32)) // || (defined(__MACH__) && !defined(MI_INTERPOSE))) +#if defined(MI_MALLOC_OVERRIDE) && !(defined(_WIN32)) // || (defined(__APPLE__) && !defined(MI_INTERPOSE))) // ------------------------------------------------------ // Override system malloc // ------------------------------------------------------ -#if (defined(__GNUC__) || defined(__clang__)) && !defined(__MACH__) +#if (defined(__GNUC__) || defined(__clang__)) && !defined(__APPLE__) // use aliasing to alias the exported function to one of our `mi_` functions #if (defined(__GNUC__) && __GNUC__ >= 9) #define MI_FORWARD(fun) __attribute__((alias(#fun), used, visibility("default"), copy(fun))) @@ -81,7 +81,7 @@ terms of the MIT license. A copy of the license can be found in the file void free(void* p) MI_FORWARD0(mi_free, p); #endif -#if (defined(__GNUC__) || defined(__clang__)) && !defined(__MACH__) +#if (defined(__GNUC__) || defined(__clang__)) && !defined(__APPLE__) #pragma GCC visibility push(default) #endif @@ -214,7 +214,7 @@ void* aligned_alloc(size_t alignment, size_t size) { return mi_aligned_alloc(a } #endif -#if (defined(__GNUC__) || defined(__clang__)) && !defined(__MACH__) +#if (defined(__GNUC__) || defined(__clang__)) && !defined(__APPLE__) #pragma GCC visibility pop #endif diff --git a/src/options.c b/src/options.c index 6e229f9f..14df8fba 100644 --- a/src/options.c +++ b/src/options.c @@ -259,7 +259,7 @@ static _Atomic(uintptr_t) warning_count; // = 0; // when >= max_warning_count s static mi_decl_thread bool recurse = false; static bool mi_recurse_enter(void) { - #if defined(__MACH__) || defined(MI_TLS_RECURSE_GUARD) + #if defined(__APPLE__) || defined(MI_TLS_RECURSE_GUARD) if (_mi_preloading()) return true; #endif if (recurse) return false; @@ -268,7 +268,7 @@ static bool mi_recurse_enter(void) { } static void mi_recurse_exit(void) { - #if defined(__MACH__) || defined(MI_TLS_RECURSE_GUARD) + #if defined(__APPLE__) || defined(MI_TLS_RECURSE_GUARD) if (_mi_preloading()) return; #endif recurse = false; diff --git a/src/stats.c b/src/stats.c index 8cd74e41..a82eeb8a 100644 --- a/src/stats.c +++ b/src/stats.c @@ -479,12 +479,12 @@ static void mi_stat_process_info(mi_msecs_t* elapsed, mi_msecs_t* utime, mi_msec *page_faults = (size_t)info.PageFaultCount; } -#elif defined(__unix__) || defined(__unix) || defined(unix) || (defined(__APPLE__) && defined(__MACH__)) || defined(__HAIKU__) +#elif defined(__unix__) || defined(__unix) || defined(unix) || defined(__APPLE__) || defined(__HAIKU__) #include #include #include -#if defined(__APPLE__) && defined(__MACH__) +#if defined(__APPLE__) #include #endif @@ -520,7 +520,7 @@ static void mi_stat_process_info(mi_msecs_t* elapsed, mi_msecs_t* utime, mi_msec while (get_next_area_info(tid.team, &c, &mem) == B_OK) { *peak_rss += mem.ram_size; } -#elif defined(__APPLE__) && defined(__MACH__) +#elif defined(__APPLE__) *peak_rss = rusage.ru_maxrss; // BSD reports in bytes struct mach_task_basic_info info; mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT;