From dea132a6e110c07a867e0afac387998a97cb5918 Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Tue, 28 Feb 2023 11:56:08 -0800 Subject: [PATCH 1/9] Reduce the maximum number of data segments. --- src/snapshot.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/snapshot.rs b/src/snapshot.rs index d2bc3b0..9e75497 100644 --- a/src/snapshot.rs +++ b/src/snapshot.rs @@ -4,8 +4,10 @@ use wasmtime::{AsContext, AsContextMut}; const WASM_PAGE_SIZE: u64 = 65_536; -/// The maximum number of data segments that most engines support. -const MAX_DATA_SEGMENTS: usize = 100_000; +/// The maximum number of data segments that we will emit. Most +/// engines support more than this, but we want to leave some +/// headroom. +const MAX_DATA_SEGMENTS: usize = 10_000; /// A "snapshot" of Wasm state from its default value after having been initialized. pub struct Snapshot { From 75e1800c17af5b45127ccccf4c55877ff4e71caf Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Tue, 28 Feb 2023 16:51:22 -0800 Subject: [PATCH 2/9] 1.6.1-beta --- npm/wizer/package.json | 7 ++----- npm/wizer/update.js | 5 +---- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/npm/wizer/package.json b/npm/wizer/package.json index 266e8d7..ae9eaae 100644 --- a/npm/wizer/package.json +++ b/npm/wizer/package.json @@ -1,11 +1,8 @@ { - "name": "@bytecode-alliance/wizer", - "version": "1.6.0", + "name": "@bytecodealliance/wizer", + "version": "1.6.1-beta", "description": "The WebAssembly Pre-Initializer", "type": "module", - "publishConfig": { - "access": "public" - }, "scripts": { "version": "node ./update.js $npm_package_version" }, diff --git a/npm/wizer/update.js b/npm/wizer/update.js index 25adef7..2ea3193 100644 --- a/npm/wizer/update.js +++ b/npm/wizer/update.js @@ -117,7 +117,7 @@ export default location function packageJson(name, version, description, os, cpu) { version = version.startsWith('v') ? version.replace('v','') : version return JSON.stringify({ - name: `@bytecode-alliance/${name}`, + name: `@bytecodealliance/${name}`, bin: { [name]: "wizer" }, @@ -129,8 +129,5 @@ function packageJson(name, version, description, os, cpu) { preferUnplugged: false, os: [os], cpu: [cpu], - publishConfig: { - access: "public" - }, }, null, 4); } From 4c7f547da5dca28c45371ddd7f013353fdb57a1c Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Tue, 28 Feb 2023 17:37:52 -0800 Subject: [PATCH 3/9] fixup: release changes --- npm/wizer/README.md | 4 ++-- npm/wizer/package.json | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/npm/wizer/README.md b/npm/wizer/README.md index fff50d0..1a50125 100644 --- a/npm/wizer/README.md +++ b/npm/wizer/README.md @@ -5,12 +5,12 @@ ## API ``` -$ npm install --save @bytecode-alliance/wizer +$ npm install --save @bytecodealliance/wizer ``` ```js const execFile = require('child_process').execFile; -const wizer = require('@bytecode-alliance/wizer'); +const wizer = require('@bytecodealliance/wizer'); execFile(wizer, ['input.wasm', '-o', 'initialized.wasm'], (err, stdout) => { console.log(stdout); diff --git a/npm/wizer/package.json b/npm/wizer/package.json index ae9eaae..1d1bf96 100644 --- a/npm/wizer/package.json +++ b/npm/wizer/package.json @@ -20,10 +20,10 @@ "wizer": "./wizer.js" }, "optionalDependencies": { - "@bytecode-alliance/wizer-darwin-arm64": "1.6.0", - "@bytecode-alliance/wizer-darwin-x64": "1.6.0", - "@bytecode-alliance/wizer-linux-x64": "1.6.0", - "@bytecode-alliance/wizer-win32-x64": "1.6.0" + "@bytecode-alliance/wizer-darwin-arm64": "1.6.1-beta", + "@bytecode-alliance/wizer-darwin-x64": "1.6.1-beta", + "@bytecode-alliance/wizer-linux-x64": "1.6.1-beta", + "@bytecode-alliance/wizer-win32-x64": "1.6.1-beta" }, "license": "Apache-2.0", "repository": { From c5cd97824ec8a35dbc8fdcc87d11999b74a03951 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Tue, 28 Feb 2023 17:39:51 -0800 Subject: [PATCH 4/9] fixup --- npm/wizer/package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/npm/wizer/package.json b/npm/wizer/package.json index 1d1bf96..4829cb6 100644 --- a/npm/wizer/package.json +++ b/npm/wizer/package.json @@ -1,6 +1,6 @@ { "name": "@bytecodealliance/wizer", - "version": "1.6.1-beta", + "version": "1.6.1-beta.2", "description": "The WebAssembly Pre-Initializer", "type": "module", "scripts": { @@ -20,10 +20,10 @@ "wizer": "./wizer.js" }, "optionalDependencies": { - "@bytecode-alliance/wizer-darwin-arm64": "1.6.1-beta", - "@bytecode-alliance/wizer-darwin-x64": "1.6.1-beta", - "@bytecode-alliance/wizer-linux-x64": "1.6.1-beta", - "@bytecode-alliance/wizer-win32-x64": "1.6.1-beta" + "@bytecodealliance/wizer-darwin-arm64": "1.6.1-beta", + "@bytecodealliance/wizer-darwin-x64": "1.6.1-beta", + "@bytecodealliance/wizer-linux-x64": "1.6.1-beta", + "@bytecodealliance/wizer-win32-x64": "1.6.1-beta" }, "license": "Apache-2.0", "repository": { From 303ad26fdd3378b9095bcd5d30cec0d4d693eee1 Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Wed, 1 Mar 2023 11:57:49 +0000 Subject: [PATCH 5/9] match cargo and npm versions --- Cargo.lock | 2 +- Cargo.toml | 2 +- npm/wizer/package-lock.json | 16 ++++++++-------- npm/wizer/package.json | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3dfe339..8796c52 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2071,7 +2071,7 @@ dependencies = [ [[package]] name = "wizer" -version = "1.6.0" +version = "1.6.1-beta.3" dependencies = [ "anyhow", "cap-std", diff --git a/Cargo.toml b/Cargo.toml index 3b77abd..844d8c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "1.6.0" +version = "1.6.1-beta.3" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/npm/wizer/package-lock.json b/npm/wizer/package-lock.json index bde0ae2..db15063 100644 --- a/npm/wizer/package-lock.json +++ b/npm/wizer/package-lock.json @@ -1,12 +1,12 @@ { - "name": "@bytecode-alliance/wizer", - "version": "1.6.0", + "name": "@bytecodealliance/wizer", + "version": "1.6.1-beta.3", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "@bytecode-alliance/wizer", - "version": "1.6.0", + "name": "@bytecodealliance/wizer", + "version": "1.6.1-beta.3", "license": "Apache-2.0", "bin": { "wizer": "wizer.js" @@ -21,10 +21,10 @@ "node": ">=16" }, "optionalDependencies": { - "@bytecode-alliance/wizer-darwin-arm64": "1.6.0", - "@bytecode-alliance/wizer-darwin-x64": "1.6.0", - "@bytecode-alliance/wizer-linux-x64": "1.6.0", - "@bytecode-alliance/wizer-win32-x64": "1.6.0" + "@bytecodealliance/wizer-darwin-arm64": "1.6.1-beta.3", + "@bytecodealliance/wizer-darwin-x64": "1.6.1-beta.3", + "@bytecodealliance/wizer-linux-x64": "1.6.1-beta.3", + "@bytecodealliance/wizer-win32-x64": "1.6.1-beta.3" } }, "node_modules/base64-js": { diff --git a/npm/wizer/package.json b/npm/wizer/package.json index 4829cb6..f756035 100644 --- a/npm/wizer/package.json +++ b/npm/wizer/package.json @@ -1,6 +1,6 @@ { "name": "@bytecodealliance/wizer", - "version": "1.6.1-beta.2", + "version": "1.6.1-beta.3", "description": "The WebAssembly Pre-Initializer", "type": "module", "scripts": { @@ -20,10 +20,10 @@ "wizer": "./wizer.js" }, "optionalDependencies": { - "@bytecodealliance/wizer-darwin-arm64": "1.6.1-beta", - "@bytecodealliance/wizer-darwin-x64": "1.6.1-beta", - "@bytecodealliance/wizer-linux-x64": "1.6.1-beta", - "@bytecodealliance/wizer-win32-x64": "1.6.1-beta" + "@bytecodealliance/wizer-darwin-arm64": "1.6.1-beta.3", + "@bytecodealliance/wizer-darwin-x64": "1.6.1-beta.3", + "@bytecodealliance/wizer-linux-x64": "1.6.1-beta.3", + "@bytecodealliance/wizer-win32-x64": "1.6.1-beta.3" }, "license": "Apache-2.0", "repository": { From 558ea9c1521a72a8c644d2f74e12cbea96285465 Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Wed, 1 Mar 2023 13:36:22 +0000 Subject: [PATCH 6/9] correct npm organisation name within the npm packages --- npm/wizer/index.js | 16 ++++++++-------- npm/wizer/wizer.js | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/npm/wizer/index.js b/npm/wizer/index.js index cde395e..65917ef 100644 --- a/npm/wizer/index.js +++ b/npm/wizer/index.js @@ -2,10 +2,10 @@ import { endianness } from "node:os"; import { platform, arch } from "node:process"; const knownPackages = { - "win32 x64 LE": "@bytecode-alliance/wizer-win32-x64", - "darwin arm64 LE": "@bytecode-alliance/wizer-darwin-arm64", - "darwin x64 LE": "@bytecode-alliance/wizer-darwin-x64", - "linux x64 LE": "@bytecode-alliance/wizer-linux-x64", + "win32 x64 LE": "@bytecodealliance/wizer-win32-x64", + "darwin arm64 LE": "@bytecodealliance/wizer-darwin-arm64", + "darwin x64 LE": "@bytecodealliance/wizer-darwin-x64", + "linux x64 LE": "@bytecodealliance/wizer-linux-x64", }; function pkgForCurrentPlatform() { @@ -14,7 +14,7 @@ function pkgForCurrentPlatform() { if (platformKey in knownPackages) { return knownPackages[platformKey]; } - throw new Error(`Unsupported platform: "${platformKey}". "@bytecode-alliance/wizer does not have a precompiled binary for the platform/architecture you are using. You can open an issue on https://github.com/bytecodealliance/wizer/issues to request for your platform/architecture to be included."`); + throw new Error(`Unsupported platform: "${platformKey}". "@bytecodealliance/wizer does not have a precompiled binary for the platform/architecture you are using. You can open an issue on https://github.com/bytecodealliance/wizer/issues to request for your platform/architecture to be included."`); } const pkg = pkgForCurrentPlatform(); @@ -25,10 +25,10 @@ try { // package should have been installed alongside this package at install time. location = (await import(pkg)).default; } catch (e) { - throw new Error(`The package "${pkg}" could not be found, and is needed by @bytecode-alliance/wizer. -If you are installing @bytecode-alliance/wizer with npm, make sure that you don't specify the + throw new Error(`The package "${pkg}" could not be found, and is needed by @bytecodealliance/wizer. +If you are installing @bytecodealliance/wizer with npm, make sure that you don't specify the "--no-optional" flag. The "optionalDependencies" package.json feature is used -by @bytecode-alliance/wizer to install the correct binary executable for your current platform.`); +by @bytecodealliance/wizer to install the correct binary executable for your current platform.`); } export default location; \ No newline at end of file diff --git a/npm/wizer/wizer.js b/npm/wizer/wizer.js index c791a8c..46b9a93 100755 --- a/npm/wizer/wizer.js +++ b/npm/wizer/wizer.js @@ -3,10 +3,10 @@ import { endianness } from "node:os"; import { platform, arch } from "node:process"; import { execFileSync } from "node:child_process"; const knownPackages = { - "win32 x64 LE": "@bytecode-alliance/wizer-win32-x64", - "darwin arm64 LE": "@bytecode-alliance/wizer-darwin-arm64", - "darwin x64 LE": "@bytecode-alliance/wizer-darwin-x64", - "linux x64 LE": "@bytecode-alliance/wizer-linux-x64", + "win32 x64 LE": "@bytecodealliance/wizer-win32-x64", + "darwin arm64 LE": "@bytecodealliance/wizer-darwin-arm64", + "darwin x64 LE": "@bytecodealliance/wizer-darwin-x64", + "linux x64 LE": "@bytecodealliance/wizer-linux-x64", }; function pkgForCurrentPlatform() { @@ -15,7 +15,7 @@ function pkgForCurrentPlatform() { if (platformKey in knownPackages) { return knownPackages[platformKey]; } - throw new Error(`Unsupported platform: "${platformKey}". "@bytecode-alliance/wizer does not have a precompiled binary for the platform/architecture you are using. You can open an issue on https://github.com/bytecodealliance/wizer/issues to request for your platform/architecture to be included."`); + throw new Error(`Unsupported platform: "${platformKey}". "@bytecodealliance/wizer does not have a precompiled binary for the platform/architecture you are using. You can open an issue on https://github.com/bytecodealliance/wizer/issues to request for your platform/architecture to be included."`); } const pkg = pkgForCurrentPlatform(); @@ -26,10 +26,10 @@ try { // package should have been installed alongside this package at install time. location = (await import(pkg)).default; } catch (e) { - throw new Error(`The package "${pkg}" could not be found, and is needed by @bytecode-alliance/wizer. -If you are installing @bytecode-alliance/wizer with npm, make sure that you don't specify the + throw new Error(`The package "${pkg}" could not be found, and is needed by @bytecodealliance/wizer. +If you are installing @bytecodealliance/wizer with npm, make sure that you don't specify the "--no-optional" flag. The "optionalDependencies" package.json feature is used -by @bytecode-alliance/wizer to install the correct binary executable for your current platform.`); +by @bytecodealliance/wizer to install the correct binary executable for your current platform.`); } execFileSync(location, process.argv.slice(2), { stdio: "inherit" }); From 25bc65bd3f2265be6b6060c8c67994f8eb5757b8 Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Wed, 1 Mar 2023 13:37:02 +0000 Subject: [PATCH 7/9] 1.6.1-beta.4 --- Cargo.lock | 2 +- Cargo.toml | 2 +- npm/wizer/package-lock.json | 12 ++++++------ npm/wizer/package.json | 10 +++++----- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8796c52..25aec03 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2071,7 +2071,7 @@ dependencies = [ [[package]] name = "wizer" -version = "1.6.1-beta.3" +version = "1.6.1-beta.4" dependencies = [ "anyhow", "cap-std", diff --git a/Cargo.toml b/Cargo.toml index 844d8c3..0322a55 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "1.6.1-beta.3" +version = "1.6.1-beta.4" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/npm/wizer/package-lock.json b/npm/wizer/package-lock.json index db15063..43ae84b 100644 --- a/npm/wizer/package-lock.json +++ b/npm/wizer/package-lock.json @@ -1,12 +1,12 @@ { "name": "@bytecodealliance/wizer", - "version": "1.6.1-beta.3", + "version": "1.6.1-beta.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@bytecodealliance/wizer", - "version": "1.6.1-beta.3", + "version": "1.6.1-beta.4", "license": "Apache-2.0", "bin": { "wizer": "wizer.js" @@ -21,10 +21,10 @@ "node": ">=16" }, "optionalDependencies": { - "@bytecodealliance/wizer-darwin-arm64": "1.6.1-beta.3", - "@bytecodealliance/wizer-darwin-x64": "1.6.1-beta.3", - "@bytecodealliance/wizer-linux-x64": "1.6.1-beta.3", - "@bytecodealliance/wizer-win32-x64": "1.6.1-beta.3" + "@bytecodealliance/wizer-darwin-arm64": "1.6.1-beta.4", + "@bytecodealliance/wizer-darwin-x64": "1.6.1-beta.4", + "@bytecodealliance/wizer-linux-x64": "1.6.1-beta.4", + "@bytecodealliance/wizer-win32-x64": "1.6.1-beta.4" } }, "node_modules/base64-js": { diff --git a/npm/wizer/package.json b/npm/wizer/package.json index f756035..0180b79 100644 --- a/npm/wizer/package.json +++ b/npm/wizer/package.json @@ -1,6 +1,6 @@ { "name": "@bytecodealliance/wizer", - "version": "1.6.1-beta.3", + "version": "1.6.1-beta.4", "description": "The WebAssembly Pre-Initializer", "type": "module", "scripts": { @@ -20,10 +20,10 @@ "wizer": "./wizer.js" }, "optionalDependencies": { - "@bytecodealliance/wizer-darwin-arm64": "1.6.1-beta.3", - "@bytecodealliance/wizer-darwin-x64": "1.6.1-beta.3", - "@bytecodealliance/wizer-linux-x64": "1.6.1-beta.3", - "@bytecodealliance/wizer-win32-x64": "1.6.1-beta.3" + "@bytecodealliance/wizer-darwin-arm64": "1.6.1-beta.4", + "@bytecodealliance/wizer-darwin-x64": "1.6.1-beta.4", + "@bytecodealliance/wizer-linux-x64": "1.6.1-beta.4", + "@bytecodealliance/wizer-win32-x64": "1.6.1-beta.4" }, "license": "Apache-2.0", "repository": { From 5b9857070628746c04b422190213ecfd9df41177 Mon Sep 17 00:00:00 2001 From: Cheng Shao Date: Tue, 28 Mar 2023 16:11:16 +0000 Subject: [PATCH 8/9] feat: Add option to enable the Wasm SIMD128 feature This commit adds a --wasm-simd option to enable the Wasm SIMD128 feature. It's on by default. --- src/lib.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c629f33..5423fd5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -35,6 +35,7 @@ const DEFAULT_WASM_MULTI_VALUE: bool = true; const DEFAULT_WASM_MULTI_MEMORY: bool = true; const DEFAULT_WASM_MODULE_LINKING: bool = false; const DEFAULT_WASM_BULK_MEMORY: bool = false; +const DEFAULT_WASM_SIMD: bool = true; /// We only ever use `Store` with a fixed `T` that is our optional WASI /// context. @@ -209,6 +210,12 @@ pub struct Wizer { /// Disabled by default. #[cfg_attr(feature = "structopt", structopt(long, value_name = "true|false"))] wasm_bulk_memory: Option, + + /// Enable or disable the Wasm SIMD128 proposal. + /// + /// Enabled by default. + #[cfg_attr(feature = "structopt", structopt(long, value_name = "true|false"))] + wasm_simd: Option, } impl std::fmt::Debug for Wizer { @@ -227,6 +234,7 @@ impl std::fmt::Debug for Wizer { wasm_multi_value, wasm_module_linking, wasm_bulk_memory, + wasm_simd, } = self; f.debug_struct("Wizer") .field("init_func", &init_func) @@ -242,6 +250,7 @@ impl std::fmt::Debug for Wizer { .field("wasm_multi_value", &wasm_multi_value) .field("wasm_module_linking", &wasm_module_linking) .field("wasm_bulk_memory", &wasm_bulk_memory) + .field("wasm_simd", &wasm_simd) .finish() } } @@ -304,6 +313,7 @@ impl Wizer { wasm_multi_value: None, wasm_module_linking: None, wasm_bulk_memory: None, + wasm_simd: None, } } @@ -455,6 +465,14 @@ impl Wizer { self } + /// Enable or disable the Wasm SIMD128 proposal. + /// + /// Defaults to `true`. + pub fn wasm_simd(&mut self, enable: bool) -> &mut Self { + self.wasm_simd = Some(enable); + self + } + /// Initialize the given Wasm, snapshot it, and return the serialized /// snapshot as a new, pre-initialized Wasm module. pub fn run(&self, wasm: &[u8]) -> anyhow::Result> { @@ -533,9 +551,10 @@ impl Wizer { // `memory.init` for the time being: config.wasm_bulk_memory(self.wasm_bulk_memory.unwrap_or(DEFAULT_WASM_BULK_MEMORY)); + config.wasm_simd(self.wasm_simd.unwrap_or(DEFAULT_WASM_SIMD)); + // Proposals that we should add support for. config.wasm_reference_types(false); - config.wasm_simd(false); config.wasm_threads(false); Ok(config) @@ -553,7 +572,7 @@ impl Wizer { // Proposals that we should add support for. reference_types: false, - simd: false, + simd: self.wasm_simd.unwrap_or(DEFAULT_WASM_SIMD), threads: false, tail_call: false, memory64: false, From b09a17cd8f6f5b78219536535c57eded9e6bae4e Mon Sep 17 00:00:00 2001 From: Cheng Shao Date: Tue, 28 Mar 2023 17:31:17 +0000 Subject: [PATCH 9/9] feat: SIMD128 support This patch actually implements SIMD128 support, and also adds a test case. --- fuzz/fuzz_targets/same_result.rs | 1 + src/rewrite.rs | 4 ++++ src/translate.rs | 3 ++- tests/tests.rs | 20 ++++++++++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/fuzz/fuzz_targets/same_result.rs b/fuzz/fuzz_targets/same_result.rs index f943136..2b7feeb 100644 --- a/fuzz/fuzz_targets/same_result.rs +++ b/fuzz/fuzz_targets/same_result.rs @@ -186,6 +186,7 @@ fn assert_val_eq(a: &Val, b: &Val) { let b = f64::from_bits(*b); a == b || (a.is_nan() && b.is_nan()) }), + (Val::V128(a), Val::V128(b)) => assert_eq!(a, b), _ => panic!("{:?} != {:?}", a, b), } } diff --git a/src/rewrite.rs b/src/rewrite.rs index 9c60ce6..7b9dd1c 100644 --- a/src/rewrite.rs +++ b/src/rewrite.rs @@ -124,6 +124,9 @@ impl Wizer { wasmtime::Val::F64(x) => { wasm_encoder::Instruction::F64Const(f64::from_bits(*x)) } + wasmtime::Val::V128(x) => { + wasm_encoder::Instruction::V128Const(*x as i128) + } _ => unreachable!(), }, ); @@ -1095,6 +1098,7 @@ fn rewrite_state_module( wasmtime::Val::F64(x) => { wasm_encoder::Instruction::F64Const(f64::from_bits(*x)) } + wasmtime::Val::V128(x) => wasm_encoder::Instruction::V128Const(*x as i128), _ => unreachable!(), }, ); diff --git a/src/translate.rs b/src/translate.rs index 2e17ee2..7ff9b83 100644 --- a/src/translate.rs +++ b/src/translate.rs @@ -16,8 +16,9 @@ pub(crate) fn val_type(ty: wasmparser::Type) -> wasm_encoder::ValType { I64 => ValType::I64, F32 => ValType::F32, F64 => ValType::F64, + V128 => ValType::V128, FuncRef => ValType::FuncRef, - V128 | ExternRef | ExnRef => panic!("not supported"), + ExternRef | ExnRef => panic!("not supported"), Func | EmptyBlockType => unreachable!(), } } diff --git a/tests/tests.rs b/tests/tests.rs index 86dc97a..7e172de 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1257,3 +1257,23 @@ fn accept_bulk_memory_init() -> Result<()> { "#, ) } + +#[test] +fn accept_simd128() -> Result<()> { + run_wat( + &[], + 49, + r#" + (module + (global $g (mut v128) (v128.const i32x4 2 3 5 7)) + (func (export "wizer.initialize") + global.get $g + global.get $g + i32x4.mul + global.set $g) + (func (export "run") (result i32) + global.get $g + i32x4.extract_lane 3)) + "#, + ) +}