Skip to content

Add initial support for WebAssembly Interface Types#282

Merged
tschneidereit merged 1 commit intobytecodealliance:masterfrom
alexcrichton:wasm-interface-types
Aug 19, 2019
Merged

Add initial support for WebAssembly Interface Types#282
tschneidereit merged 1 commit intobytecodealliance:masterfrom
alexcrichton:wasm-interface-types

Conversation

@alexcrichton
Copy link
Member

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-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.

Co-authored-by: Yury Delendik ydelendik@mozilla.com

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>
@alexcrichton
Copy link
Member Author

Some more logistical notes on this are:

  • There are three new builders of the Python extension all present on CI (Windows/Mac/Linux). The main thing to note here is that a nightly version of Rust is used (pinned for now to hopefully reduce breakage)
  • The Python extension is published to GitHub artifacts for releases in the same manner that the wasmtime binary itself is.
  • This is a sort of mass-import of what Yury/I have been working on. It's had some rounds of pre-review in preparation, but this is all likely to be in a state of flux for some time now!

@tschneidereit
Copy link
Member

@yurydelendik, @alexcrichton, @sunfishcode, and I have reviewed this over the last few days, so it's good to go!

@tschneidereit tschneidereit merged commit af2b4e4 into bytecodealliance:master Aug 19, 2019
@alexcrichton alexcrichton deleted the wasm-interface-types branch August 19, 2019 11:32
@@ -0,0 +1,3 @@
import.wasm
main.wasm
__pycache__ No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing trailing newline

@@ -0,0 +1,3 @@
one.wasm
two.wasm
__pycache__ No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

@@ -0,0 +1,17 @@

Copy link
Contributor

@bjorn3 bjorn3 Aug 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this empty line?

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>
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

Successfully merging this pull request may close these issues.

4 participants