Description
I think it's better support WebAssembly.instantiateStreaming
.
It makes more easy to use WebAssembly and we can get more compatibility for Web.
It already implemented in Google Chrome, Firefox and some browsers.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming
instantiateStreaming
already exists in deps/v8/src/wasm/wasm-js.cc
but cannot cover this branch.
node/deps/v8/src/wasm/wasm-js.cc
Lines 1177 to 1182 in de73272
To cover this branch, we must call SetWasmCompileStreamingCallback
.
Line 7805 in de73272
Lines 8876 to 8877 in de73272
In chromium, implemented here:
https://github.com/chromium/chromium/blob/51459d663d841c6430747aec97be9f7e7a7ca41f/third_party/blink/renderer/bindings/core/v8/v8_wasm_response_extensions.cc#L194-L222
And use it here:
https://github.com/chromium/chromium/blob/51459d663d841c6430747aec97be9f7e7a7ca41f/third_party/blink/renderer/bindings/core/v8/v8_wasm_response_extensions.cc#L228
Why we must inject the actual implementation,
It's said that this is for layering reasons.
WebAssembly/design#1085
Discussion
- How about it?
- How to make
instantiateStreaming
compatible with design.- ex.
instantiateStreaming(fs.promises.readFile('./some.wasm'), importObject)
- It's not compatible with design.
- readFile returns
Buffer
, notArrayBuffer
.
- ex.