@@ -729,8 +729,11 @@ the core wasm toolchain) `$retp` must be a 4-byte-aligned pointer into linear
729729memory from which the 8-byte (pointer, length) of the string result can be
730730loaded.
731731
732- The async export ABI provides two flavors: stackful and stackless. The stackful
733- ABI is currently gated by the 🚟 feature.
732+ The async export ABI provides two flavors: stackful and stackless.
733+
734+ ##### Stackful Async Exports
735+
736+ The stackful ABI is currently gated by the 🚟 feature.
734737
735738The async stackful export function signature is:
736739``` wat
@@ -749,6 +752,8 @@ WIT parameter type of a synchronous function. For example, if more than 16
749752core parameters would be needed, a single ` i32 ` pointer into linear memory is
750753used.
751754
755+ ##### Stackless Async Exports
756+
752757The async stackless export function signature is:
753758``` wat
754759;; async, callback
@@ -789,7 +794,9 @@ This rest of this section sketches the shape of a component that uses `async`
789794to lift and lower its imports and exports with both the stackful and stackless
790795ABI options.
791796
792- Starting with the stackless ABI, the meat of this example component is replaced
797+ ### Stackful ABI example
798+
799+ Starting with the stackful ABI, the meat of this example component is replaced
793800with ` ... ` to focus on the overall flow of function calls:
794801``` wat
795802(component
@@ -800,8 +807,8 @@ with `...` to focus on the overall flow of function calls:
800807 ...
801808 )
802809 (core module $Main
803- (import "libc " "mem" (memory 1))
804- (import "libc " "realloc" (func (param i32 i32 i32 i32) (result i32)))
810+ (import "" "mem" (memory 1))
811+ (import "" "realloc" (func (param i32 i32 i32 i32) (result i32)))
805812 (import "" "fetch" (func $fetch (param i32 i32 i32) (result i32)))
806813 (import "" "waitable-set.new" (func $new_waitable_set (result i32)))
807814 (import "" "waitable-set.wait" (func $wait (param i32 i32) (result i32)))
@@ -876,13 +883,19 @@ call to `waitable-set.wait` blocks, the runtime will suspend its callstack
876883entry point and store it in context-local storage (via ` context.set ` ) instead
877884of simply using a ` global ` , as in a synchronous function.
878885
879- This same example can be re-written to use the ` callback ` immediate (thereby
880- avoiding the need for fibers) as follows. Note that the internal structure of
881- this component is almost the same as the previous one (other than that
882- ` summarize ` is now lifted from * two* core wasm functions instead of one) and
883- the public signature of this component is the exact same. Thus, the difference
884- is just about whether the stack is cleared by the core wasm code between events,
885- not externally-visible behavior.
886+ ### Stackless ABI example
887+
888+ The stackful example can be re-written to use the ` callback ` immediate (thereby
889+ avoiding the need for fibers) as follows.
890+
891+ Note that the internal structure of this component is almost the same as the
892+ previous one (other than that ` summarize ` is now lifted from * two* core wasm
893+ functions instead of one) and the public signature of this component is
894+ the exact same.
895+
896+ Thus, the difference is just about whether the stack is cleared by the
897+ core wasm code between events, not externally-visible behavior.
898+
886899``` wat
887900(component
888901 (import "fetch" (func $fetch (param "url" string) (result (list u8))))
0 commit comments