Skip to content

Commit 6199089

Browse files
GentleGentle
and
Gentle
authored
enable reference types and bulk memory support by default (#129)
* enable reference types and bulk memory support by default * update tests --------- Co-authored-by: Gentle <[email protected]>
1 parent 46dccb9 commit 6199089

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ const DEFAULT_INHERIT_ENV: bool = false;
4040
const DEFAULT_KEEP_INIT_FUNC: bool = false;
4141
const DEFAULT_WASM_MULTI_VALUE: bool = true;
4242
const DEFAULT_WASM_MULTI_MEMORY: bool = true;
43-
const DEFAULT_WASM_BULK_MEMORY: bool = false;
43+
const DEFAULT_WASM_BULK_MEMORY: bool = true;
4444
const DEFAULT_WASM_SIMD: bool = true;
45-
const DEFAULT_WASM_REFERENCE_TYPES: bool = false;
45+
const DEFAULT_WASM_REFERENCE_TYPES: bool = true;
4646

4747
/// The type of data that is stored in the `wasmtime::Store` during
4848
/// initialization.
@@ -241,7 +241,7 @@ pub struct Wizer {
241241
/// are currently supported. Modules which use other instructions, such as
242242
/// `table.copy` will be rejected.
243243
///
244-
/// Disabled by default.
244+
/// Enabled by default.
245245
#[cfg_attr(feature = "structopt", structopt(long, value_name = "true|false"))]
246246
wasm_bulk_memory: Option<bool>,
247247

@@ -257,7 +257,7 @@ pub struct Wizer {
257257
/// but enables initializing Wasm modules that use encodings introduced
258258
/// in the reference-types proposal.
259259
///
260-
/// Disabled by default.
260+
/// Enabled by default.
261261
#[cfg_attr(feature = "structopt", structopt(long, value_name = "true|false"))]
262262
wasm_reference_types: Option<bool>,
263263
}
@@ -556,7 +556,7 @@ impl Wizer {
556556
/// operations are currently supported. Modules which use other
557557
/// instructions, such as `table.copy` will be rejected.
558558
///
559-
/// Defaults to `false`.
559+
/// Defaults to `true`.
560560
pub fn wasm_bulk_memory(&mut self, enable: bool) -> &mut Self {
561561
self.wasm_bulk_memory = Some(enable);
562562
self
@@ -576,7 +576,7 @@ impl Wizer {
576576
/// but enables initializing Wasm modules that use encodings introduced
577577
/// in the reference-types proposal.
578578
///
579-
/// Defaults to `false`.
579+
/// Defaults to `true`.
580580
pub fn wasm_reference_types(&mut self, enable: bool) -> &mut Self {
581581
self.wasm_reference_types = Some(enable);
582582
self

tests/tests.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,7 @@ fn reject_table_copy() -> Result<()> {
238238

239239
#[test]
240240
fn reject_table_get_set() -> Result<()> {
241-
let result = run_wat(
242-
&[],
243-
42,
244-
r#"
241+
let wat = r#"
245242
(module
246243
(table 3 funcref)
247244
@@ -257,8 +254,15 @@ fn reject_table_get_set() -> Result<()> {
257254
258255
(elem (i32.const 0) $f $g $h)
259256
)
260-
"#,
261-
);
257+
"#;
258+
259+
let _ = env_logger::try_init();
260+
let mut wizer = Wizer::new();
261+
wizer.wasm_reference_types(false);
262+
263+
let wasm = wat_to_wasm(wat)?;
264+
let result = wizen_and_run_wasm(&[], 42, &wasm, wizer);
265+
262266
assert!(result.is_err());
263267

264268
let err = result.unwrap_err();
@@ -271,7 +275,10 @@ fn reject_table_get_set() -> Result<()> {
271275

272276
#[test]
273277
fn reject_table_get_set_with_reference_types_enabled() -> Result<()> {
274-
let wat = r#"
278+
let result = run_wat(
279+
&[],
280+
42,
281+
r#"
275282
(module
276283
(table 3 funcref)
277284
@@ -286,15 +293,8 @@ fn reject_table_get_set_with_reference_types_enabled() -> Result<()> {
286293
table.set)
287294
288295
(elem (i32.const 0) $f $g $h)
289-
)"#;
290-
291-
let _ = env_logger::try_init();
292-
let mut wizer = Wizer::new();
293-
wizer.wasm_reference_types(true);
294-
295-
let wasm = wat_to_wasm(wat)?;
296-
let result = wizen_and_run_wasm(&[], 42, &wasm, wizer);
297-
296+
)"#,
297+
);
298298
assert!(result.is_err());
299299

300300
let err = result.unwrap_err();

0 commit comments

Comments
 (0)