From d695bd0c849becaec9f9f10f7fddbceff2fbb494 Mon Sep 17 00:00:00 2001 From: Brandon Fish Date: Mon, 12 Aug 2019 15:35:32 -0600 Subject: [PATCH 1/7] Update WABT dep to fixe names spectests --- Cargo.lock | 17 ++++++++--------- Cargo.toml | 4 ++-- lib/emscripten-tests/Cargo.toml | 2 +- lib/llvm-backend/Cargo.toml | 2 +- lib/middleware-common/Cargo.toml | 2 +- lib/runtime/Cargo.toml | 2 +- lib/spectests/Cargo.toml | 4 ++-- lib/spectests/tests/excludes.txt | 3 --- 8 files changed, 16 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0c81bdc3c..debd9be12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1359,7 +1359,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wabt" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1397,7 +1397,7 @@ dependencies = [ "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "structopt 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", - "wabt 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wabt 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "wasmer-clif-backend 0.6.0", "wasmer-dev-utils 0.6.0", "wasmer-emscripten 0.6.0", @@ -1484,7 +1484,7 @@ name = "wasmer-emscripten-tests" version = "0.6.0" dependencies = [ "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wabt 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wabt 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "wasmer-clif-backend 0.6.0", "wasmer-dev-utils 0.6.0", "wasmer-emscripten 0.6.0", @@ -1516,8 +1516,7 @@ dependencies = [ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", - "wabt 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wabt 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "wasmer-runtime-core 0.6.0", "wasmparser 0.35.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1528,7 +1527,7 @@ name = "wasmer-middleware-common" version = "0.6.0" dependencies = [ "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "wabt 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wabt 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "wasmer-clif-backend 0.6.0", "wasmer-llvm-backend 0.6.0", "wasmer-runtime-core 0.6.0", @@ -1543,7 +1542,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wabt 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wabt 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "wasmer-clif-backend 0.6.0", "wasmer-llvm-backend 0.6.0", "wasmer-runtime-core 0.6.0", @@ -1609,7 +1608,7 @@ name = "wasmer-spectests" version = "0.6.0" dependencies = [ "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wabt 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wabt 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "wasmer-clif-backend 0.6.0", "wasmer-llvm-backend 0.6.0", "wasmer-runtime-core 0.6.0", @@ -1889,7 +1888,7 @@ dependencies = [ "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -"checksum wabt 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d07edd40d190ddcbd0113c2150ccb214f47a02ff36958630ba0e5b8138ece1c1" +"checksum wabt 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "94b5f5d6984ca42df66280baa8a15ac188a173ddaf4580b574a98931c01920e7" "checksum wabt-sys 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b064c81821100adb4b71923cecfc67fef083db21c3bbd454b0162c7ffe63eeaa" "checksum walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d9d7ed3431229a144296213105a390676cc49c9b6a72bd19f3176c98e129fa1" "checksum wasmer-clif-fork-frontend 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bd6bec1587a3b11222f4ff129fd119785713c41de413f54f99d3c03743812f4" diff --git a/Cargo.toml b/Cargo.toml index 54dcaa3a3..b2992bc64 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ include = [ byteorder = "1.3.2" errno = "0.2.4" structopt = "0.2.18" -wabt = "0.9.0" +wabt = "0.9.1" wasmer-clif-backend = { path = "lib/clif-backend" } wasmer-singlepass-backend = { path = "lib/singlepass-backend", optional = true } wasmer-middleware-common = { path = "lib/middleware-common" } @@ -60,7 +60,7 @@ members = [ ] [build-dependencies] -wabt = "0.9.0" +wabt = "0.9.1" glob = "0.3.0" rustc_version = "0.2.3" diff --git a/lib/emscripten-tests/Cargo.toml b/lib/emscripten-tests/Cargo.toml index e715e3fc0..71546fbeb 100644 --- a/lib/emscripten-tests/Cargo.toml +++ b/lib/emscripten-tests/Cargo.toml @@ -16,7 +16,7 @@ wasmer-llvm-backend = { path = "../llvm-backend", version = "0.6.0", optional = wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.6.0", optional = true } [dev-dependencies] -wabt = "0.9.0" +wabt = "0.9.1" wasmer-dev-utils = { path = "../dev-utils", version = "0.6.0"} [build-dependencies] diff --git a/lib/llvm-backend/Cargo.toml b/lib/llvm-backend/Cargo.toml index d8bc78f39..b34164405 100644 --- a/lib/llvm-backend/Cargo.toml +++ b/lib/llvm-backend/Cargo.toml @@ -33,7 +33,7 @@ semver = "0.9" rustc_version = "0.2.3" [dev-dependencies] -wabt = "0.9.0" +wabt = "0.9.1" [features] debug = ["wasmer-runtime-core/debug"] diff --git a/lib/middleware-common/Cargo.toml b/lib/middleware-common/Cargo.toml index b0e43f7ac..8944bfa21 100644 --- a/lib/middleware-common/Cargo.toml +++ b/lib/middleware-common/Cargo.toml @@ -14,7 +14,7 @@ wasmer-llvm-backend = { path = "../llvm-backend", version = "0.6.0", optional = wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.6.0", optional = true } [dev-dependencies] -wabt = "0.9.0" +wabt = "0.9.1" criterion = "0.2" [features] diff --git a/lib/runtime/Cargo.toml b/lib/runtime/Cargo.toml index 4be2d29b7..b1383fa20 100644 --- a/lib/runtime/Cargo.toml +++ b/lib/runtime/Cargo.toml @@ -25,7 +25,7 @@ optional = true [dev-dependencies] tempfile = "3.1.0" criterion = "0.2" -wabt = "0.9.0" +wabt = "0.9.1" [dependencies.wasmer-llvm-backend] path = "../llvm-backend" diff --git a/lib/spectests/Cargo.toml b/lib/spectests/Cargo.toml index f79acdfbb..2bac32872 100644 --- a/lib/spectests/Cargo.toml +++ b/lib/spectests/Cargo.toml @@ -15,10 +15,10 @@ wasmer-llvm-backend = { path = "../llvm-backend", version = "0.6.0", optional = wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.6.0", optional = true } [build-dependencies] -wabt = "0.9.0" +wabt = "0.9.1" [dev-dependencies] -wabt = "0.9.0" +wabt = "0.9.1" [features] default = ["fast-tests"] diff --git a/lib/spectests/tests/excludes.txt b/lib/spectests/tests/excludes.txt index bc6b1963e..55ab7f851 100644 --- a/lib/spectests/tests/excludes.txt +++ b/lib/spectests/tests/excludes.txt @@ -17,7 +17,6 @@ # # Cranelift -clif:skip:names.wast:* # Names file has parsing error? clif:skip:simd.wast:* # SIMD not implemented clif:skip:simd_binaryen.wast:* # SIMD not implemented @@ -818,7 +817,6 @@ llvm:skip:imports.wast:391 # Running forever llvm:skip:imports.wast:402 # Running forever llvm:skip:imports.wast:487 # LLVM ERROR: Program used external function '_vm.memory.grow.static.import' which could not be resolved! llvm:skip:linking.wast:306 # LLVM ERROR: Program used external function '_vm.memory.grow.static.import' which could not be resolved! -llvm:skip:names.wast:* # Names file has parsing error? llvm:skip:call.wast:273 # Spec running forever llvm:skip:call_indirect.wast:556 # Spec running forever llvm:skip:call_indirect.wast:557 # Spec running forever @@ -919,7 +917,6 @@ llvm:skip:unreachable.wast:*:windows llvm:skip:unwind.wast:*:windows # Singlepass -singlepass:skip:names.wast:* # Names file has parsing error? singlepass:skip:simd.wast:* # SIMD not implemented singlepass:skip:simd_binaryen.wast:* # SIMD not implemented From e76777ed9ba8ba2ab7712391d4793cd9a3a77bab Mon Sep 17 00:00:00 2001 From: Brandon Fish Date: Mon, 12 Aug 2019 20:22:54 -0600 Subject: [PATCH 2/7] Finalize signatures & names when no function bodies --- lib/runtime-core/src/parse.rs | 11 +++++-- lib/spectests/tests/excludes.txt | 56 ++++---------------------------- 2 files changed, 14 insertions(+), 53 deletions(-) diff --git a/lib/runtime-core/src/parse.rs b/lib/runtime-core/src/parse.rs index f482b10ca..1ca9f1a43 100644 --- a/lib/runtime-core/src/parse.rs +++ b/lib/runtime-core/src/parse.rs @@ -369,12 +369,17 @@ pub fn read_module< info.write().unwrap().globals.push(global_init); } ParserState::EndWasm => { - if namespace_builder.is_some() { + // TODO Consolidate with BeginFunction body if possible + if func_count == ::std::usize::MAX { info.write().unwrap().namespace_table = namespace_builder.take().unwrap().finish(); - } - if name_builder.is_some() { info.write().unwrap().name_table = name_builder.take().unwrap().finish(); + mcg.feed_signatures(info.read().unwrap().signatures.clone()) + .map_err(|x| LoadError::Codegen(format!("{:?}", x)))?; + mcg.feed_function_signatures(info.read().unwrap().func_assoc.clone()) + .map_err(|x| LoadError::Codegen(format!("{:?}", x)))?; + mcg.check_precondition(&info.read().unwrap()) + .map_err(|x| LoadError::Codegen(format!("{:?}", x)))?; } break; } diff --git a/lib/spectests/tests/excludes.txt b/lib/spectests/tests/excludes.txt index bc6b1963e..5bdb291cc 100644 --- a/lib/spectests/tests/excludes.txt +++ b/lib/spectests/tests/excludes.txt @@ -827,58 +827,16 @@ llvm:skip:skip-stack-guard-page.wast:* # Spec running forever or (signal: 4, SIG llvm:skip:linking.wast:236 # terminating with uncaught exception of type WasmTrap llvm:skip:linking.wast:248 # terminating with uncaught exception of type WasmTrap -llvm:fail:binary-leb128.wast:56 # Module - caught panic Any -llvm:fail:binary-leb128.wast:65 # Module - caught panic Any -llvm:fail:binary-leb128.wast:74 # Module - caught panic Any -llvm:fail:binary-leb128.wast:86 # Module - caught panic Any -llvm:fail:binary-leb128.wast:98 # Module - caught panic Any -llvm:fail:binary.wast:446 # Module - caught panic Any llvm:fail:globals.wast:243 # AssertInvalid - caught panic Any -llvm:fail:i32.wast:243 # AssertReturn - result I32(205242703) ("0xc3bc14f") does not match expected I32(32) ("0x20") -llvm:fail:i32.wast:252 # AssertReturn - result I32(205242720) ("0xc3bc160") does not match expected I32(32) ("0x20") -llvm:fail:i64.wast:243 # AssertReturn - result I64(4500210159) ("0x10c3bc1ef") does not match expected I64(64) ("0x40") -llvm:fail:i64.wast:252 # AssertReturn - result I64(4500210144) ("0x10c3bc1e0") does not match expected I64(64) ("0x40") -llvm:fail:imports.wast:98 # Module - caught panic Any -llvm:fail:imports.wast:99 # Module - caught panic Any -llvm:fail:imports.wast:100 # Module - caught panic Any -llvm:fail:imports.wast:101 # Module - caught panic Any -llvm:fail:imports.wast:102 # Module - caught panic Any -llvm:fail:imports.wast:103 # Module - caught panic Any -llvm:fail:imports.wast:104 # Module - caught panic Any -llvm:fail:imports.wast:107 # AssertUnlinkable - caught panic Any -llvm:fail:imports.wast:111 # AssertUnlinkable - caught panic Any -llvm:fail:imports.wast:116 # AssertUnlinkable - caught panic Any -llvm:fail:imports.wast:120 # AssertUnlinkable - caught panic Any -llvm:fail:imports.wast:124 # AssertUnlinkable - caught panic Any -llvm:fail:imports.wast:128 # AssertUnlinkable - caught panic Any -llvm:fail:imports.wast:132 # AssertUnlinkable - caught panic Any -llvm:fail:imports.wast:136 # AssertUnlinkable - caught panic Any -llvm:fail:imports.wast:140 # AssertUnlinkable - caught panic Any -llvm:fail:imports.wast:144 # AssertUnlinkable - caught panic Any -llvm:fail:imports.wast:148 # AssertUnlinkable - caught panic Any -llvm:fail:imports.wast:152 # AssertUnlinkable - caught panic Any -llvm:fail:imports.wast:156 # AssertUnlinkable - caught panic Any -llvm:fail:imports.wast:160 # AssertUnlinkable - caught panic Any -llvm:fail:imports.wast:164 # AssertUnlinkable - caught panic Any -llvm:fail:imports.wast:168 # AssertUnlinkable - caught panic Any -llvm:fail:imports.wast:172 # AssertUnlinkable - caught panic Any -llvm:fail:imports.wast:176 # AssertUnlinkable - caught panic Any -llvm:fail:imports.wast:181 # AssertUnlinkable - caught panic Any -llvm:fail:imports.wast:185 # AssertUnlinkable - caught panic Any -llvm:fail:imports.wast:189 # AssertUnlinkable - caught panic Any -llvm:fail:imports.wast:193 # AssertUnlinkable - caught panic Any -llvm:fail:imports.wast:197 # AssertUnlinkable - caught panic Any -llvm:fail:imports.wast:201 # AssertUnlinkable - caught panic Any +llvm:fail:i32.wast:243 # AssertReturn - result I32(61374799) ("0x3a8814f") does not match expected I32(32) ("0x20") +llvm:fail:i32.wast:252 # AssertReturn - result I32(61374816) ("0x3a88160") does not match expected I32(32) ("0x20") +llvm:fail:i64.wast:243 # AssertReturn - result I64(4356342255) ("0x103a881ef") does not match expected I64(64) ("0x40") +llvm:fail:i64.wast:252 # AssertReturn - result I64(4356342240) ("0x103a881e0") does not match expected I64(64) ("0x40") llvm:fail:imports.wast:491 # AssertReturn - Call failed ResolveError: ExportNotFound { name: "grow" } llvm:fail:imports.wast:492 # AssertReturn - Call failed ResolveError: ExportNotFound { name: "grow" } llvm:fail:imports.wast:493 # AssertReturn - Call failed ResolveError: ExportNotFound { name: "grow" } llvm:fail:imports.wast:494 # AssertReturn - Call failed ResolveError: ExportNotFound { name: "grow" } llvm:fail:imports.wast:495 # AssertReturn - Call failed ResolveError: ExportNotFound { name: "grow" } -llvm:fail:imports.wast:574 # AssertUnlinkable - caught panic Any -llvm:fail:linking.wast:22 # Module - caught panic Any -llvm:fail:linking.wast:26 # Register - No instance available -llvm:fail:linking.wast:28 # AssertUnlinkable - caught panic Any -llvm:fail:linking.wast:32 # AssertUnlinkable - caught panic Any llvm:fail:linking.wast:314 # AssertReturn - No instance available: Some("$Pm") llvm:fail:linking.wast:315 # AssertReturn - No instance available: Some("$Pm") llvm:fail:linking.wast:316 # AssertReturn - No instance available: Some("$Pm") @@ -887,12 +845,10 @@ llvm:fail:linking.wast:318 # AssertReturn - No instance available: Some("$Pm") llvm:fail:linking.wast:319 # AssertReturn - No instance available: Some("$Pm") llvm:fail:linking.wast:320 # AssertReturn - No instance available: Some("$Pm") llvm:fail:linking.wast:321 # AssertReturn - No instance available: Some("$Pm") -llvm:fail:linking.wast:324 # AssertUnlinkable - caught panic Any llvm:fail:linking.wast:387 # AssertReturn - result I32(0) ("0x0") does not match expected I32(104) ("0x68") llvm:fail:linking.wast:388 # AssertReturn - Call failed RuntimeError: WebAssembly trap occurred during runtime: incorrect `call_indirect` signature -llvm:fail:load.wast:201 # AssertReturn - result I32(205795359) ("0xc44301f") does not match expected I32(32) ("0x20") -llvm:fail:start.wast:92 # Module - caught panic Any -llvm:fail:type.wast:3 # Module - caught panic Any +llvm:fail:load.wast:201 # AssertReturn - result I32(66175007) ("0x3f1c01f") does not match expected I32(32) ("0x20") + # LLVM Windows llvm:skip:address.wast:*:windows From f22250d85a5a1fbb85f4d0f706b0268fd28177bb Mon Sep 17 00:00:00 2001 From: Brandon Fish Date: Mon, 12 Aug 2019 21:36:17 -0600 Subject: [PATCH 3/7] Refactor func_count in parser --- lib/runtime-core/src/parse.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/runtime-core/src/parse.rs b/lib/runtime-core/src/parse.rs index 1ca9f1a43..259a628dd 100644 --- a/lib/runtime-core/src/parse.rs +++ b/lib/runtime-core/src/parse.rs @@ -92,7 +92,8 @@ pub fn read_module< let mut namespace_builder = Some(StringTableBuilder::new()); let mut name_builder = Some(StringTableBuilder::new()); - let mut func_count: usize = ::std::usize::MAX; + let mut func_count: usize = 0; + let mut mcg_info_fed = false; loop { use wasmparser::ParserState; @@ -196,9 +197,9 @@ pub fn read_module< info.write().unwrap().start_func = Some(FuncIndex::new(start_index as usize)); } ParserState::BeginFunctionBody { .. } => { - let id = func_count.wrapping_add(1); - func_count = id; - if func_count == 0 { + let id = func_count; + if !mcg_info_fed { + mcg_info_fed = true; info.write().unwrap().namespace_table = namespace_builder.take().unwrap().finish(); info.write().unwrap().name_table = name_builder.take().unwrap().finish(); @@ -279,6 +280,7 @@ pub fn read_module< .map_err(|x| LoadError::Codegen(x))?; fcg.finalize() .map_err(|x| LoadError::Codegen(format!("{:?}", x)))?; + func_count = func_count.wrapping_add(1); } ParserState::BeginActiveElementSectionEntry(table_index) => { let table_index = TableIndex::new(table_index as usize); @@ -370,7 +372,7 @@ pub fn read_module< } ParserState::EndWasm => { // TODO Consolidate with BeginFunction body if possible - if func_count == ::std::usize::MAX { + if !mcg_info_fed { info.write().unwrap().namespace_table = namespace_builder.take().unwrap().finish(); info.write().unwrap().name_table = name_builder.take().unwrap().finish(); From de8fe32dbe3f5419010ade89e0a60769f5773a05 Mon Sep 17 00:00:00 2001 From: Brandon Fish Date: Tue, 13 Aug 2019 13:04:13 -0600 Subject: [PATCH 4/7] Add memory validation --- lib/runtime-core/src/memory/mod.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/runtime-core/src/memory/mod.rs b/lib/runtime-core/src/memory/mod.rs index 04ffaa384..f618c33d8 100644 --- a/lib/runtime-core/src/memory/mod.rs +++ b/lib/runtime-core/src/memory/mod.rs @@ -73,6 +73,12 @@ impl Memory { } } + if desc.shared && desc.maximum.is_none() { + return Err(CreationError::InvalidDescriptor( + "Max number of pages is required for shared memory".to_string(), + )); + } + let variant = if !desc.shared { MemoryVariant::Unshared(UnsharedMemory::new(desc)?) } else { @@ -325,4 +331,17 @@ mod memory_tests { assert_eq!(unshared_memory.size(), Pages(10)); } + #[test] + fn test_invalid_descriptor_returns_error() { + let result = Memory::new(MemoryDescriptor { + minimum: Pages(10), + maximum: None, + shared: true, + }); + assert!( + result.is_err(), + "Max number of pages is required for shared memory" + ) + } + } From 137ac206afe010b6713f8a78f5db53cd7f771b82 Mon Sep 17 00:00:00 2001 From: Brandon Fish Date: Tue, 13 Aug 2019 17:59:04 -0600 Subject: [PATCH 5/7] Return compile error (llvm) for setting immutable global --- lib/llvm-backend/src/code.rs | 4 +++- lib/spectests/tests/excludes.txt | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/llvm-backend/src/code.rs b/lib/llvm-backend/src/code.rs index 4398b3548..004d0e386 100644 --- a/lib/llvm-backend/src/code.rs +++ b/lib/llvm-backend/src/code.rs @@ -1151,7 +1151,9 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { builder.build_store(ptr_to_value, value); } GlobalCache::Const { value: _ } => { - unreachable!("cannot set non-mutable globals") + return Err(CodegenError { + message: "global is immutable".to_string(), + }); } } } diff --git a/lib/spectests/tests/excludes.txt b/lib/spectests/tests/excludes.txt index 741aba8c1..ae3cc7fef 100644 --- a/lib/spectests/tests/excludes.txt +++ b/lib/spectests/tests/excludes.txt @@ -825,7 +825,6 @@ llvm:skip:skip-stack-guard-page.wast:* # Spec running forever or (signal: 4, SIG llvm:skip:linking.wast:236 # terminating with uncaught exception of type WasmTrap llvm:skip:linking.wast:248 # terminating with uncaught exception of type WasmTrap -llvm:fail:globals.wast:243 # AssertInvalid - caught panic Any llvm:fail:i32.wast:243 # AssertReturn - result I32(61374799) ("0x3a8814f") does not match expected I32(32) ("0x20") llvm:fail:i32.wast:252 # AssertReturn - result I32(61374816) ("0x3a88160") does not match expected I32(32) ("0x20") llvm:fail:i64.wast:243 # AssertReturn - result I64(4356342255) ("0x103a881ef") does not match expected I64(64) ("0x40") From 0bf33662d1ca92956f95ba6cc38008f848e94108 Mon Sep 17 00:00:00 2001 From: Brandon Fish Date: Tue, 13 Aug 2019 20:07:55 -0600 Subject: [PATCH 6/7] Add missing LLVM imported memory functions --- lib/llvm-backend/src/backend.rs | 5 +++++ lib/spectests/tests/excludes.txt | 26 +++++--------------------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/lib/llvm-backend/src/backend.rs b/lib/llvm-backend/src/backend.rs index 763a7b348..92f0f06a1 100644 --- a/lib/llvm-backend/src/backend.rs +++ b/lib/llvm-backend/src/backend.rs @@ -105,6 +105,11 @@ fn get_callbacks() -> Callbacks { fn_name!("vm.memory.grow.static.local") => vmcalls::local_static_memory_grow as _, fn_name!("vm.memory.size.static.local") => vmcalls::local_static_memory_size as _, + fn_name!("vm.memory.grow.dynamic.import") => vmcalls::imported_dynamic_memory_grow as _, + fn_name!("vm.memory.size.dynamic.import") => vmcalls::imported_dynamic_memory_size as _, + fn_name!("vm.memory.grow.static.import") => vmcalls::imported_static_memory_grow as _, + fn_name!("vm.memory.size.static.import") => vmcalls::imported_static_memory_size as _, + fn_name!("vm.exception.trap") => throw_trap as _, fn_name!("vm.breakpoint") => throw_breakpoint as _, diff --git a/lib/spectests/tests/excludes.txt b/lib/spectests/tests/excludes.txt index ae3cc7fef..bfa255a14 100644 --- a/lib/spectests/tests/excludes.txt +++ b/lib/spectests/tests/excludes.txt @@ -815,8 +815,6 @@ llvm:skip:f64.wast:2418 llvm:skip:br_table.wast:1255 llvm:skip:imports.wast:391 # Running forever llvm:skip:imports.wast:402 # Running forever -llvm:skip:imports.wast:487 # LLVM ERROR: Program used external function '_vm.memory.grow.static.import' which could not be resolved! -llvm:skip:linking.wast:306 # LLVM ERROR: Program used external function '_vm.memory.grow.static.import' which could not be resolved! llvm:skip:call.wast:273 # Spec running forever llvm:skip:call_indirect.wast:556 # Spec running forever llvm:skip:call_indirect.wast:557 # Spec running forever @@ -825,27 +823,13 @@ llvm:skip:skip-stack-guard-page.wast:* # Spec running forever or (signal: 4, SIG llvm:skip:linking.wast:236 # terminating with uncaught exception of type WasmTrap llvm:skip:linking.wast:248 # terminating with uncaught exception of type WasmTrap -llvm:fail:i32.wast:243 # AssertReturn - result I32(61374799) ("0x3a8814f") does not match expected I32(32) ("0x20") -llvm:fail:i32.wast:252 # AssertReturn - result I32(61374816) ("0x3a88160") does not match expected I32(32) ("0x20") -llvm:fail:i64.wast:243 # AssertReturn - result I64(4356342255) ("0x103a881ef") does not match expected I64(64) ("0x40") -llvm:fail:i64.wast:252 # AssertReturn - result I64(4356342240) ("0x103a881e0") does not match expected I64(64) ("0x40") -llvm:fail:imports.wast:491 # AssertReturn - Call failed ResolveError: ExportNotFound { name: "grow" } -llvm:fail:imports.wast:492 # AssertReturn - Call failed ResolveError: ExportNotFound { name: "grow" } -llvm:fail:imports.wast:493 # AssertReturn - Call failed ResolveError: ExportNotFound { name: "grow" } -llvm:fail:imports.wast:494 # AssertReturn - Call failed ResolveError: ExportNotFound { name: "grow" } -llvm:fail:imports.wast:495 # AssertReturn - Call failed ResolveError: ExportNotFound { name: "grow" } -llvm:fail:linking.wast:314 # AssertReturn - No instance available: Some("$Pm") -llvm:fail:linking.wast:315 # AssertReturn - No instance available: Some("$Pm") -llvm:fail:linking.wast:316 # AssertReturn - No instance available: Some("$Pm") -llvm:fail:linking.wast:317 # AssertReturn - No instance available: Some("$Pm") -llvm:fail:linking.wast:318 # AssertReturn - No instance available: Some("$Pm") -llvm:fail:linking.wast:319 # AssertReturn - No instance available: Some("$Pm") -llvm:fail:linking.wast:320 # AssertReturn - No instance available: Some("$Pm") -llvm:fail:linking.wast:321 # AssertReturn - No instance available: Some("$Pm") +llvm:fail:i32.wast:243 # AssertReturn - result I32(270618959) ("0x1021514f") does not match expected I32(32) ("0x20") +llvm:fail:i32.wast:252 # AssertReturn - result I32(270618976) ("0x10215160") does not match expected I32(32) ("0x20") +llvm:fail:i64.wast:243 # AssertReturn - result I64(4565586415) ("0x1102151ef") does not match expected I64(64) ("0x40") +llvm:fail:i64.wast:252 # AssertReturn - result I64(4565586400) ("0x1102151e0") does not match expected I64(64) ("0x40") llvm:fail:linking.wast:387 # AssertReturn - result I32(0) ("0x0") does not match expected I32(104) ("0x68") llvm:fail:linking.wast:388 # AssertReturn - Call failed RuntimeError: WebAssembly trap occurred during runtime: incorrect `call_indirect` signature -llvm:fail:load.wast:201 # AssertReturn - result I32(66175007) ("0x3f1c01f") does not match expected I32(32) ("0x20") - +llvm:fail:load.wast:201 # AssertReturn - result I32(272117791) ("0x1038301f") does not match expected I32(32) ("0x20") # LLVM Windows llvm:skip:address.wast:*:windows From 8e46e797acf13a71befd9aa3790013e2e4d278cd Mon Sep 17 00:00:00 2001 From: Brandon Fish Date: Tue, 13 Aug 2019 22:14:10 -0600 Subject: [PATCH 7/7] Compare float bits in spectests assert return --- lib/spectests/tests/excludes.txt | 34 +++++++++++++--------- lib/spectests/tests/spectest.rs | 48 +++++++++++++++++++++++++------- 2 files changed, 59 insertions(+), 23 deletions(-) diff --git a/lib/spectests/tests/excludes.txt b/lib/spectests/tests/excludes.txt index bfa255a14..7bb0beaa4 100644 --- a/lib/spectests/tests/excludes.txt +++ b/lib/spectests/tests/excludes.txt @@ -23,14 +23,14 @@ clif:skip:simd_binaryen.wast:* # SIMD not implemented # linking.wast:387,388 appear to be related to WABT issue: https://github.com/pepyakin/wabt-rs/issues/51 clif:fail:globals.wast:243 # AssertInvalid - Should be invalid -clif:fail:linking.wast:137 # AssertTrap - expected trap, got Runtime:Error "unknown trap at 0x1069f3062 - illegal instruction" -clif:fail:linking.wast:139 # AssertTrap - expected trap, got Runtime:Error "unknown trap at 0x1069f3062 - illegal instruction" -clif:fail:linking.wast:142 # AssertTrap - expected trap, got Runtime:Error "unknown trap at 0x1069f3062 - illegal instruction" -clif:fail:linking.wast:144 # AssertTrap - expected trap, got Runtime:Error "unknown trap at 0x1069f3062 - illegal instruction" -clif:fail:linking.wast:147 # AssertTrap - expected trap, got Runtime:Error "unknown trap at 0x1069f3037 - illegal instruction" -clif:fail:linking.wast:149 # AssertTrap - expected trap, got Runtime:Error "unknown trap at 0x1069f3037 - illegal instruction" -clif:fail:linking.wast:185 # AssertTrap - expected trap, got Runtime:Error "unknown trap at 0x1069f3062 - illegal instruction" -clif:fail:linking.wast:187 # AssertTrap - expected trap, got Runtime:Error "unknown trap at 0x1069f3062 - illegal instruction" +clif:fail:linking.wast:137 # AssertTrap - expected trap, got Runtime:Error "unknown trap at 0x106883062 - illegal instruction" +clif:fail:linking.wast:139 # AssertTrap - expected trap, got Runtime:Error "unknown trap at 0x106883062 - illegal instruction" +clif:fail:linking.wast:142 # AssertTrap - expected trap, got Runtime:Error "unknown trap at 0x106883062 - illegal instruction" +clif:fail:linking.wast:144 # AssertTrap - expected trap, got Runtime:Error "unknown trap at 0x106883062 - illegal instruction" +clif:fail:linking.wast:147 # AssertTrap - expected trap, got Runtime:Error "unknown trap at 0x106883037 - illegal instruction" +clif:fail:linking.wast:149 # AssertTrap - expected trap, got Runtime:Error "unknown trap at 0x106883037 - illegal instruction" +clif:fail:linking.wast:185 # AssertTrap - expected trap, got Runtime:Error "unknown trap at 0x106883062 - illegal instruction" +clif:fail:linking.wast:187 # AssertTrap - expected trap, got Runtime:Error "unknown trap at 0x106883062 - illegal instruction" clif:fail:linking.wast:387 # AssertReturn - result I32(0) ("0x0") does not match expected I32(104) ("0x68") clif:fail:linking.wast:388 # AssertReturn - Call failed RuntimeError: WebAssembly trap occurred during runtime: `call_indirect` out-of-bounds @@ -823,13 +823,17 @@ llvm:skip:skip-stack-guard-page.wast:* # Spec running forever or (signal: 4, SIG llvm:skip:linking.wast:236 # terminating with uncaught exception of type WasmTrap llvm:skip:linking.wast:248 # terminating with uncaught exception of type WasmTrap -llvm:fail:i32.wast:243 # AssertReturn - result I32(270618959) ("0x1021514f") does not match expected I32(32) ("0x20") -llvm:fail:i32.wast:252 # AssertReturn - result I32(270618976) ("0x10215160") does not match expected I32(32) ("0x20") -llvm:fail:i64.wast:243 # AssertReturn - result I64(4565586415) ("0x1102151ef") does not match expected I64(64) ("0x40") -llvm:fail:i64.wast:252 # AssertReturn - result I64(4565586400) ("0x1102151e0") does not match expected I64(64) ("0x40") +llvm:fail:f32.wast:1621 # AssertReturn - result F32(0) ("0x0") does not match expected F32(2147483648) ("0x80000000") +llvm:fail:f32.wast:2020 # AssertReturn - result F32(2147483648) ("0x80000000") does not match expected F32(0) ("0x0") +llvm:fail:f64.wast:1621 # AssertReturn - result F64(0) ("0x0") does not match expected F64(9223372036854775808) ("0x8000000000000000") +llvm:fail:f64.wast:2020 # AssertReturn - result F64(9223372036854775808) ("0x8000000000000000") does not match expected F64(0) ("0x0") +llvm:fail:i32.wast:243 # AssertReturn - result I32(283816271) ("0x10eab14f") does not match expected I32(32) ("0x20") +llvm:fail:i32.wast:252 # AssertReturn - result I32(283816288) ("0x10eab160") does not match expected I32(32) ("0x20") +llvm:fail:i64.wast:243 # AssertReturn - result I64(4578783727) ("0x110eab1ef") does not match expected I64(64) ("0x40") +llvm:fail:i64.wast:252 # AssertReturn - result I64(4578783712) ("0x110eab1e0") does not match expected I64(64) ("0x40") llvm:fail:linking.wast:387 # AssertReturn - result I32(0) ("0x0") does not match expected I32(104) ("0x68") llvm:fail:linking.wast:388 # AssertReturn - Call failed RuntimeError: WebAssembly trap occurred during runtime: incorrect `call_indirect` signature -llvm:fail:load.wast:201 # AssertReturn - result I32(272117791) ("0x1038301f") does not match expected I32(32) ("0x20") +llvm:fail:load.wast:201 # AssertReturn - result I32(285315103) ("0x1101901f") does not match expected I32(32) ("0x20") # LLVM Windows llvm:skip:address.wast:*:windows @@ -1102,6 +1106,7 @@ singlepass:fail:exports.wast:167 # Module - caught panic Any singlepass:fail:exports.wast:168 # Module - caught panic Any singlepass:fail:exports.wast:169 # Module - caught panic Any singlepass:fail:exports.wast:170 # Module - caught panic Any +singlepass:fail:f32.wast:1620 # AssertReturn - result F32(0) ("0x0") does not match expected F32(2147483648) ("0x80000000") singlepass:fail:f32.wast:1652 # "AssertReturnArithmeticNan" - value is not arithmetic nan F32(NaN) singlepass:fail:f32.wast:1654 # "AssertReturnArithmeticNan" - value is not arithmetic nan F32(NaN) singlepass:fail:f32.wast:1656 # "AssertReturnArithmeticNan" - value is not arithmetic nan F32(NaN) @@ -1206,6 +1211,7 @@ singlepass:fail:f32.wast:2013 # "AssertReturnArithmeticNan" - value is not arith singlepass:fail:f32.wast:2014 # "AssertReturnArithmeticNan" - value is not arithmetic nan F32(NaN) singlepass:fail:f32.wast:2017 # "AssertReturnArithmeticNan" - value is not arithmetic nan F32(NaN) singlepass:fail:f32.wast:2018 # "AssertReturnArithmeticNan" - value is not arithmetic nan F32(NaN) +singlepass:fail:f32.wast:2021 # AssertReturn - result F32(2147483648) ("0x80000000") does not match expected F32(0) ("0x0") singlepass:fail:f32.wast:2052 # "AssertReturnArithmeticNan" - value is not arithmetic nan F32(NaN) singlepass:fail:f32.wast:2054 # "AssertReturnArithmeticNan" - value is not arithmetic nan F32(NaN) singlepass:fail:f32.wast:2056 # "AssertReturnArithmeticNan" - value is not arithmetic nan F32(NaN) @@ -1310,6 +1316,7 @@ singlepass:fail:f32.wast:2413 # "AssertReturnArithmeticNan" - value is not arith singlepass:fail:f32.wast:2414 # "AssertReturnArithmeticNan" - value is not arithmetic nan F32(NaN) singlepass:fail:f32.wast:2417 # "AssertReturnArithmeticNan" - value is not arithmetic nan F32(NaN) singlepass:fail:f32.wast:2418 # "AssertReturnArithmeticNan" - value is not arithmetic nan F32(NaN) +singlepass:fail:f64.wast:1620 # AssertReturn - result F64(0) ("0x0") does not match expected F64(9223372036854775808) ("0x8000000000000000") singlepass:fail:f64.wast:1652 # "AssertReturnArithmeticNan" - value is not arithmetic nan F64(NaN) singlepass:fail:f64.wast:1654 # "AssertReturnArithmeticNan" - value is not arithmetic nan F64(NaN) singlepass:fail:f64.wast:1656 # "AssertReturnArithmeticNan" - value is not arithmetic nan F64(NaN) @@ -1414,6 +1421,7 @@ singlepass:fail:f64.wast:2013 # "AssertReturnArithmeticNan" - value is not arith singlepass:fail:f64.wast:2014 # "AssertReturnArithmeticNan" - value is not arithmetic nan F64(NaN) singlepass:fail:f64.wast:2017 # "AssertReturnArithmeticNan" - value is not arithmetic nan F64(NaN) singlepass:fail:f64.wast:2018 # "AssertReturnArithmeticNan" - value is not arithmetic nan F64(NaN) +singlepass:fail:f64.wast:2021 # AssertReturn - result F64(9223372036854775808) ("0x8000000000000000") does not match expected F64(0) ("0x0") singlepass:fail:f64.wast:2052 # "AssertReturnArithmeticNan" - value is not arithmetic nan F64(NaN) singlepass:fail:f64.wast:2054 # "AssertReturnArithmeticNan" - value is not arithmetic nan F64(NaN) singlepass:fail:f64.wast:2056 # "AssertReturnArithmeticNan" - value is not arithmetic nan F64(NaN) diff --git a/lib/spectests/tests/spectest.rs b/lib/spectests/tests/spectest.rs index c3ebc2890..412689231 100644 --- a/lib/spectests/tests/spectest.rs +++ b/lib/spectests/tests/spectest.rs @@ -291,10 +291,9 @@ mod tests { Ok(values) => { for (i, v) in values.iter().enumerate() { let expected_value = - convert_value(*expected.get(i).unwrap()); - if *v != expected_value - && !(*v != *v && expected_value != expected_value) - { + convert_wabt_value(*expected.get(i).unwrap()); + let v = convert_wasmer_value(v.clone()); + if v != expected_value { test_report.add_failure(SpecFailure { file: filename.to_string(), line, @@ -968,6 +967,35 @@ mod tests { } } + #[derive(Debug, Clone, Eq, PartialEq)] + pub enum SpectestValue { + I32(i32), + I64(i64), + F32(u32), + F64(u64), + V128(u128), + } + + fn convert_wasmer_value(other: wasmer_runtime_core::types::Value) -> SpectestValue { + match other { + wasmer_runtime_core::types::Value::I32(v) => SpectestValue::I32(v), + wasmer_runtime_core::types::Value::I64(v) => SpectestValue::I64(v), + wasmer_runtime_core::types::Value::F32(v) => SpectestValue::F32(v.to_bits()), + wasmer_runtime_core::types::Value::F64(v) => SpectestValue::F64(v.to_bits()), + wasmer_runtime_core::types::Value::V128(v) => SpectestValue::V128(v), + } + } + + fn convert_wabt_value(other: Value) -> SpectestValue { + match other { + Value::I32(v) => SpectestValue::I32(v), + Value::I64(v) => SpectestValue::I64(v), + Value::F32(v) => SpectestValue::F32(v.to_bits()), + Value::F64(v) => SpectestValue::F64(v.to_bits()), + Value::V128(v) => SpectestValue::V128(v), + } + } + fn convert_value(other: Value) -> wasmer_runtime_core::types::Value { match other { Value::I32(v) => wasmer_runtime_core::types::Value::I32(v), @@ -978,13 +1006,13 @@ mod tests { } } - fn to_hex(v: wasmer_runtime_core::types::Value) -> String { + fn to_hex(v: SpectestValue) -> String { match v { - wasmer_runtime_core::types::Value::I32(v) => format!("{:#x}", v), - wasmer_runtime_core::types::Value::I64(v) => format!("{:#x}", v), - wasmer_runtime_core::types::Value::F32(v) => format!("{:#x}", v.to_bits()), - wasmer_runtime_core::types::Value::F64(v) => format!("{:#x}", v.to_bits()), - wasmer_runtime_core::types::Value::V128(v) => format!("{:#x}", v), + SpectestValue::I32(v) => format!("{:#x}", v), + SpectestValue::I64(v) => format!("{:#x}", v), + SpectestValue::F32(v) => format!("{:#x}", v), + SpectestValue::F64(v) => format!("{:#x}", v), + SpectestValue::V128(v) => format!("{:#x}", v), } }