@@ -33,6 +33,7 @@ being specified here.
33
33
* [ Canonical definitions] ( #canonical-definitions )
34
34
* [ ` canon lift ` ] ( #canon-lift )
35
35
* [ ` canon lower ` ] ( #canon-lower )
36
+ * [ ` canon $opts ` ] ( #canon-opts )
36
37
* [ ` canon resource.new ` ] ( #canon-resourcenew )
37
38
* [ ` canon resource.drop ` ] ( #canon-resourcedrop )
38
39
* [ ` canon resource.rep ` ] ( #canon-resourcerep )
@@ -2727,12 +2728,14 @@ For a canonical definition:
2727
2728
``` wat
2728
2729
(canon lift $callee:<funcidx> $opts:<canonopt>* (func $f (type $ft)))
2729
2730
```
2730
- validation specifies:
2731
+
2732
+ In addition to [ general validation of ` $opts ` ] ( #canon-opts ) the additional
2733
+ validation is performed:
2734
+
2731
2735
* ` $callee ` must have type ` flatten_functype($opts, $ft, 'lift') `
2732
2736
* ` $f ` is given type ` $ft `
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
2737
+ * a ` memory ` is present if required by lifting
2738
+ * a ` realloc ` is present if required by lifting
2736
2739
* if a ` post-return ` is present, it has type ` (func (param flatten_functype({}, $ft, 'lift').results)) `
2737
2740
2738
2741
When instantiating component instance ` $inst ` :
@@ -2890,11 +2893,13 @@ For a canonical definition:
2890
2893
``` wat
2891
2894
(canon lower $callee:<funcidx> $opts:<canonopt>* (core func $f))
2892
2895
```
2893
- where ` $callee ` has type ` $ft ` , validation specifies:
2896
+
2897
+ In addition to [ general validation of ` $opts ` ] ( #canon-opts ) the additional
2898
+ validation is performed where ` $callee ` has type ` $ft ` :
2899
+
2894
2900
* ` $f ` is given type ` flatten_functype($opts, $ft, 'lower') `
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 `
2901
+ * a ` memory ` is present if required by lowering
2902
+ * a ` realloc ` is present if required by lowering
2898
2903
* if ` contains_async_value($ft) ` , then ` $opts.async ` must be set
2899
2904
2900
2905
When instantiating component instance ` $inst ` :
@@ -3034,6 +3039,26 @@ elimination of string operations on the labels of records and variants) as well
3034
3039
as post-MVP [ adapter functions] .
3035
3040
3036
3041
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
+
3037
3062
### ` canon resource.new `
3038
3063
3039
3064
For a canonical definition:
@@ -3205,7 +3230,10 @@ For a canonical definition:
3205
3230
``` wat
3206
3231
(canon task.return (result $t)? $opts (core func $f))
3207
3232
```
3208
- validation specifies:
3233
+
3234
+ In addition to [ general validation of ` $opts ` ] ( #canon-opts ) validation
3235
+ specifies:
3236
+
3209
3237
* ` $f ` is given type ` flatten_functype($opts, (func (param $t)?), 'lower') `
3210
3238
* ` $opts ` may only contain ` memory ` , ` string-encoding ` and ` realloc `
3211
3239
@@ -3461,8 +3489,12 @@ For canonical definitions:
3461
3489
(canon stream.read $t $opts (core func $f))
3462
3490
(canon stream.write $t $opts (core func $f))
3463
3491
```
3464
- validation specifies:
3492
+ In addition to [ general validation of ` $opts ` ] ( #canon-opts ) validation
3493
+ specifies:
3465
3494
* ` $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
3466
3498
3467
3499
For canonical definitions:
3468
3500
``` wat
@@ -3471,6 +3503,9 @@ For canonical definitions:
3471
3503
```
3472
3504
validation specifies:
3473
3505
* ` $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
3474
3509
3475
3510
The implementation of these four built-ins all funnel down to a single
3476
3511
parameterized ` copy ` function:
@@ -3704,6 +3739,8 @@ For a canonical definition:
3704
3739
```
3705
3740
validation specifies:
3706
3741
* ` $f ` is given type ` (func (param i32 i32) (result i32)) `
3742
+ * ` async ` is not present
3743
+ * ` memory ` must be present
3707
3744
3708
3745
Calling ` $f ` calls the following function which uses the ` $opts ` immediate to
3709
3746
(non-deterministically) lift the debug message, create a new ` ErrorContext `
@@ -3743,6 +3780,9 @@ For a canonical definition:
3743
3780
```
3744
3781
validation specifies:
3745
3782
* ` $f ` is given type ` (func (param i32 i32)) `
3783
+ * ` async ` is not present
3784
+ * ` memory ` must be present
3785
+ * ` realloc ` must be present
3746
3786
3747
3787
Calling ` $f ` calls the following function which uses the ` $opts ` immediate to
3748
3788
lowers the ` ErrorContext ` 's debug message. While * producing* an ` error-context `
0 commit comments