Stream: git-wasmtime

Topic: wasmtime / PR #4501 Add initial support for fused adapter...


view this post on Zulip Wasmtime GitHub notifications bot (Jul 21 2022 at 19:35):

alexcrichton opened PR #4501 from trampoline-compiler to main:

This commit lands a significant new piece of functionality to Wasmtime's
implementation of the component model in the form of the implementation
of fused adapter trampolines. Internally within a component core wasm
modules can communicate with each other by having their exports
canon lift'd to get canon lower'd into a different component. This
signifies that two components are communicating through a statically
known interface via the canonical ABI at this time. Previously Wasmtime
was able to identify that this communication was happening but it simply
panicked with unimplemented! upon seeing it. This commit is the
beginning of filling out this panic location with an actual
implementation.

The implementation route chosen here for fused adapters is to use a
WebAssembly module itself for the implementation. This means that, at
compile time of a component, Wasmtime is generating core WebAssembly
modules which then get recursively compiled within Wasmtime as well. The
choice to use WebAssembly itself as the implementation of fused adapters
stems from a few motivations:

The compiler added in this commit is dubbed Wasmtime's Fused Adapter
Compiler of Trampolines (FACT) because who doesn't like deriving a name
from an acronym. Currently the trampoline compiler is limited in its
support for interface types and only supports a few primitives. I plan
on filing future PRs to flesh out the support here for all the variants
of InterfaceType. For now this PR is primarily focused on all of the
other infrastructure for the addition of a trampoline compiler.

With the choice to use core WebAssembly to implement fused adapters it
means that adapters need to be inserted into a module. Unfortunately
adapters cannot all go into a single WebAssembly module because adapters
themselves have dependencies which may be provided transitively through
instances that were instantiated with other adapters. This means that a
significant chunk of this PR (adapt.rs) is dedicated to determining
precisely which adapters go into precisely which adapter modules. This
partitioning process attempts to make large modules wherever it can to
cut down on core wasm instantiations but is likely not optimal as
it's just a simple heuristic today.

With all of this added together it's now possible to start writing
*.wast tests that internally have adapted modules communicating with
one another. A fused.wast test suite was added as part of this PR
which is the beginning of tests for the support of the fused adapter
compiler added in this PR. Currently this is primarily testing some
various topologies of adapters along with direct/indirect modes. This
will grow many more tests over time as more types are supported.

Overall I'm not 100% satisfied with the testing story of this PR. When a
test fails it's very difficult to debug since everything is written in
the text format of WebAssembly meaning there's no "conveniences" to
print out the state of the world when things go wrong and easily debug.
I think this will become even more apparent as more tests are written
for more types in subsequent PRs. At this time though I know of no
better alternative other than leaning pretty heavily on fuzz-testing to
ensure this is all exercised.

<!--

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 (Jul 21 2022 at 19:35):

alexcrichton requested fitzgen for a review on PR #4501.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 21 2022 at 19:44):

alexcrichton updated PR #4501 from trampoline-compiler to main.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 21 2022 at 20:03):

alexcrichton updated PR #4501 from trampoline-compiler to main.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 22 2022 at 17:06):

alexcrichton updated PR #4501 from trampoline-compiler to main.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 25 2022 at 18:37):

alexcrichton updated PR #4501 from trampoline-compiler to main.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 25 2022 at 20:04):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 25 2022 at 20:04):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 25 2022 at 20:04):

fitzgen created PR review comment:

*imports

view this post on Zulip Wasmtime GitHub notifications bot (Jul 25 2022 at 21:44):

alexcrichton updated PR #4501 from trampoline-compiler to main.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 25 2022 at 21:48):

alexcrichton updated PR #4501 from trampoline-compiler to main.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 25 2022 at 21:48):

alexcrichton has enabled auto merge for PR #4501.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 25 2022 at 23:13):

alexcrichton merged PR #4501.


Last updated: Nov 22 2024 at 16:03 UTC