From b3b7ce4f6bdb1565ecac3158dee3ff99eab20813 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Tue, 29 Oct 2019 12:54:58 -0700 Subject: [PATCH 1/4] Enable all Wasm multi-value proposal tests! --- build.rs | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/build.rs b/build.rs index 924cfd2122..085ac3eea3 100644 --- a/build.rs +++ b/build.rs @@ -160,34 +160,18 @@ fn write_testsuite_tests( /// Ignore tests that aren't supported yet. fn ignore(testsuite: &str, testname: &str, strategy: &str) -> bool { - let is_multi_value = testsuite.ends_with("multi_value"); match strategy { #[cfg(feature = "lightbeam")] "Lightbeam" => match (testsuite, testname) { (_, _) if testname.starts_with("simd") => return true, - (_, _) if is_multi_value => return true, + (_, _) if testsuite.ends_with("multi_value") => return true, _ => (), }, "Cranelift" => match (testsuite, testname) { - // We don't currently support more return values than available - // registers, and this contains a function with many, many more - // return values than that. - (_, "func") if is_multi_value => return true, _ => {} }, _ => panic!("unrecognized strategy"), } - if cfg!(windows) { - return match (testsuite, testname) { - // Currently, our multi-value support only works with however many - // extra return registers we have available, and windows' fastcall - // ABI only has a single return register, so we need to wait on full - // multi-value support in Cranelift. - (_, _) if is_multi_value => true, - (_, _) => false, - }; - } - false } From a29303dedd4face76b2f58ebc767f2013e8c7d13 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Tue, 29 Oct 2019 14:24:36 -0700 Subject: [PATCH 2/4] Expand the muli-value example for wasmtime-api to use many return values This should exercise the Rust-calling-Wasm code path for when there are more return values than fit into return registers. --- crates/api/examples/multi.rs | 47 ++++++++++++++++++++++++++++----- crates/api/examples/multi.wasm | Bin 49 -> 114 bytes crates/api/examples/multi.wat | 15 +++++++++++ 3 files changed, 56 insertions(+), 6 deletions(-) diff --git a/crates/api/examples/multi.rs b/crates/api/examples/multi.rs index 9506c18ebe..e3d35c296e 100644 --- a/crates/api/examples/multi.rs +++ b/crates/api/examples/multi.rs @@ -51,19 +51,22 @@ fn main() -> Result<()> { .context("Error instantiating module!")?, ); - // Extract export. + // Extract exports. println!("Extracting export..."); let exports = Ref::map(instance.borrow(), |instance| instance.exports()); ensure!(!exports.is_empty(), "Error accessing exports!"); - let run_func = exports[0].func().context("Error accessing exports!")?; + let g = exports[0].func().context("> Error accessing export $g!")?; + let round_trip_many = exports[1] + .func() + .context("> Error accessing export $round_trip_many")?; - // Call. - println!("Calling export..."); + // Call `$g`. + println!("Calling export \"g\"..."); let args = vec![Val::I32(1), Val::I64(3)]; - let results = run_func + let results = g .borrow() .call(&args) - .map_err(|e| format_err!("> Error calling function: {:?}", e))?; + .map_err(|e| format_err!("> Error calling g! {:?}", e))?; println!("Printing result..."); println!("> {} {}", results[0].i64(), results[1].i32()); @@ -71,6 +74,38 @@ fn main() -> Result<()> { debug_assert_eq!(results[0].i64(), 4); debug_assert_eq!(results[1].i32(), 2); + // Call `$round_trip_many`. + println!("Calling export \"round_trip_many\"..."); + let args = vec![ + Val::I64(0), + Val::I64(1), + Val::I64(2), + Val::I64(3), + Val::I64(4), + Val::I64(5), + Val::I64(6), + Val::I64(7), + Val::I64(8), + Val::I64(9), + ]; + let results = round_trip_many + .borrow() + .call(&args) + .map_err(|e| format_err!("> Error calling round_trip_many! {:?}", e))?; + + println!("Printing result..."); + print!(">"); + for r in results.iter() { + print!(" {}", r.i64()); + } + println!(); + + debug_assert_eq!(results.len(), 10); + debug_assert!(args + .iter() + .zip(results.iter()) + .all(|(a, r)| a.i64() == r.i64())); + // Shut down. println!("Shutting down..."); drop(store); diff --git a/crates/api/examples/multi.wasm b/crates/api/examples/multi.wasm index 2b117daa8628f0fb9fe3e69d508571f718f81b12..9684f9fa1d998c4a3c10f104e634f80f8c454b8c 100644 GIT binary patch literal 114 zcmYkuy9$Fq6a>(@v&LtURHk(NG8IHgp%EWNn%!R)EP|&x=(foKSjCpX(}y2GtB}$bQCvb}wn*aa+ literal 49 zcmV~$u@QhE5CFluXHW(bN}x1NBr-CG*4^d)UIB|&>=kRrAwG~o&a4w_wJ;cV+7G1c B1rPuL diff --git a/crates/api/examples/multi.wat b/crates/api/examples/multi.wat index f26a857e17..cacd95504a 100644 --- a/crates/api/examples/multi.wat +++ b/crates/api/examples/multi.wat @@ -4,4 +4,19 @@ (func $g (export "g") (param i32 i64) (result i64 i32) (call $f (local.get 0) (local.get 1)) ) + + (func $round_trip_many + (export "round_trip_many") + (param i64 i64 i64 i64 i64 i64 i64 i64 i64 i64) + (result i64 i64 i64 i64 i64 i64 i64 i64 i64 i64) + local.get 0 + local.get 1 + local.get 2 + local.get 3 + local.get 4 + local.get 5 + local.get 6 + local.get 7 + local.get 8 + local.get 9) ) From 4c4699a22647978957d38693f886302fc46cddce Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Tue, 29 Oct 2019 15:42:07 -0700 Subject: [PATCH 3/4] Test the multi-value example on windows --- crates/api/tests/examples.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/api/tests/examples.rs b/crates/api/tests/examples.rs index 3f6468f9a9..24de77f3ed 100644 --- a/crates/api/tests/examples.rs +++ b/crates/api/tests/examples.rs @@ -32,7 +32,6 @@ fn test_run_memory_example() { run_example("memory"); } -#[cfg(not(target_os = "windows"))] #[test] fn test_run_multi_example() { run_example("multi"); From 01ab20e372361768b57f8456c140baec93651f4a Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Mon, 11 Nov 2019 15:52:49 -0800 Subject: [PATCH 4/4] Bump cranelift deps to 0.50.0 --- Cargo.toml | 8 ++++---- crates/api/Cargo.toml | 10 +++++----- crates/debug/Cargo.toml | 6 +++--- crates/environ/Cargo.toml | 8 ++++---- crates/interface-types/Cargo.toml | 2 +- crates/jit/Cargo.toml | 8 ++++---- crates/lightbeam/Cargo.toml | 2 +- crates/misc/py/Cargo.toml | 10 +++++----- crates/misc/rust/Cargo.toml | 4 ++-- crates/obj/Cargo.toml | 6 +++--- crates/runtime/Cargo.toml | 6 +++--- crates/wasi-c/Cargo.toml | 6 +++--- crates/wasi-common/Cargo.toml | 2 +- crates/wasi/Cargo.toml | 6 +++--- crates/wast/Cargo.toml | 6 +++--- 15 files changed, 45 insertions(+), 45 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d78cb4b9f4..22208d23b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,10 +14,10 @@ default-run = "wasmtime" [dependencies] # Enable all supported architectures by default. -cranelift-codegen = { version = "0.49", features = ["enable-serde", "all-arch"] } -cranelift-entity = { version = "0.49", features = ["enable-serde"] } -cranelift-wasm = { version = "0.49", features = ["enable-serde"] } -cranelift-native = "0.49" +cranelift-codegen = { version = "0.50.0", features = ["enable-serde", "all-arch"] } +cranelift-entity = { version = "0.50.0", features = ["enable-serde"] } +cranelift-wasm = { version = "0.50.0", features = ["enable-serde"] } +cranelift-native = "0.50.0" wasmtime = { path = "crates/api" } wasmtime-debug = { path = "crates/debug" } wasmtime-environ = { path = "crates/environ" } diff --git a/crates/api/Cargo.toml b/crates/api/Cargo.toml index f649eccbae..6f39564bb4 100644 --- a/crates/api/Cargo.toml +++ b/crates/api/Cargo.toml @@ -13,11 +13,11 @@ name = "wasmtime_api" crate-type = ["lib", "staticlib", "cdylib"] [dependencies] -cranelift-codegen = { version = "0.49", features = ["enable-serde"] } -cranelift-native = "0.49" -cranelift-entity = { version = "0.49", features = ["enable-serde"] } -cranelift-wasm = { version = "0.49", features = ["enable-serde"] } -cranelift-frontend = "0.49" +cranelift-codegen = { version = "0.50.0", features = ["enable-serde"] } +cranelift-native = "0.50.0" +cranelift-entity = { version = "0.50.0", features = ["enable-serde"] } +cranelift-wasm = { version = "0.50.0", features = ["enable-serde"] } +cranelift-frontend = "0.50.0" wasmtime-runtime = { path = "../runtime" } wasmtime-environ = { path = "../environ" } wasmtime-jit = { path = "../jit" } diff --git a/crates/debug/Cargo.toml b/crates/debug/Cargo.toml index 8ad753c693..1ccaf72be1 100644 --- a/crates/debug/Cargo.toml +++ b/crates/debug/Cargo.toml @@ -14,9 +14,9 @@ edition = "2018" [dependencies] gimli = "0.19.0" wasmparser = "0.39.2" -cranelift-codegen = { version = "0.49", features = ["enable-serde"] } -cranelift-entity = { version = "0.49", features = ["enable-serde"] } -cranelift-wasm = { version = "0.49", features = ["enable-serde"] } +cranelift-codegen = { version = "0.50.0", features = ["enable-serde"] } +cranelift-entity = { version = "0.50.0", features = ["enable-serde"] } +cranelift-wasm = { version = "0.50.0", features = ["enable-serde"] } faerie = "0.12.0" wasmtime-environ = { path = "../environ", default-features = false } target-lexicon = { version = "0.9.0", default-features = false } diff --git a/crates/environ/Cargo.toml b/crates/environ/Cargo.toml index 8e6112dcf3..62629ecdf7 100644 --- a/crates/environ/Cargo.toml +++ b/crates/environ/Cargo.toml @@ -12,9 +12,9 @@ readme = "README.md" edition = "2018" [dependencies] -cranelift-codegen = { version = "0.49", features = ["enable-serde"] } -cranelift-entity = { version = "0.49", features = ["enable-serde"] } -cranelift-wasm = { version = "0.49", features = ["enable-serde"] } +cranelift-codegen = { version = "0.50.0", features = ["enable-serde"] } +cranelift-entity = { version = "0.50.0", features = ["enable-serde"] } +cranelift-wasm = { version = "0.50.0", features = ["enable-serde"] } lightbeam = { path = "../lightbeam", optional = true } indexmap = "1.0.2" rayon = "1.2" @@ -44,7 +44,7 @@ tempfile = "3" target-lexicon = { version = "0.9.0", default-features = false } pretty_env_logger = "0.3.0" rand = { version = "0.7.0", features = ["small_rng"] } -cranelift-codegen = { version = "0.49", features = ["enable-serde", "all-arch"] } +cranelift-codegen = { version = "0.50.0", features = ["enable-serde", "all-arch"] } filetime = "0.2.7" [features] diff --git a/crates/interface-types/Cargo.toml b/crates/interface-types/Cargo.toml index c7cc8d243c..ffb91aaf5e 100644 --- a/crates/interface-types/Cargo.toml +++ b/crates/interface-types/Cargo.toml @@ -12,7 +12,7 @@ edition = "2018" [dependencies] anyhow = "1.0.19" -cranelift-codegen = { version = "0.49", default-features = false } +cranelift-codegen = { version = "0.50.0", default-features = false } walrus = "0.13" wasmparser = { version = "0.39.2", default-features = false } wasm-webidl-bindings = "0.6" diff --git a/crates/jit/Cargo.toml b/crates/jit/Cargo.toml index 5fec8b6bee..51bb1789ce 100644 --- a/crates/jit/Cargo.toml +++ b/crates/jit/Cargo.toml @@ -11,10 +11,10 @@ readme = "README.md" edition = "2018" [dependencies] -cranelift-codegen = { version = "0.49", features = ["enable-serde"] } -cranelift-entity = { version = "0.49", features = ["enable-serde"] } -cranelift-wasm = { version = "0.49", features = ["enable-serde"] } -cranelift-frontend = "0.49" +cranelift-codegen = { version = "0.50.0", features = ["enable-serde"] } +cranelift-entity = { version = "0.50.0", features = ["enable-serde"] } +cranelift-wasm = { version = "0.50.0", features = ["enable-serde"] } +cranelift-frontend = "0.50.0" wasmtime-environ = { path = "../environ", default-features = false } wasmtime-runtime = { path = "../runtime", default-features = false } wasmtime-debug = { path = "../debug", default-features = false } diff --git a/crates/lightbeam/Cargo.toml b/crates/lightbeam/Cargo.toml index da07aeaf7f..9a118f4afb 100644 --- a/crates/lightbeam/Cargo.toml +++ b/crates/lightbeam/Cargo.toml @@ -20,7 +20,7 @@ memoffset = "0.5.1" itertools = "0.8" capstone = "0.6.0" thiserror = "1.0.4" -cranelift-codegen = "0.49" +cranelift-codegen = "0.50.0" multi_mut = "0.1" either = "1.5" typemap = "0.3" diff --git a/crates/misc/py/Cargo.toml b/crates/misc/py/Cargo.toml index 9acf8ed85b..ee9af74782 100644 --- a/crates/misc/py/Cargo.toml +++ b/crates/misc/py/Cargo.toml @@ -15,11 +15,11 @@ name = "_wasmtime" crate-type = ["cdylib"] [dependencies] -cranelift-codegen = "0.49" -cranelift-native = "0.49" -cranelift-entity = "0.49" -cranelift-wasm = "0.49" -cranelift-frontend = "0.49" +cranelift-codegen = "0.50.0" +cranelift-native = "0.50.0" +cranelift-entity = "0.50.0" +cranelift-wasm = "0.50.0" +cranelift-frontend = "0.50.0" wasmtime-environ = { path = "../../environ" } wasmtime-interface-types = { path = "../../interface-types" } wasmtime-jit = { path = "../../jit" } diff --git a/crates/misc/rust/Cargo.toml b/crates/misc/rust/Cargo.toml index 872c8e4e59..2f47219605 100644 --- a/crates/misc/rust/Cargo.toml +++ b/crates/misc/rust/Cargo.toml @@ -15,8 +15,8 @@ test = false doctest = false [dependencies] -cranelift-codegen = "0.49" -cranelift-native = "0.49" +cranelift-codegen = "0.50.0" +cranelift-native = "0.50.0" wasmtime-interface-types = { path = "../../interface-types" } wasmtime-jit = { path = "../../jit" } wasmtime-rust-macro = { path = "./macro" } diff --git a/crates/obj/Cargo.toml b/crates/obj/Cargo.toml index 02677e3857..0f4b6d36e2 100644 --- a/crates/obj/Cargo.toml +++ b/crates/obj/Cargo.toml @@ -11,9 +11,9 @@ readme = "README.md" edition = "2018" [dependencies] -cranelift-codegen = { version = "0.49", features = ["enable-serde"] } -cranelift-entity = { version = "0.49", features = ["enable-serde"] } -cranelift-wasm = { version = "0.49", features = ["enable-serde"] } +cranelift-codegen = { version = "0.50.0", features = ["enable-serde"] } +cranelift-entity = { version = "0.50.0", features = ["enable-serde"] } +cranelift-wasm = { version = "0.50.0", features = ["enable-serde"] } wasmtime-environ = { path = "../environ" } faerie = "0.12.0" more-asserts = "0.2.1" diff --git a/crates/runtime/Cargo.toml b/crates/runtime/Cargo.toml index 30cbf421a8..f255c7c3ef 100644 --- a/crates/runtime/Cargo.toml +++ b/crates/runtime/Cargo.toml @@ -11,9 +11,9 @@ readme = "README.md" edition = "2018" [dependencies] -cranelift-codegen = { version = "0.49", features = ["enable-serde"] } -cranelift-entity = { version = "0.49", features = ["enable-serde"] } -cranelift-wasm = { version = "0.49", features = ["enable-serde"] } +cranelift-codegen = { version = "0.50.0", features = ["enable-serde"] } +cranelift-entity = { version = "0.50.0", features = ["enable-serde"] } +cranelift-wasm = { version = "0.50.0", features = ["enable-serde"] } wasmtime-environ = { path = "../environ", default-features = false } region = "2.0.0" lazy_static = "1.2.0" diff --git a/crates/wasi-c/Cargo.toml b/crates/wasi-c/Cargo.toml index dafba67b58..477880a03d 100644 --- a/crates/wasi-c/Cargo.toml +++ b/crates/wasi-c/Cargo.toml @@ -14,9 +14,9 @@ edition = "2018" wasmtime-runtime = { path = "../runtime" } wasmtime-environ = { path = "../environ" } wasmtime-jit = { path = "../jit" } -cranelift-codegen = { version = "0.49", features = ["enable-serde"] } -cranelift-entity = { version = "0.49", features = ["enable-serde"] } -cranelift-wasm = { version = "0.49", features = ["enable-serde"] } +cranelift-codegen = { version = "0.50.0", features = ["enable-serde"] } +cranelift-entity = { version = "0.50.0", features = ["enable-serde"] } +cranelift-wasm = { version = "0.50.0", features = ["enable-serde"] } target-lexicon = "0.9.0" log = { version = "0.4.8", default-features = false } libc = "0.2.60" diff --git a/crates/wasi-common/Cargo.toml b/crates/wasi-common/Cargo.toml index 26d4751b45..6e6af87bf5 100644 --- a/crates/wasi-common/Cargo.toml +++ b/crates/wasi-common/Cargo.toml @@ -42,7 +42,7 @@ wasmtime-environ = { path = "../environ" } wasmtime-jit = { path = "../jit" } wasmtime-wasi = { path = "../wasi" } wasmtime = { path = "../api" } -cranelift-codegen = "0.49.0" +cranelift-codegen = "0.50.0" target-lexicon = "0.9.0" pretty_env_logger = "0.3.0" tempfile = "3.1.0" diff --git a/crates/wasi/Cargo.toml b/crates/wasi/Cargo.toml index 0b4ff60a87..7d0c898459 100644 --- a/crates/wasi/Cargo.toml +++ b/crates/wasi/Cargo.toml @@ -15,9 +15,9 @@ wasmtime-runtime = { path = "../runtime" } wasmtime-environ = { path = "../environ" } wasmtime-jit = { path = "../jit" } wasi-common = { path = "../wasi-common" } -cranelift-codegen = { version = "0.49", features = ["enable-serde"] } -cranelift-entity = { version = "0.49", features = ["enable-serde"] } -cranelift-wasm = { version = "0.49", features = ["enable-serde"] } +cranelift-codegen = { version = "0.50.0", features = ["enable-serde"] } +cranelift-entity = { version = "0.50.0", features = ["enable-serde"] } +cranelift-wasm = { version = "0.50.0", features = ["enable-serde"] } target-lexicon = "0.9.0" log = { version = "0.4.8", default-features = false } diff --git a/crates/wast/Cargo.toml b/crates/wast/Cargo.toml index 356e9b36d8..85d42e80ac 100644 --- a/crates/wast/Cargo.toml +++ b/crates/wast/Cargo.toml @@ -11,9 +11,9 @@ readme = "README.md" edition = "2018" [dependencies] -cranelift-codegen = { version = "0.49", features = ["enable-serde"] } -cranelift-entity = { version = "0.49", features = ["enable-serde"] } -cranelift-wasm = { version = "0.49", features = ["enable-serde"] } +cranelift-codegen = { version = "0.50.0", features = ["enable-serde"] } +cranelift-entity = { version = "0.50.0", features = ["enable-serde"] } +cranelift-wasm = { version = "0.50.0", features = ["enable-serde"] } wasmtime-jit = { path = "../jit" } wasmtime-runtime = { path = "../runtime" } wasmtime-environ = { path = "../environ" }