Skip to content

Commit

Permalink
Enable the multi-value proposal by default
Browse files Browse the repository at this point in the history
This was merged into the wasm spec upstream in WebAssembly/spec#1145, so
let's follow the spec and enable it by default here as well!
  • Loading branch information
alexcrichton committed May 6, 2020
1 parent 1d90751 commit 4e4b597
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 27 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 2 additions & 8 deletions crates/api/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl Config {
enable_reference_types: false,
enable_bulk_memory: false,
enable_simd: false,
enable_multi_value: false,
enable_multi_value: true,
},
},
flags,
Expand Down Expand Up @@ -247,16 +247,10 @@ impl Config {
/// Configures whether the WebAssembly multi-value proposal will
/// be enabled for compilation.
///
/// The [WebAssembly multi-value proposal][proposal] is not
/// currently fully standardized and is undergoing development.
/// Additionally the support in wasmtime itself is still being worked on.
/// Support for this feature can be enabled through this method for
/// appropriate wasm modules.
///
/// This feature gates functions and blocks returning multiple values in a
/// module, for example.
///
/// This is `false` by default.
/// This is `true` by default.
///
/// [proposal]: https://github.com/webassembly/multi-value
pub fn wasm_multi_value(&mut self, enable: bool) -> &mut Self {
Expand Down
1 change: 0 additions & 1 deletion crates/fuzzing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ pub(crate) fn fuzz_default_config(
config
.cranelift_debug_verifier(true)
.cranelift_nan_canonicalization(true)
.wasm_multi_value(true)
.wasm_bulk_memory(true)
.strategy(strategy)?;
Ok(config)
Expand Down
3 changes: 1 addition & 2 deletions crates/misc/rust/macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ fn generate_load(item: &syn::ItemTrait) -> syn::Result<TokenStream> {
use #root::wasmtime::{Config, Extern, Engine, Store, Instance, Module};
use #root::anyhow::{bail, format_err};

let engine = Engine::new(Config::new().wasm_multi_value(true));
let store = Store::new(&engine);
let store = Store::default();

let data = #root::wasmtime_interface_types::ModuleData::new(bytes.as_ref())?;

Expand Down
2 changes: 2 additions & 0 deletions crates/wast/src/wast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ fn is_matching_assert_invalid_error_message(expected: &str, actual: &str) -> boo
// `elem.wast` and `proposals/bulk-memory-operations/elem.wast` disagree
// on the expected error message for the same error.
|| (expected.contains("out of bounds") && actual.contains("does not fit"))
// slight difference in error messages
|| (expected.contains("unknown elem segment") && actual.contains("unknown element segment"))
}

fn extract_lane_as_i8(bytes: u128, lane: usize) -> i8 {
Expand Down
5 changes: 1 addition & 4 deletions examples/multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ wasm_trap_t* closure_callback(
int main(int argc, const char* argv[]) {
// Initialize.
printf("Initializing...\n");
wasm_config_t *config = wasm_config_new();
assert(config != NULL);
wasmtime_config_wasm_multi_value_set(config, true);
wasm_engine_t* engine = wasm_engine_new_with_config(config);
wasm_engine_t* engine = wasm_engine_new();
wasm_store_t* store = wasm_store_new(engine);

// Load our input file to parse it next
Expand Down
5 changes: 1 addition & 4 deletions examples/multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ use anyhow::{format_err, Result};
use wasmtime::*;

fn main() -> Result<()> {
// Configure our `Store`, but be sure to use a `Config` that enables the
// wasm multi-value feature since it's not stable yet.
println!("Initializing...");
let engine = Engine::new(Config::new().wasm_multi_value(true));
let store = Store::new(&engine);
let store = Store::default();

// Compile.
println!("Compiling module...");
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ struct CommonOptions {

/// Enable support for multi-value functions
#[structopt(long)]
enable_multi_value: bool,
enable_multi_value: Option<bool>,

/// Enable support for Wasm threads
#[structopt(long)]
Expand Down Expand Up @@ -176,7 +176,7 @@ impl CommonOptions {
.wasm_bulk_memory(self.enable_bulk_memory || self.enable_all)
.wasm_simd(self.enable_simd || self.enable_all)
.wasm_reference_types(self.enable_reference_types || self.enable_all)
.wasm_multi_value(self.enable_multi_value || self.enable_all)
.wasm_multi_value(self.enable_multi_value.unwrap_or(true) || self.enable_all)
.wasm_threads(self.enable_threads || self.enable_all)
.cranelift_opt_level(self.opt_level())
.strategy(pick_compilation_strategy(self.cranelift, self.lightbeam)?)?
Expand Down
3 changes: 0 additions & 3 deletions tests/all/wast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@ fn run_wast(wast: &str, strategy: Strategy) -> anyhow::Result<()> {
// by reference types.
let reftypes = simd || wast.iter().any(|s| s == "reference-types");

let multi_val = wast.iter().any(|s| s == "multi-value");

let mut cfg = Config::new();
cfg.wasm_simd(simd)
.wasm_bulk_memory(bulk_mem)
.wasm_reference_types(reftypes)
.wasm_multi_value(multi_val)
.strategy(strategy)?
.cranelift_debug_verifier(true);

Expand Down
2 changes: 1 addition & 1 deletion tests/spec_testsuite
Submodule spec_testsuite updated 84 files
+18 −2 README.md
+2 −2 binary.wast
+374 −3 block.wast
+51 −0 br.wast
+55 −0 call.wast
+39 −10 call_indirect.wast
+199 −0 conversions.wast
+2 −2 custom.wast
+20 −0 fac.wast
+275 −15 func.wast
+497 −0 global.wast
+18 −0 i32.wast
+30 −0 i64.wast
+628 −11 if.wast
+318 −2 loop.wast
+30 −0 memory.wast
+195 −0 proposals/annotations/annotations.wast
+2 −2 proposals/bulk-memory-operations/binary.wast
+44 −0 proposals/bulk-memory-operations/bulk.wast
+2 −2 proposals/bulk-memory-operations/custom.wast
+17 −1 proposals/bulk-memory-operations/memory_init.wast
+26 −2 proposals/bulk-memory-operations/table_init.wast
+329 −2 proposals/reference-types/binary.wast
+12 −12 proposals/reference-types/br_table.wast
+307 −0 proposals/reference-types/bulk.wast
+130 −0 proposals/reference-types/custom.wast
+345 −0 proposals/reference-types/data.wast
+468 −0 proposals/reference-types/elem.wast
+4 −4 proposals/reference-types/imports.wast
+23 −18 proposals/reference-types/linking.wast
+5,577 −0 proposals/reference-types/memory_copy.wast
+685 −0 proposals/reference-types/memory_fill.wast
+951 −0 proposals/reference-types/memory_init.wast
+23 −1 proposals/reference-types/ref_func.wast
+2 −1 proposals/reference-types/ref_is_null.wast
+4 −4 proposals/reference-types/select.wast
+31 −0 proposals/reference-types/table-sub.wast
+1,595 −0 proposals/reference-types/table_copy.wast
+2 −2 proposals/reference-types/table_fill.wast
+2 −1 proposals/reference-types/table_get.wast
+2 −0 proposals/reference-types/table_grow.wast
+1,752 −0 proposals/reference-types/table_init.wast
+2 −1 proposals/reference-types/table_set.wast
+568 −31 proposals/sign-extension-ops/i32.wast
+66 −32 proposals/sign-extension-ops/i64.wast
+268 −77 proposals/simd/simd_align.wast
+100 −1 proposals/simd/simd_bit_shift.wast
+101 −1 proposals/simd/simd_bitwise.wast
+52 −1 proposals/simd/simd_boolean.wast
+5 −1 proposals/simd/simd_const.wast
+168 −283 proposals/simd/simd_conversions.wast
+49 −7 proposals/simd/simd_f32x4.wast
+83 −0 proposals/simd/simd_f32x4_arith.wast
+99 −0 proposals/simd/simd_f32x4_cmp.wast
+47 −4 proposals/simd/simd_f64x2.wast
+83 −0 proposals/simd/simd_f64x2_arith.wast
+99 −0 proposals/simd/simd_f64x2_cmp.wast
+59 −0 proposals/simd/simd_i16x8_arith.wast
+611 −0 proposals/simd/simd_i16x8_arith2.wast
+164 −0 proposals/simd/simd_i16x8_cmp.wast
+67 −0 proposals/simd/simd_i16x8_sat_arith.wast
+59 −0 proposals/simd/simd_i32x4_arith.wast
+494 −0 proposals/simd/simd_i32x4_arith2.wast
+163 −0 proposals/simd/simd_i32x4_cmp.wast
+59 −0 proposals/simd/simd_i64x2_arith.wast
+43 −0 proposals/simd/simd_i8x16_arith.wast
+614 −0 proposals/simd/simd_i8x16_arith2.wast
+163 −0 proposals/simd/simd_i8x16_cmp.wast
+67 −0 proposals/simd/simd_i8x16_sat_arith.wast
+448 −21 proposals/simd/simd_lane.wast
+4 −0 proposals/simd/simd_load.wast
+54 −2 proposals/simd/simd_load_extend.wast
+37 −1 proposals/simd/simd_load_splat.wast
+54 −2 proposals/simd/simd_splat.wast
+29 −1 proposals/simd/simd_store.wast
+112 −57 proposals/threads/atomic.wast
+30 −0 proposals/threads/memory.wast
+54 −0 table.wast
+18 −27 type.wast
+16 −1 update-testsuite.sh
+188 −188 utf8-custom-section-id.wast
+188 −188 utf8-import-field.wast
+188 −188 utf8-import-module.wast
+176 −176 utf8-invalid-encoding.wast

0 comments on commit 4e4b597

Please sign in to comment.