Stream: git-wasmtime

Topic: wasmtime / PR #4039 components: Implement the ability to ...


view this post on Zulip Wasmtime GitHub notifications bot (Apr 15 2022 at 19:53):

alexcrichton requested fitzgen for a review on PR #4039.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 15 2022 at 19:53):

alexcrichton opened PR #4039 from component-call-export to main:

This commit is an implementation of the typed method of calling
component exports. This is intended to represent the most efficient way
of calling a component in Wasmtime, similar to what TypedFunc
represents today for core wasm.

Internally this contains all the traits and implementations necessary to
invoke component exports with any type signature (e.g. arbitrary
parameters and/or results). The expectation is that for results we'll
reuse all of this infrastructure except in reverse (arguments and
results will be swapped when defining imports).

Some features of this implementation are:

The goal of this commit is to create the ability to actually invoke wasm
components. This represents what is expected to be the performance
threshold for these calls where it ideally should be optimal how
WebAssembly is invoked. One major missing piece of this is a #[derive]
of some sort to generate Rust types for arbitrary *.wit types such as
custom records, variants, flags, unions, etc. The current trait impls
for tuples and Result<T, E> are expected to have fleshed out most of
what such a derive would look like.

There are some downsides and missing pieces to this commit and method of
calling components, however, such as:

Overall I'm feeling optimistic about this trajectory of implementing
value lifting/lowering in Wasmtime. While there are a number of
downsides none seem completely insurmountable. There's naturally still a
good deal of work with the component model but this should be a
significant step up towards implementing and testing the component model.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 18 2022 at 21:15):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 18 2022 at 21:15):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 18 2022 at 21:15):

fitzgen created PR review comment:

Don't we have impls of plain T for TypedFunc? Can we do the same here? I guess that would introduce ambiguity between a single tuple parameter and N parameters?

view this post on Zulip Wasmtime GitHub notifications bot (Apr 18 2022 at 21:15):

fitzgen created PR review comment:

    /// Calling a function which takes multiple parameters and returns a boolean:

view this post on Zulip Wasmtime GitHub notifications bot (Apr 18 2022 at 21:15):

fitzgen created PR review comment:

Maybe easier for folks to understand if we talk about how scalars don't use Value vs compound types do use Value? I think they are the same, right? Unless the canonical ABI packs, e.g., an interface type (tuple u32 u32) into a Wasm i64 return.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 18 2022 at 21:15):

fitzgen created PR review comment:

Can we factor 0xab out into const CANON_ABI_UNINIT_PATTERN: u8 = 0xAB; or something?

view this post on Zulip Wasmtime GitHub notifications bot (Apr 18 2022 at 21:15):

fitzgen created PR review comment:

Debug assert that align is a power of two (which the & stuff relies on, I believe)?

Alternatively, just use division (which will work with non-powers-of-two) and let LLVM clean up the generated code.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 18 2022 at 21:15):

fitzgen created PR review comment:

Can we debug_assert! the type signature of realloc here?

view this post on Zulip Wasmtime GitHub notifications bot (Apr 18 2022 at 21:15):

fitzgen created PR review comment:

            other => bail!("expected `string` found `{}`", desc(other)),

view this post on Zulip Wasmtime GitHub notifications bot (Apr 18 2022 at 21:15):

fitzgen created PR review comment:

    /// Views this instance of `ComponentParams` as a tuple, allowing

view this post on Zulip Wasmtime GitHub notifications bot (Apr 18 2022 at 21:15):

fitzgen created PR review comment:

        // Perform the lowering operation for the parameters which will write

view this post on Zulip Wasmtime GitHub notifications bot (Apr 19 2022 at 13:59):

alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 19 2022 at 13:59):

alexcrichton created PR review comment:

We do have impls for plain T, yeah. But yes as you deduced the ambiguity prevents the impl from existing for interface types.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 28 2022 at 18:49):

alexcrichton updated PR #4039 from component-call-export to main.

view this post on Zulip Wasmtime GitHub notifications bot (May 20 2022 at 20:53):

alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (May 20 2022 at 20:53):

alexcrichton created PR review comment:

Indeed! This is done in call_raw

view this post on Zulip Wasmtime GitHub notifications bot (May 20 2022 at 20:54):

alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (May 20 2022 at 20:54):

alexcrichton created PR review comment:

Unfortunately this isn't 100% accurate advice in the sense that (tuple u32) is returned by-value. No fancy bit-packing happens but if the number of return values is small enough (e.g. 1) then it's returned by-value.

view this post on Zulip Wasmtime GitHub notifications bot (May 20 2022 at 20:55):

alexcrichton updated PR #4039 from component-call-export to main.

view this post on Zulip Wasmtime GitHub notifications bot (May 24 2022 at 18:08):

alexcrichton updated PR #4039 from component-call-export to main.

view this post on Zulip Wasmtime GitHub notifications bot (May 24 2022 at 18:08):

alexcrichton has marked PR #4039 as ready for review.

view this post on Zulip Wasmtime GitHub notifications bot (May 24 2022 at 18:14):

alexcrichton requested fitzgen for a review on PR #4039.

view this post on Zulip Wasmtime GitHub notifications bot (May 24 2022 at 19:24):

alexcrichton updated PR #4039 from component-call-export to main.

view this post on Zulip Wasmtime GitHub notifications bot (May 24 2022 at 19:26):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (May 24 2022 at 19:26):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (May 24 2022 at 19:26):

fitzgen created PR review comment:

// A simple bump allocator which can be used with modules below.

view this post on Zulip Wasmtime GitHub notifications bot (May 24 2022 at 19:43):

alexcrichton updated PR #4039 from component-call-export to main.

view this post on Zulip Wasmtime GitHub notifications bot (May 24 2022 at 22:02):

alexcrichton merged PR #4039.


Last updated: Oct 23 2024 at 20:03 UTC