brson / miri

An experimental compiler from Rust to WebAssembly (inactive - do not use)
Apache License 2.0
209 stars 15 forks source link

Enable calls to JS. Update some tests. #61

Open eholk opened 7 years ago

eholk commented 7 years ago

This PR enables a few more tests that were previously xfailed or disabled during one of my recent changes.

The most significant change is that we now have a way of importing arbitrary functions from the host. See tinycore.rs for an example of how this works. Basically, you create an extern block with #[link(name)]. Then mir2wasm will emit imports for each of the functions in the block from the module name.

Using this new capability, rustrt.js now provides a panic function, which is called by Rust when code panics. Right now this just throws a Javascript error, but we could improve this significantly.

Unfortunately, the binaryen interpreter doesn't give us a way to import Javascript (as far as I know), so we can't call into rustrt.js. Because of this, I've disabled running in binaryen in the tests. This means from now on our only supported mode of execution is in a proper JS VM.

This change also includes some miscellaneous cleanup and refactoring, although more is still needed. Finally, I pointed the binaryen submodule at my own fork because I need a small fix to run on one of my Linux machines, but we can't merge this into binaryen proper because of ASAN failures.