co_await
unicomp21 opened this issue · 4 comments
With wasm tail calls landing around the same time, if not earlier, than webgpu, does this mean we'll no longer need need asyncify? We can use co_await and co_yield instead via clang targeting webassembly?
My understanding is tail calls must be supported in order for co_await to work on browser wasm?
This is an interesting topic. Currently there is ASYNCIFY support, and I think there would be possibility to integrate with JSPI to turn asynchronous calls to synchronous ones. That is still something on the list to investigate.
I don't know enough about the co_await/co_yield API to know how that would look in practice. Dedicated browser support in the Wasm VM will definitely be needed.
Coroutines are stackless, and don't require TCO or any other special functionality to work. However they also aren't an exact drop in for Asyncify, at a minimum you need some kind of scheduler to use them in a fiber-like way (which still won't be exactly the same as a fiber since, as mentioned, they're stackless so any type of yield can only happen in the coroutine and not any other routine the coroutine calls). Coroutines will also make your brain bleed for a while until you get used to them.
All of this said, I was able to create a decent, simple scheduler that works well for my application in a couple of days, so this is useful.