1
0
mirror of https://github.com/fluencelabs/wasm-bindgen synced 2025-04-05 03:41:05 +00:00

Ensure our JS heap is a dense array

Turns out `heap.fill(undefined)` is required to ensure it's a dense
array, otherwise we'll accidentally be a sparse array and much slower
than necessary!
This commit is contained in:
Alex Crichton 2018-11-30 13:23:41 -08:00
parent 29531c0abf
commit a83c3af4bf

@ -907,6 +907,7 @@ impl<'a> Context<'a> {
return; return;
} }
self.global(&format!("const heap = new Array({});", INITIAL_HEAP_OFFSET)); self.global(&format!("const heap = new Array({});", INITIAL_HEAP_OFFSET));
self.global("heap.fill(undefined);");
self.global(&format!("heap.push({});", INITIAL_HEAP_VALUES.join(", "))); self.global(&format!("heap.push({});", INITIAL_HEAP_VALUES.join(", ")));
} }