Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8751,8 +8751,7 @@ def test_mallinfo(self):
@parameterized({
'': ([],),
'emmalloc': (['-sMALLOC=emmalloc'],),
# TODO: investigate removing `-sABORTING_MALLOC=0`, as it's only needed for `wasm64_4gb.test_wrap_malloc_mimalloc`
'mimalloc': (['-sMALLOC=mimalloc', '-sABORTING_MALLOC=0'],),
'mimalloc': (['-sMALLOC=mimalloc'],),
})
def test_wrap_malloc(self, args):
self.do_runf('core/test_wrap_malloc.c', 'done\n', cflags=args)
Expand Down
5 changes: 4 additions & 1 deletion tools/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -1516,11 +1516,14 @@ def limit_incoming_module_api():
if not settings.DECLARE_ASM_MODULE_EXPORTS:
settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['$assignWasmExports']

if settings.ALLOW_MEMORY_GROWTH:
if settings.ALLOW_MEMORY_GROWTH or settings.MALLOC == 'mimalloc':
# Setting ALLOW_MEMORY_GROWTH turns off ABORTING_MALLOC, as in that mode we default to
# the behavior of trying to grow and returning 0 from malloc on failure, like
# a standard system would. However, if the user sets the flag it
# overrides that.
# Also default to non-aborting malloc behavior for -sMALLOC=mimalloc,
# so mimalloc can handle allocation failures from its underlying emmalloc
# allocator and fall back gracefully.
default_setting('ABORTING_MALLOC', 0)

if settings.EMBIND:
Expand Down
4 changes: 2 additions & 2 deletions tools/system_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1895,8 +1895,8 @@ class libmimalloc(MTLibrary):
'-DMI_LIBC_MUSL',
# enable use of `__builtin_thread_pointer()`
'-DMI_USE_BUILTIN_THREAD_POINTER',
# always use the page map when free-ing a pointer, as we don't support
# large OS aligned allocations well
# always use the page map in `mi_free()`, as we don't support large
# aligned allocations well (needed for aligned page metadata)
Comment on lines +1898 to +1899

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive-by: I've synced this comment with:

// Always use the page map in `mi_free` on CHERI as we cannot derive the page meta-data from a (bounded) user pointer,
// and on WebAssembly as it cannot do large aligned allocations well (needed for aligned page meta-data).

'-DMI_FREE_USE_PAGEMAP=1',
# to reduce code size, disable environ customization, profiling and
# nonessential stats
Expand Down
Loading