Skip to content

Commit 84aae7c

Browse files
authored
Add wasmi Wasm simd proposal support skeleton (#1415)
* add wasm_simd option in Config Only available if wasmi was compiled with `simd` enabled. Enabled by default. * propagate wasmparser/simd crate feature * add skeleton for SIMD translation * apply clippy suggestion * add skeleton for SIMD ops in executor
1 parent dcafe1c commit 84aae7c

File tree

7 files changed

+1785
-1
lines changed

7 files changed

+1785
-1
lines changed

crates/wasmi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ prefer-btree-collections = [
5555
"wasmparser/prefer-btree-collections",
5656
]
5757
wat = ["dep:wat", "std"]
58-
simd = ["wasmi_core/simd", "wasmi_ir/simd"]
58+
simd = ["wasmi_core/simd", "wasmi_ir/simd", "wasmparser/simd"]
5959

6060
# Enables extra checks performed during Wasmi bytecode execution.
6161
#

crates/wasmi/src/engine/config.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ impl Config {
184184
features.set(WasmFeatures::CUSTOM_PAGE_SIZES, false);
185185
features.set(WasmFeatures::MEMORY64, true);
186186
features.set(WasmFeatures::WIDE_ARITHMETIC, false);
187+
features.set(WasmFeatures::SIMD, cfg!(feature = "simd"));
187188
features
188189
}
189190

@@ -358,6 +359,17 @@ impl Config {
358359
self
359360
}
360361

362+
/// Enable or disable the [`simd`] Wasm proposal for the [`Config`].
363+
///
364+
/// Enabled by default.
365+
///
366+
/// [`simd`]: https://github.com/WebAssembly/simd
367+
#[cfg(feature = "simd")]
368+
pub fn wasm_simd(&mut self, enable: bool) -> &mut Self {
369+
self.features.set(WasmFeatures::SIMD, enable);
370+
self
371+
}
372+
361373
/// Enable or disable Wasm floating point (`f32` and `f64`) instructions and types.
362374
///
363375
/// Enabled by default.

crates/wasmi/src/engine/executor/instrs.rs

Lines changed: 733 additions & 0 deletions
Large diffs are not rendered by default.

crates/wasmi/src/engine/translator/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ mod utils;
1414
mod visit;
1515
mod visit_register;
1616

17+
#[cfg(feature = "simd")]
18+
mod simd;
19+
1720
#[cfg(test)]
1821
mod tests;
1922

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mod visit;

0 commit comments

Comments
 (0)