Stream: git-wasmtime

Topic: wasmtime / PR #2806 Fully support multiple returns in Was...


view this post on Zulip Wasmtime GitHub notifications bot (Apr 05 2021 at 18:33):

alexcrichton opened PR #2806 from multi-return to main:

For quite some time now Wasmtime has "supported" multiple return values,
but only in the mose bare bones ways. Up until recently you couldn't get
a typed version of functions with multiple return values, and never have
you been able to use Func::wrap with functions that return multiple
values. Even recently where Func::typed can call functions that return
multiple values it uses a double-indirection by calling a trampoline
which calls the real function.

The underlying reason for this lack of support is that cranelift's ABI
for returning multiple values is not possible to write in Rust. For
example if a wasm function returns two i32 values there is no Rust (or
C!) function you can write to correspond to that. This commit, however
fixes that.

This commit adds two new ABIs to Cranelift: WasmtimeSystemV and
WasmtimeFastcall. The intention is that these Wasmtime-specific ABIs
match their corresponding ABI (e.g. SystemV or WindowsFastcall) for
everything except how multiple values are returned. For multiple
return values we simply define our own version of the ABI which Wasmtime
implements, which is that for N return values the first is returned as
if the function only returned that and the latter N-1 return values are
returned via an out-ptr that's the last parameter to the function.

These custom ABIs provides the ability for Wasmtime to bind these in
Rust meaning that Func::wrap can now wrap functions that return
multiple values and Func::typed no longer uses trampolines when
calling functions that return multiple values. Although there's lots of
internal changes there's no actual changes in the API surface area of
Wasmtime, just a few more impls of more public traits which means that
more types are supported in more places!

Another change made with this PR is a consolidation of how the ABI of
each function in a wasm module is selected. The native SystemV ABI,
for example, is more efficient at returning multiple values than the
wasmtime version of the ABI (since more things are in more registers).
To continue to take advantage of this Wasmtime will now classify some
functions in a wasm module with the "fast" ABI. Only functions that are
not reachable externally from the module are classified with the fast
ABI (e.g. those not exported, used in tables, or used with ref.func).
This should enable purely internal functions of modules to have a faster
calling convention than those which might be exposed to Wasmtime itself.

Closes #1178

<!--

Please ensure that the following steps are all taken care of before submitting
the PR.

Please ensure all communication adheres to the code of conduct.
-->

view this post on Zulip Wasmtime GitHub notifications bot (Apr 05 2021 at 18:36):

alexcrichton updated PR #2806 from multi-return to main.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 05 2021 at 18:37):

alexcrichton updated PR #2806 from multi-return to main.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 05 2021 at 18:45):

alexcrichton updated PR #2806 from multi-return to main.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 05 2021 at 18:47):

alexcrichton updated PR #2806 from multi-return to main.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 05 2021 at 18:52):

alexcrichton updated PR #2806 from multi-return to main.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 05 2021 at 19:01):

bjorn3 submitted PR Review.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 05 2021 at 19:01):

bjorn3 created PR Review Comment:

Can you please avoid this wildcard arm? This makes it harder to find all places that need updates when adding a new call conv.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 05 2021 at 19:09):

alexcrichton updated PR #2806 from multi-return to main.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 05 2021 at 19:47):

alexcrichton updated PR #2806 from multi-return to main.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 05 2021 at 19:51):

alexcrichton updated PR #2806 from multi-return to main.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 05 2021 at 20:43):

alexcrichton updated PR #2806 from multi-return to main.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 06 2021 at 18:50):

alexcrichton updated PR #2806 from multi-return to main.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 06 2021 at 19:26):

cfallin submitted PR Review.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 06 2021 at 19:26):

cfallin submitted PR Review.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 06 2021 at 19:26):

cfallin created PR Review Comment:

s/impleemnted/implemented/

view this post on Zulip Wasmtime GitHub notifications bot (Apr 06 2021 at 20:21):

alexcrichton updated PR #2806 from multi-return to main.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 06 2021 at 20:22):

alexcrichton updated PR #2806 from multi-return to main.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 06 2021 at 20:25):

alexcrichton requested peterhuene for a review on PR #2806.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 06 2021 at 22:33):

alexcrichton updated PR #2806 from multi-return to main.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 07 2021 at 01:27):

peterhuene submitted PR Review.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 07 2021 at 01:29):

peterhuene submitted PR Review.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 07 2021 at 15:43):

alexcrichton updated PR #2806 from multi-return to main.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 07 2021 at 16:30):

alexcrichton updated PR #2806 from multi-return to main.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 07 2021 at 17:34):

alexcrichton merged PR #2806.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 07 2021 at 19:35):

peterhuene submitted PR Review.


Last updated: Dec 23 2024 at 13:07 UTC