-
Notifications
You must be signed in to change notification settings - Fork 850
Add Asyncify mode that uses "native" stack #2934
Description
Something I mentioned in personal discussions with @kripken, posting here for tracking.
Low-level Asyncify API is flexible enough to support arbitrary suspend/resume use-cases, including coroutines. However, many applications don't really care about those and want to only suspend/resume the whole app on an external I/O.
For such cases, it could be nice to avoid having to allocate a separate "scratch space" for Asyncify, and instead push values directly onto the shadow stack behind __stack_pointer as defined by Tool Conventions. Semantically, those stored values are the spilled stack, so it only makes sense to store them there.
This would, in particular, simplify integrations like https://github.com/GoogleChromeLabs/asyncify, which currently have to make guesses about a free space area in a Wasm file where they could store Asyncify data, and would centralise stack size management for both Asyncify and regular stack in a single place.