dyon
dyon copied to clipboard
WASM Support
I am working on the Arsenal project and was considering using Dyon to provide a scripting layer for Amethyst. Right now it is just in the experimentation phase, but WASM scripting is being tested out for Amethyst and, if that was successful, I was speculating that we could compile Dyon to WASM and then use Dyon for scripting through the WASM interface.
I successfully compiled Dyon to WASM using Rust's wasm32-wasi
target, and I attempted to use Wasmer to run a Dyon example, but it failed because threads are not supported in WASM yet:
> wasmer run dyonrun.wasm --dir source/ -- source/test.dyon
thread 'main' panicked at 'failed to spawn thread: Custom { kind: Other, error: "operation not supported on wasm yet" }', src/libcore/result.rs:999:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
thread 'main' panicked at 'wasm trap occured: unknown', src/bin/wasmer.rs:515:51
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
My question was whether or not we could put threading in Dyon behind a feature flag that could be disabled when compiling for WASM.
It is not yet clear whether or not we will even be able to use WASM in Amethyst yet, so this isn't necessarily high priority yet, but I figured I'd bring up the question earlier rather than later to see what you thought about it.
Currently, Dyon uses two threads, one to run lifetime and type checker and the main thread to construct AST.
I'm in favor adding a feature flag that disables this behavior, such that it can run in the browser.
Not sure what to do about attempts to start new threads from within the script. Perhaps we should report an error message?
I think that makes sense.
Any update on this?