Skip to content

Commit ff45908

Browse files
committed
Add RecGroupBuilder embedder API for defining recursion groups
Adds `RecGroupBuilder`, which lets embedders declare kind-typed labels (`PendingStructId`/`PendingArrayId`/`PendingFuncId`), use them as forward references while defining other types via a small build-time "template" family, and register the whole group at once with `build()`. This makes it possible to construct self-referential and mutually-recursive struct/array/func types directly from the embedder API, which previously required plucking such types out of a module's imports/exports. The builder lowers its members to module-canonical `WasmSubType`s (using 0-based `Module` indices for intra-group references and `Engine` indices for already-registered types) and reuses the existing rec-group registration path, so hash-consing, runtime canonicalization, supertype lists, and GC layouts all come for free. Implements the embedder API requested in #10176.
1 parent 413422e commit ff45908

5 files changed

Lines changed: 1442 additions & 0 deletions

File tree

RELEASES.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,18 @@ Unreleased.
44

55
### Added
66

7+
* Added `RecGroupBuilder`, an embedder API for defining recursion groups of Wasm
8+
types, including types that reference themselves or each other (e.g. linked
9+
lists and mutually-recursive structs).
10+
[#10176](https://github.com/bytecodealliance/wasmtime/issues/10176)
11+
712
### Changed
813

14+
### Fixed
15+
16+
* Fixed `StorageType::is_val_type` to report whether the storage type is a value
17+
type; it previously returned whether it was an `i16`.
18+
919
--------------------------------------------------------------------------------
1020

1121
Release notes for previous releases of Wasmtime can be found on the respective

crates/wasmtime/src/runtime.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ pub(crate) mod memory;
5353
pub(crate) mod module;
5454
#[cfg(feature = "debug-builtins")]
5555
pub(crate) mod native_debug;
56+
pub(crate) mod rec_group;
5657
pub(crate) mod resources;
5758
pub(crate) mod store;
5859
pub(crate) mod trampoline;
@@ -97,6 +98,7 @@ pub use limits::*;
9798
pub use linker::*;
9899
pub use memory::*;
99100
pub use module::{Module, ModuleExport, ModuleFunction};
101+
pub use rec_group::*;
100102
pub use resources::*;
101103
#[cfg(all(feature = "async", feature = "call-hook"))]
102104
pub use store::CallHookHandler;

0 commit comments

Comments
 (0)