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

View File

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