@@ -1300,19 +1300,18 @@ default is `utf8`. It is a validation error to include more than one
13001300The ` (memory ...) ` option specifies the memory that the Canonical ABI will
13011301use to load and store values. If the Canonical ABI needs to load or store,
13021302validation requires this option to be present (there is no default). The types
1303- of lowered functions may also depend on whether this memory is a 32-bit or
1304- 64-bit memory if pointers are transitively contained in parameters or results.
1305- In what follows the notation ` PTR ` will refer to the core Wasm type ` i32 ` or
1306- ` i64 ` corresponding to the type of the ` (memory ...) ` option.
1303+ of lowered functions may also depend on the [ ` core:memory-type ` ] of this memory,
1304+ specifically it's [ ` core:address-type ` ] (indicated by ` memory.addrtype ` ), if pointers
1305+ are transitively contained in parameters or results.
13071306
13081307The ` (realloc ...) ` option specifies a core function that is validated to
13091308have the following core function type:
13101309``` wat
1311- (func (param $originalPtr PTR )
1312- (param $originalSize PTR )
1313- (param $alignment PTR )
1314- (param $newSize PTR )
1315- (result PTR ))
1310+ (func (param $originalPtr memory.addrtype )
1311+ (param $originalSize memory.addrtype )
1312+ (param $alignment memory.addrtype )
1313+ (param $newSize memory.addrtype )
1314+ (result memory.addrtype ))
13161315```
13171316The Canonical ABI will use ` realloc ` both to allocate (passing ` 0 ` for the first
13181317two parameters) and reallocate. If the Canonical ABI needs ` realloc ` , validation
@@ -1339,10 +1338,9 @@ validated to have the following core function type:
13391338``` wat
13401339(func (param $ctx i32)
13411340 (param $event i32)
1342- (param $payload PTR )
1341+ (param $payload i32 )
13431342 (result $done i32))
13441343```
1345- where ` PTR ` is determined by the ` memory ` canonopt as described above.
13461344Again, see the [ concurrency explainer] for more details.
13471345
13481346Based on this description of the AST, the [ Canonical ABI explainer] gives a
@@ -1675,10 +1673,10 @@ For details, see [Waitables and Waitable Sets] in the concurrency explainer and
16751673
16761674###### 🔀 ` waitable-set.wait `
16771675
1678- | Synopsis | |
1679- | -------------------------- | ---------------------------------------------- |
1680- | Approximate WIT signature | ` func<cancellable?>(s: waitable-set) -> event ` |
1681- | Canonical ABI signature | ` [s:i32 payload-addr:PTR ] -> [event-code:i32] ` |
1676+ | Synopsis | |
1677+ | -------------------------- | ---------------------------------------------------------- |
1678+ | Approximate WIT signature | ` func<cancellable?,memory >(s: waitable-set) -> event ` |
1679+ | Canonical ABI signature | ` [s:i32 payload-addr:memory.addrtype ] -> [event-code:i32] ` |
16821680
16831681where ` event ` is defined in WIT as:
16841682``` wit
@@ -1740,10 +1738,10 @@ For details, see [Waitables and Waitable Sets] in the concurrency explainer and
17401738
17411739###### 🔀 ` waitable-set.poll `
17421740
1743- | Synopsis | |
1744- | -------------------------- | ---------------------------------------------- |
1745- | Approximate WIT signature | ` func<cancellable?>(s: waitable-set) -> event ` |
1746- | Canonical ABI signature | ` [s:i32 payload-addr:PTR ] -> [event-code:i32] ` |
1741+ | Synopsis | |
1742+ | -------------------------- | ---------------------------------------------------------- |
1743+ | Approximate WIT signature | ` func<cancellable?,memory >(s: waitable-set) -> event ` |
1744+ | Canonical ABI signature | ` [s:i32 payload-addr:memory.addrtype ] -> [event-code:i32] ` |
17471745
17481746where ` event ` is defined as in [ ` waitable-set.wait ` ] ( #-waitable-setwait ) .
17491747
@@ -1857,11 +1855,11 @@ For details, see [Streams and Futures] in the concurrency explainer and
18571855
18581856###### 🔀 ` stream.read ` and ` stream.write `
18591857
1860- | Synopsis | |
1861- | -------------------------------------------- | ----------------------------------------------------------------------------------------------- |
1862- | Approximate WIT signature for ` stream.read ` | ` func<stream<T?>>(e: readable-stream-end<T?>, b: writable-buffer<T>?) -> option<stream-result> ` |
1863- | Approximate WIT signature for ` stream.write ` | ` func<stream<T?>>(e: writable-stream-end<T?>, b: readable-buffer<T>?) -> option<stream-result> ` |
1864- | Canonical ABI signature | ` [stream-end:i32 ptr:PTR num:PTR ] -> [PTR] ` |
1858+ | Synopsis | |
1859+ | -------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
1860+ | Approximate WIT signature for ` stream.read ` | ` func<stream<T?>,memory >(e: readable-stream-end<T?>, b: writable-buffer<T>?) -> option<stream-result> ` |
1861+ | Approximate WIT signature for ` stream.write ` | ` func<stream<T?>,memory >(e: writable-stream-end<T?>, b: readable-buffer<T>?) -> option<stream-result> ` |
1862+ | Canonical ABI signature | ` [stream-end:i32 ptr:memory.addrtype num:memory.addrtype ] -> [memory.addrtype] ` |
18651863
18661864where ` stream-result ` is defined in WIT as:
18671865``` wit
@@ -1917,10 +1915,10 @@ any subsequent operation on the stream other than `stream.drop-{readable,writabl
19171915traps.
19181916
19191917In the Canonical ABI, the ` {readable,writable}-stream-end ` is passed as an
1920- ` i32 ` index into the component instance's table followed by a pair of ` PTR ` s
1918+ ` i32 ` index into the component instance's table followed by a pair of ` memory.addrtype ` s
19211919describing the linear memory offset and size-in-elements of the
19221920` {readable,writable}-buffer<T> ` . The ` option<stream-result> ` return value is
1923- bit-packed into a single ` PTR ` where:
1921+ bit-packed into a single ` memory.addrtype ` where:
19241922* all-ones represents ` none ` .
19251923* Otherwise, the ` result ` is in the low 4 bits and the ` progress ` is in the
19261924 remaining high bits.
@@ -1930,11 +1928,11 @@ For details, see [Streams and Futures] in the concurrency explainer and
19301928
19311929###### 🔀 ` future.read ` and ` future.write `
19321930
1933- | Synopsis | |
1934- | -------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
1935- | Approximate WIT signature for ` future.read ` | ` func<future<T?>>(e: readable-future-end<T?>, b: writable-buffer<T; 1>?) -> option<future-read-result> ` |
1936- | Approximate WIT signature for ` future.write ` | ` func<future<T?>>(e: writable-future-end<T?>, v: readable-buffer<T; 1>?) -> option<future-write-result> ` |
1937- | Canonical ABI signature | ` [readable-future-end:i32 ptr:PTR ] -> [i32] ` |
1931+ | Synopsis | |
1932+ | -------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
1933+ | Approximate WIT signature for ` future.read ` | ` func<future<T?>,memory >(e: readable-future-end<T?>, b: writable-buffer<T; 1>?) -> option<future-read-result> ` |
1934+ | Approximate WIT signature for ` future.write ` | ` func<future<T?>,memory >(e: writable-future-end<T?>, v: readable-buffer<T; 1>?) -> option<future-write-result> ` |
1935+ | Canonical ABI signature | ` [readable-future-end:i32 ptr:memory.addrtype ] -> [i32] ` |
19381936
19391937where ` future-{read,write}-result ` are defined in WIT as:
19401938``` wit
@@ -1985,7 +1983,7 @@ called before successfully writing a value.
19851983
19861984In the Canonical ABI, the ` {readable,writable}-future-end ` is passed as an
19871985` i32 ` index into the component instance's table followed by a single
1988- ` PTR ` describing the linear memory offset of the
1986+ ` memory.addrtype ` describing the linear memory offset of the
19891987` {readable,writable}-buffer<T; 1> ` . The ` option<future-{read,write}-result> `
19901988return value is bit-packed into the single ` i32 ` return value where all-ones
19911989represents ` none ` . And, ` future-read-result.cancelled ` is encoded
@@ -2254,10 +2252,10 @@ explainer.
22542252
22552253###### 📝 ` error-context.new `
22562254
2257- | Synopsis | |
2258- | -------------------------------- | ---------------------------------------- |
2259- | Approximate WIT signature | ` func(message: string) -> error-context ` |
2260- | Canonical ABI signature | ` [ptr:PTR len:PTR ] -> [i32] ` |
2255+ | Synopsis | |
2256+ | -------------------------------- | ---------------------------------------------------- |
2257+ | Approximate WIT signature | ` func<memory> (message: string) -> error-context ` |
2258+ | Canonical ABI signature | ` [ptr:memory.addrtype len:memory.addrtype ] -> [i32] ` |
22612259
22622260The ` error-context.new ` built-in returns a new ` error-context ` value. The given
22632261string is non-deterministically transformed to produce the ` error-context ` 's
@@ -2270,10 +2268,10 @@ For details, see [`canon_error_context_new`] in the Canonical ABI explainer.
22702268
22712269###### 📝 ` error-context.debug-message `
22722270
2273- | Synopsis | |
2274- | -------------------------------- | --------------------------------------- |
2275- | Approximate WIT signature | ` func(errctx: error-context) -> string ` |
2276- | Canonical ABI signature | ` [errctxi:i32 ptr:PTR ] -> [] ` |
2271+ | Synopsis | |
2272+ | -------------------------------- | ----------------------------------------------- |
2273+ | Approximate WIT signature | ` func<memory> (errctx: error-context) -> string ` |
2274+ | Canonical ABI signature | ` [errctxi:i32 ptr:memory.addrtype ] -> [] ` |
22772275
22782276The ` error-context.debug-message ` built-in returns the
22792277[ debug message] ( #error-context-type ) of the given ` error-context ` .
@@ -3176,6 +3174,8 @@ For some use-case-focused, worked examples, see:
31763174[ func-import-abbrev ] : https://webassembly.github.io/spec/core/text/modules.html#text-func-abbrev
31773175[ `core:version` ] : https://webassembly.github.io/spec/core/binary/modules.html#binary-version
31783176[ `core:tableidx` ] : https://webassembly.github.io/spec/core/syntax/modules.html#syntax-tableidx
3177+ [ `core:address-type` ] : https://webassembly.github.io/spec/core/syntax/types.html#address-types
3178+ [ `core:memory-type` ] : https://webassembly.github.io/spec/core/syntax/types.html#memory-types
31793179[ `core:table-type` ] : https://webassembly.github.io/spec/core/syntax/types.html#table-types
31803180
31813181[ Embedder ] : https://webassembly.github.io/spec/core/appendix/embedding.html
0 commit comments