dyon icon indicating copy to clipboard operation
dyon copied to clipboard

WASM Support

Open zicklag opened this issue 5 years ago • 3 comments

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.

zicklag avatar Jul 09 '19 17:07 zicklag

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?

bvssvni avatar Jul 10 '19 21:07 bvssvni

I think that makes sense.

zicklag avatar Jul 10 '19 21:07 zicklag

Any update on this?

Zireael07 avatar Feb 27 '20 08:02 Zireael07