Commit ff45908
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
- crates/wasmtime/src
- runtime
- tests/all
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
7 | 12 | | |
8 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
9 | 19 | | |
10 | 20 | | |
11 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| |||
97 | 98 | | |
98 | 99 | | |
99 | 100 | | |
| 101 | + | |
100 | 102 | | |
101 | 103 | | |
102 | 104 | | |
| |||
0 commit comments