File tree Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change 66
77// Define configuration macros for dlmalloc.
88
9- #ifdef __faasm
10- // Faasm supports mmap/ munmap
11- #define HAVE_MMAP 1
9+ // WebAssembly doesn't have mmap-style memory allocation.
10+ #define HAVE_MMAP 0
1211
13- // Faasm supports normal wasm memory growth, but we need to be able to reclaim
14- // memory, so force everything through mmap/ munmap
12+ #ifdef __faasm
13+ // Faasm supports memory growth and shrinkage with sbrk-style positive and
14+ // negative allocation. We need to be explicit about sbrk usage (HAVE_MORECORE
15+ // set to 1) and not mmap/munmap usage (HAVE_MMAP set to 0, default in WASM).
16+ // Note that this does not mean that we don't support application code using
17+ // mmap/munmap, it means that heap is only managed with sbrk
1518#define HAVE_MORECORE 1
1619#define MORECORE_CONTIGUOUS 1
1720
18- // Faasm supports shrinking linear memory using offsets
21+ // We don't shrink the linear memory, but claim the pages for the runtime, and
22+ // move the offset down, so that subsequent allocations can re-use the free-ed
23+ // memory
1924#define MORECORE_CANNOT_TRIM 0
20-
2125#else
22- // WebAssembly doesn't have mmap-style memory allocation.
23- #define HAVE_MMAP 0
24-
2526// WebAssembly doesn't support shrinking linear memory.
2627#define MORECORE_CANNOT_TRIM 1
2728#endif
You can’t perform that action at this time.
0 commit comments