Changing mblock size for wasm target increases failing tests
Currently, if the default MBLOCK_SHIFT
is changed for wasm target, there are roughly 100 new test failures. This is not ideal and should be fixed some time in the future, for the following reasons:
- On any platform, the
MBLOCK_SHIFT
literal ought to be the single source of truth, and changing it should only affect performance of compiled code, not correctness. - The default mblock size may not be ideal for wasm32. A smaller one may make more sense, e.g. changing it to page-sized (65536) will make it possible to drop a
wasi-libc
patch; also making it more practical to run the wasm in a rather resource-constrained runtime.
Below is one place that violates the single source of truth principle for MBLOCK_SHIFT
, and there's likely more out there that ought to be fixed.
--- a/rts/sm/HeapAlloc.h
+++ b/rts/sm/HeapAlloc.h
@@ -64,7 +64,7 @@ extern struct mblock_address_range mblock_address_space;
extern StgWord8 mblock_map[];
/* On a 32-bit machine a 4KB table is always sufficient */
-# define MBLOCK_MAP_SIZE 4096
+# define MBLOCK_MAP_SIZE (1 << (32 - MBLOCK_SHIFT))
# define MBLOCK_MAP_ENTRY(p) ((StgWord)(p) >> MBLOCK_SHIFT)
# define HEAP_ALLOCED(p) mblock_map[MBLOCK_MAP_ENTRY(p)]
# define HEAP_ALLOCED_GC(p) HEAP_ALLOCED(p)