From 8c1747cc44af8c8686590f8f78b12d12ef1ad043 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 30 Nov 2021 14:46:21 -0800 Subject: [PATCH] wasm-smith: restrict which kinds of instructions can be generated In looking into https://github.com/bytecodealliance/wasmtime/issues/3251, I created a mechanism for restricting what kinds of instructions wasm-smith can generate. The [WebAssembly specification](https://webassembly.github.io/spec/core/syntax/instructions.html) organizes its instructions into several categories (e.g., numeric, vector, reference, control, etc.) and this change allows the user to configure the module generation based on these categories: ``` head -c 10000 /dev/urandom | cargo run --bin wasm-smith -- --allowed-instructions memory,parametric -o test.wasm && wasm2wat test.wasm ``` There is some related configuration in wasm-smith to restrict what instructions are available. Currently, the wasm-smith configuration is organized around "proposals," which can be enabled or disabled. In theory, a user could be confused if the proposal was disabled and they explicitly enabled an instruction kind (e.g. reference)--"why aren't reference instructions being generated?" But this accident seems unlikely: `--allowed-instructions` defaults to enabling all kinds, so the user would have to explicitly filter out some kind, deliberately shooting themselves in the foot. Despite some risk of confusion (mitigated by the documentation in this PR), this filtering of instructions kinds ends up being useful in a general way: not only is it a start at fixing the issue above, it is useful for work I am doing to generate fuzz only parts of the spec. --- Cargo.toml | 1 + crates/wasm-smith/Cargo.toml | 1 + crates/wasm-smith/src/code_builder.rs | 926 +++++++++++++------------- crates/wasm-smith/src/config.rs | 17 + crates/wasm-smith/src/lib.rs | 40 +- src/bin/wasm-smith.rs | 12 +- 6 files changed, 532 insertions(+), 465 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5bed191dac..c7d36b642f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ members = ['fuzz', 'crates/wasm-encoder', 'crates/fuzz-stats', 'crates/wasm-muta anyhow = "1.0" arbitrary = "1.0.0" env_logger = "0.8" +flagset = "0.4" getopts = "0.2" log = "0.4" rayon = "1.0" diff --git a/crates/wasm-smith/Cargo.toml b/crates/wasm-smith/Cargo.toml index 4849958b4a..f104320f24 100644 --- a/crates/wasm-smith/Cargo.toml +++ b/crates/wasm-smith/Cargo.toml @@ -17,6 +17,7 @@ harness = false [dependencies] arbitrary = { version = "1.0.0", features = ["derive"] } +flagset = { version = "0.4", features = ["serde"] } leb128 = "0.2.4" wasm-encoder = { version = "0.8.0", path = "../wasm-encoder" } indexmap = "1.6" diff --git a/crates/wasm-smith/src/code_builder.rs b/crates/wasm-smith/src/code_builder.rs index 3c46a1ed2d..ab42636da9 100644 --- a/crates/wasm-smith/src/code_builder.rs +++ b/crates/wasm-smith/src/code_builder.rs @@ -1,4 +1,4 @@ -use super::{Elements, FuncType, Instruction, Module, ValType}; +use super::{Elements, FuncType, Instruction, InstructionKind::*, Module, ValType}; use arbitrary::{Result, Unstructured}; use std::collections::{BTreeMap, BTreeSet}; use std::convert::TryFrom; @@ -7,7 +7,7 @@ use wasm_encoder::{BlockType, MemArg}; macro_rules! instructions { ( $( - ($predicate:expr, $generator_fn:ident $(, $cost:tt)?), + ($predicate:expr, $generator_fn:ident, $instruction_kind:ident $(, $cost:tt)?), )* ) => { static NUM_OPTIONS: usize = instructions!( @@ -32,8 +32,8 @@ macro_rules! instructions { // the `corpus` benchmark. $( let predicate: Option bool> = $predicate; - if predicate.map_or(true, |f| f(module, builder)) { - + if predicate.map_or(true, |f| f(module, builder)) + && module.config.allowed_instructions().contains($instruction_kind) { builder.allocs.options.push(($generator_fn, cost)); cost += 1000 $(- $cost)?; } @@ -75,471 +75,471 @@ macro_rules! instructions { // less than 1000. instructions! { // Control instructions. - (None, unreachable, 990), - (None, nop, 800), - (None, block), - (None, r#loop), - (Some(try_valid), r#try), - (Some(delegate_valid), delegate), - (Some(catch_valid), catch), - (Some(catch_all_valid), catch_all), - (Some(if_valid), r#if), - (Some(else_valid), r#else), - (Some(end_valid), end), - (Some(br_valid), br), - (Some(br_if_valid), br_if), - (Some(br_table_valid), br_table), - (Some(return_valid), r#return, 900), - (Some(call_valid), call), - (Some(call_indirect_valid), call_indirect), - (Some(throw_valid), throw, 850), - (Some(rethrow_valid), rethrow), + (None, unreachable, Control, 990), + (None, nop, Control, 800), + (None, block, Control), + (None, r#loop, Control), + (Some(try_valid), r#try, Control), + (Some(delegate_valid), delegate, Control), + (Some(catch_valid), catch, Control), + (Some(catch_all_valid), catch_all, Control), + (Some(if_valid), r#if, Control), + (Some(else_valid), r#else, Control), + (Some(end_valid), end, Control), + (Some(br_valid), br, Control), + (Some(br_if_valid), br_if, Control), + (Some(br_table_valid), br_table, Control), + (Some(return_valid), r#return, Control, 900), + (Some(call_valid), call, Control), + (Some(call_indirect_valid), call_indirect, Control), + (Some(throw_valid), throw, Control, 850), + (Some(rethrow_valid), rethrow, Control), // Parametric instructions. - (Some(drop_valid), drop), - (Some(select_valid), select), + (Some(drop_valid), drop, Parametric), + (Some(select_valid), select, Parametric), // Variable instructions. - (Some(local_get_valid), local_get), - (Some(local_set_valid), local_set), - (Some(local_set_valid), local_tee), - (Some(global_get_valid), global_get), - (Some(global_set_valid), global_set), + (Some(local_get_valid), local_get, Variable), + (Some(local_set_valid), local_set, Variable), + (Some(local_set_valid), local_tee, Variable), + (Some(global_get_valid), global_get, Variable), + (Some(global_set_valid), global_set, Variable), // Memory instructions. - (Some(have_memory_and_offset), i32_load), - (Some(have_memory_and_offset), i64_load), - (Some(have_memory_and_offset), f32_load), - (Some(have_memory_and_offset), f64_load), - (Some(have_memory_and_offset), i32_load_8_s), - (Some(have_memory_and_offset), i32_load_8_u), - (Some(have_memory_and_offset), i32_load_16_s), - (Some(have_memory_and_offset), i32_load_16_u), - (Some(have_memory_and_offset), i64_load_8_s), - (Some(have_memory_and_offset), i64_load_16_s), - (Some(have_memory_and_offset), i64_load_32_s), - (Some(have_memory_and_offset), i64_load_8_u), - (Some(have_memory_and_offset), i64_load_16_u), - (Some(have_memory_and_offset), i64_load_32_u), - (Some(i32_store_valid), i32_store), - (Some(i64_store_valid), i64_store), - (Some(f32_store_valid), f32_store), - (Some(f64_store_valid), f64_store), - (Some(i32_store_valid), i32_store_8), - (Some(i32_store_valid), i32_store_16), - (Some(i64_store_valid), i64_store_8), - (Some(i64_store_valid), i64_store_16), - (Some(i64_store_valid), i64_store_32), - (Some(have_memory), memory_size), - (Some(memory_grow_valid), memory_grow), - (Some(memory_init_valid), memory_init), - (Some(data_drop_valid), data_drop), - (Some(memory_copy_valid), memory_copy), - (Some(memory_fill_valid), memory_fill), + (Some(have_memory_and_offset), i32_load, Memory), + (Some(have_memory_and_offset), i64_load, Memory), + (Some(have_memory_and_offset), f32_load, Memory), + (Some(have_memory_and_offset), f64_load, Memory), + (Some(have_memory_and_offset), i32_load_8_s, Memory), + (Some(have_memory_and_offset), i32_load_8_u, Memory), + (Some(have_memory_and_offset), i32_load_16_s, Memory), + (Some(have_memory_and_offset), i32_load_16_u, Memory), + (Some(have_memory_and_offset), i64_load_8_s, Memory), + (Some(have_memory_and_offset), i64_load_16_s, Memory), + (Some(have_memory_and_offset), i64_load_32_s, Memory), + (Some(have_memory_and_offset), i64_load_8_u, Memory), + (Some(have_memory_and_offset), i64_load_16_u, Memory), + (Some(have_memory_and_offset), i64_load_32_u, Memory), + (Some(i32_store_valid), i32_store, Memory), + (Some(i64_store_valid), i64_store, Memory), + (Some(f32_store_valid), f32_store, Memory), + (Some(f64_store_valid), f64_store, Memory), + (Some(i32_store_valid), i32_store_8, Memory), + (Some(i32_store_valid), i32_store_16, Memory), + (Some(i64_store_valid), i64_store_8, Memory), + (Some(i64_store_valid), i64_store_16, Memory), + (Some(i64_store_valid), i64_store_32, Memory), + (Some(have_memory), memory_size, Memory), + (Some(memory_grow_valid), memory_grow, Memory), + (Some(memory_init_valid), memory_init, Memory), + (Some(data_drop_valid), data_drop, Memory), + (Some(memory_copy_valid), memory_copy, Memory), + (Some(memory_fill_valid), memory_fill, Memory), // Numeric instructions. - (None, i32_const), - (None, i64_const), - (None, f32_const), - (None, f64_const), - (Some(i32_on_stack), i32_eqz), - (Some(i32_i32_on_stack), i32_eq), - (Some(i32_i32_on_stack), i32_neq), - (Some(i32_i32_on_stack), i32_lt_s), - (Some(i32_i32_on_stack), i32_lt_u), - (Some(i32_i32_on_stack), i32_gt_s), - (Some(i32_i32_on_stack), i32_gt_u), - (Some(i32_i32_on_stack), i32_le_s), - (Some(i32_i32_on_stack), i32_le_u), - (Some(i32_i32_on_stack), i32_ge_s), - (Some(i32_i32_on_stack), i32_ge_u), - (Some(i64_on_stack), i64_eqz), - (Some(i64_i64_on_stack), i64_eq), - (Some(i64_i64_on_stack), i64_neq), - (Some(i64_i64_on_stack), i64_lt_s), - (Some(i64_i64_on_stack), i64_lt_u), - (Some(i64_i64_on_stack), i64_gt_s), - (Some(i64_i64_on_stack), i64_gt_u), - (Some(i64_i64_on_stack), i64_le_s), - (Some(i64_i64_on_stack), i64_le_u), - (Some(i64_i64_on_stack), i64_ge_s), - (Some(i64_i64_on_stack), i64_ge_u), - (Some(f32_f32_on_stack), f32_eq), - (Some(f32_f32_on_stack), f32_neq), - (Some(f32_f32_on_stack), f32_lt), - (Some(f32_f32_on_stack), f32_gt), - (Some(f32_f32_on_stack), f32_le), - (Some(f32_f32_on_stack), f32_ge), - (Some(f64_f64_on_stack), f64_eq), - (Some(f64_f64_on_stack), f64_neq), - (Some(f64_f64_on_stack), f64_lt), - (Some(f64_f64_on_stack), f64_gt), - (Some(f64_f64_on_stack), f64_le), - (Some(f64_f64_on_stack), f64_ge), - (Some(i32_on_stack), i32_clz), - (Some(i32_on_stack), i32_ctz), - (Some(i32_on_stack), i32_popcnt), - (Some(i32_i32_on_stack), i32_add), - (Some(i32_i32_on_stack), i32_sub), - (Some(i32_i32_on_stack), i32_mul), - (Some(i32_i32_on_stack), i32_div_s), - (Some(i32_i32_on_stack), i32_div_u), - (Some(i32_i32_on_stack), i32_rem_s), - (Some(i32_i32_on_stack), i32_rem_u), - (Some(i32_i32_on_stack), i32_and), - (Some(i32_i32_on_stack), i32_or), - (Some(i32_i32_on_stack), i32_xor), - (Some(i32_i32_on_stack), i32_shl), - (Some(i32_i32_on_stack), i32_shr_s), - (Some(i32_i32_on_stack), i32_shr_u), - (Some(i32_i32_on_stack), i32_rotl), - (Some(i32_i32_on_stack), i32_rotr), - (Some(i64_on_stack), i64_clz), - (Some(i64_on_stack), i64_ctz), - (Some(i64_on_stack), i64_popcnt), - (Some(i64_i64_on_stack), i64_add), - (Some(i64_i64_on_stack), i64_sub), - (Some(i64_i64_on_stack), i64_mul), - (Some(i64_i64_on_stack), i64_div_s), - (Some(i64_i64_on_stack), i64_div_u), - (Some(i64_i64_on_stack), i64_rem_s), - (Some(i64_i64_on_stack), i64_rem_u), - (Some(i64_i64_on_stack), i64_and), - (Some(i64_i64_on_stack), i64_or), - (Some(i64_i64_on_stack), i64_xor), - (Some(i64_i64_on_stack), i64_shl), - (Some(i64_i64_on_stack), i64_shr_s), - (Some(i64_i64_on_stack), i64_shr_u), - (Some(i64_i64_on_stack), i64_rotl), - (Some(i64_i64_on_stack), i64_rotr), - (Some(f32_on_stack), f32_abs), - (Some(f32_on_stack), f32_neg), - (Some(f32_on_stack), f32_ceil), - (Some(f32_on_stack), f32_floor), - (Some(f32_on_stack), f32_trunc), - (Some(f32_on_stack), f32_nearest), - (Some(f32_on_stack), f32_sqrt), - (Some(f32_f32_on_stack), f32_add), - (Some(f32_f32_on_stack), f32_sub), - (Some(f32_f32_on_stack), f32_mul), - (Some(f32_f32_on_stack), f32_div), - (Some(f32_f32_on_stack), f32_min), - (Some(f32_f32_on_stack), f32_max), - (Some(f32_f32_on_stack), f32_copysign), - (Some(f64_on_stack), f64_abs), - (Some(f64_on_stack), f64_neg), - (Some(f64_on_stack), f64_ceil), - (Some(f64_on_stack), f64_floor), - (Some(f64_on_stack), f64_trunc), - (Some(f64_on_stack), f64_nearest), - (Some(f64_on_stack), f64_sqrt), - (Some(f64_f64_on_stack), f64_add), - (Some(f64_f64_on_stack), f64_sub), - (Some(f64_f64_on_stack), f64_mul), - (Some(f64_f64_on_stack), f64_div), - (Some(f64_f64_on_stack), f64_min), - (Some(f64_f64_on_stack), f64_max), - (Some(f64_f64_on_stack), f64_copysign), - (Some(i64_on_stack), i32_wrap_i64), - (Some(f32_on_stack), i32_trunc_f32_s), - (Some(f32_on_stack), i32_trunc_f32_u), - (Some(f64_on_stack), i32_trunc_f64_s), - (Some(f64_on_stack), i32_trunc_f64_u), - (Some(i32_on_stack), i64_extend_i32_s), - (Some(i32_on_stack), i64_extend_i32_u), - (Some(f32_on_stack), i64_trunc_f32_s), - (Some(f32_on_stack), i64_trunc_f32_u), - (Some(f64_on_stack), i64_trunc_f64_s), - (Some(f64_on_stack), i64_trunc_f64_u), - (Some(i32_on_stack), f32_convert_i32_s), - (Some(i32_on_stack), f32_convert_i32_u), - (Some(i64_on_stack), f32_convert_i64_s), - (Some(i64_on_stack), f32_convert_i64_u), - (Some(f64_on_stack), f32_demote_f64), - (Some(i32_on_stack), f64_convert_i32_s), - (Some(i32_on_stack), f64_convert_i32_u), - (Some(i64_on_stack), f64_convert_i64_s), - (Some(i64_on_stack), f64_convert_i64_u), - (Some(f32_on_stack), f64_promote_f32), - (Some(f32_on_stack), i32_reinterpret_f32), - (Some(f64_on_stack), i64_reinterpret_f64), - (Some(i32_on_stack), f32_reinterpret_i32), - (Some(i64_on_stack), f64_reinterpret_i64), - (Some(i32_on_stack), i32_extend_8_s), - (Some(i32_on_stack), i32_extend_16_s), - (Some(i64_on_stack), i64_extend_8_s), - (Some(i64_on_stack), i64_extend_16_s), - (Some(i64_on_stack), i64_extend_32_s), - (Some(f32_on_stack), i32_trunc_sat_f32_s), - (Some(f32_on_stack), i32_trunc_sat_f32_u), - (Some(f64_on_stack), i32_trunc_sat_f64_s), - (Some(f64_on_stack), i32_trunc_sat_f64_u), - (Some(f32_on_stack), i64_trunc_sat_f32_s), - (Some(f32_on_stack), i64_trunc_sat_f32_u), - (Some(f64_on_stack), i64_trunc_sat_f64_s), - (Some(f64_on_stack), i64_trunc_sat_f64_u), + (None, i32_const, Numeric), + (None, i64_const, Numeric), + (None, f32_const, Numeric), + (None, f64_const, Numeric), + (Some(i32_on_stack), i32_eqz, Numeric), + (Some(i32_i32_on_stack), i32_eq, Numeric), + (Some(i32_i32_on_stack), i32_neq, Numeric), + (Some(i32_i32_on_stack), i32_lt_s, Numeric), + (Some(i32_i32_on_stack), i32_lt_u, Numeric), + (Some(i32_i32_on_stack), i32_gt_s, Numeric), + (Some(i32_i32_on_stack), i32_gt_u, Numeric), + (Some(i32_i32_on_stack), i32_le_s, Numeric), + (Some(i32_i32_on_stack), i32_le_u, Numeric), + (Some(i32_i32_on_stack), i32_ge_s, Numeric), + (Some(i32_i32_on_stack), i32_ge_u, Numeric), + (Some(i64_on_stack), i64_eqz, Numeric), + (Some(i64_i64_on_stack), i64_eq, Numeric), + (Some(i64_i64_on_stack), i64_neq, Numeric), + (Some(i64_i64_on_stack), i64_lt_s, Numeric), + (Some(i64_i64_on_stack), i64_lt_u, Numeric), + (Some(i64_i64_on_stack), i64_gt_s, Numeric), + (Some(i64_i64_on_stack), i64_gt_u, Numeric), + (Some(i64_i64_on_stack), i64_le_s, Numeric), + (Some(i64_i64_on_stack), i64_le_u, Numeric), + (Some(i64_i64_on_stack), i64_ge_s, Numeric), + (Some(i64_i64_on_stack), i64_ge_u, Numeric), + (Some(f32_f32_on_stack), f32_eq, Numeric), + (Some(f32_f32_on_stack), f32_neq, Numeric), + (Some(f32_f32_on_stack), f32_lt, Numeric), + (Some(f32_f32_on_stack), f32_gt, Numeric), + (Some(f32_f32_on_stack), f32_le, Numeric), + (Some(f32_f32_on_stack), f32_ge, Numeric), + (Some(f64_f64_on_stack), f64_eq, Numeric), + (Some(f64_f64_on_stack), f64_neq, Numeric), + (Some(f64_f64_on_stack), f64_lt, Numeric), + (Some(f64_f64_on_stack), f64_gt, Numeric), + (Some(f64_f64_on_stack), f64_le, Numeric), + (Some(f64_f64_on_stack), f64_ge, Numeric), + (Some(i32_on_stack), i32_clz, Numeric), + (Some(i32_on_stack), i32_ctz, Numeric), + (Some(i32_on_stack), i32_popcnt, Numeric), + (Some(i32_i32_on_stack), i32_add, Numeric), + (Some(i32_i32_on_stack), i32_sub, Numeric), + (Some(i32_i32_on_stack), i32_mul, Numeric), + (Some(i32_i32_on_stack), i32_div_s, Numeric), + (Some(i32_i32_on_stack), i32_div_u, Numeric), + (Some(i32_i32_on_stack), i32_rem_s, Numeric), + (Some(i32_i32_on_stack), i32_rem_u, Numeric), + (Some(i32_i32_on_stack), i32_and, Numeric), + (Some(i32_i32_on_stack), i32_or, Numeric), + (Some(i32_i32_on_stack), i32_xor, Numeric), + (Some(i32_i32_on_stack), i32_shl, Numeric), + (Some(i32_i32_on_stack), i32_shr_s, Numeric), + (Some(i32_i32_on_stack), i32_shr_u, Numeric), + (Some(i32_i32_on_stack), i32_rotl, Numeric), + (Some(i32_i32_on_stack), i32_rotr, Numeric), + (Some(i64_on_stack), i64_clz, Numeric), + (Some(i64_on_stack), i64_ctz, Numeric), + (Some(i64_on_stack), i64_popcnt, Numeric), + (Some(i64_i64_on_stack), i64_add, Numeric), + (Some(i64_i64_on_stack), i64_sub, Numeric), + (Some(i64_i64_on_stack), i64_mul, Numeric), + (Some(i64_i64_on_stack), i64_div_s, Numeric), + (Some(i64_i64_on_stack), i64_div_u, Numeric), + (Some(i64_i64_on_stack), i64_rem_s, Numeric), + (Some(i64_i64_on_stack), i64_rem_u, Numeric), + (Some(i64_i64_on_stack), i64_and, Numeric), + (Some(i64_i64_on_stack), i64_or, Numeric), + (Some(i64_i64_on_stack), i64_xor, Numeric), + (Some(i64_i64_on_stack), i64_shl, Numeric), + (Some(i64_i64_on_stack), i64_shr_s, Numeric), + (Some(i64_i64_on_stack), i64_shr_u, Numeric), + (Some(i64_i64_on_stack), i64_rotl, Numeric), + (Some(i64_i64_on_stack), i64_rotr, Numeric), + (Some(f32_on_stack), f32_abs, Numeric), + (Some(f32_on_stack), f32_neg, Numeric), + (Some(f32_on_stack), f32_ceil, Numeric), + (Some(f32_on_stack), f32_floor, Numeric), + (Some(f32_on_stack), f32_trunc, Numeric), + (Some(f32_on_stack), f32_nearest, Numeric), + (Some(f32_on_stack), f32_sqrt, Numeric), + (Some(f32_f32_on_stack), f32_add, Numeric), + (Some(f32_f32_on_stack), f32_sub, Numeric), + (Some(f32_f32_on_stack), f32_mul, Numeric), + (Some(f32_f32_on_stack), f32_div, Numeric), + (Some(f32_f32_on_stack), f32_min, Numeric), + (Some(f32_f32_on_stack), f32_max, Numeric), + (Some(f32_f32_on_stack), f32_copysign, Numeric), + (Some(f64_on_stack), f64_abs, Numeric), + (Some(f64_on_stack), f64_neg, Numeric), + (Some(f64_on_stack), f64_ceil, Numeric), + (Some(f64_on_stack), f64_floor, Numeric), + (Some(f64_on_stack), f64_trunc, Numeric), + (Some(f64_on_stack), f64_nearest, Numeric), + (Some(f64_on_stack), f64_sqrt, Numeric), + (Some(f64_f64_on_stack), f64_add, Numeric), + (Some(f64_f64_on_stack), f64_sub, Numeric), + (Some(f64_f64_on_stack), f64_mul, Numeric), + (Some(f64_f64_on_stack), f64_div, Numeric), + (Some(f64_f64_on_stack), f64_min, Numeric), + (Some(f64_f64_on_stack), f64_max, Numeric), + (Some(f64_f64_on_stack), f64_copysign, Numeric), + (Some(i64_on_stack), i32_wrap_i64, Numeric), + (Some(f32_on_stack), i32_trunc_f32_s, Numeric), + (Some(f32_on_stack), i32_trunc_f32_u, Numeric), + (Some(f64_on_stack), i32_trunc_f64_s, Numeric), + (Some(f64_on_stack), i32_trunc_f64_u, Numeric), + (Some(i32_on_stack), i64_extend_i32_s, Numeric), + (Some(i32_on_stack), i64_extend_i32_u, Numeric), + (Some(f32_on_stack), i64_trunc_f32_s, Numeric), + (Some(f32_on_stack), i64_trunc_f32_u, Numeric), + (Some(f64_on_stack), i64_trunc_f64_s, Numeric), + (Some(f64_on_stack), i64_trunc_f64_u, Numeric), + (Some(i32_on_stack), f32_convert_i32_s, Numeric), + (Some(i32_on_stack), f32_convert_i32_u, Numeric), + (Some(i64_on_stack), f32_convert_i64_s, Numeric), + (Some(i64_on_stack), f32_convert_i64_u, Numeric), + (Some(f64_on_stack), f32_demote_f64, Numeric), + (Some(i32_on_stack), f64_convert_i32_s, Numeric), + (Some(i32_on_stack), f64_convert_i32_u, Numeric), + (Some(i64_on_stack), f64_convert_i64_s, Numeric), + (Some(i64_on_stack), f64_convert_i64_u, Numeric), + (Some(f32_on_stack), f64_promote_f32, Numeric), + (Some(f32_on_stack), i32_reinterpret_f32, Numeric), + (Some(f64_on_stack), i64_reinterpret_f64, Numeric), + (Some(i32_on_stack), f32_reinterpret_i32, Numeric), + (Some(i64_on_stack), f64_reinterpret_i64, Numeric), + (Some(i32_on_stack), i32_extend_8_s, Numeric), + (Some(i32_on_stack), i32_extend_16_s, Numeric), + (Some(i64_on_stack), i64_extend_8_s, Numeric), + (Some(i64_on_stack), i64_extend_16_s, Numeric), + (Some(i64_on_stack), i64_extend_32_s, Numeric), + (Some(f32_on_stack), i32_trunc_sat_f32_s, Numeric), + (Some(f32_on_stack), i32_trunc_sat_f32_u, Numeric), + (Some(f64_on_stack), i32_trunc_sat_f64_s, Numeric), + (Some(f64_on_stack), i32_trunc_sat_f64_u, Numeric), + (Some(f32_on_stack), i64_trunc_sat_f32_s, Numeric), + (Some(f32_on_stack), i64_trunc_sat_f32_u, Numeric), + (Some(f64_on_stack), i64_trunc_sat_f64_s, Numeric), + (Some(f64_on_stack), i64_trunc_sat_f64_u, Numeric), // reference types proposal - (Some(ref_null_valid), ref_null), - (Some(ref_func_valid), ref_func), - (Some(ref_is_null_valid), ref_is_null), - (Some(table_fill_valid), table_fill), - (Some(table_set_valid), table_set), - (Some(table_get_valid), table_get), - (Some(table_size_valid), table_size), - (Some(table_grow_valid), table_grow), - (Some(table_copy_valid), table_copy), - (Some(table_init_valid), table_init), - (Some(elem_drop_valid), elem_drop), + (Some(ref_null_valid), ref_null, Reference), + (Some(ref_func_valid), ref_func, Reference), + (Some(ref_is_null_valid), ref_is_null, Reference), + (Some(table_fill_valid), table_fill, Reference), + (Some(table_set_valid), table_set, Reference), + (Some(table_get_valid), table_get, Reference), + (Some(table_size_valid), table_size, Reference), + (Some(table_grow_valid), table_grow, Reference), + (Some(table_copy_valid), table_copy, Reference), + (Some(table_init_valid), table_init, Reference), + (Some(elem_drop_valid), elem_drop, Reference), // SIMD instructions. - (Some(simd_have_memory_and_offset), v128_load), - (Some(simd_have_memory_and_offset), v128_load8x8s), - (Some(simd_have_memory_and_offset), v128_load8x8u), - (Some(simd_have_memory_and_offset), v128_load16x4s), - (Some(simd_have_memory_and_offset), v128_load16x4u), - (Some(simd_have_memory_and_offset), v128_load32x2s), - (Some(simd_have_memory_and_offset), v128_load32x2u), - (Some(simd_have_memory_and_offset), v128_load8_splat), - (Some(simd_have_memory_and_offset), v128_load16_splat), - (Some(simd_have_memory_and_offset), v128_load32_splat), - (Some(simd_have_memory_and_offset), v128_load64_splat), - (Some(simd_have_memory_and_offset), v128_load32_zero), - (Some(simd_have_memory_and_offset), v128_load64_zero), - (Some(simd_v128_store_valid), v128_store), - (Some(simd_have_memory_and_offset_and_v128), v128_load8_lane), - (Some(simd_have_memory_and_offset_and_v128), v128_load16_lane), - (Some(simd_have_memory_and_offset_and_v128), v128_load32_lane), - (Some(simd_have_memory_and_offset_and_v128), v128_load64_lane), - (Some(simd_v128_store_valid), v128_store8_lane), - (Some(simd_v128_store_valid), v128_store16_lane), - (Some(simd_v128_store_valid), v128_store32_lane), - (Some(simd_v128_store_valid), v128_store64_lane), - (Some(simd_enabled), v128_const), - (Some(simd_v128_v128_on_stack), i8x16_shuffle), - (Some(simd_v128_on_stack), i8x16_extract_lane_s), - (Some(simd_v128_on_stack), i8x16_extract_lane_u), - (Some(simd_v128_i32_on_stack), i8x16_replace_lane), - (Some(simd_v128_on_stack), i16x8_extract_lane_s), - (Some(simd_v128_on_stack), i16x8_extract_lane_u), - (Some(simd_v128_i32_on_stack), i16x8_replace_lane), - (Some(simd_v128_on_stack), i32x4_extract_lane), - (Some(simd_v128_i32_on_stack), i32x4_replace_lane), - (Some(simd_v128_on_stack), i64x2_extract_lane), - (Some(simd_v128_i64_on_stack), i64x2_replace_lane), - (Some(simd_v128_on_stack), f32x4_extract_lane), - (Some(simd_v128_f32_on_stack), f32x4_replace_lane), - (Some(simd_v128_on_stack), f64x2_extract_lane), - (Some(simd_v128_f64_on_stack), f64x2_replace_lane), - (Some(simd_i32_on_stack), i8x16_splat), - (Some(simd_i32_on_stack), i16x8_splat), - (Some(simd_i32_on_stack), i32x4_splat), - (Some(simd_i64_on_stack), i64x2_splat), - (Some(simd_f32_on_stack), f32x4_splat), - (Some(simd_f64_on_stack), f64x2_splat), - (Some(simd_v128_v128_on_stack), i8x16_swizzle), - (Some(simd_v128_v128_on_stack_relaxed), i8x16_swizzle_relaxed), - (Some(simd_v128_v128_v128_on_stack), v128_bitselect), - (Some(simd_v128_v128_v128_on_stack_relaxed), i8x16_laneselect), - (Some(simd_v128_v128_v128_on_stack_relaxed), i16x8_laneselect), - (Some(simd_v128_v128_v128_on_stack_relaxed), i32x4_laneselect), - (Some(simd_v128_v128_v128_on_stack_relaxed), i64x2_laneselect), - (Some(simd_v128_v128_on_stack), i8x16_eq), - (Some(simd_v128_v128_on_stack), i8x16_ne), - (Some(simd_v128_v128_on_stack), i8x16_lt_s), - (Some(simd_v128_v128_on_stack), i8x16_lt_u), - (Some(simd_v128_v128_on_stack), i8x16_gt_s), - (Some(simd_v128_v128_on_stack), i8x16_gt_u), - (Some(simd_v128_v128_on_stack), i8x16_le_s), - (Some(simd_v128_v128_on_stack), i8x16_le_u), - (Some(simd_v128_v128_on_stack), i8x16_ge_s), - (Some(simd_v128_v128_on_stack), i8x16_ge_u), - (Some(simd_v128_v128_on_stack), i16x8_eq), - (Some(simd_v128_v128_on_stack), i16x8_ne), - (Some(simd_v128_v128_on_stack), i16x8_lt_s), - (Some(simd_v128_v128_on_stack), i16x8_lt_u), - (Some(simd_v128_v128_on_stack), i16x8_gt_s), - (Some(simd_v128_v128_on_stack), i16x8_gt_u), - (Some(simd_v128_v128_on_stack), i16x8_le_s), - (Some(simd_v128_v128_on_stack), i16x8_le_u), - (Some(simd_v128_v128_on_stack), i16x8_ge_s), - (Some(simd_v128_v128_on_stack), i16x8_ge_u), - (Some(simd_v128_v128_on_stack), i32x4_eq), - (Some(simd_v128_v128_on_stack), i32x4_ne), - (Some(simd_v128_v128_on_stack), i32x4_lt_s), - (Some(simd_v128_v128_on_stack), i32x4_lt_u), - (Some(simd_v128_v128_on_stack), i32x4_gt_s), - (Some(simd_v128_v128_on_stack), i32x4_gt_u), - (Some(simd_v128_v128_on_stack), i32x4_le_s), - (Some(simd_v128_v128_on_stack), i32x4_le_u), - (Some(simd_v128_v128_on_stack), i32x4_ge_s), - (Some(simd_v128_v128_on_stack), i32x4_ge_u), - (Some(simd_v128_v128_on_stack), i64x2_eq), - (Some(simd_v128_v128_on_stack), i64x2_ne), - (Some(simd_v128_v128_on_stack), i64x2_lt_s), - (Some(simd_v128_v128_on_stack), i64x2_gt_s), - (Some(simd_v128_v128_on_stack), i64x2_le_s), - (Some(simd_v128_v128_on_stack), i64x2_ge_s), - (Some(simd_v128_v128_on_stack), f32x4_eq), - (Some(simd_v128_v128_on_stack), f32x4_ne), - (Some(simd_v128_v128_on_stack), f32x4_lt), - (Some(simd_v128_v128_on_stack), f32x4_gt), - (Some(simd_v128_v128_on_stack), f32x4_le), - (Some(simd_v128_v128_on_stack), f32x4_ge), - (Some(simd_v128_v128_on_stack), f64x2_eq), - (Some(simd_v128_v128_on_stack), f64x2_ne), - (Some(simd_v128_v128_on_stack), f64x2_lt), - (Some(simd_v128_v128_on_stack), f64x2_gt), - (Some(simd_v128_v128_on_stack), f64x2_le), - (Some(simd_v128_v128_on_stack), f64x2_ge), - (Some(simd_v128_on_stack), v128_not), - (Some(simd_v128_v128_on_stack), v128_and), - (Some(simd_v128_v128_on_stack), v128_and_not), - (Some(simd_v128_v128_on_stack), v128_or), - (Some(simd_v128_v128_on_stack), v128_xor), - (Some(simd_v128_v128_on_stack), v128_any_true), - (Some(simd_v128_on_stack), i8x16_abs), - (Some(simd_v128_on_stack), i8x16_neg), - (Some(simd_v128_on_stack), i8x16_popcnt), - (Some(simd_v128_on_stack), i8x16_all_true), - (Some(simd_v128_on_stack), i8x16_bitmask), - (Some(simd_v128_v128_on_stack), i8x16_narrow_i16x8s), - (Some(simd_v128_v128_on_stack), i8x16_narrow_i16x8u), - (Some(simd_v128_i32_on_stack), i8x16_shl), - (Some(simd_v128_i32_on_stack), i8x16_shr_s), - (Some(simd_v128_i32_on_stack), i8x16_shr_u), - (Some(simd_v128_v128_on_stack), i8x16_add), - (Some(simd_v128_v128_on_stack), i8x16_add_sat_s), - (Some(simd_v128_v128_on_stack), i8x16_add_sat_u), - (Some(simd_v128_v128_on_stack), i8x16_sub), - (Some(simd_v128_v128_on_stack), i8x16_sub_sat_s), - (Some(simd_v128_v128_on_stack), i8x16_sub_sat_u), - (Some(simd_v128_v128_on_stack), i8x16_min_s), - (Some(simd_v128_v128_on_stack), i8x16_min_u), - (Some(simd_v128_v128_on_stack), i8x16_max_s), - (Some(simd_v128_v128_on_stack), i8x16_max_u), - (Some(simd_v128_v128_on_stack), i8x16_rounding_average_u), - (Some(simd_v128_on_stack), i16x8_ext_add_pairwise_i8x16s), - (Some(simd_v128_on_stack), i16x8_ext_add_pairwise_i8x16u), - (Some(simd_v128_on_stack), i16x8_abs), - (Some(simd_v128_on_stack), i16x8_neg), - (Some(simd_v128_v128_on_stack), i16x8q15_mulr_sat_s), - (Some(simd_v128_on_stack), i16x8_all_true), - (Some(simd_v128_on_stack), i16x8_bitmask), - (Some(simd_v128_v128_on_stack), i16x8_narrow_i32x4s), - (Some(simd_v128_v128_on_stack), i16x8_narrow_i32x4u), - (Some(simd_v128_on_stack), i16x8_extend_low_i8x16s), - (Some(simd_v128_on_stack), i16x8_extend_high_i8x16s), - (Some(simd_v128_on_stack), i16x8_extend_low_i8x16u), - (Some(simd_v128_on_stack), i16x8_extend_high_i8x16u), - (Some(simd_v128_i32_on_stack), i16x8_shl), - (Some(simd_v128_i32_on_stack), i16x8_shr_s), - (Some(simd_v128_i32_on_stack), i16x8_shr_u), - (Some(simd_v128_v128_on_stack), i16x8_add), - (Some(simd_v128_v128_on_stack), i16x8_add_sat_s), - (Some(simd_v128_v128_on_stack), i16x8_add_sat_u), - (Some(simd_v128_v128_on_stack), i16x8_sub), - (Some(simd_v128_v128_on_stack), i16x8_sub_sat_s), - (Some(simd_v128_v128_on_stack), i16x8_sub_sat_u), - (Some(simd_v128_v128_on_stack), i16x8_mul), - (Some(simd_v128_v128_on_stack), i16x8_min_s), - (Some(simd_v128_v128_on_stack), i16x8_min_u), - (Some(simd_v128_v128_on_stack), i16x8_max_s), - (Some(simd_v128_v128_on_stack), i16x8_max_u), - (Some(simd_v128_v128_on_stack), i16x8_rounding_average_u), - (Some(simd_v128_v128_on_stack), i16x8_ext_mul_low_i8x16s), - (Some(simd_v128_v128_on_stack), i16x8_ext_mul_high_i8x16s), - (Some(simd_v128_v128_on_stack), i16x8_ext_mul_low_i8x16u), - (Some(simd_v128_v128_on_stack), i16x8_ext_mul_high_i8x16u), - (Some(simd_v128_on_stack), i32x4_ext_add_pairwise_i16x8s), - (Some(simd_v128_on_stack), i32x4_ext_add_pairwise_i16x8u), - (Some(simd_v128_on_stack), i32x4_abs), - (Some(simd_v128_on_stack), i32x4_neg), - (Some(simd_v128_on_stack), i32x4_all_true), - (Some(simd_v128_on_stack), i32x4_bitmask), - (Some(simd_v128_on_stack), i32x4_extend_low_i16x8s), - (Some(simd_v128_on_stack), i32x4_extend_high_i16x8s), - (Some(simd_v128_on_stack), i32x4_extend_low_i16x8u), - (Some(simd_v128_on_stack), i32x4_extend_high_i16x8u), - (Some(simd_v128_i32_on_stack), i32x4_shl), - (Some(simd_v128_i32_on_stack), i32x4_shr_s), - (Some(simd_v128_i32_on_stack), i32x4_shr_u), - (Some(simd_v128_v128_on_stack), i32x4_add), - (Some(simd_v128_v128_on_stack), i32x4_sub), - (Some(simd_v128_v128_on_stack), i32x4_mul), - (Some(simd_v128_v128_on_stack), i32x4_min_s), - (Some(simd_v128_v128_on_stack), i32x4_min_u), - (Some(simd_v128_v128_on_stack), i32x4_max_s), - (Some(simd_v128_v128_on_stack), i32x4_max_u), - (Some(simd_v128_v128_on_stack), i32x4_dot_i16x8s), - (Some(simd_v128_v128_on_stack), i32x4_ext_mul_low_i16x8s), - (Some(simd_v128_v128_on_stack), i32x4_ext_mul_high_i16x8s), - (Some(simd_v128_v128_on_stack), i32x4_ext_mul_low_i16x8u), - (Some(simd_v128_v128_on_stack), i32x4_ext_mul_high_i16x8u), - (Some(simd_v128_on_stack), i64x2_abs), - (Some(simd_v128_on_stack), i64x2_neg), - (Some(simd_v128_on_stack), i64x2_all_true), - (Some(simd_v128_on_stack), i64x2_bitmask), - (Some(simd_v128_on_stack), i64x2_extend_low_i32x4s), - (Some(simd_v128_on_stack), i64x2_extend_high_i32x4s), - (Some(simd_v128_on_stack), i64x2_extend_low_i32x4u), - (Some(simd_v128_on_stack), i64x2_extend_high_i32x4u), - (Some(simd_v128_i32_on_stack), i64x2_shl), - (Some(simd_v128_i32_on_stack), i64x2_shr_s), - (Some(simd_v128_i32_on_stack), i64x2_shr_u), - (Some(simd_v128_v128_on_stack), i64x2_add), - (Some(simd_v128_v128_on_stack), i64x2_sub), - (Some(simd_v128_v128_on_stack), i64x2_mul), - (Some(simd_v128_v128_on_stack), i64x2_ext_mul_low_i32x4s), - (Some(simd_v128_v128_on_stack), i64x2_ext_mul_high_i32x4s), - (Some(simd_v128_v128_on_stack), i64x2_ext_mul_low_i32x4u), - (Some(simd_v128_v128_on_stack), i64x2_ext_mul_high_i32x4u), - (Some(simd_v128_on_stack), f32x4_ceil), - (Some(simd_v128_on_stack), f32x4_floor), - (Some(simd_v128_on_stack), f32x4_trunc), - (Some(simd_v128_on_stack), f32x4_nearest), - (Some(simd_v128_on_stack), f32x4_abs), - (Some(simd_v128_on_stack), f32x4_neg), - (Some(simd_v128_on_stack), f32x4_sqrt), - (Some(simd_v128_v128_on_stack), f32x4_add), - (Some(simd_v128_v128_on_stack), f32x4_sub), - (Some(simd_v128_v128_on_stack), f32x4_mul), - (Some(simd_v128_v128_on_stack), f32x4_div), - (Some(simd_v128_v128_on_stack), f32x4_min), - (Some(simd_v128_v128_on_stack), f32x4_max), - (Some(simd_v128_v128_on_stack), f32x4p_min), - (Some(simd_v128_v128_on_stack), f32x4p_max), - (Some(simd_v128_on_stack), f64x2_ceil), - (Some(simd_v128_on_stack), f64x2_floor), - (Some(simd_v128_on_stack), f64x2_trunc), - (Some(simd_v128_on_stack), f64x2_nearest), - (Some(simd_v128_on_stack), f64x2_abs), - (Some(simd_v128_on_stack), f64x2_neg), - (Some(simd_v128_on_stack), f64x2_sqrt), - (Some(simd_v128_v128_on_stack), f64x2_add), - (Some(simd_v128_v128_on_stack), f64x2_sub), - (Some(simd_v128_v128_on_stack), f64x2_mul), - (Some(simd_v128_v128_on_stack), f64x2_div), - (Some(simd_v128_v128_on_stack), f64x2_min), - (Some(simd_v128_v128_on_stack), f64x2_max), - (Some(simd_v128_v128_on_stack), f64x2p_min), - (Some(simd_v128_v128_on_stack), f64x2p_max), - (Some(simd_v128_on_stack), i32x4_trunc_sat_f32x4s), - (Some(simd_v128_on_stack), i32x4_trunc_sat_f32x4u), - (Some(simd_v128_on_stack), f32x4_convert_i32x4s), - (Some(simd_v128_on_stack), f32x4_convert_i32x4u), - (Some(simd_v128_on_stack), i32x4_trunc_sat_f64x2s_zero), - (Some(simd_v128_on_stack), i32x4_trunc_sat_f64x2u_zero), - (Some(simd_v128_on_stack), f64x2_convert_low_i32x4s), - (Some(simd_v128_on_stack), f64x2_convert_low_i32x4u), - (Some(simd_v128_on_stack), f32x4_demote_f64x2_zero), - (Some(simd_v128_on_stack), f64x2_promote_low_f32x4), - (Some(simd_v128_on_stack_relaxed), i32x4_trunc_sat_f32x4s_relaxed), - (Some(simd_v128_on_stack_relaxed), i32x4_trunc_sat_f32x4u_relaxed), - (Some(simd_v128_on_stack_relaxed), i32x4_trunc_sat_f64x2s_zero_relaxed), - (Some(simd_v128_on_stack_relaxed), i32x4_trunc_sat_f64x2u_zero_relaxed), - (Some(simd_v128_v128_on_stack_relaxed), f32x4_fma_relaxed), - (Some(simd_v128_v128_on_stack_relaxed), f32x4_fms_relaxed), - (Some(simd_v128_v128_on_stack_relaxed), f64x2_fma_relaxed), - (Some(simd_v128_v128_on_stack_relaxed), f64x2_fms_relaxed), - (Some(simd_v128_v128_on_stack_relaxed), f32x4_min_relaxed), - (Some(simd_v128_v128_on_stack_relaxed), f32x4_max_relaxed), - (Some(simd_v128_v128_on_stack_relaxed), f64x2_min_relaxed), - (Some(simd_v128_v128_on_stack_relaxed), f64x2_max_relaxed), + (Some(simd_have_memory_and_offset), v128_load, Vector), + (Some(simd_have_memory_and_offset), v128_load8x8s, Vector), + (Some(simd_have_memory_and_offset), v128_load8x8u, Vector), + (Some(simd_have_memory_and_offset), v128_load16x4s, Vector), + (Some(simd_have_memory_and_offset), v128_load16x4u, Vector), + (Some(simd_have_memory_and_offset), v128_load32x2s, Vector), + (Some(simd_have_memory_and_offset), v128_load32x2u, Vector), + (Some(simd_have_memory_and_offset), v128_load8_splat, Vector), + (Some(simd_have_memory_and_offset), v128_load16_splat, Vector), + (Some(simd_have_memory_and_offset), v128_load32_splat, Vector), + (Some(simd_have_memory_and_offset), v128_load64_splat, Vector), + (Some(simd_have_memory_and_offset), v128_load32_zero, Vector), + (Some(simd_have_memory_and_offset), v128_load64_zero, Vector), + (Some(simd_v128_store_valid), v128_store, Vector), + (Some(simd_have_memory_and_offset_and_v128), v128_load8_lane, Vector), + (Some(simd_have_memory_and_offset_and_v128), v128_load16_lane, Vector), + (Some(simd_have_memory_and_offset_and_v128), v128_load32_lane, Vector), + (Some(simd_have_memory_and_offset_and_v128), v128_load64_lane, Vector), + (Some(simd_v128_store_valid), v128_store8_lane, Vector), + (Some(simd_v128_store_valid), v128_store16_lane, Vector), + (Some(simd_v128_store_valid), v128_store32_lane, Vector), + (Some(simd_v128_store_valid), v128_store64_lane, Vector), + (Some(simd_enabled), v128_const, Vector), + (Some(simd_v128_v128_on_stack), i8x16_shuffle, Vector), + (Some(simd_v128_on_stack), i8x16_extract_lane_s, Vector), + (Some(simd_v128_on_stack), i8x16_extract_lane_u, Vector), + (Some(simd_v128_i32_on_stack), i8x16_replace_lane, Vector), + (Some(simd_v128_on_stack), i16x8_extract_lane_s, Vector), + (Some(simd_v128_on_stack), i16x8_extract_lane_u, Vector), + (Some(simd_v128_i32_on_stack), i16x8_replace_lane, Vector), + (Some(simd_v128_on_stack), i32x4_extract_lane, Vector), + (Some(simd_v128_i32_on_stack), i32x4_replace_lane, Vector), + (Some(simd_v128_on_stack), i64x2_extract_lane, Vector), + (Some(simd_v128_i64_on_stack), i64x2_replace_lane, Vector), + (Some(simd_v128_on_stack), f32x4_extract_lane, Vector), + (Some(simd_v128_f32_on_stack), f32x4_replace_lane, Vector), + (Some(simd_v128_on_stack), f64x2_extract_lane, Vector), + (Some(simd_v128_f64_on_stack), f64x2_replace_lane, Vector), + (Some(simd_i32_on_stack), i8x16_splat, Vector), + (Some(simd_i32_on_stack), i16x8_splat, Vector), + (Some(simd_i32_on_stack), i32x4_splat, Vector), + (Some(simd_i64_on_stack), i64x2_splat, Vector), + (Some(simd_f32_on_stack), f32x4_splat, Vector), + (Some(simd_f64_on_stack), f64x2_splat, Vector), + (Some(simd_v128_v128_on_stack), i8x16_swizzle, Vector), + (Some(simd_v128_v128_on_stack_relaxed), i8x16_swizzle_relaxed, Vector), + (Some(simd_v128_v128_v128_on_stack), v128_bitselect, Vector), + (Some(simd_v128_v128_v128_on_stack_relaxed), i8x16_laneselect, Vector), + (Some(simd_v128_v128_v128_on_stack_relaxed), i16x8_laneselect, Vector), + (Some(simd_v128_v128_v128_on_stack_relaxed), i32x4_laneselect, Vector), + (Some(simd_v128_v128_v128_on_stack_relaxed), i64x2_laneselect, Vector), + (Some(simd_v128_v128_on_stack), i8x16_eq, Vector), + (Some(simd_v128_v128_on_stack), i8x16_ne, Vector), + (Some(simd_v128_v128_on_stack), i8x16_lt_s, Vector), + (Some(simd_v128_v128_on_stack), i8x16_lt_u, Vector), + (Some(simd_v128_v128_on_stack), i8x16_gt_s, Vector), + (Some(simd_v128_v128_on_stack), i8x16_gt_u, Vector), + (Some(simd_v128_v128_on_stack), i8x16_le_s, Vector), + (Some(simd_v128_v128_on_stack), i8x16_le_u, Vector), + (Some(simd_v128_v128_on_stack), i8x16_ge_s, Vector), + (Some(simd_v128_v128_on_stack), i8x16_ge_u, Vector), + (Some(simd_v128_v128_on_stack), i16x8_eq, Vector), + (Some(simd_v128_v128_on_stack), i16x8_ne, Vector), + (Some(simd_v128_v128_on_stack), i16x8_lt_s, Vector), + (Some(simd_v128_v128_on_stack), i16x8_lt_u, Vector), + (Some(simd_v128_v128_on_stack), i16x8_gt_s, Vector), + (Some(simd_v128_v128_on_stack), i16x8_gt_u, Vector), + (Some(simd_v128_v128_on_stack), i16x8_le_s, Vector), + (Some(simd_v128_v128_on_stack), i16x8_le_u, Vector), + (Some(simd_v128_v128_on_stack), i16x8_ge_s, Vector), + (Some(simd_v128_v128_on_stack), i16x8_ge_u, Vector), + (Some(simd_v128_v128_on_stack), i32x4_eq, Vector), + (Some(simd_v128_v128_on_stack), i32x4_ne, Vector), + (Some(simd_v128_v128_on_stack), i32x4_lt_s, Vector), + (Some(simd_v128_v128_on_stack), i32x4_lt_u, Vector), + (Some(simd_v128_v128_on_stack), i32x4_gt_s, Vector), + (Some(simd_v128_v128_on_stack), i32x4_gt_u, Vector), + (Some(simd_v128_v128_on_stack), i32x4_le_s, Vector), + (Some(simd_v128_v128_on_stack), i32x4_le_u, Vector), + (Some(simd_v128_v128_on_stack), i32x4_ge_s, Vector), + (Some(simd_v128_v128_on_stack), i32x4_ge_u, Vector), + (Some(simd_v128_v128_on_stack), i64x2_eq, Vector), + (Some(simd_v128_v128_on_stack), i64x2_ne, Vector), + (Some(simd_v128_v128_on_stack), i64x2_lt_s, Vector), + (Some(simd_v128_v128_on_stack), i64x2_gt_s, Vector), + (Some(simd_v128_v128_on_stack), i64x2_le_s, Vector), + (Some(simd_v128_v128_on_stack), i64x2_ge_s, Vector), + (Some(simd_v128_v128_on_stack), f32x4_eq, Vector), + (Some(simd_v128_v128_on_stack), f32x4_ne, Vector), + (Some(simd_v128_v128_on_stack), f32x4_lt, Vector), + (Some(simd_v128_v128_on_stack), f32x4_gt, Vector), + (Some(simd_v128_v128_on_stack), f32x4_le, Vector), + (Some(simd_v128_v128_on_stack), f32x4_ge, Vector), + (Some(simd_v128_v128_on_stack), f64x2_eq, Vector), + (Some(simd_v128_v128_on_stack), f64x2_ne, Vector), + (Some(simd_v128_v128_on_stack), f64x2_lt, Vector), + (Some(simd_v128_v128_on_stack), f64x2_gt, Vector), + (Some(simd_v128_v128_on_stack), f64x2_le, Vector), + (Some(simd_v128_v128_on_stack), f64x2_ge, Vector), + (Some(simd_v128_on_stack), v128_not, Vector), + (Some(simd_v128_v128_on_stack), v128_and, Vector), + (Some(simd_v128_v128_on_stack), v128_and_not, Vector), + (Some(simd_v128_v128_on_stack), v128_or, Vector), + (Some(simd_v128_v128_on_stack), v128_xor, Vector), + (Some(simd_v128_v128_on_stack), v128_any_true, Vector), + (Some(simd_v128_on_stack), i8x16_abs, Vector), + (Some(simd_v128_on_stack), i8x16_neg, Vector), + (Some(simd_v128_on_stack), i8x16_popcnt, Vector), + (Some(simd_v128_on_stack), i8x16_all_true, Vector), + (Some(simd_v128_on_stack), i8x16_bitmask, Vector), + (Some(simd_v128_v128_on_stack), i8x16_narrow_i16x8s, Vector), + (Some(simd_v128_v128_on_stack), i8x16_narrow_i16x8u, Vector), + (Some(simd_v128_i32_on_stack), i8x16_shl, Vector), + (Some(simd_v128_i32_on_stack), i8x16_shr_s, Vector), + (Some(simd_v128_i32_on_stack), i8x16_shr_u, Vector), + (Some(simd_v128_v128_on_stack), i8x16_add, Vector), + (Some(simd_v128_v128_on_stack), i8x16_add_sat_s, Vector), + (Some(simd_v128_v128_on_stack), i8x16_add_sat_u, Vector), + (Some(simd_v128_v128_on_stack), i8x16_sub, Vector), + (Some(simd_v128_v128_on_stack), i8x16_sub_sat_s, Vector), + (Some(simd_v128_v128_on_stack), i8x16_sub_sat_u, Vector), + (Some(simd_v128_v128_on_stack), i8x16_min_s, Vector), + (Some(simd_v128_v128_on_stack), i8x16_min_u, Vector), + (Some(simd_v128_v128_on_stack), i8x16_max_s, Vector), + (Some(simd_v128_v128_on_stack), i8x16_max_u, Vector), + (Some(simd_v128_v128_on_stack), i8x16_rounding_average_u, Vector), + (Some(simd_v128_on_stack), i16x8_ext_add_pairwise_i8x16s, Vector), + (Some(simd_v128_on_stack), i16x8_ext_add_pairwise_i8x16u, Vector), + (Some(simd_v128_on_stack), i16x8_abs, Vector), + (Some(simd_v128_on_stack), i16x8_neg, Vector), + (Some(simd_v128_v128_on_stack), i16x8q15_mulr_sat_s, Vector), + (Some(simd_v128_on_stack), i16x8_all_true, Vector), + (Some(simd_v128_on_stack), i16x8_bitmask, Vector), + (Some(simd_v128_v128_on_stack), i16x8_narrow_i32x4s, Vector), + (Some(simd_v128_v128_on_stack), i16x8_narrow_i32x4u, Vector), + (Some(simd_v128_on_stack), i16x8_extend_low_i8x16s, Vector), + (Some(simd_v128_on_stack), i16x8_extend_high_i8x16s, Vector), + (Some(simd_v128_on_stack), i16x8_extend_low_i8x16u, Vector), + (Some(simd_v128_on_stack), i16x8_extend_high_i8x16u, Vector), + (Some(simd_v128_i32_on_stack), i16x8_shl, Vector), + (Some(simd_v128_i32_on_stack), i16x8_shr_s, Vector), + (Some(simd_v128_i32_on_stack), i16x8_shr_u, Vector), + (Some(simd_v128_v128_on_stack), i16x8_add, Vector), + (Some(simd_v128_v128_on_stack), i16x8_add_sat_s, Vector), + (Some(simd_v128_v128_on_stack), i16x8_add_sat_u, Vector), + (Some(simd_v128_v128_on_stack), i16x8_sub, Vector), + (Some(simd_v128_v128_on_stack), i16x8_sub_sat_s, Vector), + (Some(simd_v128_v128_on_stack), i16x8_sub_sat_u, Vector), + (Some(simd_v128_v128_on_stack), i16x8_mul, Vector), + (Some(simd_v128_v128_on_stack), i16x8_min_s, Vector), + (Some(simd_v128_v128_on_stack), i16x8_min_u, Vector), + (Some(simd_v128_v128_on_stack), i16x8_max_s, Vector), + (Some(simd_v128_v128_on_stack), i16x8_max_u, Vector), + (Some(simd_v128_v128_on_stack), i16x8_rounding_average_u, Vector), + (Some(simd_v128_v128_on_stack), i16x8_ext_mul_low_i8x16s, Vector), + (Some(simd_v128_v128_on_stack), i16x8_ext_mul_high_i8x16s, Vector), + (Some(simd_v128_v128_on_stack), i16x8_ext_mul_low_i8x16u, Vector), + (Some(simd_v128_v128_on_stack), i16x8_ext_mul_high_i8x16u, Vector), + (Some(simd_v128_on_stack), i32x4_ext_add_pairwise_i16x8s, Vector), + (Some(simd_v128_on_stack), i32x4_ext_add_pairwise_i16x8u, Vector), + (Some(simd_v128_on_stack), i32x4_abs, Vector), + (Some(simd_v128_on_stack), i32x4_neg, Vector), + (Some(simd_v128_on_stack), i32x4_all_true, Vector), + (Some(simd_v128_on_stack), i32x4_bitmask, Vector), + (Some(simd_v128_on_stack), i32x4_extend_low_i16x8s, Vector), + (Some(simd_v128_on_stack), i32x4_extend_high_i16x8s, Vector), + (Some(simd_v128_on_stack), i32x4_extend_low_i16x8u, Vector), + (Some(simd_v128_on_stack), i32x4_extend_high_i16x8u, Vector), + (Some(simd_v128_i32_on_stack), i32x4_shl, Vector), + (Some(simd_v128_i32_on_stack), i32x4_shr_s, Vector), + (Some(simd_v128_i32_on_stack), i32x4_shr_u, Vector), + (Some(simd_v128_v128_on_stack), i32x4_add, Vector), + (Some(simd_v128_v128_on_stack), i32x4_sub, Vector), + (Some(simd_v128_v128_on_stack), i32x4_mul, Vector), + (Some(simd_v128_v128_on_stack), i32x4_min_s, Vector), + (Some(simd_v128_v128_on_stack), i32x4_min_u, Vector), + (Some(simd_v128_v128_on_stack), i32x4_max_s, Vector), + (Some(simd_v128_v128_on_stack), i32x4_max_u, Vector), + (Some(simd_v128_v128_on_stack), i32x4_dot_i16x8s, Vector), + (Some(simd_v128_v128_on_stack), i32x4_ext_mul_low_i16x8s, Vector), + (Some(simd_v128_v128_on_stack), i32x4_ext_mul_high_i16x8s, Vector), + (Some(simd_v128_v128_on_stack), i32x4_ext_mul_low_i16x8u, Vector), + (Some(simd_v128_v128_on_stack), i32x4_ext_mul_high_i16x8u, Vector), + (Some(simd_v128_on_stack), i64x2_abs, Vector), + (Some(simd_v128_on_stack), i64x2_neg, Vector), + (Some(simd_v128_on_stack), i64x2_all_true, Vector), + (Some(simd_v128_on_stack), i64x2_bitmask, Vector), + (Some(simd_v128_on_stack), i64x2_extend_low_i32x4s, Vector), + (Some(simd_v128_on_stack), i64x2_extend_high_i32x4s, Vector), + (Some(simd_v128_on_stack), i64x2_extend_low_i32x4u, Vector), + (Some(simd_v128_on_stack), i64x2_extend_high_i32x4u, Vector), + (Some(simd_v128_i32_on_stack), i64x2_shl, Vector), + (Some(simd_v128_i32_on_stack), i64x2_shr_s, Vector), + (Some(simd_v128_i32_on_stack), i64x2_shr_u, Vector), + (Some(simd_v128_v128_on_stack), i64x2_add, Vector), + (Some(simd_v128_v128_on_stack), i64x2_sub, Vector), + (Some(simd_v128_v128_on_stack), i64x2_mul, Vector), + (Some(simd_v128_v128_on_stack), i64x2_ext_mul_low_i32x4s, Vector), + (Some(simd_v128_v128_on_stack), i64x2_ext_mul_high_i32x4s, Vector), + (Some(simd_v128_v128_on_stack), i64x2_ext_mul_low_i32x4u, Vector), + (Some(simd_v128_v128_on_stack), i64x2_ext_mul_high_i32x4u, Vector), + (Some(simd_v128_on_stack), f32x4_ceil, Vector), + (Some(simd_v128_on_stack), f32x4_floor, Vector), + (Some(simd_v128_on_stack), f32x4_trunc, Vector), + (Some(simd_v128_on_stack), f32x4_nearest, Vector), + (Some(simd_v128_on_stack), f32x4_abs, Vector), + (Some(simd_v128_on_stack), f32x4_neg, Vector), + (Some(simd_v128_on_stack), f32x4_sqrt, Vector), + (Some(simd_v128_v128_on_stack), f32x4_add, Vector), + (Some(simd_v128_v128_on_stack), f32x4_sub, Vector), + (Some(simd_v128_v128_on_stack), f32x4_mul, Vector), + (Some(simd_v128_v128_on_stack), f32x4_div, Vector), + (Some(simd_v128_v128_on_stack), f32x4_min, Vector), + (Some(simd_v128_v128_on_stack), f32x4_max, Vector), + (Some(simd_v128_v128_on_stack), f32x4p_min, Vector), + (Some(simd_v128_v128_on_stack), f32x4p_max, Vector), + (Some(simd_v128_on_stack), f64x2_ceil, Vector), + (Some(simd_v128_on_stack), f64x2_floor, Vector), + (Some(simd_v128_on_stack), f64x2_trunc, Vector), + (Some(simd_v128_on_stack), f64x2_nearest, Vector), + (Some(simd_v128_on_stack), f64x2_abs, Vector), + (Some(simd_v128_on_stack), f64x2_neg, Vector), + (Some(simd_v128_on_stack), f64x2_sqrt, Vector), + (Some(simd_v128_v128_on_stack), f64x2_add, Vector), + (Some(simd_v128_v128_on_stack), f64x2_sub, Vector), + (Some(simd_v128_v128_on_stack), f64x2_mul, Vector), + (Some(simd_v128_v128_on_stack), f64x2_div, Vector), + (Some(simd_v128_v128_on_stack), f64x2_min, Vector), + (Some(simd_v128_v128_on_stack), f64x2_max, Vector), + (Some(simd_v128_v128_on_stack), f64x2p_min, Vector), + (Some(simd_v128_v128_on_stack), f64x2p_max, Vector), + (Some(simd_v128_on_stack), i32x4_trunc_sat_f32x4s, Vector), + (Some(simd_v128_on_stack), i32x4_trunc_sat_f32x4u, Vector), + (Some(simd_v128_on_stack), f32x4_convert_i32x4s, Vector), + (Some(simd_v128_on_stack), f32x4_convert_i32x4u, Vector), + (Some(simd_v128_on_stack), i32x4_trunc_sat_f64x2s_zero, Vector), + (Some(simd_v128_on_stack), i32x4_trunc_sat_f64x2u_zero, Vector), + (Some(simd_v128_on_stack), f64x2_convert_low_i32x4s, Vector), + (Some(simd_v128_on_stack), f64x2_convert_low_i32x4u, Vector), + (Some(simd_v128_on_stack), f32x4_demote_f64x2_zero, Vector), + (Some(simd_v128_on_stack), f64x2_promote_low_f32x4, Vector), + (Some(simd_v128_on_stack_relaxed), i32x4_trunc_sat_f32x4s_relaxed, Vector), + (Some(simd_v128_on_stack_relaxed), i32x4_trunc_sat_f32x4u_relaxed, Vector), + (Some(simd_v128_on_stack_relaxed), i32x4_trunc_sat_f64x2s_zero_relaxed, Vector), + (Some(simd_v128_on_stack_relaxed), i32x4_trunc_sat_f64x2u_zero_relaxed, Vector), + (Some(simd_v128_v128_on_stack_relaxed), f32x4_fma_relaxed, Vector), + (Some(simd_v128_v128_on_stack_relaxed), f32x4_fms_relaxed, Vector), + (Some(simd_v128_v128_on_stack_relaxed), f64x2_fma_relaxed, Vector), + (Some(simd_v128_v128_on_stack_relaxed), f64x2_fms_relaxed, Vector), + (Some(simd_v128_v128_on_stack_relaxed), f32x4_min_relaxed, Vector), + (Some(simd_v128_v128_on_stack_relaxed), f32x4_max_relaxed, Vector), + (Some(simd_v128_v128_on_stack_relaxed), f64x2_min_relaxed, Vector), + (Some(simd_v128_v128_on_stack_relaxed), f64x2_max_relaxed, Vector), } pub(crate) struct CodeBuilderAllocations { diff --git a/crates/wasm-smith/src/config.rs b/crates/wasm-smith/src/config.rs index 184f81bb47..f34f787995 100644 --- a/crates/wasm-smith/src/config.rs +++ b/crates/wasm-smith/src/config.rs @@ -1,6 +1,8 @@ //! Configuring the shape of generated Wasm modules. +use crate::InstructionKind; use arbitrary::{Arbitrary, Result, Unstructured}; +use flagset::FlagSet; /// Configuration for a generated module. /// @@ -319,6 +321,21 @@ pub trait Config: 'static + std::fmt::Debug { fn canonicalize_nans(&self) -> bool { false } + + /// Returns the kinds of instructions allowed in the generated wasm + /// programs. + /// + /// The categories of instructions match the categories used by the + /// [WebAssembly + /// specification](https://webassembly.github.io/spec/core/syntax/instructions.html); + /// e.g., numeric, vector, control, memory, etc. Note that modifying this + /// setting is separate from the proposal flags; that is, if `simd_enabled() + /// == true` but `allowed_instruction_kinds()` does not include vector + /// instructions, the generated programs will not include these instructions + /// but could contain vector types. + fn allowed_instructions(&self) -> FlagSet { + FlagSet::full() + } } /// The default configuration. diff --git a/crates/wasm-smith/src/lib.rs b/crates/wasm-smith/src/lib.rs index 26607a6c66..6fcfa4e9a7 100644 --- a/crates/wasm-smith/src/lib.rs +++ b/crates/wasm-smith/src/lib.rs @@ -74,12 +74,13 @@ mod terminate; use crate::code_builder::CodeBuilderAllocations; use arbitrary::{Arbitrary, Result, Unstructured}; +use flagset::{flags, FlagSet}; use std::collections::{HashMap, HashSet}; use std::convert::TryFrom; use std::marker; use std::ops::Range; use std::rc::Rc; -use std::str; +use std::str::{self}; use wasm_encoder::{BlockType, Export, GlobalType, ItemKind, MemoryType, TableType, ValType}; pub use config::{Config, DefaultConfig, SwarmConfig}; @@ -2456,3 +2457,40 @@ struct Outer { types: Vec, modules: Vec>, } + +flags! { + /// Enumerate the categories of instructions defined in the [WebAssembly + /// specification](https://webassembly.github.io/spec/core/syntax/instructions.html). + #[allow(missing_docs)] + pub enum InstructionKind: u16 { + Numeric, + Vector, + Reference, + Parametric, + Variable, + Table, + Memory, + Control, + } +} + +/// Parse a comma-separated list of instruction kinds into a `FlagSet`. +pub fn parse_instruction_kinds(s: &str) -> std::result::Result, String> { + let mut kinds = FlagSet::::default(); + for s in s.split(",") { + let matched = match s.to_lowercase().as_str() { + "numeric" => InstructionKind::Numeric, + "vector" => InstructionKind::Vector, + "reference" => InstructionKind::Reference, + "parametric" => InstructionKind::Parametric, + "variable" => InstructionKind::Variable, + "table" => InstructionKind::Table, + "memory" => InstructionKind::Memory, + "control" => InstructionKind::Control, + _ => return Err(format!("unknown instruction kind: {}", s)), + }; + kinds |= matched; + } + println!("Parsed kinds: {:?}", kinds); + Ok(kinds) +} diff --git a/src/bin/wasm-smith.rs b/src/bin/wasm-smith.rs index a43b7553a5..1448080a94 100644 --- a/src/bin/wasm-smith.rs +++ b/src/bin/wasm-smith.rs @@ -1,11 +1,12 @@ use anyhow::Context; use arbitrary::Arbitrary; +use flagset::FlagSet; use std::fs; use std::io::{stdin, stdout, Read, Write}; use std::path::PathBuf; use std::process; use structopt::StructOpt; -use wasm_smith::{MaybeInvalidModule, Module}; +use wasm_smith::{parse_instruction_kinds, InstructionKind, MaybeInvalidModule, Module}; /// A WebAssembly test case generator. /// @@ -163,6 +164,14 @@ struct Config { memory64_enabled: Option, #[structopt(long = "canonicalize-nans")] canonicalize_nans: Option, + /// Limit what kinds of instructions are allowed. + /// + /// By default, all kinds are allowed; available kinds: numeric, vector, + /// reference, parametric, variable, table, memory, control. Specify + /// multiple kinds with a comma-separated list: e.g., + /// `--allowed-instructions numeric,control,parametric` + #[structopt(long = "allowed-instructions", parse(try_from_str = parse_instruction_kinds))] + allowed_instructions: Option>, } fn main() -> anyhow::Result<()> { @@ -297,6 +306,7 @@ impl wasm_smith::Config for CliAndJsonConfig { (max_nesting_depth, usize, 1000), (max_type_size, u32, 1000), (canonicalize_nans, bool, false), + (allowed_instructions, FlagSet, FlagSet::default()), } fn max_memory_pages(&self, _is_64: bool) -> u64 {