@@ -729,8 +729,11 @@ the core wasm toolchain) `$retp` must be a 4-byte-aligned pointer into linear
729
729
memory from which the 8-byte (pointer, length) of the string result can be
730
730
loaded.
731
731
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.
734
737
735
738
The async stackful export function signature is:
736
739
``` wat
@@ -749,6 +752,8 @@ WIT parameter type of a synchronous function. For example, if more than 16
749
752
core parameters would be needed, a single ` i32 ` pointer into linear memory is
750
753
used.
751
754
755
+ ##### Stackless Async Exports
756
+
752
757
The async stackless export function signature is:
753
758
``` wat
754
759
;; async, callback
@@ -789,7 +794,9 @@ This rest of this section sketches the shape of a component that uses `async`
789
794
to lift and lower its imports and exports with both the stackful and stackless
790
795
ABI options.
791
796
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
793
800
with ` ... ` to focus on the overall flow of function calls:
794
801
``` wat
795
802
(component
@@ -800,8 +807,8 @@ with `...` to focus on the overall flow of function calls:
800
807
...
801
808
)
802
809
(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)))
805
812
(import "" "fetch" (func $fetch (param i32 i32 i32) (result i32)))
806
813
(import "" "waitable-set.new" (func $new_waitable_set (result i32)))
807
814
(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
876
883
entry point and store it in context-local storage (via ` context.set ` ) instead
877
884
of simply using a ` global ` , as in a synchronous function.
878
885
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
+
886
899
``` wat
887
900
(component
888
901
(import "fetch" (func $fetch (param "url" string) (result (list u8))))
0 commit comments