Skip to content
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

Closed
littledan opened this issue Oct 15, 2018 · 3 comments
Closed

Circular imports of functions as a host-bindings follow-on? #17

littledan opened this issue Oct 15, 2018 · 3 comments

Comments

@littledan
Copy link
Collaborator

littledan commented Oct 15, 2018

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?

@xtuc
Copy link
Contributor

xtuc commented Oct 16, 2018

[...] rewriting parts of the code to implement live bindings.

They aren't really live bindings, we pass the values once the module has been instantiated. Here's one example webpack/webpack#6433 (comment).

@littledan
Copy link
Collaborator Author

littledan commented Oct 16, 2018

@xtuc I see, thanks for explaining. Is that how circular Wasm function imports work too?

@xtuc
Copy link
Contributor

xtuc commented Oct 16, 2018

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.

xtuc pushed a commit to xtuc/esm-integration that referenced this issue Aug 13, 2019
- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants