From af6fb294d0ebe23e19ccda26e18cbdfc82cdfc89 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 24 Dec 2022 16:41:37 -0800 Subject: [PATCH] wasm: use wasm allocator, rather than page allocator Uses 4x less pages because we're not allocating 1 page (more or less) per allocation and instead actually bin-packing it a bit. --- src/os/wasm.zig | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/os/wasm.zig b/src/os/wasm.zig index 31435314b..1be8bb011 100644 --- a/src/os/wasm.zig +++ b/src/os/wasm.zig @@ -19,14 +19,10 @@ pub const shared_mem = options.wasm_shared; /// unless toHostOwned is called on them. In this case, the caller is expected /// to call free. If a pointer is NOT host-owned, then the wasm module is /// expected to call the normal alloc.free/destroy functions. -/// -/// TODO: we should NOT be using page_allocator because we're getting -/// full 64kb pages for every allocation. I plan on changing this to the -/// new stdlib wasm allocator once that is merged and available. pub const alloc = if (builtin.is_test) std.testing.allocator else - std.heap.page_allocator; + std.heap.wasm_allocator; /// For host-owned allocations: /// We need to keep track of our own pointer lengths because Zig