Stream: git-wasmtime

Topic: wasmtime / issue #9155 wasmtime::component::bindgen: Gues...


view this post on Zulip Wasmtime GitHub notifications bot (Aug 20 2024 at 18:52):

pchickey opened issue #9155:

Context: wasmtime::component::bindgen creates a GuestPre struct (https://github.com/bytecodealliance/wasmtime/blob/main/crates/wit-bindgen/src/lib.rs#L578) for each exported interface.

GuestPre::new performs the export_index lookups to validate that each function in the interface exists. However, it does not typecheck the functions in new - instead, they are typechecked in GuestPre::load, which takes a store and therefore must occur at instantiation time.

The information to typecheck these exports exists in the Component (specifically in the wasmtime_environ::component::Component via Component::env_component) but right now there is no straightforward way to typecheck against that - load typechecks by way of Func::typed which requires a store argument, but ultimately ends up getting all the types out of that same env_component information.

We should fix this so that GuestPre can be used to validate that the component's exports are all typechecked. This is useful for two reasons:

  1. it allows bindgen's Pre types to be used to fully validate a component is well typed without instantiating it - it already does this for imports, only exports are missing
  2. we could potentially eliminate type checking performed in the (Instance::get_typed_func)[https://github.com/bytecodealliance/wasmtime/blob/main/crates/wit-bindgen/src/lib.rs#L2577] performed in GuestPre::load which would make instantiation faster, and have one less path of possible failure.

Last updated: Nov 22 2024 at 17:03 UTC