Add initial support for WebAssembly Interface Types#282
Merged
tschneidereit merged 1 commit intobytecodealliance:masterfrom Aug 19, 2019
Merged
Add initial support for WebAssembly Interface Types#282tschneidereit merged 1 commit intobytecodealliance:masterfrom
tschneidereit merged 1 commit intobytecodealliance:masterfrom
Conversation
This commit adds initial support for [WebAssembly Interface
Types][proposal] to wasmtime. This is all intended to be quite
experimental, so experimental in fact that even the name of the
[proposal] is still in flux. (this has otherwise been known as "host
bindings" or "webidl bindings" or "wasm bindings").
The goal of this commit is to start adding support the wasmtime set of
crates for WebAssembly Interface Types. A new `wasmtime-interface-types`
crate has been added with very basic support for dynamically invoking
and inspecting the various bindings of a module. This is in turn powered
by the `wasm-webidl-bindings` crate which is shared with the
`wasm-bindgen` CLI tool as a producer of this section.
Currently the only integration in `wasmtime`-the-binary itself is that
when passed the `--invoke` argument the CLI will now attempt to invoke
the target function with arguments as parsed from the command line
itself. For example if you export a function like:
fn render(&str) -> String
Then passing `--invoke render` will require one argument on the command
line, which is the first argument as a string, and the return value is
printed to the console. This differs from today's interpretation of
`--invoke` where it is a failure if the invoked function takes more than
one argument and the return values are currently ignored.
This is intended to also be the basis of embedding wasmtime in other
contexts which also want to consume WebAssembly interface types. A
Python extension is also added to this repository which implements the
`wasmtime` package on PyPI. This Python extension is intended to make it
as easy as `pip3 install wasmtime` to load a WebAssembly file with
WebAssembly Interface Types into Python. Extensions for other languages
is of course possible as well!
One of the major missing pieces from this is handling imported functions
with interface bindings. Currently the embedding support doesn't have
much ability to support handling imports ergonomically, so it's intended
that this will be included in a follow-up patch.
[proposal]: https://github.com/webassembly/webidl-bindings
Co-authored-by: Yury Delendik <ydelendik@mozilla.com>
Member
Author
|
Some more logistical notes on this are:
|
Member
|
@yurydelendik, @alexcrichton, @sunfishcode, and I have reviewed this over the last few days, so it's good to go! |
bjorn3
reviewed
Aug 19, 2019
| @@ -0,0 +1,3 @@ | |||
| import.wasm | |||
| main.wasm | |||
| __pycache__ No newline at end of file | |||
| @@ -0,0 +1,3 @@ | |||
| one.wasm | |||
| two.wasm | |||
| __pycache__ No newline at end of file | |||
| @@ -0,0 +1,17 @@ | |||
|
|
|||
arkpar
pushed a commit
to paritytech/wasmtime
that referenced
this pull request
Mar 4, 2020
This reorganizes some things in ir.rst to put all instructions not meant for frontends to worry about in a dedicated section. Fixes bytecodealliance#282.
avanhatt
added a commit
to wellesley-prog-sys/wasmtime
that referenced
this pull request
Apr 9, 2025
Simple passthrough with narrowed type. Updates bytecodealliance#260 Co-authored-by: Alexa VanHattum <av111@wellesley.edu>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit adds initial support for WebAssembly Interface
Types to wasmtime. This is all intended to be quite
experimental, so experimental in fact that even the name of the
proposal is still in flux. (this has otherwise been known as "host
bindings" or "webidl bindings" or "wasm bindings").
The goal of this commit is to start adding support the wasmtime set of
crates for WebAssembly Interface Types. A new
wasmtime-interface-typescrate has been added with very basic support for dynamically invoking
and inspecting the various bindings of a module. This is in turn powered
by the
wasm-webidl-bindingscrate which is shared with thewasm-bindgenCLI tool as a producer of this section.Currently the only integration in
wasmtime-the-binary itself is thatwhen passed the
--invokeargument the CLI will now attempt to invokethe target function with arguments as parsed from the command line
itself. For example if you export a function like:
Then passing
--invoke renderwill require one argument on the commandline, which is the first argument as a string, and the return value is
printed to the console. This differs from today's interpretation of
--invokewhere it is a failure if the invoked function takes more thanone argument and the return values are currently ignored.
This is intended to also be the basis of embedding wasmtime in other
contexts which also want to consume WebAssembly interface types. A
Python extension is also added to this repository which implements the
wasmtimepackage on PyPI. This Python extension is intended to make itas easy as
pip3 install wasmtimeto load a WebAssembly file withWebAssembly Interface Types into Python. Extensions for other languages
is of course possible as well!
One of the major missing pieces from this is handling imported functions
with interface bindings. Currently the embedding support doesn't have
much ability to support handling imports ergonomically, so it's intended
that this will be included in a follow-up patch.
Co-authored-by: Yury Delendik ydelendik@mozilla.com