@@ -58,6 +58,9 @@ additional goals and requirements for native async support:
5858* Maintain meaningful cross-language call stacks (for the benefit of debugging,
5959 logging and tracing).
6060* 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.
6164
6265
6366## High-level Approach
@@ -474,6 +477,16 @@ wants to accept new accept new export calls while waiting or not.
474477See the [ ` canon_backpressure_set ` ] function and [ ` Task.enter ` ] method in the
475478Canonical ABI explainer for the setting and implementation of backpressure.
476479
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+
477490Once a task is allowed to start according to these backpressure rules, its
478491arguments are lowered into the callee's linear memory and the task is in
479492the "started" state.
@@ -607,6 +620,9 @@ defined by the Component Model:
607620* Whenever a task yields or waits on (or polls) a waitable set with an already
608621 pending event, whether the task "blocks" and transfers execution to its async
609622 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.
610626
611627Despite the above, the following scenarios do behave deterministically:
612628* If a component ` a ` asynchronously calls the export of another component ` b ` ,
0 commit comments