[whatwg/streams] Could a byte stream be read directly into and out of a SAB (w/o transfer)? (#757)

It would be really great if wasm could read from a stream directly into its memory.  The backing `ArrayBuffer` of a `WebAssembly.Memory` cannot be detached (nor would you want to since it holds the general program state needed for execution in the meantime) so what would be great is if the caller of a read or write could pass a typed array view of a buffer that is *not* detached.  For a regular `ArrayBuffer`, this would mean some additional copying to avoid races.  However, if the buffer is a `SharedArrayBuffer`, then perhaps it would be fine to expose the races (and no worse than anything else with SAB).

As an additional benefit, I think the implementation of "read into a view" from a file-backed stream could use `mmap` to make a copy-on-write mapping of the file directly into the target memory.

(cc @flagxor)

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/757

Received on Monday, 24 July 2017 21:38:17 UTC