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

API to instantiate a module from a bytes #477

Open
kgtkr opened this issue Apr 7, 2022 · 3 comments
Open

API to instantiate a module from a bytes #477

kgtkr opened this issue Apr 7, 2022 · 3 comments
Labels
feature-request Requests for new WASI APIs

Comments

@kgtkr
Copy link

kgtkr commented Apr 7, 2022

JavaScript API has WebAssembly.compile and WebAssembly.instantiate.
There seems to be no equivalent to this in wasi.

For example, if wasi have this, it should be able to realize a JIT compiler by generating a wasm module bytes and instantiating it by passing a function or memory. We can already do this with the JavaScript API.

Module-linking proposal

This looks like a problem that the module-linking proposal doesn't solve.

The general case of runtime dynamic linking in the style of dlopen, where an
a priori unknown module is linked into the program at runtime, is not possible
to do purely within wasm with this proposal. Additional host-provided APIs are
required for:

  • compiling files or bytes into a module;

https://github.com/WebAssembly/module-linking/blob/main/design/proposals/module-linking/Example-SharedEverythingDynamicLinking.md#runtime-dynamic-linking

@SamuraiCrow
Copy link

Does the WITX to WIT transition address some of this? I remember seeing a new modularity feature being associated with the transition.

Secondly, I think dynamic code generation is incompatible with static compilation. It would only work during AOT or JIT compilation.

@abrown
Copy link
Contributor

abrown commented Apr 8, 2022

Seems like an interesting idea!

@sunfishcode
Copy link
Member

I agree, I expect we will eventually want APIs for dynamic instantiation from module bytes. To do this, we'll likely want first-class type for holding references to dynamically created instances. These instance references could then be passed into other instances, potentially forming reference cycles, which means it'll probably need some form of GC.

Also, the ability to create code dynamically will need to be coordinated with the content-security-policy.

The WITX to WIT transition does not add dynamic instantiation from wasm module bytes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Requests for new WASI APIs
Projects
None yet
Development

No branches or pull requests

4 participants