Skip to content

Commit 6f1fb38

Browse files
committed
Revert "Clarify validation rules of canonical options"
This reverts commit 0ed3af4.
1 parent c003ea7 commit 6f1fb38

File tree

1 file changed

+10
-50
lines changed

1 file changed

+10
-50
lines changed

design/mvp/CanonicalABI.md

Lines changed: 10 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ being specified here.
3333
* [Canonical definitions](#canonical-definitions)
3434
* [`canon lift`](#canon-lift)
3535
* [`canon lower`](#canon-lower)
36-
* [`canon $opts`](#canon-opts)
3736
* [`canon resource.new`](#canon-resourcenew)
3837
* [`canon resource.drop`](#canon-resourcedrop)
3938
* [`canon resource.rep`](#canon-resourcerep)
@@ -2728,14 +2727,12 @@ For a canonical definition:
27282727
```wat
27292728
(canon lift $callee:<funcidx> $opts:<canonopt>* (func $f (type $ft)))
27302729
```
2731-
2732-
In addition to [general validation of `$opts`](#canon-opts) the additional
2733-
validation is performed:
2734-
2730+
validation specifies:
27352731
* `$callee` must have type `flatten_functype($opts, $ft, 'lift')`
27362732
* `$f` is given type `$ft`
2737-
* a `memory` is present if required by lifting
2738-
* a `realloc` is present if required by lifting
2733+
* a `memory` is present if required by lifting and is a subtype of `(memory 1)`
2734+
* a `realloc` is present if required by lifting and has type `(func (param i32 i32 i32 i32) (result i32))`
2735+
* if `async` is set, a `post-return` function may not be set
27392736
* if a `post-return` is present, it has type `(func (param flatten_functype({}, $ft, 'lift').results))`
27402737

27412738
When instantiating component instance `$inst`:
@@ -2893,13 +2890,11 @@ For a canonical definition:
28932890
```wat
28942891
(canon lower $callee:<funcidx> $opts:<canonopt>* (core func $f))
28952892
```
2896-
2897-
In addition to [general validation of `$opts`](#canon-opts) the additional
2898-
validation is performed where `$callee` has type `$ft`:
2899-
2893+
where `$callee` has type `$ft`, validation specifies:
29002894
* `$f` is given type `flatten_functype($opts, $ft, 'lower')`
2901-
* a `memory` is present if required by lowering
2902-
* a `realloc` is present if required by lowering
2895+
* a `memory` is present if required by lifting and is a subtype of `(memory 1)`
2896+
* a `realloc` is present if required by lifting and has type `(func (param i32 i32 i32 i32) (result i32))`
2897+
* there is no `post-return` in `$opts`
29032898
* if `contains_async_value($ft)`, then `$opts.async` must be set
29042899

29052900
When instantiating component instance `$inst`:
@@ -3039,26 +3034,6 @@ elimination of string operations on the labels of records and variants) as well
30393034
as post-MVP [adapter functions].
30403035

30413036

3042-
### `canon $opts`
3043-
3044-
Canonical options, specified here as `$opts` in a number of locations
3045-
throughout this document, can be specified at most once per `$opts`. For example
3046-
specifying `string-encoding=utf8` twice is an error. Each individual option, if
3047-
present, is validated as such:
3048-
3049-
* `string-encoding=utf8` - cannot be combined with `utf16` or `latin1+utf16`
3050-
* `string-encoding=utf16` - cannot be combined with `utf8` or `latin1+utf16`
3051-
* `string-encoding=latin1+utf16` - cannot be combined with `utf8` or `utf16`
3052-
* `memory` - this is a subtype of `(memory 1)`
3053-
* `realloc` - the function has type `(func (param i32 i32 i32 i32) (result i32))`
3054-
* `post-return` - only allowed on [`canon lift`](#canon-lift), which has rules
3055-
for validation
3056-
* 🔀 `async` - cannot be present with `post-return`
3057-
* 🔀 `callback` - the function has type `(func (param i32 i32 i32 i32) (result
3058-
i32))` and cannot be present without `async` and is only allowed with [`canon
3059-
lift`](#canon-lift)
3060-
3061-
30623037
### `canon resource.new`
30633038

30643039
For a canonical definition:
@@ -3230,10 +3205,7 @@ For a canonical definition:
32303205
```wat
32313206
(canon task.return (result $t)? $opts (core func $f))
32323207
```
3233-
3234-
In addition to [general validation of `$opts`](#canon-opts) validation
3235-
specifies:
3236-
3208+
validation specifies:
32373209
* `$f` is given type `flatten_functype($opts, (func (param $t)?), 'lower')`
32383210
* `$opts` may only contain `memory`, `string-encoding` and `realloc`
32393211

@@ -3489,12 +3461,8 @@ For canonical definitions:
34893461
(canon stream.read $t $opts (core func $f))
34903462
(canon stream.write $t $opts (core func $f))
34913463
```
3492-
In addition to [general validation of `$opts`](#canon-opts) validation
3493-
specifies:
3464+
validation specifies:
34943465
* `$f` is given type `(func (param i32 i32 i32) (result i32))`
3495-
* `memory` is required for `stream.write` if required by lowering
3496-
* `memory` is required for `stream.read` if required by lifting
3497-
* `realloc` is required for `stream.read` if required by lifting
34983466

34993467
For canonical definitions:
35003468
```wat
@@ -3503,9 +3471,6 @@ For canonical definitions:
35033471
```
35043472
validation specifies:
35053473
* `$f` is given type `(func (param i32 i32) (result i32))`
3506-
* `memory` is required for `future.write` if required by lowering
3507-
* `memory` is required for `future.read` if required by lifting
3508-
* `realloc` is required for `future.read` if required by lifting
35093474

35103475
The implementation of these four built-ins all funnel down to a single
35113476
parameterized `copy` function:
@@ -3739,8 +3704,6 @@ For a canonical definition:
37393704
```
37403705
validation specifies:
37413706
* `$f` is given type `(func (param i32 i32) (result i32))`
3742-
* `async` is not present
3743-
* `memory` must be present
37443707

37453708
Calling `$f` calls the following function which uses the `$opts` immediate to
37463709
(non-deterministically) lift the debug message, create a new `ErrorContext`
@@ -3780,9 +3743,6 @@ For a canonical definition:
37803743
```
37813744
validation specifies:
37823745
* `$f` is given type `(func (param i32 i32))`
3783-
* `async` is not present
3784-
* `memory` must be present
3785-
* `realloc` must be present
37863746

37873747
Calling `$f` calls the following function which uses the `$opts` immediate to
37883748
lowers the `ErrorContext`'s debug message. While *producing* an `error-context`

0 commit comments

Comments
 (0)