@@ -58,6 +58,9 @@ additional goals and requirements for native async support:
58
58
* Maintain meaningful cross-language call stacks (for the benefit of debugging,
59
59
logging and tracing).
60
60
* Provide mechanisms for applying and observing backpressure.
61
+ * Allow non-reentrant synchronous and event-loop-driven core wasm code (that,
62
+ e.g., assumes a single global linear memory stack) to not have to worry about
63
+ additional reentrancy.
61
64
62
65
63
66
## High-level Approach
@@ -474,6 +477,16 @@ wants to accept new accept new export calls while waiting or not.
474
477
See the [ ` canon_backpressure_set ` ] function and [ ` Task.enter ` ] method in the
475
478
Canonical ABI explainer for the setting and implementation of backpressure.
476
479
480
+ In addition to * explicit* backpressure set by wasm code, there is also an
481
+ * implicit* source of backpressure used to protect non-reentrant core wasm
482
+ code. In particular, when an export is lifted synchronously or using an
483
+ ` async callback ` , a component-instance-wide lock is implicitly acquired every
484
+ time core wasm is executed. By returning to the event loop after every event
485
+ (instead of once at the end of the task), ` async callback ` exports release
486
+ the lock between every event, allowing a higher degree of concurrency than
487
+ synchronous exports. ` async ` (stackful) exports ignore the lock entirely and
488
+ thus achieve the highest degree of (cooperative) concurrency.
489
+
477
490
Once a task is allowed to start according to these backpressure rules, its
478
491
arguments are lowered into the callee's linear memory and the task is in
479
492
the "started" state.
@@ -607,6 +620,9 @@ defined by the Component Model:
607
620
* Whenever a task yields or waits on (or polls) a waitable set with an already
608
621
pending event, whether the task "blocks" and transfers execution to its async
609
622
caller is nondeterministic.
623
+ * If multiple tasks are waiting on [ backpressure] ( #backpressure ) , and the
624
+ backpressure is disabled, the order in which these pending tasks (and new
625
+ tasks started while there are still pending tasks) start is nondeterministic.
610
626
611
627
Despite the above, the following scenarios do behave deterministically:
612
628
* If a component ` a ` asynchronously calls the export of another component ` b ` ,
0 commit comments