Fill out GC type reflection in the C API#13235
Merged
alexcrichton merged 8 commits intobytecodealliance:mainfrom May 1, 2026
Merged
Fill out GC type reflection in the C API#13235alexcrichton merged 8 commits intobytecodealliance:mainfrom
alexcrichton merged 8 commits intobytecodealliance:mainfrom
Conversation
This commit fills out APIs necessary to reflect on value types to get the full type hierarchy of WebAssembly. Currently types in the C API are primarily inherited from `wasm.h` which notably doesn't handle proposals such as simd or GC or typed function references. This puts us in a bit of an awkward position where much of our API relies on `wasm.h`, but there's obvious holes in `wasm.h` that would otherwise require modifications. This commit takes the route of adding a parallel `wasmtime_valtype_t` definition fully tailored for Wasmtime's use case. Conversions are then provided between `wasmtime_valtype_t` and `wasm_valtype_t`. The Wasmtime version notably has a different representation which enables, for example, constructing primitive types without function calls. This then fills out the corresponding C++ APIs and fills gaps in the preexisting types. For example `FieldType` is much different from before and now follows C++ idioms and semantics. Additionally it now has the ability to express the full breadth of all wasm types in fields and they can both be constructed and read. This is all necessary for some implementation work to fill out the GC proposal in the `wasmtime-py` bindings where the lack of type information was otherwise leading to a pretty awkward API relative to the rest of the package.
The type information is always available.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit fills out APIs necessary to reflect on value types to get the full type hierarchy of WebAssembly. Currently types in the C API are primarily inherited from
wasm.hwhich notably doesn't handle proposals such as simd or GC or typed function references. This puts us in a bit of an awkward position where much of our API relies onwasm.h, but there's obvious holes inwasm.hthat would otherwise require modifications.This commit takes the route of adding a parallel
wasmtime_valtype_tdefinition fully tailored for Wasmtime's use case. Conversions are then provided betweenwasmtime_valtype_tandwasm_valtype_t. The Wasmtime version notably has a different representation which enables, for example, constructing primitive types without function calls.This then fills out the corresponding C++ APIs and fills gaps in the preexisting types. For example
FieldTypeis much different from before and now follows C++ idioms and semantics. Additionally it now has the ability to express the full breadth of all wasm types in fields and they can both be constructed and read.This is all necessary for some implementation work to fill out the GC proposal in the
wasmtime-pybindings where the lack of type information was otherwise leading to a pretty awkward API relative to the rest of the package.