Skip to content

Commit 3cd6861

Browse files
authored
[mimalloc] Remove no-longer-needed limit on emmalloc alignment (#21905)
#20704 removed the maximum alignment limit from emmalloc, so we no longer need it in the mimalloc port. Without it, we can properly use the 4GB-aligned pages that mimalloc requests.
1 parent e7e3b25 commit 3cd6861

File tree

1 file changed

+2
-10
lines changed
  • system/lib/mimalloc/src/prim/emscripten

1 file changed

+2
-10
lines changed

system/lib/mimalloc/src/prim/emscripten/prim.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* ----------------------------------------------------------------------------
2-
Copyright (c) 2018-2023, Microsoft Research, Daan Leijen
2+
Copyright (c) 2018-2023, Microsoft Research, Daan Leijen, Alon Zakai
33
This is free software; you can redistribute it and/or modify it under the
44
terms of the MIT license. A copy of the license can be found in the file
55
"LICENSE" at the root of this distribution.
@@ -78,17 +78,10 @@ int _mi_prim_alloc(size_t size, size_t try_alignment, bool commit, bool allow_la
7878
// That assumes no one else uses sbrk but us (they could go up,
7979
// scribble, and then down), but we could assert on that perhaps.
8080
*is_zero = false;
81-
// emmalloc has some limitations on alignment size.
82-
// TODO: Why does mimalloc ask for an align of 4MB? that ends up allocating
83-
// 8, which wastes quite a lot for us in wasm. If that is unavoidable,
84-
// we may want to improve emmalloc to support such alignment. See also
85-
// https://github.com/emscripten-core/emscripten/issues/20645
81+
// emmalloc has a minimum alignment size.
8682
#define MIN_EMMALLOC_ALIGN 8
87-
#define MAX_EMMALLOC_ALIGN (1024*1024)
8883
if (try_alignment < MIN_EMMALLOC_ALIGN) {
8984
try_alignment = MIN_EMMALLOC_ALIGN;
90-
} else if (try_alignment > MAX_EMMALLOC_ALIGN) {
91-
try_alignment = MAX_EMMALLOC_ALIGN;
9285
}
9386
void* p = emmalloc_memalign(try_alignment, size);
9487
*addr = p;
@@ -249,4 +242,3 @@ void _mi_prim_thread_associate_default_heap(mi_heap_t* heap) {
249242

250243
}
251244
#endif
252-

0 commit comments

Comments
 (0)