Skip to content

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

Description

@littledan

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions