-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
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
| if (isolate->wasm_compile_streaming_callback() != nullptr) { | |
| InstallFunc(isolate, webassembly, "compileStreaming", | |
| WebAssemblyCompileStreaming, 1); | |
| InstallFunc(isolate, webassembly, "instantiateStreaming", | |
| WebAssemblyInstantiateStreaming, 1); | |
| } |
To cover this branch, we must call SetWasmCompileStreamingCallback.
Line 7805 in de73272
| void SetWasmCompileStreamingCallback(ApiImplementationCallback callback); |
Lines 8876 to 8877 in de73272
| CALLBACK_SETTER(WasmCompileStreamingCallback, ApiImplementationCallback, | |
| wasm_compile_streaming_callback) |
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
instantiateStreamingcompatible with design.- ex.
instantiateStreaming(fs.promises.readFile('./some.wasm'), importObject)- It's not compatible with design.
- readFile returns
Buffer, notArrayBuffer.
- ex.