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

Experimental: Add interpreter support for Wasmer #4515

Open
wants to merge 63 commits into
base: main
Choose a base branch
from
Open

Conversation

syrusakbary
Copy link
Member

This PR adds support for running Wasm modules in interpreted mode (in this case, via WAMR).

Progress:

  • Make the baseline functionality work
  • Most of the examples work
  • Most of the test work
  • Integrate it into CI
  • Document the differences when using WAMR (for example: memory grow can't be called outside of the host)
  • Test this on iOS

Comment on lines +151 to +154
#[cfg_attr(
feature = "wasm-c-api",
ignore = "wasm-c-api has a different memory testuite"
)]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably remove this, since we are skipping the failing tests

@xdoardo xdoardo mentioned this pull request Mar 26, 2024
@@ -128,6 +124,7 @@ default = ["wat", "wast", "cache", "wasi", "engine", "emscripten", "middlewares"
# That means: that is able to execute modules
backend = []
jsc = ["wasmer/jsc", "backend", "wat", "wasmer/std"]
wasm-c-api = ["wasmer/wasm-c-api", "backend", "wat", "wasmer/std"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a new one: wamr = ["wasm-c-api"]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -98,7 +98,7 @@ fn main() -> anyhow::Result<()> {
Ok(())
}
Err(e) => {
bail!("Unknown error `{}` found. expected `ErrorCode`", e);
bail!("Unknown error `{}` found. expected `ExitCode`", e);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

Comment on lines 98 to 100
default = ["sys-default"]
# default = ["js-default"]
# default = ["sys-default"]
default = ["wasm-c-api"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep the defaults once everything is passing

@@ -0,0 +1,50 @@
fn main() {
#[cfg(feature = "wasm-c-api")]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shoudl do here wamr feature instead of wasm-c-api

lib/api/build.rs Outdated
Comment on lines 39 to 48
let bindings = bindgen::Builder::default()
.header("wasm.h")
// This is needed if use `#include <nng.h>` instead of `#include "path/nng.h"`
//.clang_arg("-Inng/src/")
.generate()
.expect("Unable to generate bindings");
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in the wasm-c-api feature (not wamr)

Comment on lines +16 to +19
unimplemented!()
// let error = Trap::user(error);
// let js_error: JsValue = error.into();
// wasm_bindgen::throw_val(js_error)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably do the same implementation as jsc

impl PrettyError {
/// Process a `Result` printing any errors and exiting
/// the process after
pub fn report<T>(result: Result<T, Error>) -> ! {
use wasmer::RuntimeError;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move the import up, and do it with a cfg decorator instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants