Stream: git-wasmtime

Topic: wasmtime / issue #9595 Expose Parameter Names method for ...


view this post on Zulip Wasmtime GitHub notifications bot (Nov 17 2024 at 09:10):

Swivelgames edited issue #9595:

Feature

Provide an interface for deriving a ComponentFunc params original names

Benefit

Presently, wasmtime provides a number tools that can be leveraged for something that resembles Reflection, but the details for Function Parameters are lossy. Especially for more complex runtime parameter mapping, it would be great if the names of function parameters were preserved, and an interface provided for retrieving them.

Implementation

In order to maintain backwards compatibility, it could likely be something like a param_names() method.

impl ComponentFunc

  pub fn param_names(&self) -> impl ExactSizeIterator<Item = String> + '_`

      Iterates over names of function parameters

Alternatives

There really doesn't seem to be one that's built-in to wasmtime. In order to grab the parameter names, I'd likely need to do something far more complex.

Based on wasm-tools, though, it seems like the name of the params are preserved in the .wasm, which is intriguing.

To my knowledge, ComponentFunc params are the entities that do not have some way of deriving their original names.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 18 2024 at 17:28):

alexcrichton commented on issue #9595:

Parameter names don't affect the ABI but they do affect type-checking. Regardless though I think it'd be reasonable to expose this information!

view this post on Zulip Wasmtime GitHub notifications bot (Nov 18 2024 at 18:25):

pchickey closed issue #9595:

Feature

Provide an interface for deriving a ComponentFunc params original names

Benefit

Presently, wasmtime provides a number tools that can be leveraged for something that resembles Reflection, but the details for Function Parameters are lossy. Especially for more complex runtime parameter mapping, it would be great if the names of function parameters were preserved, and an interface provided for retrieving them.

Implementation

In order to maintain backwards compatibility, it could likely be something like a param_names() method.

impl ComponentFunc

  pub fn param_names(&self) -> impl ExactSizeIterator<Item = String> + '_`

      Iterates over names of function parameters

Alternatives

There really doesn't seem to be one that's built-in to wasmtime. In order to grab the parameter names, I'd likely need to do something far more complex.

Based on wasm-tools, though, it seems like the name of the params are preserved in the .wasm, which is intriguing.

To my knowledge, ComponentFunc params are the entities that do not have some way of deriving their original names.

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

bjorn3 commented on issue #9595:

Parameter names don't affect the ABI but they do affect type-checking.

??? If changing a parameter name causes a component to not type check, then said change is an ABI breaking change, right?

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

alexcrichton commented on issue #9595:

Er, to clarify a bit, I mean that the canonical ABI doesn't depend on the parameter names. That was my own definition of "ABI" but you're more accurate that "ABI" in this sense should encompass function linking and yes there different names cause issues.


Last updated: Nov 22 2024 at 16:03 UTC