I am building a compiler targeting WebAssembly for a language that makes heavy use of first-class coroutines. WASM doesn't have native coroutine support (yet), so I have to emulate it. Given the native tools that WebAssembly does provide, what is the most suitable approach to implementing them?
These are primarily within-language coroutines, but calls out to platform functionality will occur within them occasionally. Coroutines are currently stackless but ubiquitous. I am primarily interested in browser-based execution, but ideally it would work on other WASM environments as well.