Stream: git-wasmtime

Topic: wasmtime / PR #5139 Expose type information in module tra...


view this post on Zulip Wasmtime GitHub notifications bot (Oct 27 2022 at 12:42):

saulecabrera opened PR #5139 from expose-type-info-in-translation to main:

@alexcrichton following up from our Zulip discussion last week.

This adds a new field types to ModuleTranslation, so that consumers can have access to the module type information known after validation has finished. This change is useful when consumers want to have access to the type information in wasmparser's terms rather than in wasmtime_environ's equivalent types (e.g. WasmFuncType).

I went with the simplest approach, wrapping the Types with Option, and introducing a method to get the types to preserve the invariant that after a successful translation, types should always be available. But I also considered some alternatives, so I'm happy to change this if any of the other alternatives are preferred.

Other alternatives considered:

  1. Making wasmparser::types::Types derive Default. To achieve this, wasmparser::validator::types::TypesKind, should also need to derive Default, and the question that pops up here is, which is a good default for TypesKind? We could go with either or, but I'm not convinced that semantically it makes sense, IMO if we're going this route, it probably makes more sense to have an extra entry to represent the "untyped" state.
  2. Introduce a module translation builder of some sort, and use that instead of ModuleTranslation for the translation/validation process. This would allow avoiding the Option, but seems a lot of duplication for a single field.

<!--

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 (Oct 27 2022 at 14:38):

alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 27 2022 at 14:38):

alexcrichton merged PR #5139.


Last updated: Oct 23 2024 at 20:03 UTC