-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Circular imports of functions as a host-bindings follow-on? #17
Comments
They aren't really live bindings, we pass the values once the module has been instantiated. Here's one example webpack/webpack#6433 (comment). |
@xtuc I see, thanks for explaining. Is that how circular Wasm function imports work too? |
That's more or less a side-effect, but yes. IRC a circular import with the same module is in discussion somewhere (maybe for threads, I can't remember) and that would be possible in Webpack. |
- Initialize Wasm exports in TDZ; closes WebAssembly#18 - Document motivation for no circular modules and circular imports of functions as a follow-on; closes WebAssembly#17 - Avoid use of the term "live binding"; closes WebAssembly#19 - Permit imports of Numbers as constant globals; closes WebAssembly#16
Thanks to @xtuc and @sokra, webpack supports WebAssembly modules. We're currently discussing how to align webpack and the new specification in this repository.
One interesting thing about webpack is that (if I understand correctly) it supports cyclic Wasm modules importing globals and functions, rewriting parts of the code to implement live bindings.
Webpack implements these circular imports on top of the Wasm/JS API, so it's doing it without interrupting the Wasm instantiate path. I believe that's just the invariant we need we need in order to make type imports work.
As an MVP, I think it's OK to leave out circular Wasm modules, but I'd like to go about this design thinking about enabling some limited use of circular modules as a follow-on proposal. It would still be based on, modules are instantiated one by one, separately, but if you mark an import as "circular" with host bindings, then an extra snippet is generated to create a function that throws an exception, until the other module is loaded, and then it forwards to that other function.
Thoughts?
The text was updated successfully, but these errors were encountered: