Comment by Dwedit

Comment by Dwedit 9 hours ago

3 replies

I just wish WASM could use more than one ArrayBuffer at a time. Would eliminate unnecessary copying for interop with JS code.

Dwedit 3 hours ago

Well I just thought of something obvious... Have a function that lets you pass in an ArrayBuffer, then it brings it into the virtual address space of the WASM program. Function would return the virtual address that was assigned to that array buffer. From there, you call into WASM again with that pointer, and the program can take action.

Then there would be another function to relinquish ownership of the ArrayBuffer.

  • throwaway290 3 hours ago

    There's no SharedArrayBuffer support? Or I misunderstand the idea

    • flohofwoe an hour ago

      There is, but then you'd need to declare the entire WASM heap as a single SharedArrayBuffer. It only makes sense for shared-memory multithreading (but not that support for SharedArrayBuffer only works in 'cross-origin isolated' contexts).

      There is a related 'multiple memories' proposal btw: https://github.com/WebAssembly/multi-memory