use WebAssembly.instantiateStreaming #6709
This is probably going to be a long PR, that's just an early preview.
What kind of change does this PR introduce?
wasm-edit and WebAssembly.instantiateStreaming
Also includes #6531.
For ref xtuc/webassemblyjs#196
Did you add tests for your changes?
If relevant, link to documentation update:
Does this PR introduce a breaking change?
A few open thoughts
Unfortunately using a WebAssembly.Table for the interop with Webpack don't work because we are not able to
The table has some good advantages tho:
Another idea, we could inject a new function that will fill the globals that were imported.
(module (import "env" "global" (global i32)) (func (export "t") (result i32) (get_global 0) ) )
(module (global (mut i32) (i32.const 0)) (func (export "t") (result i32) (get_global 0) ) (func (export "init") (param i32) (get_local 0) (set_global 0) ) )
We first call
This solution doesn't require much transformation to the binary. According to v8's limits, a function can have 1k params (so 1k global imports, note that if that doesn't suffice we can add a second init function):
While we change the mutability of the global, that program has already been compiled and ensures that the user don't modify the global (I hope).
Globals and functions indices are preserved.
sokra left a comment
Looks pretty good so far.
FetchCompileWasmMainTemplatePlugin is only used for browser target. The tests and node.js target uses ReadFileCompileWasmTemplatePlugin, this need to be changed too. It makes sense here to move the common code into a new file.
This reverts commit 0ef8c12.