From 509c3b7cfaf90dcda940002500e4d49d3f6c4239 Mon Sep 17 00:00:00 2001 From: Gentle Date: Wed, 26 Feb 2025 23:08:45 +0100 Subject: [PATCH 1/2] enable reference types and bulk memory support by default --- src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 9194ce39..5a0a31e7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -40,9 +40,9 @@ const DEFAULT_INHERIT_ENV: bool = false; const DEFAULT_KEEP_INIT_FUNC: bool = false; const DEFAULT_WASM_MULTI_VALUE: bool = true; const DEFAULT_WASM_MULTI_MEMORY: bool = true; -const DEFAULT_WASM_BULK_MEMORY: bool = false; +const DEFAULT_WASM_BULK_MEMORY: bool = true; const DEFAULT_WASM_SIMD: bool = true; -const DEFAULT_WASM_REFERENCE_TYPES: bool = false; +const DEFAULT_WASM_REFERENCE_TYPES: bool = true; /// The type of data that is stored in the `wasmtime::Store` during /// initialization. @@ -241,7 +241,7 @@ pub struct Wizer { /// are currently supported. Modules which use other instructions, such as /// `table.copy` will be rejected. /// - /// Disabled by default. + /// Enabled by default. #[cfg_attr(feature = "structopt", structopt(long, value_name = "true|false"))] wasm_bulk_memory: Option, @@ -257,7 +257,7 @@ pub struct Wizer { /// but enables initializing Wasm modules that use encodings introduced /// in the reference-types proposal. /// - /// Disabled by default. + /// Enabled by default. #[cfg_attr(feature = "structopt", structopt(long, value_name = "true|false"))] wasm_reference_types: Option, } @@ -556,7 +556,7 @@ impl Wizer { /// operations are currently supported. Modules which use other /// instructions, such as `table.copy` will be rejected. /// - /// Defaults to `false`. + /// Defaults to `true`. pub fn wasm_bulk_memory(&mut self, enable: bool) -> &mut Self { self.wasm_bulk_memory = Some(enable); self @@ -576,7 +576,7 @@ impl Wizer { /// but enables initializing Wasm modules that use encodings introduced /// in the reference-types proposal. /// - /// Defaults to `false`. + /// Defaults to `true`. pub fn wasm_reference_types(&mut self, enable: bool) -> &mut Self { self.wasm_reference_types = Some(enable); self From dca55dd2ad5e5c06c492fde107038ad45641e30d Mon Sep 17 00:00:00 2001 From: Gentle Date: Wed, 26 Feb 2025 23:22:35 +0100 Subject: [PATCH 2/2] update tests --- tests/tests.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/tests.rs b/tests/tests.rs index e7d18733..4005f414 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -238,10 +238,7 @@ fn reject_table_copy() -> Result<()> { #[test] fn reject_table_get_set() -> Result<()> { - let result = run_wat( - &[], - 42, - r#" + let wat = r#" (module (table 3 funcref) @@ -257,8 +254,15 @@ fn reject_table_get_set() -> Result<()> { (elem (i32.const 0) $f $g $h) ) -"#, - ); +"#; + + let _ = env_logger::try_init(); + let mut wizer = Wizer::new(); + wizer.wasm_reference_types(false); + + let wasm = wat_to_wasm(wat)?; + let result = wizen_and_run_wasm(&[], 42, &wasm, wizer); + assert!(result.is_err()); let err = result.unwrap_err(); @@ -271,7 +275,10 @@ fn reject_table_get_set() -> Result<()> { #[test] fn reject_table_get_set_with_reference_types_enabled() -> Result<()> { - let wat = r#" + let result = run_wat( + &[], + 42, + r#" (module (table 3 funcref) @@ -286,15 +293,8 @@ fn reject_table_get_set_with_reference_types_enabled() -> Result<()> { table.set) (elem (i32.const 0) $f $g $h) - )"#; - - let _ = env_logger::try_init(); - let mut wizer = Wizer::new(); - wizer.wasm_reference_types(true); - - let wasm = wat_to_wasm(wat)?; - let result = wizen_and_run_wasm(&[], 42, &wasm, wizer); - + )"#, + ); assert!(result.is_err()); let err = result.unwrap_err();