Skip to content

Commit c003ea7

Browse files
committed
Revert "Review comments"
This reverts commit 6b2d6f9.
1 parent 6b2d6f9 commit c003ea7

File tree

1 file changed

+37
-56
lines changed

1 file changed

+37
-56
lines changed

design/mvp/CanonicalABI.md

Lines changed: 37 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ being specified here.
3131
* [Flat Lowering](#flat-lowering)
3232
* [Lifting and Lowering Values](#lifting-and-lowering-values)
3333
* [Canonical definitions](#canonical-definitions)
34-
* [`canonopt` Validation](#canonopt-validation)
3534
* [`canon lift`](#canon-lift)
3635
* [`canon lower`](#canon-lower)
36+
* [`canon $opts`](#canon-opts)
3737
* [`canon resource.new`](#canon-resourcenew)
3838
* [`canon resource.drop`](#canon-resourcedrop)
3939
* [`canon resource.rep`](#canon-resourcerep)
@@ -2722,60 +2722,21 @@ Using the above supporting definitions, we can describe the static and dynamic
27222722
semantics of component-level [`canon`] definitions. The following subsections
27232723
cover each of these `canon` cases.
27242724

2725-
### `canonopt` Validation
2726-
2727-
Canonical options, specified here as `$opts` in a number of locations
2728-
throughout this document, can be specified at most once per `$opts`. For example
2729-
specifying `string-encoding=utf8` twice is an error. Each individual option, if
2730-
present, is validated as such:
2731-
2732-
* `string-encoding=N` - can be passed at most once, regardless of `N`.
2733-
* `memory` - this is a subtype of `(memory 1)`
2734-
* `realloc` - the function has type `(func (param i32 i32 i32 i32) (result i32))`
2735-
* if `realloc` is present, then `memory` must be present
2736-
* `post-return` - only allowed on [`canon lift`](#canon-lift), which has rules
2737-
for validation
2738-
* 🔀 `async` - cannot be present with `post-return`
2739-
* 🔀 `callback` - the function has type `(func (param i32 i32 i32 i32) (result
2740-
i32))` and cannot be present without `async` and is only allowed with [`canon
2741-
lift`](#canon-lift)
2742-
2743-
Additionally some options are required depending on lift/lower operations
2744-
performed for a component. These are defined as:
2745-
2746-
* `lower_func(ft)`
2747-
* requires options based on `lower(param)` for all parameters in `ft`
2748-
* requires options based on `lift(result)` if `ft` has a result
2749-
* if `len(flatten_types(ft.param_types())) > MAX_FLAT_PARAMS`, `memory` is required
2750-
* if `len(flatten_types(ft.result_types())) > MAX_FLAT_RESULTS`, `realloc` is required
2751-
2752-
* `lift_func(ft)`
2753-
* requires options based on `lift(param)` for all parameters in `ft`
2754-
* requires options based on `lower(result)` if `ft` has a result
2755-
* if `len(flatten_types(ft.param_types())) > MAX_FLAT_PARAMS`, `realloc` is required
2756-
* if `len(flatten_types(ft.result_types())) > MAX_FLAT_RESULTS`, `memory` is required
2757-
2758-
* `lower(T)`
2759-
* requires `memory` if `T` contains a `list` or `string`
2760-
2761-
* `lift(T)`
2762-
* requires `realloc` if `T` contains a `list` or `string`
2763-
2764-
27652725
### `canon lift`
27662726

27672727
For a canonical definition:
27682728
```wat
27692729
(canon lift $callee:<funcidx> $opts:<canonopt>* (func $f (type $ft)))
27702730
```
27712731

2772-
In addition to [general validation of `$opts`](#canonopt-validation) the additional
2732+
In addition to [general validation of `$opts`](#canon-opts) the additional
27732733
validation is performed:
27742734

27752735
* `$callee` must have type `flatten_functype($opts, $ft, 'lift')`
27762736
* `$f` is given type `$ft`
2737+
* a `memory` is present if required by lifting
2738+
* a `realloc` is present if required by lifting
27772739
* if a `post-return` is present, it has type `(func (param flatten_functype({}, $ft, 'lift').results))`
2778-
* [`lift_func($ft)` above](#canonopt-validation) defines extra required options.
27792740

27802741
When instantiating component instance `$inst`:
27812742
* Define `$f` to be the partially-bound closure `canon_lift($opts, $inst, $ft, $callee)`
@@ -2933,12 +2894,13 @@ For a canonical definition:
29332894
(canon lower $callee:<funcidx> $opts:<canonopt>* (core func $f))
29342895
```
29352896

2936-
In addition to [general validation of `$opts`](#canonopt-validation) the additional
2897+
In addition to [general validation of `$opts`](#canon-opts) the additional
29372898
validation is performed where `$callee` has type `$ft`:
29382899

29392900
* `$f` is given type `flatten_functype($opts, $ft, 'lower')`
2940-
* [`lower_func($ft)` above](#canonopt-validation) defines extra required options.
2941-
* if `async` is specified, `memory` must be present
2901+
* a `memory` is present if required by lowering
2902+
* a `realloc` is present if required by lowering
2903+
* if `contains_async_value($ft)`, then `$opts.async` must be set
29422904

29432905
When instantiating component instance `$inst`:
29442906
* Define `$f` to be the partially-bound closure: `canon_lower($opts, $ft, $callee)`
@@ -3077,6 +3039,26 @@ elimination of string operations on the labels of records and variants) as well
30773039
as post-MVP [adapter functions].
30783040

30793041

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+
30803062
### `canon resource.new`
30813063

30823064
For a canonical definition:
@@ -3249,12 +3231,11 @@ For a canonical definition:
32493231
(canon task.return (result $t)? $opts (core func $f))
32503232
```
32513233

3252-
In addition to [general validation of `$opts`](#canonopt-validation) validation
3234+
In addition to [general validation of `$opts`](#canon-opts) validation
32533235
specifies:
32543236

32553237
* `$f` is given type `flatten_functype($opts, (func (param $t)?), 'lower')`
3256-
* `$opts` may only contain `memory` and `string-encoding`
3257-
* [`lift_func($f.result)` above](#canonopt-validation) defines required options
3238+
* `$opts` may only contain `memory`, `string-encoding` and `realloc`
32583239

32593240
Calling `$f` invokes the following function which uses `Task.return_` to lift
32603241
and pass the results to the caller:
@@ -3508,12 +3489,12 @@ For canonical definitions:
35083489
(canon stream.read $t $opts (core func $f))
35093490
(canon stream.write $t $opts (core func $f))
35103491
```
3511-
In addition to [general validation of `$opts`](#canonopt-validation) validation
3492+
In addition to [general validation of `$opts`](#canon-opts) validation
35123493
specifies:
35133494
* `$f` is given type `(func (param i32 i32 i32) (result i32))`
3514-
* [`lower($t)` above](#canonopt-validation) defines required options for `stream.write`
3515-
* [`lift($t)` above](#canonopt-validation) defines required options for `stream.read`
3516-
* `memory` is required to be present
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
35173498

35183499
For canonical definitions:
35193500
```wat
@@ -3522,9 +3503,9 @@ For canonical definitions:
35223503
```
35233504
validation specifies:
35243505
* `$f` is given type `(func (param i32 i32) (result i32))`
3525-
* [`lower($t)` above](#canonopt-validation) defines required options for `future.write`
3526-
* [`lift($t)` above](#canonopt-validation) defines required options for `future.read`
3527-
* `memory` is required to be present
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
35283509

35293510
The implementation of these four built-ins all funnel down to a single
35303511
parameterized `copy` function:

0 commit comments

Comments
 (0)