Skip to content

Commit 6f98299

Browse files
abrownalexcrichton
authored andcommitted
Add type definition for rectype
This changes the component model specification to reference a `rectype` in its type defintions. This makes sense since the [GC] proposal has graduated to become standard WebAssembly and the previous definitions refer to `arraytype` and `structtype` which are subsumed by `rectype`. Adding this also benefits the [shared-everything-threads] proposal, which uses `shared` bits on composite types. In talking with @alexcrichton about this, the `functype` alternative is retained for now to allow backward compatibility for existing components (e.g., components using the `0x60` prefix to define a core `functype`). In the future, the `functype` alternative should be removed completely (since it is subsumed under `rectype`). Potentially the `0x00` prefix could be tweaked as well. In the meantime, this change allows more than one way to encode a `functype`. [GC]: https://github.com/WebAssembly/gc [shared-everything-threads]: https://github.com/WebAssembly/shared-everything-threads Co-authored-by: Alex Crichton <[email protected]>
1 parent cc4e9d2 commit 6f98299

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

design/mvp/Binary.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ Notes:
138138
```ebnf
139139
core:type ::= dt:<core:deftype> => (type dt) (GC proposal)
140140
core:deftype ::= ft:<core:functype> => ft (WebAssembly 1.0)
141-
| st:<core:structtype> => st (GC proposal)
142-
| at:<core:arraytype> => at (GC proposal)
141+
| 0x00 rt:<core:rectype> => rt (WebAssembly 3.0)
143142
| mt:<core:moduletype> => mt
144143
core:moduletype ::= 0x50 md*:vec(<core:moduledecl>) => (module md*)
145144
core:moduledecl ::= 0x00 i:<core:import> => i
@@ -152,7 +151,15 @@ core:importdecl ::= i:<core:import> => i
152151
core:exportdecl ::= n:<core:name> d:<core:importdesc> => (export n d)
153152
```
154153
Notes:
155-
* Reused Core binary rules: [`core:import`], [`core:importdesc`], [`core:functype`]
154+
* Reused Core binary rules: [`core:import`], [`core:importdesc`],
155+
[`core:functype`], [`core:rectype`]
156+
* The three branches of `core:deftype` have prefix bytes of 0x60
157+
(`core:functype`), 0x50 (`core:moduletype` ), and 0x00 (`core:rectype`). This
158+
is because the component model and the GC specifications (i.e., source of
159+
`core:rectype`) have evolved in parallel and independently. Ideally, in the
160+
future, the `core:functype` production would be removed as it can be expressed
161+
within `core:rectype`. Also, the prefix byte of `core:moduletype` (0x50) will
162+
also likely change as well.
156163
* Validation of `core:moduledecl` rejects `core:moduletype` definitions
157164
and `outer` aliases of `core:moduletype` definitions inside `type`
158165
declarators. Thus, as an invariant, when validating a `core:moduletype`, the
@@ -474,6 +481,7 @@ named once.
474481
[`core:import`]: https://webassembly.github.io/spec/core/binary/modules.html#binary-import
475482
[`core:importdesc`]: https://webassembly.github.io/spec/core/binary/modules.html#binary-importdesc
476483
[`core:functype`]: https://webassembly.github.io/spec/core/binary/types.html#binary-functype
484+
[`core:rectype]: https://webassembly.github.io/gc/core/binary/types.html#recursive-types
477485

478486
[type-imports]: https://github.com/WebAssembly/proposal-type-imports/blob/master/proposals/type-imports/Overview.md
479487
[module-linking]: https://github.com/WebAssembly/module-linking/blob/main/proposals/module-linking/Explainer.md

0 commit comments

Comments
 (0)