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.
This commit is contained in:
Mitchell Hashimoto
2022-12-24 16:41:37 -08:00
parent 2e462a3e7c
commit af6fb294d0

View File

@ -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