Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish implementing the wasm3 runtime #266

Merged
merged 7 commits into from
Aug 25, 2021

Conversation

jonas-schievink
Copy link
Contributor

@jonas-schievink jonas-schievink commented Aug 23, 2021

This adds a --wasm3 option to rune run, and duplicates the Wasmer API implementation for wasm3. It also updates to wasm3 0.2, which fixes the soundness bug I encountered last time.

The result:

$ cargo run --bin rune -- run examples/sine/sine.rune --raw .gitignore 
   Compiling hotg-rune-cli v0.6.1-dev (/home/jonas/dev/rune/crates/rune-cli)
    Finished dev [unoptimized + debuginfo] target(s) in 6.83s
     Running `target/debug/rune run examples/sine/sine.rune --raw .gitignore`
[2021-08-23T16:43:56.422Z INFO  hotg_rune_cli::run::command] Running rune: examples/sine/sine.rune
[2021-08-23T16:43:56.689Z INFO  hotg_rune_runtime::common_outputs] Serial: {"type_name":"f32","channel":2,"elements":[27.202106],"dimensions":[1,1]}
$ cargo run --bin rune -- run examples/sine/sine.rune --raw .gitignore --wasm3
    Finished dev [unoptimized + debuginfo] target(s) in 0.09s
     Running `target/debug/rune run examples/sine/sine.rune --raw .gitignore --wasm3`
[2021-08-23T16:43:59.314Z INFO  hotg_rune_cli::run::command] Running rune: examples/sine/sine.rune
[2021-08-23T16:43:59.316Z INFO  hotg_rune_runtime::common_outputs] Serial: {"type_name":"f32","channel":2,"elements":[27.202106],"dimensions":[1,1]}

There are some caveats due to limitations of the wasm3 crate: it doesn't have a very sophisticated interface for building host functions, so I had to manually implement some wrappers that resemble what Wasmer offers here. The crate also doesn't have a way to bubble up runtime errors, which means that an error in a host function results in the WASM binary continuing to run (currently I log the error that occurred and return u32::MAX to the WASM program).

The "all intrinsics are implemented" test from the wasmer implementation has been configured out for now, since wasm3 does not have the required introspection APIs.

@jonas-schievink jonas-schievink marked this pull request as draft August 23, 2021 16:48
@jonas-schievink jonas-schievink marked this pull request as ready for review August 23, 2021 17:06
@Michael-F-Bryan
Copy link
Contributor

@jonas-schievink, did you want to add the code for propagating errors to this PR before we merge it? Or should I merge it now and we'll add error handling later?

@jonas-schievink
Copy link
Contributor Author

I'd prefer to land this now so that #271 is unblocked

@Michael-F-Bryan
Copy link
Contributor

I'd prefer to land this now so that #271 is unblocked

Perfect. It looks like you just need to rebase onto master to pick up the latest changes then GitHub should merge this PR automatically.

auto-merge was automatically disabled August 25, 2021 15:09

Head branch was pushed to by a user without write access

@jonas-schievink
Copy link
Contributor Author

@Michael-F-Bryan looks like you need to re-approve the PR for auto-merging to work

@Michael-F-Bryan Michael-F-Bryan merged commit c73d822 into hotg-ai:master Aug 25, 2021
@jonas-schievink jonas-schievink deleted the wasm3-impl branch August 25, 2021 16:22
@f0rodo f0rodo linked an issue Aug 26, 2021 that may be closed by this pull request
3 tasks
@Michael-F-Bryan Michael-F-Bryan mentioned this pull request Aug 26, 2021
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WASM3 WebAssembly Backend
2 participants