Stream: git-wasmtime

Topic: wasmtime / PR #6638 Lean on wasmparser's type information...


view this post on Zulip Wasmtime GitHub notifications bot (Jun 24 2023 at 00:43):

alexcrichton opened PR #6638 from alexcrichton:use-wasmparser-types to bytecodealliance:main:

Before this commit Wasmtime would build up its own representation of type information independently of wasmparser, effectively duplicating things such as type scopes and managing indices. This to some degree is required because Wasmtime's type information is serialized into compiled images and wasmparser's information isn't easily serialized. With the advent of resources in components, however, the task of doing this correctly has become much more difficult.

When component translation was first written it was more difficult to acquire type information from wasmparser::Validator. Nowadays there's helpful type information exposed every step of the way which makes it much easier to get at the types of items while we're translating rather than only at the very end (or not at all). This is one of the motivations for this commit where now it's possible to avoid duplicating the work wasmparser is doing whereas before it wasn't as easy.

Additionally with resources in the component model they perform namely a number of involved type substitutions during instantiation of arbitrary components which isn't implemented in Wasmtime today. Some of this will be required for Wasmtime to correctly implement resources so instead of doing all that again I've decided to replace Wasmtime's management of types with wasmparser's management of types.

The main difference in this commit is that Wasmtime no longer tracks type information during translation and that conversion into Wasmtime's type hierarchy now has a different entry point. Previously conversion would happen based on raw types read from the wasm file (think index-based things) whereas now translation happens on wasmparser's parsed and validated hierarchy of types (think ID-based things rather than index-based things). This makes translation slightly more involved but overall it's largely performing the same work.

One gotcha with this PR is that core wasm modules using GC types and typed function references could theoretically have worked previously but they no longer work. It turns out that wasmparser is not correctly surfacing type information in components for core modules that use GC types, namely because wasmparser's validated type hierarchy uses the same core wasm types as what's read raw from the type section. This in turn means that the index-based format can't be resolved. This is a bug in wasmparser which will need resolving but is a big chunk of work to take on, so for now the component model will panic on these sorts of modules (which are disabled by default anyway).

Overall the end-goal of this commit is to ease the implementation of resources a bit by heavily relying on wasmparser's understanding of resources, chiefly the functionality of performing type substitutions on subcomponent instantiations.

<!--
Please make sure you include the following information:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

view this post on Zulip Wasmtime GitHub notifications bot (Jun 24 2023 at 00:43):

alexcrichton requested itsrainy for a review on PR #6638.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 24 2023 at 00:43):

alexcrichton requested wasmtime-core-reviewers for a review on PR #6638.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 24 2023 at 01:01):

alexcrichton updated PR #6638.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 26 2023 at 03:53):

alexcrichton updated PR #6638.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2023 at 17:06):

pchickey requested pchickey for a review on PR #6638.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2023 at 17:10):

pchickey submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2023 at 18:52):

alexcrichton merged PR #6638.


Last updated: Nov 22 2024 at 16:03 UTC