julia
f7472911 - Tasking for Emscripten/Wasm target

Commit
6 years ago
Tasking for Emscripten/Wasm target This is an implementation of Julia's coroutine/tasking system on top of the binaryen Bysyncify transform [1] recently implemented by @kripken. The wasm target is unusual in several ways: 1. It has an implicitly managed call stack that we may not modify directly (i.e. is only modified through calls/returns). 2. The event loop is inverted, in that the browser runs the main event loop and we get callbacks for events, rather than Julia being the main event loop. Bysyncify takes care of the first problem by providing a mechanism to explicitly unwind and rewind the implicitly managed stack (essentially copying it to an explicitly managed stack - see the linked implementation for more information). For the second, I am currently using the ptls root_task to represent the browser event loop, i.e. yielding to that task will return control back to the browser and this is the task in which functions called by javascript will run unless they explicitly construct a task to run. As a result, julia code executed in the main task may not perform any blocking operations (though this is currently not enforced). I think this is a sensible setup since the main task will want to run some minor julia code (e.g. to introspect some data structures), but the bulk of the code will run in their own tasks (e.g. the REPL backend task). [1] https://github.com/WebAssembly/binaryen/blob/master/src/passes/Bysyncify.cpp
Author
Committer
Parents
Loading