Wasm32, 4gb limit, ArrayBuffer

  1. ArrayBuffer - JavaScript | MDN is allocated in JS land, off the wasm32 heap right ?

  2. Does this imply that in wasm32, we can create ArrayBuffer objects, whose storage does not count towards the 4GB limit ?

  3. What is the absolute fastest way to read/write wasm32 <-> ArrayBuffer ?

  4. For T: Copy, can we create a MyVec<T> that is backed by an ArrayBuffer ?

Yes

They're created in javascript, so you can't directly access them in wasm.

If you try to pass them to wasm as an array you'll have to copy them, and that will count torwards the 4GB limit (otherwise how would you be able to address them?).

Alternatively you can keep it in js land and access it only through host functions, but do note that calling into the host is relatively slow.

Question 3. and 4. depend on how you choose to represent the ArrayBuffer in wasm land.

Are you aware of Calls between JavaScript and WebAssembly are finally fast 🎉 - Mozilla Hacks - the Web developer blog ? I have not benchmarked it myself, but the blog post seems to imply it is quite fast.

I wonder what block size we need to copy over from ArrayBuffer to wasm32 land to have it dwarf out the js call overhead. 4kb? 64kb 1MB ?