Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Bysyncify: async transform for wasm #2172
This adds a new pass, Bysyncify, which transforms code to allow unwind and rewinding the call stack and local state. This allows things like coroutines, turning synchronous code asynchronous, etc.
The new pass file itself has a large comment on top with docs.
So far the tests here seem to show this works, but this hasn't been tested heavily yet. My next step is to hook this up to emscripten as a replacement for asyncify/emterpreter, see emscripten-core/emscripten#8561
Note that this is completely usable by itself, so it could be useful for any language that needs coroutines etc., and not just ones using LLVM and/or emscripten. See docs on the ABI in the pass source.
Sounds great, I'll try this with the Doom 3 port as a replacement for Emterpretify.
Also, that would maybe allow to have someday a blocking filesystem backend using IndexedDB, since neither FilesystemSync API and IndexedDBSync API are on the browsers vendors roadmap.
@gabrielcuvillier this isn't quite ready! No emscripten integration yet, and hasn't been tested heavily. But hopefully next week I'll finish those things.
About IndexedDB synchronously, something like that is already available with the emterpreter, see https://emscripten.org/docs/api_reference/emscripten.h.html#indexeddb (and I intend to make it work with bysyncify too).
Jun 15, 2019
Ok, no issue. I'll test as soon as it is ready.
Yes, I know about those synchrounous IndexedDB functions, they are working well but does indeed require the Emterpreter. In D3 the file loading operations are done very very deeply in the code (+ D3 implement a concept of virtual filesystem on top of .pak files, that are .zips of assets), and using Emterpreter at the file read operation require to have too much stuff in the emterpreter whitelist in the end... something like more than 100 functions (omg!) :/ The performance impact starts to be seen compared to a non emterpreter build (not speaking about compilaiton time:)