├── .gitattributes ├── .gitignore ├── Cargo.toml ├── LICENSE.md ├── README.md ├── build.rs ├── src ├── ast.rs ├── binary.rs ├── interpreter.rs ├── lib.rs ├── ops.rs ├── runtime.rs ├── types.rs ├── valid.rs └── values.rs └── tests ├── README.md ├── run_suite.rs ├── script ├── mod.rs ├── parser.rs └── run.rs └── suite ├── address.bin.wast ├── align.bin.wast ├── binary-leb128.bin.wast ├── binary.bin.wast ├── block.bin.wast ├── br.bin.wast ├── br_if.bin.wast ├── br_table.bin.wast ├── break-drop.bin.wast ├── call.bin.wast ├── call_indirect.bin.wast ├── comments.bin.wast ├── const.bin.wast ├── conversions.bin.wast ├── custom.bin.wast ├── custom_section.bin.wast ├── data.bin.wast ├── elem.bin.wast ├── endianness.bin.wast ├── exports.bin.wast ├── f32.bin.wast ├── f32_bitwise.bin.wast ├── f32_cmp.bin.wast ├── f64.bin.wast ├── f64_bitwise.bin.wast ├── f64_cmp.bin.wast ├── fac.bin.wast ├── float_exprs.bin.wast ├── float_literals.bin.wast ├── float_memory.bin.wast ├── float_misc.bin.wast ├── forward.bin.wast ├── func.bin.wast ├── func_ptrs.bin.wast ├── get_local.bin.wast ├── globals.bin.wast ├── i32.bin.wast ├── i64.bin.wast ├── if.bin.wast ├── imports.bin.wast ├── inline-module.bin.wast ├── int_exprs.bin.wast ├── int_literals.bin.wast ├── labels.bin.wast ├── left-to-right.bin.wast ├── linking.bin.wast ├── load.bin.wast ├── local_get.bin.wast ├── local_set.bin.wast ├── local_tee.bin.wast ├── loop.bin.wast ├── memory.bin.wast ├── memory_grow.bin.wast ├── memory_redundancy.bin.wast ├── memory_size.bin.wast ├── memory_trap.bin.wast ├── names.bin.wast ├── nop.bin.wast ├── resizing.bin.wast ├── return.bin.wast ├── select.bin.wast ├── set_local.bin.wast ├── skip-stack-guard-page.bin.wast ├── stack.bin.wast ├── start.bin.wast ├── store.bin.wast ├── store_retval.bin.wast ├── switch.bin.wast ├── tee_local.bin.wast ├── token.bin.wast ├── traps.bin.wast ├── type.bin.wast ├── typecheck.bin.wast ├── unreachable.bin.wast ├── unreached-invalid.bin.wast ├── unwind.bin.wast ├── utf8-custom-section-id.bin.wast ├── utf8-import-field.bin.wast ├── utf8-import-module.bin.wast └── utf8-invalid-encoding.bin.wast /.gitattributes: -------------------------------------------------------------------------------- 1 | tests/suite/* linguist-vendored 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | **/*.rs.bk 3 | Cargo.lock 4 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rust-wasm" 3 | version = "0.1.0" 4 | authors = ["Yoann Blein ", "Hugo Guiroux "] 5 | build = "build.rs" 6 | 7 | [dependencies] 8 | 9 | [dev-dependencies] 10 | hexf-parse = "0.1.0" 11 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright 2017 Yoann Blein & Hugo Guiroux 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 4 | 5 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rust-WASM 2 | 3 | A [WASM](http://webassembly.org/) interpreter written in Rust. 4 | 5 | Except for parsing the text format, the implementation is complete, i.e., all the [specification](https://webassembly.github.io/spec/core/index.html) is implemented and the [official test suite](https://github.com/WebAssembly/spec/tree/master/test) is fully covered (as of 2019-10-27). 6 | 7 | ## Getting Started 8 | 9 | The project is composed of a library (`rust_wasm`) as well as a test suite. 10 | 11 | ### Prerequisites 12 | 13 | You need [Rust (at least 1.34.0)](https://www.rustup.rs/) to build the project. 14 | 15 | ### Building the library 16 | 17 | ```bash 18 | cargo build [--release] 19 | ``` 20 | 21 | ## Running the tests 22 | 23 | ```bash 24 | cargo test 25 | ``` 26 | 27 | ## Using the API 28 | 29 | The [official embedding API](https://webassembly.github.io/spec/core/appendix/embedding.html) is supported. 30 | Because the API specification is written in a pure style, we slightly modified it to best fit Rust (e.g., using mutable reference instead of returning a new store each time). 31 | 32 | ### Invoking the `main` function 33 | 34 | ```rust 35 | use rust_wasm::*; 36 | use std::fs::File; 37 | use std::io::BufReader; 38 | 39 | fn main() { 40 | let mut store = init_store(); 41 | 42 | let f = File::open("filename").unwrap(); 43 | let module = decode_module(BufReader::new(f)).unwrap(); 44 | let module_instance = instantiate_module(&mut store, module, &[]).unwrap(); 45 | 46 | if let ExternVal::Func(main_addr) = get_export(&module_instance, "main").unwrap() { 47 | let res = invoke_func(&mut store, main_addr, Vec::new()); 48 | println!("{:?}", res); 49 | } 50 | } 51 | ``` 52 | 53 | ### Listing module exports/imports 54 | 55 | ```rust 56 | use rust_wasm::*; 57 | use std::fs::File; 58 | use std::io::BufReader; 59 | 60 | fn main() { 61 | let f = File::open("filename").unwrap(); 62 | let module = decode_module(BufReader::new(f)).unwrap(); 63 | let mod_exports = module_exports(&module); 64 | let mod_imports = module_imports(&module); 65 | } 66 | ``` 67 | 68 | ### Declaring a host function 69 | 70 | ```rust 71 | use rust_wasm::*; 72 | 73 | fn main() { 74 | let mut store = init_store(); 75 | let func_type = types::Func { args: vec![types::I32, types::F64], result: vec![types::I64] }; 76 | let print_count_args = |args: &[values::Value], ret: &mut[values::Value]| { 77 | println!("{:?}", args); 78 | ret[0] = values::Value::I64(args.len() as u64); 79 | None 80 | }; 81 | let func_addr = alloc_func(&mut store, &func_type, Box::new(print_count_args)); 82 | } 83 | ``` 84 | 85 | ### Managing imports resolution when instantiating multiple modules 86 | 87 | This is left to the embedder. Nonetheless, you can see a working example inside `tests/scripts/run.rs`. 88 | 89 | ## Authors 90 | 91 | * **[Yoann Blein](https://github.com/yblein)** 92 | * **[Hugo Guiroux](https://github.com/HugoGuiroux)** 93 | -------------------------------------------------------------------------------- /build.rs: -------------------------------------------------------------------------------- 1 | use std::fs::{self, File}; 2 | use std::io::prelude::*; 3 | use std::env; 4 | use std::path::Path; 5 | 6 | fn main() { 7 | // generate a driver for the test suite 8 | let out_dir = env::var("OUT_DIR").unwrap(); 9 | let dest_path = Path::new(&out_dir).join("test_suite.rs"); 10 | let mut f = File::create(dest_path).unwrap(); 11 | 12 | for entry in fs::read_dir("tests/suite").unwrap() { 13 | let path = entry.unwrap().path(); 14 | let name = path.file_name().unwrap().to_str().unwrap().split('.').next().unwrap().replace("-", "_"); 15 | 16 | write!(f, 17 | "#[test] 18 | fn run_{}() {{ 19 | script::run(\"{}\"); 20 | }}\n", 21 | name, 22 | path.display(), 23 | ).unwrap(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/ast.rs: -------------------------------------------------------------------------------- 1 | use types; 2 | use values; 3 | 4 | #[derive(Debug)] 5 | pub enum IUnOp { 6 | Clz, Ctz, Popcnt, 7 | } 8 | 9 | #[derive(Debug)] 10 | pub enum FUnOp { 11 | Neg, Abs, Ceil, Floor, Trunc, Nearest, Sqrt, 12 | } 13 | 14 | #[derive(Debug)] 15 | pub enum IBinOp { 16 | Add, Sub, Mul, DivS, DivU, RemS, RemU, And, Or, Xor, Shl, ShrS, ShrU, Rotl, Rotr, 17 | } 18 | 19 | #[derive(Debug)] 20 | pub enum FBinOp { 21 | Add, Sub, Mul, Div, Min, Max, CopySign, 22 | } 23 | 24 | #[derive(Debug)] 25 | pub enum ITestOp { 26 | Eqz, 27 | } 28 | 29 | #[derive(Debug)] 30 | pub enum IRelOp { 31 | Eq_, Ne, LtS, LtU, GtS, GtU, LeS, LeU, GeS, GeU, 32 | } 33 | 34 | #[derive(Debug)] 35 | pub enum FRelOp { 36 | Eq_, Ne, Lt, Gt, Le, Ge 37 | } 38 | 39 | #[derive(Debug)] 40 | pub enum ConvertOp { 41 | I32WrapI64, 42 | I64ExtendUI32, 43 | I64ExtendSI32, 44 | Trunc { from: types::Float, to: types::Int, signed: bool }, 45 | Convert { from: types::Int, to: types::Float, signed: bool }, 46 | Reinterpret { from: types::Value, to: types::Value }, 47 | F32DemoteF64, 48 | F64PromoteF32, 49 | } 50 | 51 | #[derive(Debug)] 52 | pub struct MemOp { 53 | pub align: u32, 54 | pub offset: u32, 55 | pub type_: types::Value, 56 | pub opt: Option, 57 | } 58 | 59 | /// A memory load with optional size and sign 60 | pub type LoadOp = MemOp<(u32, bool)>; 61 | 62 | /// A memory store with optional size 63 | pub type StoreOp = MemOp<(u32)>; 64 | 65 | #[derive(Debug)] 66 | pub enum Instr { 67 | Unreachable, // trap unconditionally 68 | Nop, // do nothing 69 | Block(Vec, Vec), // execute in sequence 70 | Loop(Vec, Vec), // loop header 71 | If(Vec, Vec, Vec), // conditional 72 | Br(Index), // break to n-th surrounding label 73 | BrIf(Index), // conditional break 74 | BrTable(Vec, Index), // indexed break 75 | Return, // break from function body 76 | Call(Index), // call function 77 | CallIndirect(Index), // call function through table 78 | Drop_, // forget a value 79 | Select, // branchless conditional 80 | GetLocal(Index), // read local variable 81 | SetLocal(Index), // write local variable 82 | TeeLocal(Index), // write local variable and keep value 83 | GetGlobal(Index), // read global variable 84 | SetGlobal(Index), // write global variable 85 | Load(LoadOp), // read memory at address 86 | Store(StoreOp), // write memory at address 87 | CurrentMemory, // size(linear memory 88 | GrowMemory, // grow linear memory 89 | Const(values::Value), // constant 90 | IUnary(types::Int, IUnOp), // integer unary numeric operators 91 | FUnary(types::Float, FUnOp), // floating unary numeric operators 92 | IBin(types::Int, IBinOp), // integer binary numeric operators 93 | FBin(types::Float, FBinOp), // floating binary numeric operators 94 | ITest(types::Int, ITestOp), // integer numeric test 95 | IRel(types::Int, IRelOp), // integer numeric comparison 96 | FRel(types::Float, FRelOp), // floating numeric comparison 97 | Convert(ConvertOp), // conversion 98 | } 99 | 100 | pub type Expr = Vec; 101 | 102 | #[derive(Debug)] 103 | pub struct Module { 104 | pub types: Vec, 105 | pub funcs: Vec, 106 | pub tables: Vec, 107 | pub memories: Vec, 108 | pub globals: Vec, 109 | pub elems: Vec>, // initial values for tables 110 | pub data: Vec>, // initial values for memories 111 | pub start: Option, // optionnal index to a start function 112 | pub imports: Vec, 113 | pub exports: Vec, 114 | } 115 | 116 | pub type Index = u32; 117 | 118 | #[derive(Debug)] 119 | pub struct Func { 120 | pub type_index: Index, 121 | pub locals: Vec, 122 | pub body: Expr, 123 | } 124 | 125 | #[derive(Debug)] 126 | pub struct Table { 127 | pub type_: types::Table, 128 | } 129 | 130 | #[derive(Debug)] 131 | pub struct Memory { 132 | pub type_: types::Memory, 133 | } 134 | 135 | #[derive(Debug)] 136 | pub struct Global { 137 | pub type_: types::Global, 138 | pub value: Expr, // NB: Must be constant 139 | } 140 | 141 | #[derive(Debug)] 142 | pub struct Segment { 143 | pub index: Index, 144 | pub offset: Expr, // NB: Must be constant 145 | pub init: Vec, 146 | } 147 | 148 | #[derive(Debug)] 149 | pub struct Export { 150 | pub name: String, 151 | pub desc: ExportDesc, 152 | } 153 | 154 | #[derive(Debug)] 155 | pub enum ExportDesc { 156 | Func(Index), 157 | Table(Index), 158 | Memory(Index), 159 | Global(Index), 160 | } 161 | 162 | #[derive(Debug)] 163 | pub struct Import { 164 | pub module: String, 165 | pub name: String, 166 | pub desc: ImportDesc, 167 | } 168 | 169 | #[derive(Debug)] 170 | pub enum ImportDesc { 171 | Func(Index), 172 | Table(types::Table), 173 | Memory(types::Memory), 174 | Global(types::Global), 175 | } 176 | 177 | impl Import { 178 | pub fn type_(&self, module: &Module) -> types::Extern { 179 | match self.desc { 180 | ImportDesc::Func(idx) => types::Extern::Func(module.types[idx as usize].clone()), 181 | ImportDesc::Table(ref t) => types::Extern::Table(t.clone()), 182 | ImportDesc::Memory(ref t) => types::Extern::Memory(t.clone()), 183 | ImportDesc::Global(ref t) => types::Extern::Global(t.clone()), 184 | } 185 | } 186 | } 187 | 188 | 189 | // Helper function for tests 190 | impl Module { 191 | // Right now, we cannot only publish this function for test 192 | // See https://github.com/rust-lang/rust/issues/45599 193 | // #[cfg(test)] 194 | pub fn empty() -> Module { 195 | Module { 196 | types: Vec::new(), 197 | funcs: Vec::new(), 198 | tables: Vec::new(), 199 | memories: Vec::new(), 200 | globals: Vec::new(), 201 | elems: Vec::new(), 202 | data: Vec::new(), 203 | start: None, 204 | imports: Vec::new(), 205 | exports: Vec::new(), 206 | } 207 | } 208 | } 209 | -------------------------------------------------------------------------------- /src/ops.rs: -------------------------------------------------------------------------------- 1 | use std; 2 | use std::ops::*; 3 | 4 | use core::ptr::copy_nonoverlapping; 5 | 6 | pub trait IntOp { 7 | type FloatType; 8 | 9 | // IUnOp 10 | fn leading_zeros(self) -> Self; 11 | fn trailing_zeros(self) -> Self; 12 | fn count_ones(self) -> Self; 13 | 14 | // IBinOp 15 | fn add(self, rhs: Self) -> Self; 16 | fn sub(self, rhs: Self) -> Self; 17 | fn mul(self, rhs: Self) -> Self; 18 | fn divs(self, rhs: Self) -> Option; 19 | fn divu(self, rhs: Self) -> Option; 20 | fn rems(self, rhs: Self) -> Option; 21 | fn remu(self, rhs: Self) -> Option; 22 | fn and(self, rhs: Self) -> Self; 23 | fn or(self, rhs: Self) -> Self; 24 | fn xor(self, rhs: Self) -> Self; 25 | fn shl(self, rhs: Self) -> Self; 26 | fn shrs(self, rhs: Self) -> Self; 27 | fn shru(self, rhs: Self) -> Self; 28 | fn rotr(self, rhs: Self) -> Self; 29 | fn rotl(self, rhs: Self) -> Self; 30 | 31 | // ITestOp 32 | fn eqz(self) -> bool; 33 | 34 | // IRelOp 35 | fn eq(self, rhs: Self) -> bool; 36 | fn ne(self, rhs: Self) -> bool; 37 | fn lts(self, rhs: Self) -> bool; 38 | fn ltu(self, rhs: Self) -> bool; 39 | fn gts(self, rhs: Self) -> bool; 40 | fn gtu(self, rhs: Self) -> bool; 41 | fn les(self, rhs: Self) -> bool; 42 | fn leu(self, rhs: Self) -> bool; 43 | fn ges(self, rhs: Self) -> bool; 44 | fn geu(self, rhs: Self) -> bool; 45 | 46 | // ConvertOp 47 | fn to_u32(self) -> u32; 48 | fn to_u64(self) -> u64; 49 | fn to_i64(self) -> i64; 50 | fn to_uf32(self) -> f32; // Unsigned convert to f32 51 | fn to_if32(self) -> f32; // Signed convert to f32 52 | fn to_uf64(self) -> f64; 53 | fn to_if64(self) -> f64; 54 | fn reinterpret(self) -> Self::FloatType; 55 | } 56 | 57 | macro_rules! impl_int_op { 58 | ($T:ty, $S:ty, $U:ty, $F:ty) => ( 59 | impl IntOp for $T { 60 | type FloatType=$F; 61 | 62 | #[inline] 63 | fn leading_zeros(self) -> $T { 64 | <$T>::leading_zeros(self) as $T 65 | } 66 | 67 | #[inline] 68 | fn trailing_zeros(self) -> $T { 69 | <$T>::trailing_zeros(self) as $T 70 | } 71 | 72 | #[inline] 73 | fn count_ones(self) -> $T { 74 | <$T>::count_ones(self) as $T 75 | } 76 | 77 | #[inline] 78 | fn add(self, rhs: $T) -> $T { 79 | <$T>::wrapping_add(self, rhs) 80 | } 81 | 82 | #[inline] 83 | fn sub(self, rhs: $T) -> $T { 84 | <$T>::wrapping_sub(self, rhs) 85 | } 86 | 87 | #[inline] 88 | fn mul(self, rhs: $T) -> $T { 89 | <$T>::wrapping_mul(self, rhs) 90 | } 91 | 92 | #[inline] 93 | fn divs(self, rhs: $T) -> Option<$T> { 94 | let s_self = self as $S; 95 | let s_rhs = rhs as $S; 96 | match <$S>::checked_div(s_self, s_rhs) { 97 | Some(c) => Some(c as $T), 98 | None => None 99 | } 100 | } 101 | 102 | #[inline] 103 | fn divu(self, rhs: $T) -> Option<$T> { 104 | <$T>::checked_div(self, rhs) 105 | } 106 | 107 | #[inline] 108 | fn rems(self, rhs: $T) -> Option<$T> { 109 | if rhs == 0 { 110 | return None 111 | } 112 | let s_self = self as $S; 113 | let s_rhs = rhs as $S; 114 | Some(<$S>::wrapping_rem(s_self, s_rhs) as $T) 115 | } 116 | 117 | #[inline] 118 | fn remu(self, rhs: $T) -> Option<$T> { 119 | <$T>::checked_rem(self, rhs) 120 | } 121 | 122 | #[inline] 123 | fn and(self, rhs: $T) -> $T { 124 | <$T>::bitand(self, rhs) 125 | } 126 | 127 | #[inline] 128 | fn or(self, rhs: $T) -> $T { 129 | <$T>::bitor(self, rhs) 130 | } 131 | 132 | #[inline] 133 | fn xor(self, rhs: $T) -> $T { 134 | <$T>::bitxor(self, rhs) 135 | } 136 | 137 | #[inline] 138 | fn shl(self, rhs: $T) -> $T { 139 | <$T>::wrapping_shl(self, rhs as u32) 140 | } 141 | 142 | #[inline] 143 | fn shrs(self, rhs: $T) -> $T { 144 | let s_self = self as $S; 145 | <$S>::wrapping_shr(s_self, rhs as u32) as $T 146 | } 147 | 148 | #[inline] 149 | fn shru(self, rhs: $T) -> $T { 150 | <$T>::wrapping_shr(self, rhs as u32) 151 | } 152 | 153 | #[inline] 154 | fn rotr(self, rhs: $T) -> $T { 155 | <$T>::rotate_right(self, rhs as u32) 156 | } 157 | 158 | #[inline] 159 | fn rotl(self, rhs: $T) -> $T { 160 | <$T>::rotate_left(self, rhs as u32) 161 | } 162 | 163 | #[inline] 164 | fn eqz(self) -> bool { 165 | self == 0 166 | } 167 | 168 | #[inline] 169 | fn eq(self, rhs: $T) -> bool { 170 | self == rhs 171 | } 172 | 173 | #[inline] 174 | fn ne(self, rhs: $T) -> bool { 175 | self != rhs 176 | } 177 | 178 | #[inline] 179 | fn lts(self, rhs: $T) -> bool { 180 | (self as $S) < (rhs as $S) 181 | } 182 | 183 | #[inline] 184 | fn ltu(self, rhs: $T) -> bool { 185 | self < rhs 186 | } 187 | 188 | #[inline] 189 | fn gts(self, rhs: $T) -> bool { 190 | (self as $S) > (rhs as $S) 191 | } 192 | 193 | #[inline] 194 | fn gtu(self, rhs: $T) -> bool { 195 | self > rhs 196 | } 197 | 198 | #[inline] 199 | fn les(self, rhs: $T) -> bool { 200 | (self as $S) <= (rhs as $S) 201 | } 202 | 203 | #[inline] 204 | fn leu(self, rhs: $T) -> bool { 205 | self <= rhs 206 | } 207 | 208 | #[inline] 209 | fn ges(self, rhs: $T) -> bool { 210 | (self as $S) >= (rhs as $S) 211 | } 212 | 213 | #[inline] 214 | fn geu(self, rhs: $T) -> bool { 215 | self >= rhs 216 | } 217 | 218 | #[inline] 219 | fn to_u32(self) -> u32 { 220 | self as u32 221 | } 222 | 223 | #[inline] 224 | fn to_u64(self) -> u64 { 225 | self as u64 226 | } 227 | 228 | #[inline] 229 | fn to_i64(self) -> i64 { 230 | (self as $S) as i64 231 | } 232 | 233 | #[inline] 234 | fn to_uf32(self) -> f32 { 235 | self as f32 236 | } 237 | 238 | #[inline] 239 | fn to_if32(self) -> f32 { 240 | (self as $S) as f32 241 | } 242 | 243 | #[inline] 244 | fn to_uf64(self) -> f64 { 245 | self as f64 246 | } 247 | 248 | #[inline] 249 | fn to_if64(self) -> f64 { 250 | (self as $S) as f64 251 | } 252 | 253 | #[inline] 254 | fn reinterpret(self) -> $F { 255 | <$F>::from_bits(self) 256 | } 257 | } 258 | ) 259 | } 260 | impl_int_op!(u32, i32, u32, f32); 261 | impl_int_op!(u64, i64, u64, f64); 262 | 263 | // From crate byteorder 264 | macro_rules! impl_bits_ops { 265 | ($ty:ty, $size:expr) => { 266 | impl BitsOp for $ty { 267 | 268 | #[inline] 269 | fn from_bits(src: &[u8]) -> $ty { 270 | assert!($size == std::mem::size_of::<$ty>()); 271 | assert!($size <= src.len()); 272 | let mut data: $ty = 0; 273 | unsafe { 274 | copy_nonoverlapping( 275 | src.as_ptr(), 276 | &mut data as *mut $ty as *mut u8, 277 | $size); 278 | } 279 | data.to_le() 280 | } 281 | 282 | #[inline] 283 | fn to_bits(self, dst: &mut [u8]) { 284 | assert!($size == std::mem::size_of::<$ty>()); 285 | assert_eq!($size, dst.len()); 286 | 287 | unsafe { 288 | copy_nonoverlapping( 289 | [self].as_ptr() as *const u8, 290 | dst.as_mut_ptr(), 291 | dst.len()); 292 | } 293 | } 294 | } 295 | } 296 | } 297 | 298 | pub trait BitsOp { 299 | // MemOp 300 | fn from_bits(src: &[u8]) -> Self; 301 | fn to_bits(self, dst: &mut [u8]); 302 | } 303 | 304 | impl_bits_ops!(u8, 1); 305 | impl_bits_ops!(i8, 1); 306 | impl_bits_ops!(u16, 2); 307 | impl_bits_ops!(i16, 2); 308 | impl_bits_ops!(u32, 4); 309 | impl_bits_ops!(i32, 4); 310 | impl_bits_ops!(u64, 8); 311 | impl_bits_ops!(i64, 8); 312 | 313 | pub trait FloatOp { 314 | type IntType; 315 | 316 | // FUnOp 317 | fn neg(self) -> Self; 318 | fn abs(self) -> Self; 319 | fn ceil(self) -> Self; 320 | fn floor(self) -> Self; 321 | fn trunc(self) -> Self; 322 | /// round-to-nearest ties-to-even 323 | fn nearest(self) -> Self; 324 | fn sqrt(self) -> Self; 325 | 326 | // FBinOp 327 | fn add(self, rhs: Self) -> Self; 328 | fn sub(self, rhs: Self) -> Self; 329 | fn mul(self, rhs: Self) -> Self; 330 | fn div(self, rhs: Self) -> Self; 331 | fn min(self, rhs: Self) -> Self; 332 | fn max(self, rhs: Self) -> Self; 333 | fn copysign(self, rhs: Self) -> Self; 334 | 335 | // FRelOp 336 | fn eq(self, rhs: Self) -> bool; 337 | fn ne(self, rhs: Self) -> bool; 338 | fn lt(self, rhs: Self) -> bool; 339 | fn gt(self, rhs: Self) -> bool; 340 | fn le(self, rhs: Self) -> bool; 341 | fn ge(self, rhs: Self) -> bool; 342 | 343 | // Convert 344 | fn to_i32(self) -> Option; 345 | fn to_i64(self) -> Option; 346 | fn to_u32(self) -> Option; 347 | fn to_u64(self) -> Option; 348 | fn reinterpret(self) -> Self::IntType; 349 | 350 | // Canonical NaN 351 | fn is_canonical_nan(self) -> bool; 352 | } 353 | 354 | macro_rules! impl_convert_float_s { 355 | ($T:ty, $U:ty, $N:ident) => ( 356 | #[inline] 357 | fn $N(self) -> Option<$U> { 358 | if self.is_nan() { 359 | None 360 | } else { 361 | if self >= -(<$U>::min_value() as $T) || self < <$U>::min_value() as $T { 362 | None 363 | } else { 364 | Some(self.trunc() as $U) 365 | } 366 | } 367 | } 368 | ) 369 | } 370 | 371 | macro_rules! impl_convert_float_u { 372 | ($T:ty, $U:ty, $S:ty, $N:ident) => ( 373 | #[inline] 374 | fn $N(self) -> Option<$U> { 375 | if self.is_nan() { 376 | None 377 | } else { 378 | if self >= -(<$S>::min_value() as $T) * 2.0 || self <= -1.0 { 379 | None 380 | } else { 381 | Some(self.trunc() as $U) 382 | } 383 | } 384 | } 385 | ) 386 | } 387 | 388 | macro_rules! impl_float_op { 389 | ($T:ty, $I:ty, $SB:expr, $NAN:expr) => ( 390 | impl FloatOp for $T { 391 | type IntType = $I; 392 | 393 | #[inline] 394 | fn neg(self) -> $T { 395 | std::ops::Neg::neg(self) 396 | } 397 | 398 | #[inline] 399 | fn abs(self) -> $T { 400 | <$T>::abs(self) 401 | } 402 | 403 | #[inline] 404 | fn ceil(self) -> $T { 405 | <$T>::ceil(self) 406 | } 407 | 408 | #[inline] 409 | fn floor(self) -> $T { 410 | <$T>::floor(self) 411 | } 412 | 413 | #[inline] 414 | fn trunc(self) -> $T { 415 | <$T>::trunc(self) 416 | } 417 | 418 | #[inline] 419 | fn nearest(self) -> $T { 420 | // Implementation from 421 | // https://github.com/WebAssembly/spec/blob/fb7e7e1e381ffc283c923a87fdfea5ebbd213737/interpreter/exec/float.ml#L148 422 | 423 | // preserve the sign of 0 424 | if self == 0.0 { 425 | return self; 426 | } 427 | if self.is_nan() { 428 | return $NAN 429 | } 430 | let u = self.ceil(); 431 | let d = self.floor(); 432 | let um = (self - u).abs(); 433 | let dm = (self - d).abs(); 434 | let half_u = u / 2.0; 435 | if um < dm || um == dm && half_u.floor() == half_u { u } else { d } 436 | } 437 | 438 | #[inline] 439 | fn sqrt(self) -> $T { 440 | <$T>::sqrt(self) 441 | } 442 | 443 | #[inline] 444 | fn add(self, rhs: $T) -> $T { 445 | self + rhs 446 | } 447 | 448 | #[inline] 449 | fn sub(self, rhs: $T) -> $T { 450 | self - rhs 451 | } 452 | 453 | #[inline] 454 | fn mul(self, rhs: $T) -> $T { 455 | self * rhs 456 | } 457 | 458 | #[inline] 459 | fn div(self, rhs: $T) -> $T { 460 | self / rhs 461 | } 462 | 463 | #[inline] 464 | fn min(self, rhs: $T) -> $T { 465 | // min(-0.0, 0.0) == -0.0 466 | if self == rhs { 467 | (self.to_bits() | rhs.to_bits()).reinterpret() 468 | } else if self < rhs { 469 | self 470 | } else if self > rhs { 471 | rhs 472 | } else { 473 | $NAN 474 | } 475 | } 476 | 477 | #[inline] 478 | fn max(self, rhs: $T) -> $T { 479 | // max(-0.0, 0.0) == 0.0 480 | if self == rhs { 481 | (self.to_bits() & rhs.to_bits()).reinterpret() 482 | } else if self > rhs { 483 | self 484 | } else if self < rhs { 485 | rhs 486 | } else { 487 | $NAN 488 | } 489 | } 490 | 491 | #[inline] 492 | fn copysign(self, rhs: $T) -> $T { 493 | self.copysign(rhs) 494 | } 495 | 496 | #[inline] 497 | fn eq(self, rhs: $T) -> bool { 498 | self == rhs 499 | } 500 | 501 | #[inline] 502 | fn ne(self, rhs: $T) -> bool { 503 | self != rhs 504 | } 505 | 506 | #[inline] 507 | fn lt(self, rhs: $T) -> bool { 508 | self < rhs 509 | } 510 | 511 | #[inline] 512 | fn gt(self, rhs: $T) -> bool { 513 | self > rhs 514 | } 515 | 516 | #[inline] 517 | fn le(self, rhs: $T) -> bool { 518 | self <= rhs 519 | } 520 | 521 | #[inline] 522 | fn ge(self, rhs: $T) -> bool { 523 | self >= rhs 524 | } 525 | 526 | impl_convert_float_s!($T, i32, to_i32); 527 | impl_convert_float_s!($T, i64, to_i64); 528 | impl_convert_float_u!($T, u32, i32, to_u32); 529 | impl_convert_float_u!($T, u64, i64, to_u64); 530 | 531 | #[inline] 532 | fn reinterpret(self) -> $I { 533 | self.to_bits() 534 | } 535 | 536 | #[inline] 537 | fn is_canonical_nan(self) -> bool { 538 | self.to_bits() == $NAN.to_bits() || self.to_bits() == (-$NAN).to_bits() 539 | } 540 | } 541 | ) 542 | } 543 | 544 | impl_float_op!(f32, u32, 32, std::f32::NAN); 545 | impl_float_op!(f64, u64, 64, std::f64::NAN); 546 | 547 | // Promote/Demote are only available in one way 548 | pub trait FloatPromoteOp { 549 | fn promote(self) -> f64; 550 | } 551 | 552 | pub trait FloatDemoteOp { 553 | fn demote(self) -> f32; 554 | } 555 | 556 | impl FloatPromoteOp for f32 { 557 | #[inline] 558 | fn promote(self) -> f64 { 559 | self as f64 560 | } 561 | } 562 | 563 | impl FloatDemoteOp for f64 { 564 | #[inline] 565 | fn demote(self) -> f32 { 566 | self as f32 567 | } 568 | } 569 | -------------------------------------------------------------------------------- /src/runtime.rs: -------------------------------------------------------------------------------- 1 | use ast; 2 | use types; 3 | use values; 4 | 5 | use std::rc::Rc; 6 | use std::ops::{Index, IndexMut}; 7 | use std::collections::HashMap; 8 | 9 | // Use a map for types to answer type_{func, table, memory, global} 10 | #[derive(PartialEq, Eq, Hash)] 11 | pub struct TypeKey { 12 | pub extern_val: ExternVal, 13 | } 14 | 15 | pub type TypeHashMap = HashMap; 16 | 17 | // Instances of a Module/Func/Table/Memory/Global 18 | pub struct ModuleInst { 19 | pub(crate) types: Vec, 20 | pub(crate) func_addrs: Vec, 21 | pub(crate) table_addrs: Vec, 22 | pub(crate) mem_addrs: Vec, 23 | pub(crate) global_addrs: Vec, 24 | pub(crate) exports: Vec, 25 | } 26 | 27 | pub struct MemInst { 28 | pub data: Vec, 29 | pub max: Option, 30 | } 31 | 32 | pub struct GlobalInst { 33 | pub value: values::Value, 34 | pub mutable: bool, 35 | } 36 | 37 | pub type HostFunctionError = String; 38 | pub type HostFunc = Box Option>; 39 | 40 | pub struct HostFuncInst { 41 | pub type_: types::Func, 42 | pub hostcode: HostFunc, 43 | } 44 | 45 | pub struct ModuleFuncInst { 46 | pub type_: types::Func, 47 | pub module: Rc, 48 | pub code: ast::Func, 49 | } 50 | 51 | pub enum FuncInst { 52 | Module(ModuleFuncInst), 53 | Host(HostFuncInst), 54 | } 55 | 56 | type FuncElem = Option; 57 | 58 | pub struct TableInst { 59 | pub elem: Vec, 60 | pub max: Option, 61 | } 62 | 63 | pub struct ExportInst { 64 | pub name: String, 65 | pub value: ExternVal, 66 | } 67 | 68 | pub struct FuncInstStore(Vec); 69 | pub struct MemInstStore(Vec); 70 | pub struct TableInstStore(Vec); 71 | pub struct GlobalInstStore(Vec); 72 | 73 | // Addrs and extern valus exported to the user 74 | type Addr = usize; 75 | #[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)] 76 | pub struct FuncAddr(Addr); 77 | #[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)] 78 | pub struct TableAddr(Addr); 79 | #[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)] 80 | pub struct MemAddr(Addr); 81 | #[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)] 82 | pub struct GlobalAddr(Addr); 83 | 84 | #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] 85 | pub enum ExternVal { 86 | Func(FuncAddr), 87 | Table(TableAddr), 88 | Memory(MemAddr), 89 | Global(GlobalAddr), 90 | } 91 | 92 | // Constants 93 | pub const PAGE_SIZE: usize = 65536; 94 | 95 | // Traits 96 | impl ModuleInst { 97 | pub fn new() -> ModuleInst { 98 | ModuleInst { 99 | types: Vec::new(), 100 | func_addrs: Vec::new(), 101 | table_addrs: Vec::new(), 102 | mem_addrs: Vec::new(), 103 | global_addrs: Vec::new(), 104 | exports: Vec::new(), 105 | } 106 | } 107 | } 108 | 109 | macro_rules! impl_inst_store { 110 | ($StoreType:tt, $InnerType:ty, $AddrType:tt) => ( 111 | impl $StoreType { 112 | pub fn new() -> Self { 113 | Self { 0: Vec::new() } 114 | } 115 | 116 | pub fn len(&self) -> usize { 117 | self.0.len() 118 | } 119 | 120 | pub fn contains(&self, addr: $AddrType) -> bool { 121 | self.0.len() >= addr.0 122 | } 123 | } 124 | 125 | impl Index<$AddrType> for $StoreType { 126 | type Output = $InnerType; 127 | fn index(&self, idx: $AddrType) -> &$InnerType { 128 | self.0.get(idx.0).unwrap() 129 | } 130 | } 131 | 132 | impl IndexMut<$AddrType> for $StoreType { 133 | fn index_mut(&mut self, idx: $AddrType) -> &mut $InnerType { 134 | self.0.get_mut(idx.0).unwrap() 135 | } 136 | } 137 | 138 | impl $AddrType { 139 | pub fn new(addr: Addr) -> $AddrType { 140 | $AddrType { 0: addr } 141 | } 142 | } 143 | ) 144 | } 145 | 146 | impl_inst_store!(FuncInstStore, FuncInst, FuncAddr); 147 | impl_inst_store!(TableInstStore, TableInst, TableAddr); 148 | impl_inst_store!(GlobalInstStore, GlobalInst, GlobalAddr); 149 | impl_inst_store!(MemInstStore, MemInst, MemAddr); 150 | 151 | // Per trait functions 152 | impl FuncInstStore { 153 | pub(crate) fn alloc_module(&mut self, types_map: &mut TypeHashMap, functype: &types::Func, minst: &Rc, code: ast::Func) -> FuncAddr { 154 | self.alloc(types_map, 155 | FuncInst::Module( 156 | ModuleFuncInst { 157 | type_: functype.clone(), 158 | module: Rc::clone(minst), 159 | code: code, 160 | } 161 | ), 162 | functype 163 | ) 164 | } 165 | 166 | pub(crate) fn alloc_host(&mut self, types_map: &mut TypeHashMap, functype: &types::Func, hostfunc: HostFunc) -> FuncAddr { 167 | self.alloc(types_map, 168 | FuncInst::Host( 169 | HostFuncInst { 170 | type_: functype.clone(), 171 | hostcode: hostfunc, 172 | } 173 | ), 174 | functype 175 | ) 176 | } 177 | 178 | fn alloc(&mut self, types_map: &mut TypeHashMap, inst: FuncInst, functype: &types::Func) -> FuncAddr { 179 | self.0.push(inst); 180 | let addr = FuncAddr::new(self.len() - 1); 181 | types_map.insert(TypeKey { extern_val: ExternVal::Func(addr) }, 182 | types::Extern::Func(functype.clone())); 183 | addr 184 | } 185 | 186 | } 187 | 188 | impl MemInstStore { 189 | pub(crate) fn alloc(&mut self, types_map: &mut TypeHashMap, memtype: &types::Memory) -> MemAddr { 190 | self.0.push(MemInst { 191 | data: vec![0; (memtype.limits.min as usize) * PAGE_SIZE], 192 | max: memtype.limits.max, 193 | }); 194 | let addr = MemAddr::new(self.len() - 1); 195 | types_map.insert(TypeKey { extern_val: ExternVal::Memory(addr) }, 196 | types::Extern::Memory(memtype.clone())); 197 | addr 198 | } 199 | 200 | pub(crate) fn grow(&mut self, memaddr: MemAddr, new: usize) -> Option { 201 | let mem = &mut self[memaddr]; 202 | let sz = mem.data.len() / PAGE_SIZE; 203 | if let Some(max) = mem.max { 204 | if (max as usize) < sz + new { 205 | return None 206 | } 207 | } 208 | // Can't allocate more than 4GB since its a 32-bits machine 209 | if sz + new > ((1u64 << 32) / PAGE_SIZE as u64) as usize { 210 | return None 211 | } 212 | mem.data.resize((sz + new) * PAGE_SIZE, 0); 213 | Some(sz) 214 | } 215 | 216 | pub(crate) fn size(&self, memaddr: MemAddr) -> usize { 217 | self[memaddr].data.len() / PAGE_SIZE 218 | } 219 | } 220 | 221 | impl TableInstStore { 222 | pub(crate) fn alloc(&mut self, types_map: &mut TypeHashMap, tabletype: &types::Table) -> TableAddr { 223 | self.0.push(TableInst { 224 | elem: vec![None; tabletype.limits.min as usize], 225 | max: tabletype.limits.max, 226 | }); 227 | let addr = TableAddr::new(self.len() - 1); 228 | types_map.insert(TypeKey { extern_val: ExternVal::Table(addr) }, 229 | types::Extern::Table(tabletype.clone())); 230 | addr 231 | } 232 | } 233 | 234 | impl GlobalInstStore { 235 | pub(crate) fn alloc(&mut self, types_map: &mut TypeHashMap, globaltype: &types::Global, val: values::Value) -> GlobalAddr { 236 | self.0.push(GlobalInst { 237 | value: val, 238 | mutable: globaltype.mutable, 239 | }); 240 | let addr = GlobalAddr::new(self.len() - 1); 241 | types_map.insert(TypeKey { extern_val: ExternVal::Global(addr) }, 242 | types::Extern::Global(globaltype.clone())); 243 | addr 244 | } 245 | } 246 | -------------------------------------------------------------------------------- /src/types.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug, PartialEq, Clone, Copy)] 2 | pub enum Float { 3 | F32, 4 | F64, 5 | } 6 | 7 | #[derive(Debug, PartialEq, Clone, Copy)] 8 | pub enum Int { 9 | I32, 10 | I64, 11 | } 12 | 13 | #[derive(Debug, PartialEq, Clone, Copy)] 14 | pub enum Value { 15 | Int(Int), 16 | Float(Float), 17 | } 18 | 19 | impl Value { 20 | pub fn bit_width(&self) -> u32 { 21 | match *self { 22 | Value::Int(Int::I32) | Value::Float(Float::F32) => 32, 23 | Value::Int(Int::I64) | Value::Float(Float::F64) => 64, 24 | } 25 | } 26 | } 27 | 28 | // Useful aliases for value types 29 | pub static I32: Value = Value::Int(Int::I32); 30 | pub static I64: Value = Value::Int(Int::I64); 31 | pub static F32: Value = Value::Float(Float::F32); 32 | pub static F64: Value = Value::Float(Float::F64); 33 | 34 | 35 | #[derive(Debug, Clone, PartialEq)] 36 | pub enum Elem { 37 | AnyFunc, 38 | } 39 | 40 | #[derive(Debug, Clone, PartialEq)] 41 | pub struct Func { 42 | pub args: Vec, 43 | pub result: Vec, 44 | } 45 | 46 | // Note: Do not implement PartialEq on Limits, Limits comparison is specified and not straightforward 47 | #[derive(Debug, Clone)] 48 | pub struct Limits { 49 | pub min: u32, 50 | pub max: Option, 51 | } 52 | 53 | impl Limits { 54 | /// Check if a limit matches another according to import matching rule on limits 55 | fn matches(&self, l2: &Limits) -> bool { 56 | self.min >= l2.min && (l2.max.is_none() || (self.max.is_some() && self.max.unwrap() <= l2.max.unwrap())) 57 | } 58 | } 59 | 60 | #[derive(Debug, Clone)] 61 | pub struct Table { 62 | pub limits: Limits, 63 | pub elem: Elem, 64 | } 65 | 66 | #[derive(Debug, Clone)] 67 | pub struct Memory { 68 | pub limits: Limits, 69 | } 70 | 71 | #[derive(Debug, Clone, PartialEq)] 72 | pub struct Global { 73 | pub value: Value, 74 | pub mutable: bool, 75 | } 76 | 77 | /// Types of elements defined externally to the module 78 | #[derive(Debug)] 79 | pub enum Extern { 80 | Func(Func), 81 | Table(Table), 82 | Memory(Memory), 83 | Global(Global), 84 | } 85 | 86 | impl Extern { 87 | /// Check if an external type matches another. 88 | /// 89 | /// When instantiating a module, external values must be provided whose types 90 | /// are matched against the respective external types classifying each import. 91 | /// In some cases, this allows for a simple form of subtyping. 92 | pub fn matches(&self, other: &Extern) -> bool { 93 | use self::Extern::*; 94 | 95 | match (self, other) { 96 | (Func(f1), Func(f2)) => f1 == f2, 97 | (Table(t1), Table(t2)) => t1.elem == t2.elem && t1.limits.matches(&t2.limits), 98 | (Memory(m1), Memory(m2)) => m1.limits.matches(&m2.limits), 99 | (Global(g1), Global(g2)) => g1 == g2, 100 | _ => false, 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/values.rs: -------------------------------------------------------------------------------- 1 | use types; 2 | 3 | #[derive(Debug, Clone, Copy)] 4 | pub enum Value { 5 | I32(u32), 6 | I64(u64), 7 | F32(f32), 8 | F64(f64), 9 | } 10 | 11 | impl PartialEq for Value { 12 | /// Two values are equals if they have the same type and they are bitwise equals. 13 | fn eq(&self, other: &Value) -> bool { 14 | use self::Value::*; 15 | 16 | match (*self, *other) { 17 | (I32(a), I32(b)) => a == b, 18 | (I64(a), I64(b)) => a == b, 19 | (F32(a), F32(b)) => a.to_bits() == b.to_bits(), 20 | (F64(a), F64(b)) => a.to_bits() == b.to_bits(), 21 | _ => false, 22 | } 23 | } 24 | } 25 | 26 | impl Value { 27 | pub fn from_i32(v: i32) -> Value { 28 | Value::I32(v as u32) 29 | } 30 | 31 | pub fn from_i64(v: i64) -> Value { 32 | Value::I64(v as u64) 33 | } 34 | 35 | pub fn from_bool(v: bool) -> Value { 36 | if v { 37 | Value::true_() 38 | } else { 39 | Value::false_() 40 | } 41 | } 42 | 43 | pub fn false_() -> Value { 44 | Value::I32(0) 45 | } 46 | 47 | pub fn true_() -> Value { 48 | Value::I32(1) 49 | } 50 | 51 | pub fn type_(&self) -> types::Value { 52 | match *self { 53 | Value::I32(_) => types::I32, 54 | Value::I64(_) => types::I64, 55 | Value::F32(_) => types::F32, 56 | Value::F64(_) => types::F64, 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /tests/README.md: -------------------------------------------------------------------------------- 1 | # Official Test Suite 2 | 3 | Since this implementation of WebAssembly aims for compliance with the official specification, it is tested against the [official test suite](https://github.com/WebAssembly/spec/tree/master/test). 4 | The `script` module handles parsing and execution of the official test script format. 5 | However, this implementation does not support the WebAssembly text format, which used in most of the scripts. 6 | Therefore, test scripts must be converted into the binary format, which can be done with the official interpreter: 7 | 8 | ```bash 9 | for f in test/core/*.wast; do 10 | interpreter/wasm -d $f -o ${f%.wast}.bin.wast 11 | done 12 | ``` 13 | -------------------------------------------------------------------------------- /tests/run_suite.rs: -------------------------------------------------------------------------------- 1 | extern crate rust_wasm; 2 | extern crate hexf_parse; 3 | 4 | mod script; 5 | 6 | include!(concat!(env!("OUT_DIR"), "/test_suite.rs")); 7 | -------------------------------------------------------------------------------- /tests/script/mod.rs: -------------------------------------------------------------------------------- 1 | mod parser; 2 | mod run; 3 | 4 | use rust_wasm::*; 5 | 6 | pub use self::run::*; 7 | 8 | #[derive(Debug)] 9 | pub enum Cmd { 10 | ModuleSource(ModuleSource), 11 | Register { name: String, mod_ref: Option }, 12 | Action(Action), 13 | Assertion(Assertion), 14 | } 15 | 16 | #[derive(Debug)] 17 | pub enum ModuleSource { 18 | Binary(Option, Vec), 19 | Quoted(Option, Vec), 20 | } 21 | 22 | #[derive(Debug)] 23 | pub enum Assertion { 24 | Return(Action, Vec), 25 | ReturnCanonicalNan(Action), 26 | ReturnArithmeticNan(Action), 27 | TrapAction(Action, String), 28 | TrapInstantiate(ModuleSource, String), 29 | Exhaustion(Action, String), 30 | Invalid(ModuleSource, String), 31 | Malformed(ModuleSource, String), 32 | Unlinkable(ModuleSource, String), 33 | } 34 | 35 | #[derive(Debug)] 36 | pub enum Action { 37 | Invoke { mod_ref: Option, func: String, args: Vec }, 38 | Get { mod_ref: Option, global: String }, 39 | } 40 | -------------------------------------------------------------------------------- /tests/script/parser.rs: -------------------------------------------------------------------------------- 1 | use std::convert::TryFrom; 2 | use std::iter::Peekable; 3 | use std::str::{FromStr, CharIndices}; 4 | use std::{f32, f64}; 5 | use hexf_parse::{parse_hexf32, parse_hexf64}; 6 | use rust_wasm::values::Value; 7 | use script::*; 8 | 9 | struct Lexer<'a> { 10 | src: &'a str, 11 | chars: Peekable>, 12 | } 13 | 14 | impl<'a> Lexer<'a> { 15 | fn new(src: &str) -> Lexer { 16 | Lexer { 17 | src: src, 18 | chars: src.char_indices().peekable(), 19 | } 20 | } 21 | } 22 | 23 | impl<'a> Iterator for Lexer<'a> { 24 | type Item = &'a str; 25 | 26 | fn next(&mut self) -> Option { 27 | loop { 28 | match self.chars.next() { 29 | Some((_, c)) if c.is_whitespace() => {}, 30 | Some((start, '(')) | Some((start, ')')) => return Some(&self.src[start..start+1]), 31 | Some((start, '"')) => { // string 32 | loop { 33 | match self.chars.next() { 34 | Some((i, '\"')) => { 35 | return Some(&self.src[start..i+1]); 36 | } 37 | Some((_, '\\')) => { 38 | let _ = self.chars.next(); 39 | } 40 | Some(_) => {} 41 | None => panic!("unexpected eof"), 42 | } 43 | } 44 | 45 | } 46 | Some((start, _)) => { // symbol 47 | loop { 48 | match self.chars.peek() { 49 | Some(&(i, c)) if c.is_whitespace() => return Some(&self.src[start..i]), 50 | Some(&(i, '(')) | Some(&(i, ')')) | Some(&(i, '"')) => { 51 | return Some(&self.src[start..i]); 52 | } 53 | None => return Some(&self.src[start..]), 54 | _ => {} 55 | } 56 | self.chars.next(); 57 | } 58 | }, 59 | None => return None, 60 | } 61 | } 62 | } 63 | } 64 | 65 | 66 | pub struct Parser<'a> { 67 | lexer: Peekable>, 68 | } 69 | 70 | impl<'a> Iterator for Parser<'a> { 71 | type Item = Cmd; 72 | 73 | fn next(&mut self) -> Option { 74 | if self.lexer.peek().is_none() { 75 | None 76 | } else { 77 | Some(self.cmd()) 78 | } 79 | } 80 | } 81 | 82 | impl<'a> Parser<'a> { 83 | pub fn new(src: &'a str) -> Parser { 84 | Parser { lexer: Lexer::new(src).peekable() } 85 | } 86 | 87 | fn next_token(&mut self) -> &'a str { 88 | self.lexer.next().expect("unexpected eof") 89 | } 90 | 91 | fn open(&mut self) { 92 | match self.next_token() { 93 | "(" => {}, 94 | s => panic!(expected(s, &["("])) 95 | } 96 | } 97 | 98 | fn close(&mut self) { 99 | match self.next_token() { 100 | ")" => {}, 101 | s => panic!(expected(s, &[")"])) 102 | } 103 | } 104 | 105 | fn cmd(&mut self) -> Cmd { 106 | use script::Assertion::*; 107 | 108 | self.open(); 109 | let cmd = match self.next_token() { 110 | "module" => Cmd::ModuleSource(self.module_src()), 111 | 112 | "assert_return" => Cmd::Assertion(Return(self.action(), self.values())), 113 | "assert_trap" => Cmd::Assertion(self.assert_trap()), 114 | "assert_return_canonical_nan" => Cmd::Assertion(ReturnCanonicalNan(self.action())), 115 | "assert_return_arithmetic_nan" => Cmd::Assertion(ReturnArithmeticNan(self.action())), 116 | "assert_exhaustion" => Cmd::Assertion(Exhaustion(self.action(), self.string())), 117 | "assert_invalid" => Cmd::Assertion(Invalid(self.module(), self.string())), 118 | "assert_malformed" => Cmd::Assertion(Malformed(self.module(), self.string())), 119 | "assert_unlinkable" => Cmd::Assertion(Unlinkable(self.module(), self.string())), 120 | 121 | "register" => Cmd::Register { name: self.string(), mod_ref: self.opt_id() }, 122 | 123 | "invoke" => Cmd::Action(self.invoke()), 124 | "get" => Cmd::Action(self.get()), 125 | 126 | s => panic!("invalid cmd `{}`", s), 127 | }; 128 | self.close(); 129 | cmd 130 | } 131 | 132 | fn module(&mut self) -> ModuleSource { 133 | self.open(); 134 | let s = self.next_token(); 135 | if s != "module" { 136 | panic!(expected(s, &["module"])); 137 | } 138 | let mod_src = self.module_src(); 139 | self.close(); 140 | mod_src 141 | } 142 | 143 | fn module_src(&mut self) -> ModuleSource { 144 | let name = self.opt_id(); 145 | 146 | match self.next_token() { 147 | "binary" => ModuleSource::Binary(name, self.bytestrings()), 148 | "quote" => ModuleSource::Quoted(name, self.bytestrings()), 149 | s => panic!(expected(s, &["binary", "quote"])), 150 | } 151 | } 152 | 153 | fn assert_trap(&mut self) -> Assertion { 154 | self.open(); 155 | let result = match self.next_token() { 156 | "invoke" => { 157 | let action = self.invoke(); 158 | self.close(); 159 | Assertion::TrapAction(action, self.string()) 160 | } 161 | "get" => { 162 | let action = self.get(); 163 | self.close(); 164 | Assertion::TrapAction(action, self.string()) 165 | } 166 | "module" => { 167 | let mod_src = self.module_src(); 168 | self.close(); 169 | Assertion::TrapInstantiate(mod_src, self.string()) 170 | } 171 | s => panic!(expected(s, &["invoke", "get", "module"])), 172 | }; 173 | result 174 | } 175 | 176 | fn action(&mut self) -> Action { 177 | self.open(); 178 | let action = match self.next_token() { 179 | "invoke" => self.invoke(), 180 | "get" => self.get(), 181 | s => panic!(expected(s, &["invoke", "get"])), 182 | }; 183 | self.close(); 184 | action 185 | } 186 | 187 | fn invoke(&mut self) -> Action { 188 | Action::Invoke { 189 | mod_ref: self.opt_id(), 190 | func: self.string(), 191 | args: self.values(), 192 | } 193 | } 194 | 195 | fn get(&mut self) -> Action { 196 | Action::Get { 197 | mod_ref: self.opt_id(), 198 | global: self.string(), 199 | } 200 | } 201 | 202 | fn values(&mut self) -> Vec { 203 | let mut values = Vec::new(); 204 | let next_lit = |p: &mut Parser| p.next_token().replace("_", ""); 205 | 206 | loop { 207 | match self.lexer.peek() { 208 | Some(&"(") => {}, 209 | _ => return values 210 | } 211 | self.open(); 212 | values.push(match self.next_token() { 213 | "i32.const" => Value::I32(i32::from_str(&next_lit(self)).expect("invalid i32 literal") as u32), 214 | "i64.const" => Value::I64(i64::from_str(&next_lit(self)).expect("invalid i64 literal") as u64), 215 | "f32.const" => Value::F32(parse_f32(&next_lit(self))), 216 | "f64.const" => Value::F64(parse_f64(&next_lit(self))), 217 | s => panic!(expected(s, &["i32.const", "i64.const", "f32.const", "f64.const"])) 218 | }); 219 | self.close(); 220 | } 221 | } 222 | 223 | fn opt_id(&mut self) -> Option { 224 | if &self.lexer.peek()?[0..1] != "$" { 225 | return None; 226 | } 227 | 228 | Some(self.next_token()[1..].to_owned()) 229 | } 230 | 231 | fn string(&mut self) -> String { 232 | let mut vec = Vec::new(); 233 | let s = self.next_token(); 234 | unescape_in(&mut vec, &s[1..s.len()-1]); 235 | String::from_utf8(vec).expect("invalid UTF-8") 236 | } 237 | 238 | fn bytestrings(&mut self) -> Vec { 239 | let mut vec = Vec::new(); 240 | 241 | loop { 242 | match self.lexer.peek() { 243 | Some(s) if s.starts_with("\"") => {}, 244 | _ => return vec, 245 | } 246 | 247 | let s = self.next_token(); 248 | unescape_in(&mut vec, &s[1..s.len()-1]) 249 | } 250 | } 251 | } 252 | 253 | fn unescape_in<'a>(vec: &mut Vec, s: &'a str) { 254 | enum State { 255 | Normal, 256 | Esc, 257 | Unicode, 258 | Codepoint(u32), 259 | Byte(u8), 260 | } 261 | 262 | let mut state = State::Normal; 263 | 264 | for c in s.bytes() { 265 | match state { 266 | State::Normal => match c { 267 | b'\\' => state = State::Esc, 268 | _ => vec.push(c), 269 | }, 270 | State::Byte(h) => { 271 | if !c.is_ascii_hexdigit() { 272 | panic!("expected hex digit, found `{}`", c); 273 | } 274 | let l = parse_hex_digit(c); 275 | vec.push(h << 4 | l); 276 | state = State::Normal; 277 | }, 278 | State::Esc => match c { 279 | b't' => { 280 | vec.push(b'\t'); 281 | state = State::Normal; 282 | } 283 | b'n' => { 284 | vec.push(b'\n'); 285 | state = State::Normal; 286 | } 287 | b'r' => { 288 | vec.push(b'\r'); 289 | state = State::Normal; 290 | } 291 | b'\"' | b'\'' | b'\\' => { 292 | vec.push(c); 293 | state = State::Normal; 294 | } 295 | b'u' => { 296 | state = State::Unicode; 297 | } 298 | c if c.is_ascii_hexdigit() => { 299 | state = State::Byte(parse_hex_digit(c)); 300 | } 301 | _ => panic!("unexpected escape `{}`", c), 302 | }, 303 | State::Unicode => match c { 304 | b'{' => { 305 | state = State::Codepoint(0); 306 | } 307 | _ => panic!("expected `{{`, found `{}`", c), 308 | } 309 | State::Codepoint(v) => match c { 310 | b'}' => { 311 | let u: char = char::try_from(v).expect(&format!("invalid unicode point {:x}", v)).into(); 312 | let mut s = [0u8; 4]; 313 | let _ = u.encode_utf8(&mut s); 314 | vec.extend_from_slice(&s[..u.len_utf8()]); 315 | state = State::Normal; 316 | } 317 | c if c.is_ascii_hexdigit() => { 318 | let hb = parse_hex_digit(c); 319 | state = State::Codepoint(v << 4 | hb as u32); 320 | } 321 | _ => panic!("expected hex digit"), 322 | } 323 | } 324 | } 325 | } 326 | 327 | fn parse_hex_digit(c: u8) -> u8 { 328 | match c { 329 | b'0'..=b'9' => c - b'0', 330 | b'a'..=b'f' => c - b'a' + 10, 331 | b'A'..=b'F' => c - b'A' + 10, 332 | _ => unreachable!() 333 | } 334 | } 335 | 336 | macro_rules! define_parse_f { 337 | ($name:ident, $f:ident, $i:ident, $parse_hex:ident) => ( 338 | fn $name(s: &str) -> $f { 339 | let (negate, s) = match &s[0..1] { 340 | "-" => (true, &s[1..]), 341 | "+" => (false, &s[1..]), 342 | _ => (false, s), 343 | }; 344 | let z = if s == "infinity" { 345 | $f::INFINITY 346 | } else if s.starts_with("nan") { 347 | $f::from_bits($f::INFINITY.to_bits() | $i::from_str_radix(&s[6..], 16).unwrap()) 348 | } else if s.starts_with("0x") { 349 | if s.contains('.') { 350 | $parse_hex(s, true).unwrap() 351 | } else { 352 | $parse_hex(&s.replace("p", ".p"), true).unwrap() 353 | } 354 | } else { 355 | $f::from_str(s).unwrap() 356 | }; 357 | if negate { -z } else { z } 358 | } 359 | ) 360 | } 361 | 362 | define_parse_f!(parse_f32, f32, u32, parse_hexf32); 363 | define_parse_f!(parse_f64, f64, u64, parse_hexf64); 364 | 365 | fn expected(found: &str, options: &[&str]) -> String{ 366 | format!("found: {:?}, expected: {:?}", found, options) 367 | } 368 | -------------------------------------------------------------------------------- /tests/script/run.rs: -------------------------------------------------------------------------------- 1 | use std::{f32, f64}; 2 | use std::fs::File; 3 | use std::path::Path; 4 | use std::io::{Cursor, Read}; 5 | use std::collections::HashMap; 6 | use rust_wasm::*; 7 | use script::*; 8 | 9 | type Exports = HashMap; 10 | 11 | struct Registry { 12 | mod_exports: HashMap, Exports>, 13 | last_key: Option, 14 | } 15 | 16 | pub fn run>(path: P) { 17 | let mut f = File::open(path).unwrap(); 18 | let mut src = String::new(); 19 | f.read_to_string(&mut src).unwrap(); 20 | let parser = parser::Parser::new(&src); 21 | 22 | let mut store = init_store(); 23 | let mut registry = Registry { 24 | mod_exports: HashMap::new(), 25 | last_key: None, 26 | }; 27 | 28 | // Special test host module 29 | init_spectest(&mut store, &mut registry); 30 | 31 | for cmd in parser { 32 | match cmd { 33 | Cmd::ModuleSource(src) => { 34 | let (opt_name, m) = decode_module_src(&src); 35 | 36 | let imports = resolve_imports(&m, &mut registry).unwrap(); 37 | let export_names: Vec = module_exports(&m).map(|(name, _)| name.to_owned()).collect(); 38 | 39 | let inst = instantiate_module(&mut store, m, &imports[..]).unwrap(); 40 | 41 | let exports = export_names.into_iter().map(|name| { 42 | let export = get_export(&inst, &name).unwrap(); 43 | (name, export) 44 | }).collect(); 45 | 46 | registry.last_key = opt_name.clone(); 47 | registry.mod_exports.insert(opt_name, exports); 48 | } 49 | Cmd::Assertion(a) => { 50 | run_assertion(&mut store, ®istry, a); 51 | } 52 | Cmd::Action(a) => { 53 | let _ = run_action(&mut store, ®istry, &a); 54 | } 55 | Cmd::Register { name, mod_ref } => { 56 | let mod_name = if mod_ref.is_some() { &mod_ref } else { ®istry.last_key }; 57 | let inst = registry.mod_exports[mod_name].clone(); 58 | registry.mod_exports.insert(Some(name), inst); 59 | } 60 | } 61 | } 62 | } 63 | 64 | fn decode_module_src(module: &ModuleSource) -> (Option, ast::Module) { 65 | match *module { 66 | ModuleSource::Binary(ref name, ref bytes) => (name.clone(), decode_module(Cursor::new(bytes)).unwrap()), 67 | ModuleSource::Quoted(_, _) => unimplemented!("quoted modules are not supported"), 68 | } 69 | } 70 | 71 | fn run_assertion(store: &mut Store, registry: &Registry, assertion: Assertion) { 72 | use self::Assertion::*; 73 | 74 | println!("run assertion {:?}", assertion); 75 | match assertion { 76 | Return(action, expected) => { 77 | let result = run_action(store, registry, &action); 78 | match result { 79 | Ok(ref actual) if *actual == expected => {} 80 | _ => { 81 | panic!( 82 | "the result of the action `{:?}` is `{:?}` but should be `{:?}`", 83 | action, result, expected, 84 | ); 85 | } 86 | } 87 | } 88 | ReturnCanonicalNan(action) => { 89 | let result = run_action(store, registry, &action).unwrap(); 90 | assert!(result.len() == 1); 91 | let val = result[0]; 92 | match val { 93 | values::Value::F32(f) if f.to_bits() == f32::NAN.to_bits() || f.to_bits() == (-f32::NAN).to_bits() => {}, 94 | values::Value::F64(f) if f.to_bits() == f64::NAN.to_bits() || f.to_bits() == (-f64::NAN).to_bits() => {}, 95 | _ => { 96 | panic!( 97 | "the result of the action `{:?}` is `{:?}` but should be a canonical NaN", 98 | action, result, 99 | ); 100 | } 101 | }; 102 | } 103 | ReturnArithmeticNan(action) => { 104 | let result = run_action(store, registry, &action).unwrap(); 105 | assert!(result.len() == 1); 106 | let val = result[0]; 107 | match val { 108 | values::Value::F32(f) if f.to_bits() & f32::NAN.to_bits() == f32::NAN.to_bits() => {}, 109 | values::Value::F64(f) if f.to_bits() & f64::NAN.to_bits() == f64::NAN.to_bits() => {}, 110 | _ => { 111 | panic!( 112 | "the result of the action `{:?}` is `{:?}` but should be an arithmetic NaN", 113 | action, result, 114 | ); 115 | } 116 | }; 117 | } 118 | TrapAction(action, _) => { 119 | if let Err(Error::CodeTrapped(_)) = run_action(store, registry, &action) { 120 | // There is no if let != in Rust? 121 | } else { 122 | panic!("the action `{:?}` should cause a trap", action); 123 | } 124 | } 125 | TrapInstantiate(module, _) => { 126 | let (_, m) = decode_module_src(&module); 127 | let imports = resolve_imports(&m, registry).unwrap(); 128 | if let Err(Error::CodeTrapped(_)) = instantiate_module(store, m, &imports[..]) { 129 | } else { 130 | panic!("instantiating module `{:?}` should cause a trap", module); 131 | } 132 | } 133 | Exhaustion(action, reason) => { 134 | match (reason.as_ref(), run_action(store, registry, &action)) { 135 | ("call stack exhausted", Err(Error::StackOverflow)) => (), 136 | (reason, err) => panic!("the action `{:?}` should cause a stack overflow (reason = {}, err = {:?})", action, reason, err), 137 | }; 138 | } 139 | Invalid(module, reason) => { 140 | let (_, m) = decode_module_src(&module); 141 | // Do not resolve the imports for invalid modules 142 | match (reason, instantiate_module(store, m, &[]).err()) { 143 | (_, Some(Error::InvalidModule)) => (), 144 | (reason, err) => panic!("instantiating module `{:?}` should not be valid (reason = {}, err = {:?})", module, reason, err), 145 | } 146 | } 147 | Malformed(mod_src, _) => { 148 | match mod_src { 149 | ModuleSource::Binary(_, bytes) => { 150 | assert_eq!(decode_module(Cursor::new(bytes)).unwrap_err(), Error::DecodeModuleFailed); 151 | }, 152 | ModuleSource::Quoted(_, _) => { 153 | // NB: quoted sources use text format, which we do not support 154 | } 155 | } 156 | } 157 | Unlinkable(module, reason) => { 158 | let (_, m) = decode_module_src(&module); 159 | 160 | let imports = match (reason.as_ref(), resolve_imports(&m, registry)) { 161 | ("unknown import", Err(_)) => return, 162 | (_, Err(err)) => panic!("failed to resolve import: `{:?}`", err), 163 | (_, Ok(imports)) => imports, 164 | }; 165 | 166 | match (reason.as_ref(), instantiate_module(store, m, &imports[..]).err()) { 167 | ("incompatible import type", Some(Error::ImportTypeMismatch)) => (), 168 | ("elements segment does not fit", Some(Error::ElemOffsetTooLarge(_))) => (), 169 | ("data segment does not fit", Some(Error::DataOffsetTooLarge(_))) => (), 170 | (reason, err) => panic!("instantiating module `{:?}` should not link (reason = {}, err = {:?})", module, reason, err), 171 | } 172 | } 173 | } 174 | } 175 | 176 | fn run_action(store: &mut Store, registry: &Registry, action: &Action) -> Result, Error> { 177 | match *action { 178 | Action::Invoke { mod_ref: ref mod_name, ref func, ref args } => { 179 | let mod_name = if mod_name.is_some() { mod_name } else { ®istry.last_key }; 180 | match registry.mod_exports[mod_name][func] { 181 | ExternVal::Func(addr) => { 182 | invoke_func(store, addr, args.clone()) 183 | } 184 | _ => panic!("extern val should be a function"), 185 | } 186 | } 187 | Action::Get { mod_ref: ref mod_name, ref global } => { 188 | let mod_name = if mod_name.is_some() { mod_name } else { ®istry.last_key }; 189 | match registry.mod_exports[mod_name][global] { 190 | ExternVal::Global(addr) => { 191 | Ok(vec![read_global(store, addr)]) 192 | } 193 | _ => panic!("extern val should be a global"), 194 | } 195 | } 196 | } 197 | } 198 | 199 | fn init_spectest(store: &mut Store, registry: &mut Registry) { 200 | let mut symbols = HashMap::new(); 201 | 202 | symbols.insert("table".to_owned(), ExternVal::Table( 203 | alloc_table( 204 | store, 205 | &types::Table { limits: types::Limits { min: 10, max: Some(20) }, elem: types::Elem::AnyFunc } 206 | ) 207 | )); 208 | 209 | symbols.insert("memory".to_owned(), ExternVal::Memory( 210 | alloc_mem( 211 | store, 212 | &types::Memory { limits: types::Limits { min: 1, max: Some(2) } } 213 | ) 214 | )); 215 | 216 | fn print(store: &mut Store, args_types: Vec) -> ExternVal { 217 | let func = move |args: &[values::Value], _ret: &mut[values::Value]| { 218 | for val in args { 219 | println!("{:?}", val); 220 | } 221 | None 222 | }; 223 | 224 | ExternVal::Func( 225 | alloc_func( 226 | store, 227 | &types::Func { args: args_types, result: Vec::new() }, 228 | Box::new(func) 229 | ) 230 | ) 231 | } 232 | 233 | fn global(store: &mut Store, val: values::Value) -> ExternVal { 234 | ExternVal::Global( 235 | alloc_global( 236 | store, 237 | &types::Global { value: val.type_(), mutable: false }, 238 | val 239 | ) 240 | ) 241 | } 242 | 243 | symbols.insert("print".to_owned(), print(store, vec![])); 244 | symbols.insert("print_i32".to_owned(), print(store, vec![types::I32])); 245 | symbols.insert("print_i32_f32".to_owned(), print(store, vec![types::I32, types::F32])); 246 | symbols.insert("print_f32".to_owned(), print(store, vec![types::F32])); 247 | symbols.insert("print_f64".to_owned(), print(store, vec![types::F64])); 248 | symbols.insert("print_f64_f64".to_owned(), print(store, vec![types::F64, types::F64])); 249 | symbols.insert("global_i32".to_owned(), global(store, values::Value::I32(666))); 250 | symbols.insert("global_f32".to_owned(), global(store, values::Value::F32(666.0))); 251 | symbols.insert("global_f64".to_owned(), global(store, values::Value::F64(666.0))); 252 | 253 | registry.mod_exports.insert(Some(String::from("spectest")), symbols); 254 | } 255 | 256 | #[derive(Debug)] 257 | enum UnknownImport { 258 | UnknownModule { mod_name: String }, 259 | UnknownSymbol { mod_name: String, symbol_name: String }, 260 | } 261 | 262 | fn resolve_imports(m: &ast::Module, registry: &Registry) -> Result, UnknownImport> { 263 | module_imports(m).map(|(mod_name, import_name, _)| { 264 | match registry.mod_exports.get(&Some(mod_name.to_owned())) { 265 | Some(ref mod_exports) => { 266 | match mod_exports.get(import_name) { 267 | Some(val) => Ok(val.clone()), 268 | None => Err(UnknownImport::UnknownSymbol { 269 | mod_name: mod_name.to_owned(), 270 | symbol_name: import_name.to_owned() 271 | }), 272 | } 273 | }, 274 | None => Err(UnknownImport::UnknownModule { mod_name: mod_name.to_owned() }), 275 | } 276 | }).collect() 277 | } 278 | -------------------------------------------------------------------------------- /tests/suite/binary.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary "\00\61\73\6d\01\00\00\00") 2 | (module binary "\00\61\73\6d\01\00\00\00") 3 | (module $M1 binary "\00\61\73\6d\01\00\00\00") 4 | (module $M2 binary "\00\61\73\6d\01\00\00\00") 5 | (assert_malformed (module binary) "unexpected end") 6 | (assert_malformed (module binary "\01") "unexpected end") 7 | (assert_malformed (module binary "\00\61\73") "unexpected end") 8 | (assert_malformed (module binary "\61\73\6d\00") "magic header not detected") 9 | (assert_malformed (module binary "\6d\73\61\00") "magic header not detected") 10 | (assert_malformed 11 | (module binary "\6d\73\61\00\01\00\00\00") 12 | "magic header not detected" 13 | ) 14 | (assert_malformed 15 | (module binary "\6d\73\61\00\00\00\00\01") 16 | "magic header not detected" 17 | ) 18 | (assert_malformed 19 | (module binary "\61\73\6d\01\00\00\00\00") 20 | "magic header not detected" 21 | ) 22 | (assert_malformed 23 | (module binary "\77\61\73\6d\01\00\00\00") 24 | "magic header not detected" 25 | ) 26 | (assert_malformed 27 | (module binary "\7f\61\73\6d\01\00\00\00") 28 | "magic header not detected" 29 | ) 30 | (assert_malformed 31 | (module binary "\80\61\73\6d\01\00\00\00") 32 | "magic header not detected" 33 | ) 34 | (assert_malformed 35 | (module binary "\82\61\73\6d\01\00\00\00") 36 | "magic header not detected" 37 | ) 38 | (assert_malformed 39 | (module binary "\ff\61\73\6d\01\00\00\00") 40 | "magic header not detected" 41 | ) 42 | (assert_malformed 43 | (module binary "\00\00\00\01\6d\73\61\00") 44 | "magic header not detected" 45 | ) 46 | (assert_malformed 47 | (module binary "\61\00\6d\73\00\01\00\00") 48 | "magic header not detected" 49 | ) 50 | (assert_malformed 51 | (module binary "\73\6d\00\61\00\00\01\00") 52 | "magic header not detected" 53 | ) 54 | (assert_malformed 55 | (module binary "\00\41\53\4d\01\00\00\00") 56 | "magic header not detected" 57 | ) 58 | (assert_malformed 59 | (module binary "\00\81\a2\94\01\00\00\00") 60 | "magic header not detected" 61 | ) 62 | (assert_malformed 63 | (module binary "\ef\bb\bf\00\61\73\6d\01\00\00\00") 64 | "magic header not detected" 65 | ) 66 | (assert_malformed (module binary "\00\61\73\6d") "unexpected end") 67 | (assert_malformed (module binary "\00\61\73\6d\01") "unexpected end") 68 | (assert_malformed (module binary "\00\61\73\6d\01\00\00") "unexpected end") 69 | (assert_malformed 70 | (module binary "\00\61\73\6d\00\00\00\00") 71 | "unknown binary version" 72 | ) 73 | (assert_malformed 74 | (module binary "\00\61\73\6d\0d\00\00\00") 75 | "unknown binary version" 76 | ) 77 | (assert_malformed 78 | (module binary "\00\61\73\6d\0e\00\00\00") 79 | "unknown binary version" 80 | ) 81 | (assert_malformed 82 | (module binary "\00\61\73\6d\00\01\00\00") 83 | "unknown binary version" 84 | ) 85 | (assert_malformed 86 | (module binary "\00\61\73\6d\00\00\01\00") 87 | "unknown binary version" 88 | ) 89 | (assert_malformed 90 | (module binary "\00\61\73\6d\00\00\00\01") 91 | "unknown binary version" 92 | ) 93 | (assert_malformed 94 | (module binary 95 | "\00\61\73\6d\01\00\00\00\01\04\01\60\00\00\03\02" 96 | "\01\00\04\04\01\70\00\00\0a\09\01\07\00\41\00\11" 97 | "\00\01\0b" 98 | ) 99 | "zero flag expected" 100 | ) 101 | (assert_malformed 102 | (module binary 103 | "\00\61\73\6d\01\00\00\00\01\04\01\60\00\00\03\02" 104 | "\01\00\04\04\01\70\00\00\0a\0a\01\07\00\41\00\11" 105 | "\00\80\00\0b" 106 | ) 107 | "zero flag expected" 108 | ) 109 | (assert_malformed 110 | (module binary 111 | "\00\61\73\6d\01\00\00\00\01\04\01\60\00\00\03\02" 112 | "\01\00\04\04\01\70\00\00\0a\0b\01\08\00\41\00\11" 113 | "\00\80\80\00\0b" 114 | ) 115 | "zero flag expected" 116 | ) 117 | (assert_malformed 118 | (module binary 119 | "\00\61\73\6d\01\00\00\00\01\04\01\60\00\00\03\02" 120 | "\01\00\04\04\01\70\00\00\0a\0c\01\09\00\41\00\11" 121 | "\00\80\80\80\00\0b" 122 | ) 123 | "zero flag expected" 124 | ) 125 | (assert_malformed 126 | (module binary 127 | "\00\61\73\6d\01\00\00\00\01\04\01\60\00\00\03\02" 128 | "\01\00\04\04\01\70\00\00\0a\0d\01\0a\00\41\00\11" 129 | "\00\80\80\80\80\00\0b" 130 | ) 131 | "zero flag expected" 132 | ) 133 | (assert_malformed 134 | (module binary 135 | "\00\61\73\6d\01\00\00\00\01\04\01\60\00\00\03\02" 136 | "\01\00\05\03\01\00\00\0a\09\01\07\00\41\00\40\01" 137 | "\1a\0b" 138 | ) 139 | "zero flag expected" 140 | ) 141 | (assert_malformed 142 | (module binary 143 | "\00\61\73\6d\01\00\00\00\01\04\01\60\00\00\03\02" 144 | "\01\00\05\03\01\00\00\0a\0a\01\08\00\41\00\40\80" 145 | "\00\1a\0b" 146 | ) 147 | "zero flag expected" 148 | ) 149 | (assert_malformed 150 | (module binary 151 | "\00\61\73\6d\01\00\00\00\01\04\01\60\00\00\03\02" 152 | "\01\00\05\03\01\00\00\0a\0b\01\09\00\41\00\40\80" 153 | "\80\00\1a\0b" 154 | ) 155 | "zero flag expected" 156 | ) 157 | (assert_malformed 158 | (module binary 159 | "\00\61\73\6d\01\00\00\00\01\04\01\60\00\00\03\02" 160 | "\01\00\05\03\01\00\00\0a\0c\01\0a\00\41\00\40\80" 161 | "\80\80\00\1a\0b" 162 | ) 163 | "zero flag expected" 164 | ) 165 | (assert_malformed 166 | (module binary 167 | "\00\61\73\6d\01\00\00\00\01\04\01\60\00\00\03\02" 168 | "\01\00\05\03\01\00\00\0a\0d\01\0b\00\41\00\40\80" 169 | "\80\80\80\00\1a\0b" 170 | ) 171 | "zero flag expected" 172 | ) 173 | (assert_malformed 174 | (module binary 175 | "\00\61\73\6d\01\00\00\00\01\04\01\60\00\00\03\02" 176 | "\01\00\05\03\01\00\00\0a\07\01\05\00\3f\01\1a\0b" 177 | ) 178 | "zero flag expected" 179 | ) 180 | (assert_malformed 181 | (module binary 182 | "\00\61\73\6d\01\00\00\00\01\04\01\60\00\00\03\02" 183 | "\01\00\05\03\01\00\00\0a\08\01\06\00\3f\80\00\1a" 184 | "\0b" 185 | ) 186 | "zero flag expected" 187 | ) 188 | (assert_malformed 189 | (module binary 190 | "\00\61\73\6d\01\00\00\00\01\04\01\60\00\00\03\02" 191 | "\01\00\05\03\01\00\00\0a\09\01\07\00\3f\80\80\00" 192 | "\1a\0b" 193 | ) 194 | "zero flag expected" 195 | ) 196 | (assert_malformed 197 | (module binary 198 | "\00\61\73\6d\01\00\00\00\01\04\01\60\00\00\03\02" 199 | "\01\00\05\03\01\00\00\0a\0a\01\08\00\3f\80\80\80" 200 | "\00\1a\0b" 201 | ) 202 | "zero flag expected" 203 | ) 204 | (assert_malformed 205 | (module binary 206 | "\00\61\73\6d\01\00\00\00\01\04\01\60\00\00\03\02" 207 | "\01\00\05\03\01\00\00\0a\0b\01\09\00\3f\80\80\80" 208 | "\80\00\1a\0b" 209 | ) 210 | "zero flag expected" 211 | ) 212 | (assert_malformed 213 | (module binary 214 | "\00\61\73\6d\01\00\00\00\01\04\01\60\00\00\03\02" 215 | "\01\00\0a\0c\01\0a\02\ff\ff\ff\ff\0f\7f\02\7e\0b" 216 | ) 217 | "too many locals" 218 | ) 219 | (module binary 220 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 221 | "\00\00\03\82\80\80\80\00\01\00\0a\8a\80\80\80\00" 222 | "\01\84\80\80\80\00\01\02\7d\0b" 223 | ) 224 | (assert_malformed 225 | (module binary "\00\61\73\6d\01\00\00\00\01\04\01\60\00\00\03\03" "\02\00\00") 226 | "function and code section have inconsistent lengths" 227 | ) 228 | (assert_malformed 229 | (module binary "\00\61\73\6d\01\00\00\00\0a\04\01\02\00\0b") 230 | "function and code section have inconsistent lengths" 231 | ) 232 | (assert_malformed 233 | (module binary 234 | "\00\61\73\6d\01\00\00\00\01\04\01\60\00\00\03\03" 235 | "\02\00\00\0a\04\01\02\00\0b" 236 | ) 237 | "function and code section have inconsistent lengths" 238 | ) 239 | (assert_malformed 240 | (module binary 241 | "\00\61\73\6d\01\00\00\00\01\04\01\60\00\00\03\02" 242 | "\01\00\0a\07\02\02\00\0b\02\00\0b" 243 | ) 244 | "function and code section have inconsistent lengths" 245 | ) 246 | (module binary "\00\61\73\6d\01\00\00\00") 247 | (module binary "\00\61\73\6d\01\00\00\00") 248 | (module binary "\00\61\73\6d\01\00\00\00") 249 | (assert_malformed 250 | (module binary "\00\61\73\6d\01\00\00\00\01\07\02\60\00\00") 251 | "unexpected end of section or function" 252 | ) 253 | (assert_malformed 254 | (module binary "\00\61\73\6d\01\00\00\00\01\07\01\60\00\00\60\00" "\00") 255 | "section size mismatch" 256 | ) 257 | (module binary "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" "\01\7f\00") 258 | (assert_malformed 259 | (module binary 260 | "\00\61\73\6d\01\00\00\00\01\05\01\60\01\7f\00\02" 261 | "\16\02\08\73\70\65\63\74\65\73\74\09\70\72\69\6e" 262 | "\74\5f\69\33\32\00\00" 263 | ) 264 | "unexpected end of section or function" 265 | ) 266 | (assert_malformed 267 | (module binary 268 | "\00\61\73\6d\01\00\00\00\01\09\02\60\01\7f\00\60" 269 | "\01\7d\00\02\2b\01\08\73\70\65\63\74\65\73\74\09" 270 | "\70\72\69\6e\74\5f\69\33\32\00\00\08\73\70\65\63" 271 | "\74\65\73\74\09\70\72\69\6e\74\5f\66\33\32\00\01" 272 | ) 273 | "section size mismatch" 274 | ) 275 | (module binary "\00\61\73\6d\01\00\00\00") 276 | (assert_malformed 277 | (module binary "\00\61\73\6d\01\00\00\00\04\01\01") 278 | "unexpected end of section or function" 279 | ) 280 | (module binary "\00\61\73\6d\01\00\00\00") 281 | (assert_malformed 282 | (module binary "\00\61\73\6d\01\00\00\00\05\01\01") 283 | "unexpected end of section or function" 284 | ) 285 | (module binary "\00\61\73\6d\01\00\00\00") 286 | (assert_malformed 287 | (module binary "\00\61\73\6d\01\00\00\00\06\06\02\7f\00\41\00\0b") 288 | "unexpected end of section or function" 289 | ) 290 | (assert_malformed 291 | (module binary 292 | "\00\61\73\6d\01\00\00\00\06\0b\01\7f\00\41\00\0b" 293 | "\7f\00\41\00\0b" 294 | ) 295 | "section size mismatch" 296 | ) 297 | (module binary 298 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 299 | "\00\00\03\83\80\80\80\00\02\00\00\0a\8f\80\80\80" 300 | "\00\02\82\80\80\80\00\00\0b\82\80\80\80\00\00\0b" 301 | ) 302 | (assert_malformed 303 | (module binary 304 | "\00\61\73\6d\01\00\00\00\01\04\01\60\00\00\03\03" 305 | "\02\00\00\07\06\02\02\66\31\00\00\0a\07\02\02\00" 306 | "\0b\02\00\0b" 307 | ) 308 | "unexpected end of section or function" 309 | ) 310 | (assert_malformed 311 | (module binary 312 | "\00\61\73\6d\01\00\00\00\01\04\01\60\00\00\03\03" 313 | "\02\00\00\07\0b\01\02\66\31\00\00\02\66\32\00\01" 314 | "\0a\07\02\02\00\0b\02\00\0b" 315 | ) 316 | "section size mismatch" 317 | ) 318 | (module binary 319 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 320 | "\00\00\03\82\80\80\80\00\01\00\04\84\80\80\80\00" 321 | "\01\70\00\01\0a\88\80\80\80\00\01\82\80\80\80\00" 322 | "\00\0b" 323 | ) 324 | (assert_malformed 325 | (module binary 326 | "\00\61\73\6d\01\00\00\00\01\04\01\60\00\00\03\02" 327 | "\01\00\04\04\01\70\00\01\09\07\02\00\41\00\0b\01" 328 | "\00\0a\04\01\02\00\0b" 329 | ) 330 | "invalid value type" 331 | ) 332 | (assert_malformed 333 | (module binary 334 | "\00\61\73\6d\01\00\00\00\01\04\01\60\00\00\03\02" 335 | "\01\00\04\04\01\70\00\01\09\0d\01\00\41\00\0b\01" 336 | "\00\00\41\00\0b\01\00\0a\04\01\02\00\0b" 337 | ) 338 | "section size mismatch" 339 | ) 340 | (module binary "\00\61\73\6d\01\00\00\00\05\83\80\80\80\00\01\00" "\01") 341 | (assert_malformed 342 | (module binary 343 | "\00\61\73\6d\01\00\00\00\05\03\01\00\01\0b\07\02" 344 | "\00\41\00\0b\01\61" 345 | ) 346 | "unexpected end of section or function" 347 | ) 348 | (assert_malformed 349 | (module binary 350 | "\00\61\73\6d\01\00\00\00\05\03\01\00\01\0b\0d\01" 351 | "\00\41\00\0b\01\61\00\41\01\0b\01\62" 352 | ) 353 | "section size mismatch" 354 | ) 355 | (assert_malformed 356 | (module binary 357 | "\00\61\73\6d\01\00\00\00\05\03\01\00\01\0b\0c\01" 358 | "\00\41\03\0b\07\61\62\63\64\65\66" 359 | ) 360 | "unexpected end of section or function" 361 | ) 362 | (assert_malformed 363 | (module binary 364 | "\00\61\73\6d\01\00\00\00\05\03\01\00\01\0b\0c\01" 365 | "\00\41\00\0b\05\61\62\63\64\65\66" 366 | ) 367 | "section size mismatch" 368 | ) 369 | (module binary 370 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 371 | "\00\00\03\82\80\80\80\00\01\00\0a\95\80\80\80\00" 372 | "\01\8f\80\80\80\00\00\02\40\41\01\04\40\41\01\0e" 373 | "\00\02\0b\0b\0b" 374 | ) 375 | (assert_malformed 376 | (module binary 377 | "\00\61\73\6d\01\00\00\00\01\04\01\60\00\00\03\02" 378 | "\01\00\0a\12\01\10\00\02\40\41\01\04\40\41\01\0e" 379 | "\02\00\02\0b\0b\0b" 380 | ) 381 | "unexpected end of section or function" 382 | ) 383 | (assert_malformed 384 | (module binary 385 | "\00\61\73\6d\01\00\00\00\01\04\01\60\00\00\03\02" 386 | "\01\00\0a\12\01\11\00\02\40\41\01\04\40\41\01\0e" 387 | "\01\00\01\02\0b\0b\0b" 388 | ) 389 | "invalid value type" 390 | ) 391 | (module binary 392 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 393 | "\00\00\03\82\80\80\80\00\01\00\08\81\80\80\80\00" 394 | "\00\0a\88\80\80\80\00\01\82\80\80\80\00\00\0b" 395 | ) 396 | (assert_malformed 397 | (module binary 398 | "\00\61\73\6d\01\00\00\00\01\04\01\60\00\00\03\02" 399 | "\01\00\08\01\00\08\01\00\0a\04\01\02\00\0b" 400 | ) 401 | "junk after last section" 402 | ) 403 | -------------------------------------------------------------------------------- /tests/suite/break-drop.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary 2 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 3 | "\00\00\03\84\80\80\80\00\03\00\00\00\07\99\80\80" 4 | "\80\00\03\02\62\72\00\00\05\62\72\5f\69\66\00\01" 5 | "\08\62\72\5f\74\61\62\6c\65\00\02\0a\aa\80\80\80" 6 | "\00\03\87\80\80\80\00\00\02\40\0c\00\0b\0b\89\80" 7 | "\80\80\00\00\02\40\41\01\0d\00\0b\0b\8a\80\80\80" 8 | "\00\00\02\40\41\00\0e\00\00\0b\0b" 9 | ) 10 | (assert_return (invoke "br")) 11 | (assert_return (invoke "br_if")) 12 | (assert_return (invoke "br_table")) 13 | -------------------------------------------------------------------------------- /tests/suite/comments.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary "\00\61\73\6d\01\00\00\00") 2 | (module binary "\00\61\73\6d\01\00\00\00") 3 | (module binary "\00\61\73\6d\01\00\00\00") 4 | (module binary "\00\61\73\6d\01\00\00\00") 5 | -------------------------------------------------------------------------------- /tests/suite/custom.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary "\00\61\73\6d\01\00\00\00") 2 | (module binary "\00\61\73\6d\01\00\00\00") 3 | (module binary 4 | "\00\61\73\6d\01\00\00\00\01\87\80\80\80\00\01\60" 5 | "\02\7f\7f\01\7f\03\82\80\80\80\00\01\00\07\8a\80" 6 | "\80\80\00\01\06\61\64\64\54\77\6f\00\00\0a\8d\80" 7 | "\80\80\00\01\87\80\80\80\00\00\20\00\20\01\6a\0b" 8 | ) 9 | (assert_malformed 10 | (module binary "\00\61\73\6d\01\00\00\00\00") 11 | "unexpected end" 12 | ) 13 | (assert_malformed 14 | (module binary "\00\61\73\6d\01\00\00\00\00\00") 15 | "unexpected end" 16 | ) 17 | (assert_malformed 18 | (module binary "\00\61\73\6d\01\00\00\00\00\00\00\05\01\00\07\00" "\00") 19 | "unexpected end" 20 | ) 21 | (assert_malformed 22 | (module binary 23 | "\00\61\73\6d\01\00\00\00\00\26\10\61\20\63\75\73" 24 | "\74\6f\6d\20\73\65\63\74\69\6f\6e\74\68\69\73\20" 25 | "\69\73\20\74\68\65\20\70\61\79\6c\6f\61\64" 26 | ) 27 | "unexpected end" 28 | ) 29 | (assert_malformed 30 | (module binary 31 | "\00\61\73\6d\01\00\00\00\00\25\10\61\20\63\75\73" 32 | "\74\6f\6d\20\73\65\63\74\69\6f\6e\74\68\69\73\20" 33 | "\69\73\20\74\68\65\20\70\61\79\6c\6f\61\64\00\24" 34 | "\10\61\20\63\75\73\74\6f\6d\20\73\65\63\74\69\6f" 35 | "\6e\74\68\69\73\20\69\73\20\74\68\65\20\70\61\79" 36 | "\6c\6f\61\64" 37 | ) 38 | "invalid section id" 39 | ) 40 | (assert_malformed 41 | (module binary 42 | "\00\61\73\6d\01\00\00\00\01\07\01\60\02\7f\7f\01" 43 | "\7f\00\25\10\61\20\63\75\73\74\6f\6d\20\73\65\63" 44 | "\74\69\6f\6e\74\68\69\73\20\69\73\20\74\68\65\20" 45 | "\70\61\79\6c\6f\61\64\03\02\01\00\0a\09\01\07\00" 46 | "\20\00\20\01\6a\0b\00\1b\07\63\75\73\74\6f\6d\32" 47 | "\74\68\69\73\20\69\73\20\74\68\65\20\70\61\79\6c" 48 | "\6f\61\64" 49 | ) 50 | "function and code section have inconsistent lengths" 51 | ) 52 | (assert_malformed 53 | (module binary "\00\61\73\6d\01\00\00\00\00\61\73\6d\01\00\00\00") 54 | "length out of bounds" 55 | ) 56 | -------------------------------------------------------------------------------- /tests/suite/custom_section.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary 2 | "\00\61\73\6d\01\00\00\00\00\24\10\61\20\63\75\73" 3 | "\74\6f\6d\20\73\65\63\74\69\6f\6e\74\68\69\73\20" 4 | "\69\73\20\74\68\65\20\70\61\79\6c\6f\61\64\00\20" 5 | "\10\61\20\63\75\73\74\6f\6d\20\73\65\63\74\69\6f" 6 | "\6e\74\68\69\73\20\69\73\20\70\61\79\6c\6f\61\64" 7 | "\00\11\10\61\20\63\75\73\74\6f\6d\20\73\65\63\74" 8 | "\69\6f\6e\00\10\00\74\68\69\73\20\69\73\20\70\61" 9 | "\79\6c\6f\61\64\00\01\00\00\24\10\00\00\63\75\73" 10 | "\74\6f\6d\20\73\65\63\74\69\6f\00\74\68\69\73\20" 11 | "\69\73\20\74\68\65\20\70\61\79\6c\6f\61\64\00\24" 12 | "\10\ef\bb\bf\61\20\63\75\73\74\6f\6d\20\73\65\63" 13 | "\74\74\68\69\73\20\69\73\20\74\68\65\20\70\61\79" 14 | "\6c\6f\61\64\00\24\10\61\20\63\75\73\74\6f\6d\20" 15 | "\73\65\63\74\e2\8c\a3\74\68\69\73\20\69\73\20\74" 16 | "\68\65\20\70\61\79\6c\6f\61\64\00\1f\16\6d\6f\64" 17 | "\75\6c\65\20\77\69\74\68\69\6e\20\61\20\6d\6f\64" 18 | "\75\6c\65\00\61\73\6d\01\00\00\00" 19 | ) 20 | (module binary 21 | "\00\61\73\6d\01\00\00\00\00\0e\06\63\75\73\74\6f" 22 | "\6d\70\61\79\6c\6f\61\64\00\0e\06\63\75\73\74\6f" 23 | "\6d\70\61\79\6c\6f\61\64\01\01\00\00\0e\06\63\75" 24 | "\73\74\6f\6d\70\61\79\6c\6f\61\64\00\0e\06\63\75" 25 | "\73\74\6f\6d\70\61\79\6c\6f\61\64\02\01\00\00\0e" 26 | "\06\63\75\73\74\6f\6d\70\61\79\6c\6f\61\64\00\0e" 27 | "\06\63\75\73\74\6f\6d\70\61\79\6c\6f\61\64\03\01" 28 | "\00\00\0e\06\63\75\73\74\6f\6d\70\61\79\6c\6f\61" 29 | "\64\00\0e\06\63\75\73\74\6f\6d\70\61\79\6c\6f\61" 30 | "\64\04\01\00\00\0e\06\63\75\73\74\6f\6d\70\61\79" 31 | "\6c\6f\61\64\00\0e\06\63\75\73\74\6f\6d\70\61\79" 32 | "\6c\6f\61\64\05\01\00\00\0e\06\63\75\73\74\6f\6d" 33 | "\70\61\79\6c\6f\61\64\00\0e\06\63\75\73\74\6f\6d" 34 | "\70\61\79\6c\6f\61\64\06\01\00\00\0e\06\63\75\73" 35 | "\74\6f\6d\70\61\79\6c\6f\61\64\00\0e\06\63\75\73" 36 | "\74\6f\6d\70\61\79\6c\6f\61\64\07\01\00\00\0e\06" 37 | "\63\75\73\74\6f\6d\70\61\79\6c\6f\61\64\00\0e\06" 38 | "\63\75\73\74\6f\6d\70\61\79\6c\6f\61\64\09\01\00" 39 | "\00\0e\06\63\75\73\74\6f\6d\70\61\79\6c\6f\61\64" 40 | "\00\0e\06\63\75\73\74\6f\6d\70\61\79\6c\6f\61\64" 41 | "\0a\01\00\00\0e\06\63\75\73\74\6f\6d\70\61\79\6c" 42 | "\6f\61\64\00\0e\06\63\75\73\74\6f\6d\70\61\79\6c" 43 | "\6f\61\64\0b\01\00\00\0e\06\63\75\73\74\6f\6d\70" 44 | "\61\79\6c\6f\61\64\00\0e\06\63\75\73\74\6f\6d\70" 45 | "\61\79\6c\6f\61\64" 46 | ) 47 | (module binary 48 | "\00\61\73\6d\01\00\00\00\01\07\01\60\02\7f\7f\01" 49 | "\7f\00\1a\06\63\75\73\74\6f\6d\74\68\69\73\20\69" 50 | "\73\20\74\68\65\20\70\61\79\6c\6f\61\64\03\02\01" 51 | "\00\07\0a\01\06\61\64\64\54\77\6f\00\00\0a\09\01" 52 | "\07\00\20\00\20\01\6a\0b\00\1b\07\63\75\73\74\6f" 53 | "\6d\32\74\68\69\73\20\69\73\20\74\68\65\20\70\61" 54 | "\79\6c\6f\61\64" 55 | ) 56 | (assert_malformed 57 | (module binary "\00\61\73\6d\01\00\00\00\00") 58 | "unexpected end" 59 | ) 60 | (assert_malformed 61 | (module binary "\00\61\73\6d\01\00\00\00\00\00") 62 | "unexpected end" 63 | ) 64 | (assert_malformed 65 | (module binary 66 | "\00\61\73\6d\01\00\00\00\00\26\10\61\20\63\75\73" 67 | "\74\6f\6d\20\73\65\63\74\69\6f\6e\74\68\69\73\20" 68 | "\69\73\20\74\68\65\20\70\61\79\6c\6f\61\64" 69 | ) 70 | "unexpected end" 71 | ) 72 | (assert_malformed 73 | (module binary 74 | "\00\61\73\6d\01\00\00\00\00\25\10\61\20\63\75\73" 75 | "\74\6f\6d\20\73\65\63\74\69\6f\6e\74\68\69\73\20" 76 | "\69\73\20\74\68\65\20\70\61\79\6c\6f\61\64\00\24" 77 | "\10\61\20\63\75\73\74\6f\6d\20\73\65\63\74\69\6f" 78 | "\6e\74\68\69\73\20\69\73\20\74\68\65\20\70\61\79" 79 | "\6c\6f\61\64" 80 | ) 81 | "invalid section id" 82 | ) 83 | (assert_malformed 84 | (module binary 85 | "\00\61\73\6d\01\00\00\00\01\07\01\60\02\7f\7f\01" 86 | "\7f\00\25\10\61\20\63\75\73\74\6f\6d\20\73\65\63" 87 | "\74\69\6f\6e\74\68\69\73\20\69\73\20\74\68\65\20" 88 | "\70\61\79\6c\6f\61\64\03\02\01\00\0a\09\01\07\00" 89 | "\20\00\20\01\6a\0b\00\1b\07\63\75\73\74\6f\6d\32" 90 | "\74\68\69\73\20\69\73\20\74\68\65\20\70\61\79\6c" 91 | "\6f\61\64" 92 | ) 93 | "function and code section have inconsistent lengths" 94 | ) 95 | (assert_malformed 96 | (module binary "\00\61\73\6d\01\00\00\00\00\61\73\6d\01\00\00\00") 97 | "length out of bounds" 98 | ) 99 | -------------------------------------------------------------------------------- /tests/suite/data.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary 2 | "\00\61\73\6d\01\00\00\00\05\83\80\80\80\00\01\00" 3 | "\01\0b\d2\80\80\80\00\0c\00\41\00\0b\00\00\41\01" 4 | "\0b\04\61\62\63\64\00\41\00\0b\00\00\41\00\0b\03" 5 | "\61\62\63\00\41\00\0b\00\00\41\01\0b\04\61\62\63" 6 | "\64\00\41\00\0b\00\00\41\00\0b\03\61\62\63\00\41" 7 | "\00\0b\00\00\41\01\0b\04\61\62\63\64\00\41\00\0b" 8 | "\00\00\41\00\0b\03\61\62\63" 9 | ) 10 | (module binary 11 | "\00\61\73\6d\01\00\00\00\05\83\80\80\80\00\01\00" 12 | "\01\0b\87\80\80\80\00\01\00\41\00\0b\01\61" 13 | ) 14 | (module binary 15 | "\00\61\73\6d\01\00\00\00\02\94\80\80\80\00\01\08" 16 | "\73\70\65\63\74\65\73\74\06\6d\65\6d\6f\72\79\02" 17 | "\00\01\0b\87\80\80\80\00\01\00\41\00\0b\01\61" 18 | ) 19 | (module binary 20 | "\00\61\73\6d\01\00\00\00\05\83\80\80\80\00\01\00" 21 | "\01\0b\a2\80\80\80\00\05\00\41\00\0b\01\61\00\41" 22 | "\03\0b\01\62\00\41\e4\00\0b\03\63\64\65\00\41\05" 23 | "\0b\01\78\00\41\03\0b\01\63" 24 | ) 25 | (module binary 26 | "\00\61\73\6d\01\00\00\00\02\94\80\80\80\00\01\08" 27 | "\73\70\65\63\74\65\73\74\06\6d\65\6d\6f\72\79\02" 28 | "\00\01\0b\a7\80\80\80\00\06\00\41\00\0b\01\61\00" 29 | "\41\01\0b\01\62\00\41\02\0b\03\63\64\65\00\41\03" 30 | "\0b\01\66\00\41\02\0b\01\67\00\41\01\0b\01\68" 31 | ) 32 | (module binary 33 | "\00\61\73\6d\01\00\00\00\02\98\80\80\80\00\01\08" 34 | "\73\70\65\63\74\65\73\74\0a\67\6c\6f\62\61\6c\5f" 35 | "\69\33\32\03\7f\00\05\83\80\80\80\00\01\00\01\0b" 36 | "\87\80\80\80\00\01\00\23\00\0b\01\61" 37 | ) 38 | (module binary 39 | "\00\61\73\6d\01\00\00\00\02\ab\80\80\80\00\02\08" 40 | "\73\70\65\63\74\65\73\74\0a\67\6c\6f\62\61\6c\5f" 41 | "\69\33\32\03\7f\00\08\73\70\65\63\74\65\73\74\06" 42 | "\6d\65\6d\6f\72\79\02\00\01\0b\87\80\80\80\00\01" 43 | "\00\23\00\0b\01\61" 44 | ) 45 | (module binary 46 | "\00\61\73\6d\01\00\00\00\02\98\80\80\80\00\01\08" 47 | "\73\70\65\63\74\65\73\74\0a\67\6c\6f\62\61\6c\5f" 48 | "\69\33\32\03\7f\00\05\83\80\80\80\00\01\00\01\0b" 49 | "\87\80\80\80\00\01\00\23\00\0b\01\61" 50 | ) 51 | (module binary 52 | "\00\61\73\6d\01\00\00\00\02\ab\80\80\80\00\02\08" 53 | "\73\70\65\63\74\65\73\74\0a\67\6c\6f\62\61\6c\5f" 54 | "\69\33\32\03\7f\00\08\73\70\65\63\74\65\73\74\06" 55 | "\6d\65\6d\6f\72\79\02\00\01\0b\87\80\80\80\00\01" 56 | "\00\23\00\0b\01\61" 57 | ) 58 | (module binary 59 | "\00\61\73\6d\01\00\00\00\05\83\80\80\80\00\01\00" 60 | "\01\0b\8f\80\80\80\00\02\00\41\00\0b\01\61\00\41" 61 | "\ff\ff\03\0b\01\62" 62 | ) 63 | (module binary 64 | "\00\61\73\6d\01\00\00\00\02\94\80\80\80\00\01\08" 65 | "\73\70\65\63\74\65\73\74\06\6d\65\6d\6f\72\79\02" 66 | "\00\01\0b\8f\80\80\80\00\02\00\41\00\0b\01\61\00" 67 | "\41\ff\ff\03\0b\01\62" 68 | ) 69 | (module binary 70 | "\00\61\73\6d\01\00\00\00\05\83\80\80\80\00\01\00" 71 | "\02\0b\89\80\80\80\00\01\00\41\ff\ff\07\0b\01\61" 72 | ) 73 | (module binary 74 | "\00\61\73\6d\01\00\00\00\05\83\80\80\80\00\01\00" 75 | "\00\0b\86\80\80\80\00\01\00\41\00\0b\00" 76 | ) 77 | (module binary 78 | "\00\61\73\6d\01\00\00\00\02\94\80\80\80\00\01\08" 79 | "\73\70\65\63\74\65\73\74\06\6d\65\6d\6f\72\79\02" 80 | "\00\00\0b\86\80\80\80\00\01\00\41\00\0b\00" 81 | ) 82 | (module binary 83 | "\00\61\73\6d\01\00\00\00\05\84\80\80\80\00\01\01" 84 | "\00\00\0b\86\80\80\80\00\01\00\41\00\0b\00" 85 | ) 86 | (module binary 87 | "\00\61\73\6d\01\00\00\00\05\83\80\80\80\00\01\00" 88 | "\01\0b\88\80\80\80\00\01\00\41\80\80\04\0b\00" 89 | ) 90 | (module binary 91 | "\00\61\73\6d\01\00\00\00\05\83\80\80\80\00\01\00" 92 | "\00\0b\86\80\80\80\00\01\00\41\00\0b\00" 93 | ) 94 | (module binary 95 | "\00\61\73\6d\01\00\00\00\02\94\80\80\80\00\01\08" 96 | "\73\70\65\63\74\65\73\74\06\6d\65\6d\6f\72\79\02" 97 | "\00\00\0b\86\80\80\80\00\01\00\41\00\0b\00" 98 | ) 99 | (module binary 100 | "\00\61\73\6d\01\00\00\00\05\84\80\80\80\00\01\01" 101 | "\00\00\0b\86\80\80\80\00\01\00\41\00\0b\00" 102 | ) 103 | (module binary 104 | "\00\61\73\6d\01\00\00\00\02\94\80\80\80\00\01\08" 105 | "\73\70\65\63\74\65\73\74\06\6d\65\6d\6f\72\79\02" 106 | "\00\00\0b\87\80\80\80\00\01\00\41\00\0b\01\61" 107 | ) 108 | (module binary 109 | "\00\61\73\6d\01\00\00\00\02\95\80\80\80\00\01\08" 110 | "\73\70\65\63\74\65\73\74\06\6d\65\6d\6f\72\79\02" 111 | "\01\00\03\0b\87\80\80\80\00\01\00\41\00\0b\01\61" 112 | ) 113 | (module binary 114 | "\00\61\73\6d\01\00\00\00\02\ab\80\80\80\00\02\08" 115 | "\73\70\65\63\74\65\73\74\0a\67\6c\6f\62\61\6c\5f" 116 | "\69\33\32\03\7f\00\08\73\70\65\63\74\65\73\74\06" 117 | "\6d\65\6d\6f\72\79\02\00\00\0b\87\80\80\80\00\01" 118 | "\00\23\00\0b\01\61" 119 | ) 120 | (module binary 121 | "\00\61\73\6d\01\00\00\00\02\ac\80\80\80\00\02\08" 122 | "\73\70\65\63\74\65\73\74\0a\67\6c\6f\62\61\6c\5f" 123 | "\69\33\32\03\7f\00\08\73\70\65\63\74\65\73\74\06" 124 | "\6d\65\6d\6f\72\79\02\01\00\03\0b\87\80\80\80\00" 125 | "\01\00\23\00\0b\01\61" 126 | ) 127 | (module binary 128 | "\00\61\73\6d\01\00\00\00\02\94\80\80\80\00\01\08" 129 | "\73\70\65\63\74\65\73\74\06\6d\65\6d\6f\72\79\02" 130 | "\00\00\0b\87\80\80\80\00\01\00\41\01\0b\01\61" 131 | ) 132 | (module binary 133 | "\00\61\73\6d\01\00\00\00\02\95\80\80\80\00\01\08" 134 | "\73\70\65\63\74\65\73\74\06\6d\65\6d\6f\72\79\02" 135 | "\01\00\03\0b\87\80\80\80\00\01\00\41\01\0b\01\61" 136 | ) 137 | (assert_unlinkable 138 | (module binary 139 | "\00\61\73\6d\01\00\00\00\05\83\80\80\80\00\01\00" 140 | "\00\0b\87\80\80\80\00\01\00\41\00\0b\01\61" 141 | ) 142 | "data segment does not fit" 143 | ) 144 | (assert_unlinkable 145 | (module binary 146 | "\00\61\73\6d\01\00\00\00\05\84\80\80\80\00\01\01" 147 | "\00\00\0b\87\80\80\80\00\01\00\41\00\0b\01\61" 148 | ) 149 | "data segment does not fit" 150 | ) 151 | (assert_unlinkable 152 | (module binary 153 | "\00\61\73\6d\01\00\00\00\05\84\80\80\80\00\01\01" 154 | "\00\01\0b\87\80\80\80\00\01\00\41\00\0b\01\61" 155 | ) 156 | "data segment does not fit" 157 | ) 158 | (assert_unlinkable 159 | (module binary 160 | "\00\61\73\6d\01\00\00\00\05\83\80\80\80\00\01\00" 161 | "\00\0b\86\80\80\80\00\01\00\41\01\0b\00" 162 | ) 163 | "data segment does not fit" 164 | ) 165 | (assert_unlinkable 166 | (module binary 167 | "\00\61\73\6d\01\00\00\00\05\84\80\80\80\00\01\01" 168 | "\00\01\0b\86\80\80\80\00\01\00\41\01\0b\00" 169 | ) 170 | "data segment does not fit" 171 | ) 172 | (assert_unlinkable 173 | (module binary 174 | "\00\61\73\6d\01\00\00\00\02\98\80\80\80\00\01\08" 175 | "\73\70\65\63\74\65\73\74\0a\67\6c\6f\62\61\6c\5f" 176 | "\69\33\32\03\7f\00\05\83\80\80\80\00\01\00\00\0b" 177 | "\87\80\80\80\00\01\00\23\00\0b\01\61" 178 | ) 179 | "data segment does not fit" 180 | ) 181 | (assert_unlinkable 182 | (module binary 183 | "\00\61\73\6d\01\00\00\00\05\84\80\80\80\00\01\01" 184 | "\01\02\0b\89\80\80\80\00\01\00\41\80\80\04\0b\01" 185 | "\61" 186 | ) 187 | "data segment does not fit" 188 | ) 189 | (assert_unlinkable 190 | (module binary 191 | "\00\61\73\6d\01\00\00\00\02\94\80\80\80\00\01\08" 192 | "\73\70\65\63\74\65\73\74\06\6d\65\6d\6f\72\79\02" 193 | "\00\01\0b\89\80\80\80\00\01\00\41\80\80\04\0b\01" 194 | "\61" 195 | ) 196 | "data segment does not fit" 197 | ) 198 | (assert_unlinkable 199 | (module binary 200 | "\00\61\73\6d\01\00\00\00\05\83\80\80\80\00\01\00" 201 | "\02\0b\89\80\80\80\00\01\00\41\80\80\08\0b\01\61" 202 | ) 203 | "data segment does not fit" 204 | ) 205 | (assert_unlinkable 206 | (module binary 207 | "\00\61\73\6d\01\00\00\00\05\84\80\80\80\00\01\01" 208 | "\02\03\0b\89\80\80\80\00\01\00\41\80\80\08\0b\01" 209 | "\61" 210 | ) 211 | "data segment does not fit" 212 | ) 213 | (assert_unlinkable 214 | (module binary 215 | "\00\61\73\6d\01\00\00\00\05\83\80\80\80\00\01\00" 216 | "\01\0b\87\80\80\80\00\01\00\41\7f\0b\01\61" 217 | ) 218 | "data segment does not fit" 219 | ) 220 | (assert_unlinkable 221 | (module binary 222 | "\00\61\73\6d\01\00\00\00\02\94\80\80\80\00\01\08" 223 | "\73\70\65\63\74\65\73\74\06\6d\65\6d\6f\72\79\02" 224 | "\00\01\0b\87\80\80\80\00\01\00\41\7f\0b\01\61" 225 | ) 226 | "data segment does not fit" 227 | ) 228 | (assert_unlinkable 229 | (module binary 230 | "\00\61\73\6d\01\00\00\00\05\83\80\80\80\00\01\00" 231 | "\02\0b\88\80\80\80\00\01\00\41\9c\7f\0b\01\61" 232 | ) 233 | "data segment does not fit" 234 | ) 235 | (assert_unlinkable 236 | (module binary 237 | "\00\61\73\6d\01\00\00\00\02\94\80\80\80\00\01\08" 238 | "\73\70\65\63\74\65\73\74\06\6d\65\6d\6f\72\79\02" 239 | "\00\01\0b\88\80\80\80\00\01\00\41\9c\7f\0b\01\61" 240 | ) 241 | "data segment does not fit" 242 | ) 243 | (assert_invalid 244 | (module binary 245 | "\00\61\73\6d\01\00\00\00\0b\86\80\80\80\00\01\00" 246 | "\41\00\0b\00" 247 | ) 248 | "unknown memory" 249 | ) 250 | (assert_invalid 251 | (module binary 252 | "\00\61\73\6d\01\00\00\00\05\83\80\80\80\00\01\00" 253 | "\01\0b\86\80\80\80\00\01\00\42\00\0b\00" 254 | ) 255 | "type mismatch" 256 | ) 257 | (assert_invalid 258 | (module binary 259 | "\00\61\73\6d\01\00\00\00\05\83\80\80\80\00\01\00" 260 | "\01\0b\87\80\80\80\00\01\00\41\00\68\0b\00" 261 | ) 262 | "constant expression required" 263 | ) 264 | (assert_invalid 265 | (module binary 266 | "\00\61\73\6d\01\00\00\00\05\83\80\80\80\00\01\00" 267 | "\01\0b\85\80\80\80\00\01\00\01\0b\00" 268 | ) 269 | "constant expression required" 270 | ) 271 | (assert_invalid 272 | (module binary 273 | "\00\61\73\6d\01\00\00\00\05\83\80\80\80\00\01\00" 274 | "\01\0b\87\80\80\80\00\01\00\01\41\00\0b\00" 275 | ) 276 | "constant expression required" 277 | ) 278 | (assert_invalid 279 | (module binary 280 | "\00\61\73\6d\01\00\00\00\05\83\80\80\80\00\01\00" 281 | "\01\0b\87\80\80\80\00\01\00\41\00\01\0b\00" 282 | ) 283 | "constant expression required" 284 | ) 285 | -------------------------------------------------------------------------------- /tests/suite/endianness.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary 2 | "\00\61\73\6d\01\00\00\00\01\a4\80\80\80\00\07\60" 3 | "\02\7f\7f\00\60\02\7f\7e\00\60\01\7f\01\7f\60\01" 4 | "\7f\01\7e\60\01\7e\01\7e\60\01\7d\01\7d\60\01\7c" 5 | "\01\7c\03\98\80\80\80\00\17\00\00\01\02\02\03\02" 6 | "\02\02\04\04\04\04\04\05\06\02\02\04\04\04\05\06" 7 | "\05\83\80\80\80\00\01\00\01\07\e1\81\80\80\00\11" 8 | "\0c\69\33\32\5f\6c\6f\61\64\31\36\5f\73\00\06\0c" 9 | "\69\33\32\5f\6c\6f\61\64\31\36\5f\75\00\07\08\69" 10 | "\33\32\5f\6c\6f\61\64\00\08\0c\69\36\34\5f\6c\6f" 11 | "\61\64\31\36\5f\73\00\09\0c\69\36\34\5f\6c\6f\61" 12 | "\64\31\36\5f\75\00\0a\0c\69\36\34\5f\6c\6f\61\64" 13 | "\33\32\5f\73\00\0b\0c\69\36\34\5f\6c\6f\61\64\33" 14 | "\32\5f\75\00\0c\08\69\36\34\5f\6c\6f\61\64\00\0d" 15 | "\08\66\33\32\5f\6c\6f\61\64\00\0e\08\66\36\34\5f" 16 | "\6c\6f\61\64\00\0f\0b\69\33\32\5f\73\74\6f\72\65" 17 | "\31\36\00\10\09\69\33\32\5f\73\74\6f\72\65\00\11" 18 | "\0b\69\36\34\5f\73\74\6f\72\65\31\36\00\12\0b\69" 19 | "\36\34\5f\73\74\6f\72\65\33\32\00\13\09\69\36\34" 20 | "\5f\73\74\6f\72\65\00\14\09\66\33\32\5f\73\74\6f" 21 | "\72\65\00\15\09\66\36\34\5f\73\74\6f\72\65\00\16" 22 | "\0a\d2\83\80\80\00\17\96\80\80\80\00\00\20\00\20" 23 | "\01\3a\00\00\20\00\41\01\6a\20\01\41\08\76\3a\00" 24 | "\00\0b\94\80\80\80\00\00\20\00\20\01\10\00\20\00" 25 | "\41\02\6a\20\01\41\10\76\10\00\0b\96\80\80\80\00" 26 | "\00\20\00\20\01\a7\10\01\20\00\41\04\6a\20\01\42" 27 | "\20\88\a7\10\01\0b\93\80\80\80\00\00\20\00\2d\00" 28 | "\00\20\00\41\01\6a\2d\00\00\41\08\74\72\0b\91\80" 29 | "\80\80\00\00\20\00\10\03\20\00\41\02\6a\10\03\41" 30 | "\10\74\72\0b\93\80\80\80\00\00\20\00\10\04\ad\20" 31 | "\00\41\04\6a\10\04\ad\42\20\86\84\0b\8d\80\80\80" 32 | "\00\00\41\00\20\00\10\00\41\00\2e\01\00\0b\8d\80" 33 | "\80\80\00\00\41\00\20\00\10\00\41\00\2f\01\00\0b" 34 | "\8d\80\80\80\00\00\41\00\20\00\10\01\41\00\28\02" 35 | "\00\0b\8e\80\80\80\00\00\41\00\20\00\a7\10\00\41" 36 | "\00\32\01\00\0b\8e\80\80\80\00\00\41\00\20\00\a7" 37 | "\10\00\41\00\33\01\00\0b\8e\80\80\80\00\00\41\00" 38 | "\20\00\a7\10\01\41\00\34\02\00\0b\8e\80\80\80\00" 39 | "\00\41\00\20\00\a7\10\01\41\00\35\02\00\0b\8d\80" 40 | "\80\80\00\00\41\00\20\00\10\02\41\00\29\03\00\0b" 41 | "\8e\80\80\80\00\00\41\00\20\00\bc\10\01\41\00\2a" 42 | "\02\00\0b\8e\80\80\80\00\00\41\00\20\00\bd\10\02" 43 | "\41\00\2b\03\00\0b\8d\80\80\80\00\00\41\00\20\00" 44 | "\3b\01\00\41\00\10\03\0b\8d\80\80\80\00\00\41\00" 45 | "\20\00\36\02\00\41\00\10\04\0b\8e\80\80\80\00\00" 46 | "\41\00\20\00\3d\01\00\41\00\10\03\ad\0b\8e\80\80" 47 | "\80\00\00\41\00\20\00\3e\02\00\41\00\10\04\ad\0b" 48 | "\8d\80\80\80\00\00\41\00\20\00\37\03\00\41\00\10" 49 | "\05\0b\8e\80\80\80\00\00\41\00\20\00\38\02\00\41" 50 | "\00\10\04\be\0b\8e\80\80\80\00\00\41\00\20\00\39" 51 | "\03\00\41\00\10\05\bf\0b" 52 | ) 53 | (assert_return (invoke "i32_load16_s" (i32.const -1)) (i32.const -1)) 54 | (assert_return (invoke "i32_load16_s" (i32.const -4_242)) (i32.const -4_242)) 55 | (assert_return (invoke "i32_load16_s" (i32.const 42)) (i32.const 42)) 56 | (assert_return (invoke "i32_load16_s" (i32.const 12_816)) (i32.const 12_816)) 57 | (assert_return (invoke "i32_load16_u" (i32.const -1)) (i32.const 65_535)) 58 | (assert_return (invoke "i32_load16_u" (i32.const -4_242)) (i32.const 61_294)) 59 | (assert_return (invoke "i32_load16_u" (i32.const 42)) (i32.const 42)) 60 | (assert_return (invoke "i32_load16_u" (i32.const 51_966)) (i32.const 51_966)) 61 | (assert_return (invoke "i32_load" (i32.const -1)) (i32.const -1)) 62 | (assert_return 63 | (invoke "i32_load" (i32.const -42_424_242)) 64 | (i32.const -42_424_242) 65 | ) 66 | (assert_return 67 | (invoke "i32_load" (i32.const 42_424_242)) 68 | (i32.const 42_424_242) 69 | ) 70 | (assert_return 71 | (invoke "i32_load" (i32.const -1_414_717_974)) 72 | (i32.const -1_414_717_974) 73 | ) 74 | (assert_return (invoke "i64_load16_s" (i64.const -1)) (i64.const -1)) 75 | (assert_return (invoke "i64_load16_s" (i64.const -4_242)) (i64.const -4_242)) 76 | (assert_return (invoke "i64_load16_s" (i64.const 42)) (i64.const 42)) 77 | (assert_return (invoke "i64_load16_s" (i64.const 12_816)) (i64.const 12_816)) 78 | (assert_return (invoke "i64_load16_u" (i64.const -1)) (i64.const 65_535)) 79 | (assert_return (invoke "i64_load16_u" (i64.const -4_242)) (i64.const 61_294)) 80 | (assert_return (invoke "i64_load16_u" (i64.const 42)) (i64.const 42)) 81 | (assert_return (invoke "i64_load16_u" (i64.const 51_966)) (i64.const 51_966)) 82 | (assert_return (invoke "i64_load32_s" (i64.const -1)) (i64.const -1)) 83 | (assert_return 84 | (invoke "i64_load32_s" (i64.const -42_424_242)) 85 | (i64.const -42_424_242) 86 | ) 87 | (assert_return 88 | (invoke "i64_load32_s" (i64.const 42_424_242)) 89 | (i64.const 42_424_242) 90 | ) 91 | (assert_return 92 | (invoke "i64_load32_s" (i64.const 305_419_896)) 93 | (i64.const 305_419_896) 94 | ) 95 | (assert_return (invoke "i64_load32_u" (i64.const -1)) (i64.const 4_294_967_295)) 96 | (assert_return 97 | (invoke "i64_load32_u" (i64.const -42_424_242)) 98 | (i64.const 4_252_543_054) 99 | ) 100 | (assert_return 101 | (invoke "i64_load32_u" (i64.const 42_424_242)) 102 | (i64.const 42_424_242) 103 | ) 104 | (assert_return 105 | (invoke "i64_load32_u" (i64.const 2_880_249_322)) 106 | (i64.const 2_880_249_322) 107 | ) 108 | (assert_return (invoke "i64_load" (i64.const -1)) (i64.const -1)) 109 | (assert_return 110 | (invoke "i64_load" (i64.const -42_424_242)) 111 | (i64.const -42_424_242) 112 | ) 113 | (assert_return 114 | (invoke "i64_load" (i64.const 2_880_249_322)) 115 | (i64.const 2_880_249_322) 116 | ) 117 | (assert_return 118 | (invoke "i64_load" (i64.const -6_075_977_126_246_539_798)) 119 | (i64.const -6_075_977_126_246_539_798) 120 | ) 121 | (assert_return (invoke "f32_load" (f32.const -1)) (f32.const -1)) 122 | (assert_return 123 | (invoke "f32_load" (f32.const 0.012_339_999_899_268_15)) 124 | (f32.const 0.012_339_999_899_268_15) 125 | ) 126 | (assert_return 127 | (invoke "f32_load" (f32.const 4_242.424_316_406_25)) 128 | (f32.const 4_242.424_316_406_25) 129 | ) 130 | (assert_return 131 | (invoke "f32_load" (f32.const 3.402_823_466_385_288_6e+38)) 132 | (f32.const 3.402_823_466_385_288_6e+38) 133 | ) 134 | (assert_return (invoke "f64_load" (f64.const -1)) (f64.const -1)) 135 | (assert_return 136 | (invoke "f64_load" (f64.const 1_234.567_89)) 137 | (f64.const 1_234.567_89) 138 | ) 139 | (assert_return 140 | (invoke "f64_load" (f64.const 424_242.424_241_999_98)) 141 | (f64.const 424_242.424_241_999_98) 142 | ) 143 | (assert_return 144 | (invoke "f64_load" (f64.const 1.797_693_134_862_315_7e+308)) 145 | (f64.const 1.797_693_134_862_315_7e+308) 146 | ) 147 | (assert_return (invoke "i32_store16" (i32.const -1)) (i32.const 65_535)) 148 | (assert_return (invoke "i32_store16" (i32.const -4_242)) (i32.const 61_294)) 149 | (assert_return (invoke "i32_store16" (i32.const 42)) (i32.const 42)) 150 | (assert_return (invoke "i32_store16" (i32.const 51_966)) (i32.const 51_966)) 151 | (assert_return (invoke "i32_store" (i32.const -1)) (i32.const -1)) 152 | (assert_return (invoke "i32_store" (i32.const -4_242)) (i32.const -4_242)) 153 | (assert_return 154 | (invoke "i32_store" (i32.const 42_424_242)) 155 | (i32.const 42_424_242) 156 | ) 157 | (assert_return 158 | (invoke "i32_store" (i32.const -559_035_650)) 159 | (i32.const -559_035_650) 160 | ) 161 | (assert_return (invoke "i64_store16" (i64.const -1)) (i64.const 65_535)) 162 | (assert_return (invoke "i64_store16" (i64.const -4_242)) (i64.const 61_294)) 163 | (assert_return (invoke "i64_store16" (i64.const 42)) (i64.const 42)) 164 | (assert_return (invoke "i64_store16" (i64.const 51_966)) (i64.const 51_966)) 165 | (assert_return (invoke "i64_store32" (i64.const -1)) (i64.const 4_294_967_295)) 166 | (assert_return 167 | (invoke "i64_store32" (i64.const -4_242)) 168 | (i64.const 4_294_963_054) 169 | ) 170 | (assert_return 171 | (invoke "i64_store32" (i64.const 42_424_242)) 172 | (i64.const 42_424_242) 173 | ) 174 | (assert_return 175 | (invoke "i64_store32" (i64.const 3_735_931_646)) 176 | (i64.const 3_735_931_646) 177 | ) 178 | (assert_return (invoke "i64_store" (i64.const -1)) (i64.const -1)) 179 | (assert_return 180 | (invoke "i64_store" (i64.const -42_424_242)) 181 | (i64.const -42_424_242) 182 | ) 183 | (assert_return 184 | (invoke "i64_store" (i64.const 2_880_249_322)) 185 | (i64.const 2_880_249_322) 186 | ) 187 | (assert_return 188 | (invoke "i64_store" (i64.const -6_075_977_126_246_539_798)) 189 | (i64.const -6_075_977_126_246_539_798) 190 | ) 191 | (assert_return (invoke "f32_store" (f32.const -1)) (f32.const -1)) 192 | (assert_return 193 | (invoke "f32_store" (f32.const 0.012_339_999_899_268_15)) 194 | (f32.const 0.012_339_999_899_268_15) 195 | ) 196 | (assert_return 197 | (invoke "f32_store" (f32.const 4_242.424_316_406_25)) 198 | (f32.const 4_242.424_316_406_25) 199 | ) 200 | (assert_return 201 | (invoke "f32_store" (f32.const 3.402_823_466_385_288_6e+38)) 202 | (f32.const 3.402_823_466_385_288_6e+38) 203 | ) 204 | (assert_return (invoke "f64_store" (f64.const -1)) (f64.const -1)) 205 | (assert_return 206 | (invoke "f64_store" (f64.const 1_234.567_89)) 207 | (f64.const 1_234.567_89) 208 | ) 209 | (assert_return 210 | (invoke "f64_store" (f64.const 424_242.424_241_999_98)) 211 | (f64.const 424_242.424_241_999_98) 212 | ) 213 | (assert_return 214 | (invoke "f64_store" (f64.const 1.797_693_134_862_315_7e+308)) 215 | (f64.const 1.797_693_134_862_315_7e+308) 216 | ) 217 | -------------------------------------------------------------------------------- /tests/suite/fac.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary 2 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 3 | "\01\7e\01\7e\03\86\80\80\80\00\05\00\00\00\00\00" 4 | "\07\c1\80\80\80\00\05\07\66\61\63\2d\72\65\63\00" 5 | "\00\0d\66\61\63\2d\72\65\63\2d\6e\61\6d\65\64\00" 6 | "\01\08\66\61\63\2d\69\74\65\72\00\02\0e\66\61\63" 7 | "\2d\69\74\65\72\2d\6e\61\6d\65\64\00\03\07\66\61" 8 | "\63\2d\6f\70\74\00\04\0a\d2\81\80\80\00\05\97\80" 9 | "\80\80\00\00\20\00\42\00\51\04\7e\42\01\05\20\00" 10 | "\20\00\42\01\7d\10\00\7e\0b\0b\97\80\80\80\00\00" 11 | "\20\00\42\00\51\04\7e\42\01\05\20\00\20\00\42\01" 12 | "\7d\10\01\7e\0b\0b\af\80\80\80\00\01\02\7e\20\00" 13 | "\21\01\42\01\21\02\02\40\03\40\20\01\42\00\51\04" 14 | "\40\0c\02\05\20\01\20\02\7e\21\02\20\01\42\01\7d" 15 | "\21\01\0b\0c\00\0b\0b\20\02\0b\af\80\80\80\00\01" 16 | "\02\7e\20\00\21\01\42\01\21\02\02\40\03\40\20\01" 17 | "\42\00\51\04\40\0c\02\05\20\01\20\02\7e\21\02\20" 18 | "\01\42\01\7d\21\01\0b\0c\00\0b\0b\20\02\0b\ac\80" 19 | "\80\80\00\01\01\7e\42\01\21\01\02\40\20\00\42\02" 20 | "\53\0d\00\03\40\20\01\20\00\7e\21\01\20\00\42\7f" 21 | "\7c\21\00\20\00\42\01\55\0d\00\0b\0b\20\01\0b" 22 | ) 23 | (assert_return 24 | (invoke "fac-rec" (i64.const 25)) 25 | (i64.const 7_034_535_277_573_963_776) 26 | ) 27 | (assert_return 28 | (invoke "fac-iter" (i64.const 25)) 29 | (i64.const 7_034_535_277_573_963_776) 30 | ) 31 | (assert_return 32 | (invoke "fac-rec-named" (i64.const 25)) 33 | (i64.const 7_034_535_277_573_963_776) 34 | ) 35 | (assert_return 36 | (invoke "fac-iter-named" (i64.const 25)) 37 | (i64.const 7_034_535_277_573_963_776) 38 | ) 39 | (assert_return 40 | (invoke "fac-opt" (i64.const 25)) 41 | (i64.const 7_034_535_277_573_963_776) 42 | ) 43 | (assert_exhaustion 44 | (invoke "fac-rec" (i64.const 1_073_741_824)) 45 | "call stack exhausted" 46 | ) 47 | -------------------------------------------------------------------------------- /tests/suite/float_memory.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary 2 | "\00\61\73\6d\01\00\00\00\01\8c\80\80\80\00\03\60" 3 | "\00\01\7d\60\00\01\7f\60\00\00\03\86\80\80\80\00" 4 | "\05\00\01\02\02\02\05\84\80\80\80\00\01\01\01\01" 5 | "\07\b7\80\80\80\00\05\08\66\33\32\2e\6c\6f\61\64" 6 | "\00\00\08\69\33\32\2e\6c\6f\61\64\00\01\09\66\33" 7 | "\32\2e\73\74\6f\72\65\00\02\09\69\33\32\2e\73\74" 8 | "\6f\72\65\00\03\05\72\65\73\65\74\00\04\0a\ca\80" 9 | "\80\80\00\05\87\80\80\80\00\00\41\00\2a\02\00\0b" 10 | "\87\80\80\80\00\00\41\00\28\02\00\0b\8c\80\80\80" 11 | "\00\00\41\00\43\00\00\a0\7f\38\02\00\0b\8d\80\80" 12 | "\80\00\00\41\00\41\80\80\80\fd\07\36\02\00\0b\89" 13 | "\80\80\80\00\00\41\00\41\00\36\02\00\0b\0b\8a\80" 14 | "\80\80\00\01\00\41\00\0b\04\00\00\a0\7f" 15 | ) 16 | (assert_return (invoke "i32.load") (i32.const 2_141_192_192)) 17 | (assert_return (invoke "f32.load") (f32.const nan:0x200000)) 18 | (invoke "reset") 19 | (assert_return (invoke "i32.load") (i32.const 0)) 20 | (assert_return (invoke "f32.load") (f32.const 0)) 21 | (invoke "f32.store") 22 | (assert_return (invoke "i32.load") (i32.const 2_141_192_192)) 23 | (assert_return (invoke "f32.load") (f32.const nan:0x200000)) 24 | (invoke "reset") 25 | (assert_return (invoke "i32.load") (i32.const 0)) 26 | (assert_return (invoke "f32.load") (f32.const 0)) 27 | (invoke "i32.store") 28 | (assert_return (invoke "i32.load") (i32.const 2_141_192_192)) 29 | (assert_return (invoke "f32.load") (f32.const nan:0x200000)) 30 | (module binary 31 | "\00\61\73\6d\01\00\00\00\01\8c\80\80\80\00\03\60" 32 | "\00\01\7c\60\00\01\7e\60\00\00\03\86\80\80\80\00" 33 | "\05\00\01\02\02\02\05\84\80\80\80\00\01\01\01\01" 34 | "\07\b7\80\80\80\00\05\08\66\36\34\2e\6c\6f\61\64" 35 | "\00\00\08\69\36\34\2e\6c\6f\61\64\00\01\09\66\36" 36 | "\34\2e\73\74\6f\72\65\00\02\09\69\36\34\2e\73\74" 37 | "\6f\72\65\00\03\05\72\65\73\65\74\00\04\0a\d3\80" 38 | "\80\80\00\05\87\80\80\80\00\00\41\00\2b\03\00\0b" 39 | "\87\80\80\80\00\00\41\00\29\03\00\0b\90\80\80\80" 40 | "\00\00\41\00\44\00\00\00\00\00\00\f4\7f\39\03\00" 41 | "\0b\92\80\80\80\00\00\41\00\42\80\80\80\80\80\80" 42 | "\80\fa\ff\00\37\03\00\0b\89\80\80\80\00\00\41\00" 43 | "\42\00\37\03\00\0b\0b\8e\80\80\80\00\01\00\41\00" 44 | "\0b\08\00\00\00\00\00\00\f4\7f" 45 | ) 46 | (assert_return (invoke "i64.load") (i64.const 9_219_994_337_134_247_936)) 47 | (assert_return (invoke "f64.load") (f64.const nan:0x4000000000000)) 48 | (invoke "reset") 49 | (assert_return (invoke "i64.load") (i64.const 0)) 50 | (assert_return (invoke "f64.load") (f64.const 0)) 51 | (invoke "f64.store") 52 | (assert_return (invoke "i64.load") (i64.const 9_219_994_337_134_247_936)) 53 | (assert_return (invoke "f64.load") (f64.const nan:0x4000000000000)) 54 | (invoke "reset") 55 | (assert_return (invoke "i64.load") (i64.const 0)) 56 | (assert_return (invoke "f64.load") (f64.const 0)) 57 | (invoke "i64.store") 58 | (assert_return (invoke "i64.load") (i64.const 9_219_994_337_134_247_936)) 59 | (assert_return (invoke "f64.load") (f64.const nan:0x4000000000000)) 60 | (module binary 61 | "\00\61\73\6d\01\00\00\00\01\8c\80\80\80\00\03\60" 62 | "\00\01\7d\60\00\01\7f\60\00\00\03\86\80\80\80\00" 63 | "\05\00\01\02\02\02\05\84\80\80\80\00\01\01\01\01" 64 | "\07\b7\80\80\80\00\05\08\66\33\32\2e\6c\6f\61\64" 65 | "\00\00\08\69\33\32\2e\6c\6f\61\64\00\01\09\66\33" 66 | "\32\2e\73\74\6f\72\65\00\02\09\69\33\32\2e\73\74" 67 | "\6f\72\65\00\03\05\72\65\73\65\74\00\04\0a\ca\80" 68 | "\80\80\00\05\87\80\80\80\00\00\41\01\2a\02\00\0b" 69 | "\87\80\80\80\00\00\41\01\28\02\00\0b\8c\80\80\80" 70 | "\00\00\41\01\43\00\00\a0\7f\38\02\00\0b\8d\80\80" 71 | "\80\00\00\41\01\41\80\80\80\fd\07\36\02\00\0b\89" 72 | "\80\80\80\00\00\41\01\41\00\36\02\00\0b\0b\8b\80" 73 | "\80\80\00\01\00\41\00\0b\05\00\00\00\a0\7f" 74 | ) 75 | (assert_return (invoke "i32.load") (i32.const 2_141_192_192)) 76 | (assert_return (invoke "f32.load") (f32.const nan:0x200000)) 77 | (invoke "reset") 78 | (assert_return (invoke "i32.load") (i32.const 0)) 79 | (assert_return (invoke "f32.load") (f32.const 0)) 80 | (invoke "f32.store") 81 | (assert_return (invoke "i32.load") (i32.const 2_141_192_192)) 82 | (assert_return (invoke "f32.load") (f32.const nan:0x200000)) 83 | (invoke "reset") 84 | (assert_return (invoke "i32.load") (i32.const 0)) 85 | (assert_return (invoke "f32.load") (f32.const 0)) 86 | (invoke "i32.store") 87 | (assert_return (invoke "i32.load") (i32.const 2_141_192_192)) 88 | (assert_return (invoke "f32.load") (f32.const nan:0x200000)) 89 | (module binary 90 | "\00\61\73\6d\01\00\00\00\01\8c\80\80\80\00\03\60" 91 | "\00\01\7c\60\00\01\7e\60\00\00\03\86\80\80\80\00" 92 | "\05\00\01\02\02\02\05\84\80\80\80\00\01\01\01\01" 93 | "\07\b7\80\80\80\00\05\08\66\36\34\2e\6c\6f\61\64" 94 | "\00\00\08\69\36\34\2e\6c\6f\61\64\00\01\09\66\36" 95 | "\34\2e\73\74\6f\72\65\00\02\09\69\36\34\2e\73\74" 96 | "\6f\72\65\00\03\05\72\65\73\65\74\00\04\0a\d3\80" 97 | "\80\80\00\05\87\80\80\80\00\00\41\01\2b\03\00\0b" 98 | "\87\80\80\80\00\00\41\01\29\03\00\0b\90\80\80\80" 99 | "\00\00\41\01\44\00\00\00\00\00\00\f4\7f\39\03\00" 100 | "\0b\92\80\80\80\00\00\41\01\42\80\80\80\80\80\80" 101 | "\80\fa\ff\00\37\03\00\0b\89\80\80\80\00\00\41\01" 102 | "\42\00\37\03\00\0b\0b\8f\80\80\80\00\01\00\41\00" 103 | "\0b\09\00\00\00\00\00\00\00\f4\7f" 104 | ) 105 | (assert_return (invoke "i64.load") (i64.const 9_219_994_337_134_247_936)) 106 | (assert_return (invoke "f64.load") (f64.const nan:0x4000000000000)) 107 | (invoke "reset") 108 | (assert_return (invoke "i64.load") (i64.const 0)) 109 | (assert_return (invoke "f64.load") (f64.const 0)) 110 | (invoke "f64.store") 111 | (assert_return (invoke "i64.load") (i64.const 9_219_994_337_134_247_936)) 112 | (assert_return (invoke "f64.load") (f64.const nan:0x4000000000000)) 113 | (invoke "reset") 114 | (assert_return (invoke "i64.load") (i64.const 0)) 115 | (assert_return (invoke "f64.load") (f64.const 0)) 116 | (invoke "i64.store") 117 | (assert_return (invoke "i64.load") (i64.const 9_219_994_337_134_247_936)) 118 | (assert_return (invoke "f64.load") (f64.const nan:0x4000000000000)) 119 | (module binary 120 | "\00\61\73\6d\01\00\00\00\01\8c\80\80\80\00\03\60" 121 | "\00\01\7d\60\00\01\7f\60\00\00\03\86\80\80\80\00" 122 | "\05\00\01\02\02\02\05\84\80\80\80\00\01\01\01\01" 123 | "\07\b7\80\80\80\00\05\08\66\33\32\2e\6c\6f\61\64" 124 | "\00\00\08\69\33\32\2e\6c\6f\61\64\00\01\09\66\33" 125 | "\32\2e\73\74\6f\72\65\00\02\09\69\33\32\2e\73\74" 126 | "\6f\72\65\00\03\05\72\65\73\65\74\00\04\0a\ca\80" 127 | "\80\80\00\05\87\80\80\80\00\00\41\00\2a\02\00\0b" 128 | "\87\80\80\80\00\00\41\00\28\02\00\0b\8c\80\80\80" 129 | "\00\00\41\00\43\01\00\d0\7f\38\02\00\0b\8d\80\80" 130 | "\80\00\00\41\00\41\81\80\c0\fe\07\36\02\00\0b\89" 131 | "\80\80\80\00\00\41\00\41\00\36\02\00\0b\0b\8a\80" 132 | "\80\80\00\01\00\41\00\0b\04\01\00\d0\7f" 133 | ) 134 | (assert_return (invoke "i32.load") (i32.const 2_144_337_921)) 135 | (assert_return (invoke "f32.load") (f32.const nan:0x500001)) 136 | (invoke "reset") 137 | (assert_return (invoke "i32.load") (i32.const 0)) 138 | (assert_return (invoke "f32.load") (f32.const 0)) 139 | (invoke "f32.store") 140 | (assert_return (invoke "i32.load") (i32.const 2_144_337_921)) 141 | (assert_return (invoke "f32.load") (f32.const nan:0x500001)) 142 | (invoke "reset") 143 | (assert_return (invoke "i32.load") (i32.const 0)) 144 | (assert_return (invoke "f32.load") (f32.const 0)) 145 | (invoke "i32.store") 146 | (assert_return (invoke "i32.load") (i32.const 2_144_337_921)) 147 | (assert_return (invoke "f32.load") (f32.const nan:0x500001)) 148 | (module binary 149 | "\00\61\73\6d\01\00\00\00\01\8c\80\80\80\00\03\60" 150 | "\00\01\7c\60\00\01\7e\60\00\00\03\86\80\80\80\00" 151 | "\05\00\01\02\02\02\05\84\80\80\80\00\01\01\01\01" 152 | "\07\b7\80\80\80\00\05\08\66\36\34\2e\6c\6f\61\64" 153 | "\00\00\08\69\36\34\2e\6c\6f\61\64\00\01\09\66\36" 154 | "\34\2e\73\74\6f\72\65\00\02\09\69\36\34\2e\73\74" 155 | "\6f\72\65\00\03\05\72\65\73\65\74\00\04\0a\d3\80" 156 | "\80\80\00\05\87\80\80\80\00\00\41\00\2b\03\00\0b" 157 | "\87\80\80\80\00\00\41\00\29\03\00\0b\90\80\80\80" 158 | "\00\00\41\00\44\01\00\00\00\00\00\fc\7f\39\03\00" 159 | "\0b\92\80\80\80\00\00\41\00\42\81\80\80\80\80\80" 160 | "\80\fe\ff\00\37\03\00\0b\89\80\80\80\00\00\41\00" 161 | "\42\00\37\03\00\0b\0b\8e\80\80\80\00\01\00\41\00" 162 | "\0b\08\01\00\00\00\00\00\fc\7f" 163 | ) 164 | (assert_return (invoke "i64.load") (i64.const 9_222_246_136_947_933_185)) 165 | (assert_return (invoke "f64.load") (f64.const nan:0xc000000000001)) 166 | (invoke "reset") 167 | (assert_return (invoke "i64.load") (i64.const 0)) 168 | (assert_return (invoke "f64.load") (f64.const 0)) 169 | (invoke "f64.store") 170 | (assert_return (invoke "i64.load") (i64.const 9_222_246_136_947_933_185)) 171 | (assert_return (invoke "f64.load") (f64.const nan:0xc000000000001)) 172 | (invoke "reset") 173 | (assert_return (invoke "i64.load") (i64.const 0)) 174 | (assert_return (invoke "f64.load") (f64.const 0)) 175 | (invoke "i64.store") 176 | (assert_return (invoke "i64.load") (i64.const 9_222_246_136_947_933_185)) 177 | (assert_return (invoke "f64.load") (f64.const nan:0xc000000000001)) 178 | -------------------------------------------------------------------------------- /tests/suite/forward.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary 2 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 3 | "\01\7f\01\7f\03\83\80\80\80\00\02\00\00\07\8e\80" 4 | "\80\80\00\02\04\65\76\65\6e\00\00\03\6f\64\64\00" 5 | "\01\0a\b3\80\80\80\00\02\94\80\80\80\00\00\20\00" 6 | "\41\00\46\04\7f\41\01\05\20\00\41\01\6b\10\01\0b" 7 | "\0b\94\80\80\80\00\00\20\00\41\00\46\04\7f\41\00" 8 | "\05\20\00\41\01\6b\10\00\0b\0b" 9 | ) 10 | (assert_return (invoke "even" (i32.const 13)) (i32.const 0)) 11 | (assert_return (invoke "even" (i32.const 20)) (i32.const 1)) 12 | (assert_return (invoke "odd" (i32.const 13)) (i32.const 1)) 13 | (assert_return (invoke "odd" (i32.const 20)) (i32.const 0)) 14 | -------------------------------------------------------------------------------- /tests/suite/func_ptrs.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary 2 | "\00\61\73\6d\01\00\00\00\01\9b\80\80\80\00\07\60" 3 | "\00\00\60\00\00\60\00\00\60\00\01\7f\60\00\01\7f" 4 | "\60\01\7f\01\7f\60\01\7f\00\02\96\80\80\80\00\01" 5 | "\08\73\70\65\63\74\65\73\74\09\70\72\69\6e\74\5f" 6 | "\69\33\32\00\06\03\87\80\80\80\00\06\00\01\04\05" 7 | "\05\06\07\9c\80\80\80\00\04\03\6f\6e\65\00\03\03" 8 | "\74\77\6f\00\04\05\74\68\72\65\65\00\05\04\66\6f" 9 | "\75\72\00\06\0a\bb\80\80\80\00\06\82\80\80\80\00" 10 | "\00\0b\82\80\80\80\00\00\0b\84\80\80\80\00\00\41" 11 | "\0d\0b\87\80\80\80\00\00\20\00\41\01\6a\0b\87\80" 12 | "\80\80\00\00\20\00\41\02\6b\0b\86\80\80\80\00\00" 13 | "\20\00\10\00\0b" 14 | ) 15 | (assert_return (invoke "one") (i32.const 13)) 16 | (assert_return (invoke "two" (i32.const 13)) (i32.const 14)) 17 | (assert_return (invoke "three" (i32.const 13)) (i32.const 11)) 18 | (invoke "four" (i32.const 83)) 19 | (assert_invalid 20 | (module binary 21 | "\00\61\73\6d\01\00\00\00\09\86\80\80\80\00\01\00" 22 | "\41\00\0b\00" 23 | ) 24 | "unknown table" 25 | ) 26 | (assert_invalid 27 | (module binary 28 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 29 | "\00\00\03\82\80\80\80\00\01\00\09\87\80\80\80\00" 30 | "\01\00\41\00\0b\01\00\0a\88\80\80\80\00\01\82\80" 31 | "\80\80\00\00\0b" 32 | ) 33 | "unknown table" 34 | ) 35 | (assert_invalid 36 | (module binary 37 | "\00\61\73\6d\01\00\00\00\04\84\80\80\80\00\01\70" 38 | "\00\01\09\86\80\80\80\00\01\00\42\00\0b\00" 39 | ) 40 | "type mismatch" 41 | ) 42 | (assert_invalid 43 | (module binary 44 | "\00\61\73\6d\01\00\00\00\04\84\80\80\80\00\01\70" 45 | "\00\01\09\87\80\80\80\00\01\00\41\00\68\0b\00" 46 | ) 47 | "constant expression required" 48 | ) 49 | (assert_invalid 50 | (module binary 51 | "\00\61\73\6d\01\00\00\00\04\84\80\80\80\00\01\70" 52 | "\00\01\09\85\80\80\80\00\01\00\01\0b\00" 53 | ) 54 | "constant expression required" 55 | ) 56 | (assert_invalid 57 | (module binary 58 | "\00\61\73\6d\01\00\00\00\03\82\80\80\80\00\01\2a" 59 | "\0a\88\80\80\80\00\01\82\80\80\80\00\00\0b" 60 | ) 61 | "unknown type" 62 | ) 63 | (assert_invalid 64 | (module binary 65 | "\00\61\73\6d\01\00\00\00\02\96\80\80\80\00\01\08" 66 | "\73\70\65\63\74\65\73\74\09\70\72\69\6e\74\5f\69" 67 | "\33\32\00\2b" 68 | ) 69 | "unknown type" 70 | ) 71 | (module binary 72 | "\00\61\73\6d\01\00\00\00\01\8e\80\80\80\00\03\60" 73 | "\00\01\7f\60\00\01\7f\60\01\7f\01\7f\03\88\80\80" 74 | "\80\00\07\00\00\00\01\01\02\02\04\85\80\80\80\00" 75 | "\01\70\01\07\07\07\91\80\80\80\00\02\05\63\61\6c" 76 | "\6c\74\00\05\05\63\61\6c\6c\75\00\06\09\8d\80\80" 77 | "\80\00\01\00\41\00\0b\07\00\01\02\03\04\00\02\0a" 78 | "\c6\80\80\80\00\07\84\80\80\80\00\00\41\01\0b\84" 79 | "\80\80\80\00\00\41\02\0b\84\80\80\80\00\00\41\03" 80 | "\0b\84\80\80\80\00\00\41\04\0b\84\80\80\80\00\00" 81 | "\41\05\0b\87\80\80\80\00\00\20\00\11\00\00\0b\87" 82 | "\80\80\80\00\00\20\00\11\01\00\0b" 83 | ) 84 | (assert_return (invoke "callt" (i32.const 0)) (i32.const 1)) 85 | (assert_return (invoke "callt" (i32.const 1)) (i32.const 2)) 86 | (assert_return (invoke "callt" (i32.const 2)) (i32.const 3)) 87 | (assert_return (invoke "callt" (i32.const 3)) (i32.const 4)) 88 | (assert_return (invoke "callt" (i32.const 4)) (i32.const 5)) 89 | (assert_return (invoke "callt" (i32.const 5)) (i32.const 1)) 90 | (assert_return (invoke "callt" (i32.const 6)) (i32.const 3)) 91 | (assert_trap (invoke "callt" (i32.const 7)) "undefined element") 92 | (assert_trap (invoke "callt" (i32.const 100)) "undefined element") 93 | (assert_trap (invoke "callt" (i32.const -1)) "undefined element") 94 | (assert_return (invoke "callu" (i32.const 0)) (i32.const 1)) 95 | (assert_return (invoke "callu" (i32.const 1)) (i32.const 2)) 96 | (assert_return (invoke "callu" (i32.const 2)) (i32.const 3)) 97 | (assert_return (invoke "callu" (i32.const 3)) (i32.const 4)) 98 | (assert_return (invoke "callu" (i32.const 4)) (i32.const 5)) 99 | (assert_return (invoke "callu" (i32.const 5)) (i32.const 1)) 100 | (assert_return (invoke "callu" (i32.const 6)) (i32.const 3)) 101 | (assert_trap (invoke "callu" (i32.const 7)) "undefined element") 102 | (assert_trap (invoke "callu" (i32.const 100)) "undefined element") 103 | (assert_trap (invoke "callu" (i32.const -1)) "undefined element") 104 | (module binary 105 | "\00\61\73\6d\01\00\00\00\01\8a\80\80\80\00\02\60" 106 | "\00\01\7f\60\01\7f\01\7f\03\84\80\80\80\00\03\00" 107 | "\00\01\04\85\80\80\80\00\01\70\01\02\02\07\89\80" 108 | "\80\80\00\01\05\63\61\6c\6c\74\00\02\09\88\80\80" 109 | "\80\00\01\00\41\00\0b\02\00\01\0a\9f\80\80\80\00" 110 | "\03\84\80\80\80\00\00\41\01\0b\84\80\80\80\00\00" 111 | "\41\02\0b\87\80\80\80\00\00\20\00\11\00\00\0b" 112 | ) 113 | (assert_return (invoke "callt" (i32.const 0)) (i32.const 1)) 114 | (assert_return (invoke "callt" (i32.const 1)) (i32.const 2)) 115 | -------------------------------------------------------------------------------- /tests/suite/get_local.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary 2 | "\00\61\73\6d\01\00\00\00\01\b6\80\80\80\00\0a\60" 3 | "\00\01\7f\60\00\01\7e\60\00\01\7d\60\00\01\7c\60" 4 | "\01\7f\01\7f\60\01\7e\01\7e\60\01\7d\01\7d\60\01" 5 | "\7c\01\7c\60\05\7e\7d\7c\7f\7f\00\60\05\7e\7d\7c" 6 | "\7f\7f\01\7c\03\8b\80\80\80\00\0a\00\01\02\03\04" 7 | "\05\06\07\08\09\07\9d\81\80\80\00\0a\0e\74\79\70" 8 | "\65\2d\6c\6f\63\61\6c\2d\69\33\32\00\00\0e\74\79" 9 | "\70\65\2d\6c\6f\63\61\6c\2d\69\36\34\00\01\0e\74" 10 | "\79\70\65\2d\6c\6f\63\61\6c\2d\66\33\32\00\02\0e" 11 | "\74\79\70\65\2d\6c\6f\63\61\6c\2d\66\36\34\00\03" 12 | "\0e\74\79\70\65\2d\70\61\72\61\6d\2d\69\33\32\00" 13 | "\04\0e\74\79\70\65\2d\70\61\72\61\6d\2d\69\36\34" 14 | "\00\05\0e\74\79\70\65\2d\70\61\72\61\6d\2d\66\33" 15 | "\32\00\06\0e\74\79\70\65\2d\70\61\72\61\6d\2d\66" 16 | "\36\34\00\07\0a\74\79\70\65\2d\6d\69\78\65\64\00" 17 | "\08\04\72\65\61\64\00\09\0a\c6\81\80\80\00\0a\86" 18 | "\80\80\80\00\01\01\7f\20\00\0b\86\80\80\80\00\01" 19 | "\01\7e\20\00\0b\86\80\80\80\00\01\01\7d\20\00\0b" 20 | "\86\80\80\80\00\01\01\7c\20\00\0b\84\80\80\80\00" 21 | "\00\20\00\0b\84\80\80\80\00\00\20\00\0b\84\80\80" 22 | "\80\00\00\20\00\0b\84\80\80\80\00\00\20\00\0b\ac" 23 | "\80\80\80\00\03\01\7d\02\7e\01\7c\20\00\50\1a\20" 24 | "\01\8c\1a\20\02\9a\1a\20\03\45\1a\20\04\45\1a\20" 25 | "\05\8c\1a\20\06\50\1a\20\07\50\1a\20\08\9a\1a\0b" 26 | "\bf\80\80\80\00\03\01\7d\02\7e\01\7c\43\00\00\b0" 27 | "\40\21\05\42\06\21\06\44\00\00\00\00\00\00\20\40" 28 | "\21\08\20\00\ba\20\01\bb\20\02\20\03\b8\20\04\b7" 29 | "\20\05\bb\20\06\ba\20\07\ba\20\08\a0\a0\a0\a0\a0" 30 | "\a0\a0\a0\0b" 31 | ) 32 | (assert_return (invoke "type-local-i32") (i32.const 0)) 33 | (assert_return (invoke "type-local-i64") (i64.const 0)) 34 | (assert_return (invoke "type-local-f32") (f32.const 0x0p+0)) 35 | (assert_return (invoke "type-local-f64") (f64.const 0x0p+0)) 36 | (assert_return (invoke "type-param-i32" (i32.const 2)) (i32.const 2)) 37 | (assert_return (invoke "type-param-i64" (i64.const 3)) (i64.const 3)) 38 | (assert_return 39 | (invoke "type-param-f32" (f32.const 0x1.19999ap+2)) 40 | (f32.const 0x1.19999ap+2) 41 | ) 42 | (assert_return 43 | (invoke "type-param-f64" (f64.const 0x1.6p+2)) 44 | (f64.const 0x1.6p+2) 45 | ) 46 | (assert_return 47 | (invoke "type-mixed" 48 | (i64.const 1) 49 | (f32.const 0x1.19999ap+1) 50 | (f64.const 0x1.a666666666666p+1) 51 | (i32.const 4) 52 | (i32.const 5) 53 | ) 54 | ) 55 | (assert_return 56 | (invoke "read" 57 | (i64.const 1) 58 | (f32.const 0x1p+1) 59 | (f64.const 0x1.a666666666666p+1) 60 | (i32.const 4) 61 | (i32.const 5) 62 | ) 63 | (f64.const 0x1.1666666666666p+5) 64 | ) 65 | (assert_invalid 66 | (module binary 67 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 68 | "\00\01\7e\03\82\80\80\80\00\01\00\0a\8c\80\80\80" 69 | "\00\01\86\80\80\80\00\01\01\7f\20\00\0b" 70 | ) 71 | "type mismatch" 72 | ) 73 | (assert_invalid 74 | (module binary 75 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 76 | "\00\00\03\82\80\80\80\00\01\00\0a\8d\80\80\80\00" 77 | "\01\87\80\80\80\00\01\01\7d\20\00\45\0b" 78 | ) 79 | "type mismatch" 80 | ) 81 | (assert_invalid 82 | (module binary 83 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 84 | "\00\00\03\82\80\80\80\00\01\00\0a\8f\80\80\80\00" 85 | "\01\89\80\80\80\00\02\01\7c\01\7e\20\01\9a\0b" 86 | ) 87 | "type mismatch" 88 | ) 89 | (assert_invalid 90 | (module binary 91 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 92 | "\01\7f\01\7e\03\82\80\80\80\00\01\00\0a\8a\80\80" 93 | "\80\00\01\84\80\80\80\00\00\20\00\0b" 94 | ) 95 | "type mismatch" 96 | ) 97 | (assert_invalid 98 | (module binary 99 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 100 | "\01\7d\00\03\82\80\80\80\00\01\00\0a\8b\80\80\80" 101 | "\00\01\85\80\80\80\00\00\20\00\45\0b" 102 | ) 103 | "type mismatch" 104 | ) 105 | (assert_invalid 106 | (module binary 107 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 108 | "\02\7c\7e\00\03\82\80\80\80\00\01\00\0a\8b\80\80" 109 | "\80\00\01\85\80\80\80\00\00\20\01\9a\0b" 110 | ) 111 | "type mismatch" 112 | ) 113 | (assert_invalid 114 | (module binary 115 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 116 | "\00\00\03\82\80\80\80\00\01\00\0a\8e\80\80\80\00" 117 | "\01\88\80\80\80\00\02\01\7f\01\7e\20\03\0b" 118 | ) 119 | "unknown local" 120 | ) 121 | (assert_invalid 122 | (module binary 123 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 124 | "\00\00\03\82\80\80\80\00\01\00\0a\91\80\80\80\00" 125 | "\01\8b\80\80\80\00\02\01\7f\01\7e\20\f7\a4\ea\06" 126 | "\0b" 127 | ) 128 | "unknown local" 129 | ) 130 | (assert_invalid 131 | (module binary 132 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 133 | "\02\7f\7e\00\03\82\80\80\80\00\01\00\0a\8a\80\80" 134 | "\80\00\01\84\80\80\80\00\00\20\02\0b" 135 | ) 136 | "unknown local" 137 | ) 138 | (assert_invalid 139 | (module binary 140 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 141 | "\00\00\03\82\80\80\80\00\01\00\0a\92\80\80\80\00" 142 | "\01\8c\80\80\80\00\02\01\7f\01\7e\20\f7\f2\ce\d4" 143 | "\02\0b" 144 | ) 145 | "unknown local" 146 | ) 147 | (assert_invalid 148 | (module binary 149 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 150 | "\01\7f\00\03\82\80\80\80\00\01\00\0a\8e\80\80\80" 151 | "\00\01\88\80\80\80\00\02\01\7f\01\7e\20\03\0b" 152 | ) 153 | "unknown local" 154 | ) 155 | (assert_invalid 156 | (module binary 157 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 158 | "\01\7e\00\03\82\80\80\80\00\01\00\0a\91\80\80\80" 159 | "\00\01\8b\80\80\80\00\02\01\7f\01\7e\20\f7\a8\99" 160 | "\66\0b" 161 | ) 162 | "unknown local" 163 | ) 164 | -------------------------------------------------------------------------------- /tests/suite/inline-module.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary 2 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 3 | "\00\00\03\83\80\80\80\00\02\00\00\05\83\80\80\80" 4 | "\00\01\00\00\07\85\80\80\80\00\01\01\66\00\01\0a" 5 | "\8f\80\80\80\00\02\82\80\80\80\00\00\0b\82\80\80" 6 | "\80\00\00\0b" 7 | ) 8 | -------------------------------------------------------------------------------- /tests/suite/int_literals.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary 2 | "\00\61\73\6d\01\00\00\00\01\89\80\80\80\00\02\60" 3 | "\00\01\7f\60\00\01\7e\03\9f\80\80\80\00\1e\00\00" 4 | "\00\00\00\00\00\00\00\00\00\01\01\01\01\01\01\01" 5 | "\01\01\01\01\00\00\00\00\01\01\01\01\07\b7\83\80" 6 | "\80\00\1e\08\69\33\32\2e\74\65\73\74\00\00\08\69" 7 | "\33\32\2e\75\6d\61\78\00\01\08\69\33\32\2e\73\6d" 8 | "\61\78\00\02\0c\69\33\32\2e\6e\65\67\5f\73\6d\61" 9 | "\78\00\03\08\69\33\32\2e\73\6d\69\6e\00\04\0c\69" 10 | "\33\32\2e\61\6c\74\5f\73\6d\69\6e\00\05\0c\69\33" 11 | "\32\2e\69\6e\63\5f\73\6d\69\6e\00\06\0c\69\33\32" 12 | "\2e\6e\65\67\5f\7a\65\72\6f\00\07\0d\69\33\32\2e" 13 | "\6e\6f\74\5f\6f\63\74\61\6c\00\08\14\69\33\32\2e" 14 | "\75\6e\73\69\67\6e\65\64\5f\64\65\63\69\6d\61\6c" 15 | "\00\09\0d\69\33\32\2e\70\6c\75\73\5f\73\69\67\6e" 16 | "\00\0a\08\69\36\34\2e\74\65\73\74\00\0b\08\69\36" 17 | "\34\2e\75\6d\61\78\00\0c\08\69\36\34\2e\73\6d\61" 18 | "\78\00\0d\0c\69\36\34\2e\6e\65\67\5f\73\6d\61\78" 19 | "\00\0e\08\69\36\34\2e\73\6d\69\6e\00\0f\0c\69\36" 20 | "\34\2e\61\6c\74\5f\73\6d\69\6e\00\10\0c\69\36\34" 21 | "\2e\69\6e\63\5f\73\6d\69\6e\00\11\0c\69\36\34\2e" 22 | "\6e\65\67\5f\7a\65\72\6f\00\12\0d\69\36\34\2e\6e" 23 | "\6f\74\5f\6f\63\74\61\6c\00\13\14\69\36\34\2e\75" 24 | "\6e\73\69\67\6e\65\64\5f\64\65\63\69\6d\61\6c\00" 25 | "\14\0d\69\36\34\2e\70\6c\75\73\5f\73\69\67\6e\00" 26 | "\15\0c\69\33\32\2d\64\65\63\2d\73\65\70\31\00\16" 27 | "\0c\69\33\32\2d\64\65\63\2d\73\65\70\32\00\17\0c" 28 | "\69\33\32\2d\68\65\78\2d\73\65\70\31\00\18\0c\69" 29 | "\33\32\2d\68\65\78\2d\73\65\70\32\00\19\0c\69\36" 30 | "\34\2d\64\65\63\2d\73\65\70\31\00\1a\0c\69\36\34" 31 | "\2d\64\65\63\2d\73\65\70\32\00\1b\0c\69\36\34\2d" 32 | "\68\65\78\2d\73\65\70\31\00\1c\0c\69\36\34\2d\68" 33 | "\65\78\2d\73\65\70\32\00\1d\0a\8d\83\80\80\00\1e" 34 | "\89\80\80\80\00\00\41\8d\a0\b7\dd\00\0f\0b\85\80" 35 | "\80\80\00\00\41\7f\0f\0b\89\80\80\80\00\00\41\ff" 36 | "\ff\ff\ff\07\0f\0b\89\80\80\80\00\00\41\81\80\80" 37 | "\80\78\0f\0b\89\80\80\80\00\00\41\80\80\80\80\78" 38 | "\0f\0b\89\80\80\80\00\00\41\80\80\80\80\78\0f\0b" 39 | "\8c\80\80\80\00\00\41\80\80\80\80\78\41\01\6a\0f" 40 | "\0b\85\80\80\80\00\00\41\00\0f\0b\85\80\80\80\00" 41 | "\00\41\0a\0f\0b\85\80\80\80\00\00\41\7f\0f\0b\85" 42 | "\80\80\80\00\00\41\2a\0f\0b\8d\80\80\80\00\00\42" 43 | "\ee\d4\99\dd\e0\cd\ee\d5\0c\0f\0b\85\80\80\80\00" 44 | "\00\42\7f\0f\0b\8e\80\80\80\00\00\42\ff\ff\ff\ff" 45 | "\ff\ff\ff\ff\ff\00\0f\0b\8e\80\80\80\00\00\42\81" 46 | "\80\80\80\80\80\80\80\80\7f\0f\0b\8e\80\80\80\00" 47 | "\00\42\80\80\80\80\80\80\80\80\80\7f\0f\0b\8e\80" 48 | "\80\80\00\00\42\80\80\80\80\80\80\80\80\80\7f\0f" 49 | "\0b\91\80\80\80\00\00\42\80\80\80\80\80\80\80\80" 50 | "\80\7f\42\01\7c\0f\0b\85\80\80\80\00\00\42\00\0f" 51 | "\0b\85\80\80\80\00\00\42\0a\0f\0b\85\80\80\80\00" 52 | "\00\42\7f\0f\0b\85\80\80\80\00\00\42\2a\0f\0b\86" 53 | "\80\80\80\00\00\41\c0\84\3d\0b\85\80\80\80\00\00" 54 | "\41\e8\07\0b\88\80\80\80\00\00\41\99\81\bc\d0\00" 55 | "\0b\86\80\80\80\00\00\41\8f\d4\06\0b\86\80\80\80" 56 | "\00\00\42\c0\84\3d\0b\85\80\80\80\00\00\42\e8\07" 57 | "\0b\8b\80\80\80\00\00\42\99\b3\82\80\f0\81\bc\05" 58 | "\0b\86\80\80\80\00\00\42\8f\d4\06\0b" 59 | ) 60 | (assert_return (invoke "i32.test") (i32.const 195_940_365)) 61 | (assert_return (invoke "i32.umax") (i32.const -1)) 62 | (assert_return (invoke "i32.smax") (i32.const 2_147_483_647)) 63 | (assert_return (invoke "i32.neg_smax") (i32.const -2_147_483_647)) 64 | (assert_return (invoke "i32.smin") (i32.const -2_147_483_648)) 65 | (assert_return (invoke "i32.alt_smin") (i32.const -2_147_483_648)) 66 | (assert_return (invoke "i32.inc_smin") (i32.const -2_147_483_647)) 67 | (assert_return (invoke "i32.neg_zero") (i32.const 0)) 68 | (assert_return (invoke "i32.not_octal") (i32.const 10)) 69 | (assert_return (invoke "i32.unsigned_decimal") (i32.const -1)) 70 | (assert_return (invoke "i32.plus_sign") (i32.const 42)) 71 | (assert_return (invoke "i64.test") (i64.const 913_028_331_277_281_902)) 72 | (assert_return (invoke "i64.umax") (i64.const -1)) 73 | (assert_return (invoke "i64.smax") (i64.const 9_223_372_036_854_775_807)) 74 | (assert_return (invoke "i64.neg_smax") (i64.const -9_223_372_036_854_775_807)) 75 | (assert_return (invoke "i64.smin") (i64.const -9_223_372_036_854_775_808)) 76 | (assert_return (invoke "i64.alt_smin") (i64.const -9_223_372_036_854_775_808)) 77 | (assert_return (invoke "i64.inc_smin") (i64.const -9_223_372_036_854_775_807)) 78 | (assert_return (invoke "i64.neg_zero") (i64.const 0)) 79 | (assert_return (invoke "i64.not_octal") (i64.const 10)) 80 | (assert_return (invoke "i64.unsigned_decimal") (i64.const -1)) 81 | (assert_return (invoke "i64.plus_sign") (i64.const 42)) 82 | (assert_return (invoke "i32-dec-sep1") (i32.const 1_000_000)) 83 | (assert_return (invoke "i32-dec-sep2") (i32.const 1_000)) 84 | (assert_return (invoke "i32-hex-sep1") (i32.const 168_755_353)) 85 | (assert_return (invoke "i32-hex-sep2") (i32.const 109_071)) 86 | (assert_return (invoke "i64-dec-sep1") (i64.const 1_000_000)) 87 | (assert_return (invoke "i64-dec-sep2") (i64.const 1_000)) 88 | (assert_return (invoke "i64-hex-sep1") (i64.const 3_078_696_982_321_561)) 89 | (assert_return (invoke "i64-hex-sep2") (i64.const 109_071)) 90 | (assert_malformed 91 | (module quote "(global i32 (i32.const _100))") 92 | "unknown operator" 93 | ) 94 | (assert_malformed 95 | (module quote "(global i32 (i32.const +_100))") 96 | "unknown operator" 97 | ) 98 | (assert_malformed 99 | (module quote "(global i32 (i32.const -_100))") 100 | "unknown operator" 101 | ) 102 | (assert_malformed 103 | (module quote "(global i32 (i32.const 99_))") 104 | "unknown operator" 105 | ) 106 | (assert_malformed 107 | (module quote "(global i32 (i32.const 1__000))") 108 | "unknown operator" 109 | ) 110 | (assert_malformed 111 | (module quote "(global i32 (i32.const _0x100))") 112 | "unknown operator" 113 | ) 114 | (assert_malformed 115 | (module quote "(global i32 (i32.const 0_x100))") 116 | "unknown operator" 117 | ) 118 | (assert_malformed 119 | (module quote "(global i32 (i32.const 0x_100))") 120 | "unknown operator" 121 | ) 122 | (assert_malformed 123 | (module quote "(global i32 (i32.const 0x00_))") 124 | "unknown operator" 125 | ) 126 | (assert_malformed 127 | (module quote "(global i32 (i32.const 0xff__ffff))") 128 | "unknown operator" 129 | ) 130 | (assert_malformed 131 | (module quote "(global i64 (i64.const _100))") 132 | "unknown operator" 133 | ) 134 | (assert_malformed 135 | (module quote "(global i64 (i64.const +_100))") 136 | "unknown operator" 137 | ) 138 | (assert_malformed 139 | (module quote "(global i64 (i64.const -_100))") 140 | "unknown operator" 141 | ) 142 | (assert_malformed 143 | (module quote "(global i64 (i64.const 99_))") 144 | "unknown operator" 145 | ) 146 | (assert_malformed 147 | (module quote "(global i64 (i64.const 1__000))") 148 | "unknown operator" 149 | ) 150 | (assert_malformed 151 | (module quote "(global i64 (i64.const _0x100))") 152 | "unknown operator" 153 | ) 154 | (assert_malformed 155 | (module quote "(global i64 (i64.const 0_x100))") 156 | "unknown operator" 157 | ) 158 | (assert_malformed 159 | (module quote "(global i64 (i64.const 0x_100))") 160 | "unknown operator" 161 | ) 162 | (assert_malformed 163 | (module quote "(global i64 (i64.const 0x00_))") 164 | "unknown operator" 165 | ) 166 | (assert_malformed 167 | (module quote "(global i64 (i64.const 0xff__ffff))") 168 | "unknown operator" 169 | ) 170 | -------------------------------------------------------------------------------- /tests/suite/labels.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary 2 | "\00\61\73\6d\01\00\00\00\01\8a\80\80\80\00\02\60" 3 | "\00\01\7f\60\01\7f\01\7f\03\93\80\80\80\00\12\00" 4 | "\00\00\00\01\00\00\00\00\01\01\00\00\00\00\00\00" 5 | "\00\07\9a\81\80\80\00\12\05\62\6c\6f\63\6b\00\00" 6 | "\05\6c\6f\6f\70\31\00\01\05\6c\6f\6f\70\32\00\02" 7 | "\05\6c\6f\6f\70\33\00\03\05\6c\6f\6f\70\34\00\04" 8 | "\05\6c\6f\6f\70\35\00\05\05\6c\6f\6f\70\36\00\06" 9 | "\02\69\66\00\07\03\69\66\32\00\08\06\73\77\69\74" 10 | "\63\68\00\09\06\72\65\74\75\72\6e\00\0a\06\62\72" 11 | "\5f\69\66\30\00\0b\06\62\72\5f\69\66\31\00\0c\06" 12 | "\62\72\5f\69\66\32\00\0d\06\62\72\5f\69\66\33\00" 13 | "\0e\02\62\72\00\0f\09\73\68\61\64\6f\77\69\6e\67" 14 | "\00\10\0c\72\65\64\65\66\69\6e\69\74\69\6f\6e\00" 15 | "\11\0a\c9\86\80\80\00\12\8b\80\80\80\00\00\02\7f" 16 | "\41\01\0c\00\41\00\0b\0b\a3\80\80\80\00\01\01\7f" 17 | "\41\00\21\00\02\7f\03\7f\20\00\41\01\6a\21\00\20" 18 | "\00\41\05\46\04\40\20\00\0c\02\0b\0c\00\0b\0b\0b" 19 | "\b4\80\80\80\00\01\01\7f\41\00\21\00\02\7f\03\7f" 20 | "\20\00\41\01\6a\21\00\20\00\41\05\46\04\40\0c\01" 21 | "\0b\20\00\41\08\46\04\40\20\00\0c\02\0b\20\00\41" 22 | "\01\6a\21\00\0c\00\0b\0b\0b\a3\80\80\80\00\01\01" 23 | "\7f\41\00\21\00\02\7f\03\7f\20\00\41\01\6a\21\00" 24 | "\20\00\41\05\46\04\40\20\00\0c\02\0b\20\00\0b\0b" 25 | "\0b\a3\80\80\80\00\01\01\7f\41\01\21\01\02\7f\03" 26 | "\7f\20\01\20\01\6a\21\01\20\01\20\00\4b\04\40\20" 27 | "\01\0c\02\0b\0c\00\0b\0b\0b\8a\80\80\80\00\00\03" 28 | "\7f\41\01\0b\41\01\6a\0b\8b\80\80\80\00\00\03\7f" 29 | "\41\00\0d\00\41\03\0b\0b\84\81\80\80\00\01\01\7f" 30 | "\41\00\21\00\02\40\41\01\04\40\0c\00\41\9a\05\21" 31 | "\00\0b\20\00\41\01\6a\21\00\41\01\04\40\0c\00\41" 32 | "\9a\05\21\00\05\41\f8\06\21\00\0b\20\00\41\01\6a" 33 | "\21\00\41\01\04\40\0c\00\41\9a\05\21\00\05\41\f8" 34 | "\06\21\00\0b\20\00\41\01\6a\21\00\41\00\04\40\41" 35 | "\f8\06\21\00\05\0c\00\41\9a\05\21\00\0b\20\00\41" 36 | "\01\6a\21\00\41\00\04\40\41\f8\06\21\00\05\0c\00" 37 | "\41\9a\05\21\00\0b\20\00\41\01\6a\21\00\0b\20\00" 38 | "\0b\84\81\80\80\00\01\01\7f\41\00\21\00\02\40\41" 39 | "\01\04\40\0c\00\41\9a\05\21\00\0b\20\00\41\01\6a" 40 | "\21\00\41\01\04\40\0c\00\41\9a\05\21\00\05\41\f8" 41 | "\06\21\00\0b\20\00\41\01\6a\21\00\41\01\04\40\0c" 42 | "\00\41\9a\05\21\00\05\41\f8\06\21\00\0b\20\00\41" 43 | "\01\6a\21\00\41\00\04\40\41\f8\06\21\00\05\0c\00" 44 | "\41\9a\05\21\00\0b\20\00\41\01\6a\21\00\41\00\04" 45 | "\40\41\f8\06\21\00\05\0c\00\41\9a\05\21\00\0b\20" 46 | "\00\41\01\6a\21\00\0b\20\00\0b\ad\80\80\80\00\00" 47 | "\02\7f\41\0a\02\7f\02\40\02\40\02\40\02\40\02\40" 48 | "\20\00\0e\04\04\00\01\02\03\0b\0b\41\02\0c\03\0b" 49 | "\41\03\0c\03\0b\0b\41\05\0b\6c\0b\0b\98\80\80\80" 50 | "\00\00\02\40\02\40\02\40\20\00\0e\01\00\01\0c\02" 51 | "\0b\41\00\0f\0b\0b\41\02\0b\d6\80\80\80\00\01\01" 52 | "\7f\41\00\21\00\02\7f\02\40\41\00\0d\00\20\00\41" 53 | "\01\72\21\00\41\01\0d\00\20\00\41\02\72\21\00\0b" 54 | "\02\7f\20\00\41\04\72\21\00\20\00\0b\41\00\0d\00" 55 | "\1a\20\00\41\08\72\21\00\02\7f\20\00\41\10\72\21" 56 | "\00\20\00\0b\41\01\0d\00\1a\20\00\41\20\72\21\00" 57 | "\20\00\0b\0b\93\80\80\80\00\00\02\7f\02\7f\41\01" 58 | "\0c\00\0b\41\01\0d\00\1a\41\00\0b\0b\98\80\80\80" 59 | "\00\00\02\7f\41\01\04\40\02\7f\41\01\0c\00\0b\41" 60 | "\01\0d\01\1a\0b\41\00\0b\0b\a4\80\80\80\00\01\01" 61 | "\7f\02\7f\02\7f\41\01\21\00\20\00\0b\02\7f\41\02" 62 | "\21\00\20\00\0b\0d\00\1a\41\00\0b\41\00\6a\1a\20" 63 | "\00\0b\a1\80\80\80\00\00\02\7f\41\01\04\40\02\7f" 64 | "\41\01\0c\00\0b\0c\01\05\02\40\02\7f\41\01\0c\00" 65 | "\0b\1a\0b\0b\41\01\0b\0b\8c\80\80\80\00\00\02\7f" 66 | "\41\01\0c\00\41\02\73\0b\0b\92\80\80\80\00\00\02" 67 | "\7f\02\7f\41\02\0b\02\7f\41\03\0c\00\0b\6a\0b\0b" 68 | ) 69 | (assert_return (invoke "block") (i32.const 1)) 70 | (assert_return (invoke "loop1") (i32.const 5)) 71 | (assert_return (invoke "loop2") (i32.const 8)) 72 | (assert_return (invoke "loop3") (i32.const 1)) 73 | (assert_return (invoke "loop4" (i32.const 8)) (i32.const 16)) 74 | (assert_return (invoke "loop5") (i32.const 2)) 75 | (assert_return (invoke "loop6") (i32.const 3)) 76 | (assert_return (invoke "if") (i32.const 5)) 77 | (assert_return (invoke "if2") (i32.const 5)) 78 | (assert_return (invoke "switch" (i32.const 0)) (i32.const 50)) 79 | (assert_return (invoke "switch" (i32.const 1)) (i32.const 20)) 80 | (assert_return (invoke "switch" (i32.const 2)) (i32.const 20)) 81 | (assert_return (invoke "switch" (i32.const 3)) (i32.const 3)) 82 | (assert_return (invoke "switch" (i32.const 4)) (i32.const 50)) 83 | (assert_return (invoke "switch" (i32.const 5)) (i32.const 50)) 84 | (assert_return (invoke "return" (i32.const 0)) (i32.const 0)) 85 | (assert_return (invoke "return" (i32.const 1)) (i32.const 2)) 86 | (assert_return (invoke "return" (i32.const 2)) (i32.const 2)) 87 | (assert_return (invoke "br_if0") (i32.const 29)) 88 | (assert_return (invoke "br_if1") (i32.const 1)) 89 | (assert_return (invoke "br_if2") (i32.const 1)) 90 | (assert_return (invoke "br_if3") (i32.const 2)) 91 | (assert_return (invoke "br") (i32.const 1)) 92 | (assert_return (invoke "shadowing") (i32.const 1)) 93 | (assert_return (invoke "redefinition") (i32.const 5)) 94 | (assert_invalid 95 | (module binary 96 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 97 | "\00\00\03\82\80\80\80\00\01\00\0a\91\80\80\80\00" 98 | "\01\8b\80\80\80\00\00\02\40\41\01\0d\00\8c\01\0b" 99 | "\0b" 100 | ) 101 | "type mismatch" 102 | ) 103 | (assert_invalid 104 | (module binary 105 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 106 | "\00\00\03\82\80\80\80\00\01\00\0a\94\80\80\80\00" 107 | "\01\8e\80\80\80\00\00\02\40\43\00\00\00\00\41\01" 108 | "\0d\00\0b\0b" 109 | ) 110 | "type mismatch" 111 | ) 112 | (assert_invalid 113 | (module binary 114 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 115 | "\00\00\03\82\80\80\80\00\01\00\0a\94\80\80\80\00" 116 | "\01\8e\80\80\80\00\00\02\40\43\00\00\00\00\41\01" 117 | "\0d\00\0b\0b" 118 | ) 119 | "type mismatch" 120 | ) 121 | -------------------------------------------------------------------------------- /tests/suite/local_get.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary 2 | "\00\61\73\6d\01\00\00\00\01\b6\80\80\80\00\0a\60" 3 | "\00\01\7f\60\00\01\7e\60\00\01\7d\60\00\01\7c\60" 4 | "\01\7f\01\7f\60\01\7e\01\7e\60\01\7d\01\7d\60\01" 5 | "\7c\01\7c\60\05\7e\7d\7c\7f\7f\00\60\05\7e\7d\7c" 6 | "\7f\7f\01\7c\03\94\80\80\80\00\13\00\01\02\03\04" 7 | "\05\06\07\08\09\04\04\04\04\04\04\04\04\04\07\b3" 8 | "\82\80\80\00\13\0e\74\79\70\65\2d\6c\6f\63\61\6c" 9 | "\2d\69\33\32\00\00\0e\74\79\70\65\2d\6c\6f\63\61" 10 | "\6c\2d\69\36\34\00\01\0e\74\79\70\65\2d\6c\6f\63" 11 | "\61\6c\2d\66\33\32\00\02\0e\74\79\70\65\2d\6c\6f" 12 | "\63\61\6c\2d\66\36\34\00\03\0e\74\79\70\65\2d\70" 13 | "\61\72\61\6d\2d\69\33\32\00\04\0e\74\79\70\65\2d" 14 | "\70\61\72\61\6d\2d\69\36\34\00\05\0e\74\79\70\65" 15 | "\2d\70\61\72\61\6d\2d\66\33\32\00\06\0e\74\79\70" 16 | "\65\2d\70\61\72\61\6d\2d\66\36\34\00\07\0a\74\79" 17 | "\70\65\2d\6d\69\78\65\64\00\08\04\72\65\61\64\00" 18 | "\09\0e\61\73\2d\62\6c\6f\63\6b\2d\76\61\6c\75\65" 19 | "\00\0a\0d\61\73\2d\6c\6f\6f\70\2d\76\61\6c\75\65" 20 | "\00\0b\0b\61\73\2d\62\72\2d\76\61\6c\75\65\00\0c" 21 | "\0e\61\73\2d\62\72\5f\69\66\2d\76\61\6c\75\65\00" 22 | "\0d\13\61\73\2d\62\72\5f\69\66\2d\76\61\6c\75\65" 23 | "\2d\63\6f\6e\64\00\0e\11\61\73\2d\62\72\5f\74\61" 24 | "\62\6c\65\2d\76\61\6c\75\65\00\0f\0f\61\73\2d\72" 25 | "\65\74\75\72\6e\2d\76\61\6c\75\65\00\10\0a\61\73" 26 | "\2d\69\66\2d\74\68\65\6e\00\11\0a\61\73\2d\69\66" 27 | "\2d\65\6c\73\65\00\12\0a\da\82\80\80\00\13\86\80" 28 | "\80\80\00\01\01\7f\20\00\0b\86\80\80\80\00\01\01" 29 | "\7e\20\00\0b\86\80\80\80\00\01\01\7d\20\00\0b\86" 30 | "\80\80\80\00\01\01\7c\20\00\0b\84\80\80\80\00\00" 31 | "\20\00\0b\84\80\80\80\00\00\20\00\0b\84\80\80\80" 32 | "\00\00\20\00\0b\84\80\80\80\00\00\20\00\0b\ac\80" 33 | "\80\80\00\03\01\7d\02\7e\01\7c\20\00\50\1a\20\01" 34 | "\8c\1a\20\02\9a\1a\20\03\45\1a\20\04\45\1a\20\05" 35 | "\8c\1a\20\06\50\1a\20\07\50\1a\20\08\9a\1a\0b\bf" 36 | "\80\80\80\00\03\01\7d\02\7e\01\7c\43\00\00\b0\40" 37 | "\21\05\42\06\21\06\44\00\00\00\00\00\00\20\40\21" 38 | "\08\20\00\ba\20\01\bb\20\02\20\03\b8\20\04\b7\20" 39 | "\05\bb\20\06\ba\20\07\ba\20\08\a0\a0\a0\a0\a0\a0" 40 | "\a0\a0\0b\87\80\80\80\00\00\02\7f\20\00\0b\0b\87" 41 | "\80\80\80\00\00\03\7f\20\00\0b\0b\89\80\80\80\00" 42 | "\00\02\7f\20\00\0c\00\0b\0b\8b\80\80\80\00\00\02" 43 | "\7f\20\00\41\01\0d\00\0b\0b\8b\80\80\80\00\00\02" 44 | "\7f\20\00\20\00\0d\00\0b\0b\9d\80\80\80\00\00\02" 45 | "\40\02\40\02\40\20\00\0e\02\00\01\02\41\00\0f\0b" 46 | "\41\01\0f\0b\41\02\0f\0b\41\03\0b\85\80\80\80\00" 47 | "\00\20\00\0f\0b\8c\80\80\80\00\00\20\00\04\7f\20" 48 | "\00\05\41\00\0b\0b\8c\80\80\80\00\00\20\00\04\7f" 49 | "\41\01\05\20\00\0b\0b" 50 | ) 51 | (assert_return (invoke "type-local-i32") (i32.const 0)) 52 | (assert_return (invoke "type-local-i64") (i64.const 0)) 53 | (assert_return (invoke "type-local-f32") (f32.const 0)) 54 | (assert_return (invoke "type-local-f64") (f64.const 0)) 55 | (assert_return (invoke "type-param-i32" (i32.const 2)) (i32.const 2)) 56 | (assert_return (invoke "type-param-i64" (i64.const 3)) (i64.const 3)) 57 | (assert_return 58 | (invoke "type-param-f32" (f32.const 4.400_000_095_367_431_6)) 59 | (f32.const 4.400_000_095_367_431_6) 60 | ) 61 | (assert_return (invoke "type-param-f64" (f64.const 5.5)) (f64.const 5.5)) 62 | (assert_return (invoke "as-block-value" (i32.const 6)) (i32.const 6)) 63 | (assert_return (invoke "as-loop-value" (i32.const 7)) (i32.const 7)) 64 | (assert_return (invoke "as-br-value" (i32.const 8)) (i32.const 8)) 65 | (assert_return (invoke "as-br_if-value" (i32.const 9)) (i32.const 9)) 66 | (assert_return (invoke "as-br_if-value-cond" (i32.const 10)) (i32.const 10)) 67 | (assert_return (invoke "as-br_table-value" (i32.const 1)) (i32.const 2)) 68 | (assert_return (invoke "as-return-value" (i32.const 0)) (i32.const 0)) 69 | (assert_return (invoke "as-if-then" (i32.const 1)) (i32.const 1)) 70 | (assert_return (invoke "as-if-else" (i32.const 0)) (i32.const 0)) 71 | (assert_return 72 | (invoke "type-mixed" 73 | (i64.const 1) 74 | (f32.const 2.200_000_047_683_715_8) 75 | (f64.const 3.299_999_999_999_999_8) 76 | (i32.const 4) 77 | (i32.const 5) 78 | ) 79 | ) 80 | (assert_return 81 | (invoke "read" 82 | (i64.const 1) 83 | (f32.const 2) 84 | (f64.const 3.299_999_999_999_999_8) 85 | (i32.const 4) 86 | (i32.const 5) 87 | ) 88 | (f64.const 34.799_999_999_999_997) 89 | ) 90 | (assert_invalid 91 | (module binary 92 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 93 | "\00\01\7e\03\82\80\80\80\00\01\00\0a\8c\80\80\80" 94 | "\00\01\86\80\80\80\00\01\01\7f\20\00\0b" 95 | ) 96 | "type mismatch" 97 | ) 98 | (assert_invalid 99 | (module binary 100 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 101 | "\00\01\7f\03\82\80\80\80\00\01\00\0a\8d\80\80\80" 102 | "\00\01\87\80\80\80\00\01\01\7d\20\00\45\0b" 103 | ) 104 | "type mismatch" 105 | ) 106 | (assert_invalid 107 | (module binary 108 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 109 | "\00\01\7c\03\82\80\80\80\00\01\00\0a\8f\80\80\80" 110 | "\00\01\89\80\80\80\00\02\01\7c\01\7e\20\01\9a\0b" 111 | ) 112 | "type mismatch" 113 | ) 114 | (assert_invalid 115 | (module binary 116 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 117 | "\01\7f\01\7e\03\82\80\80\80\00\01\00\0a\8a\80\80" 118 | "\80\00\01\84\80\80\80\00\00\20\00\0b" 119 | ) 120 | "type mismatch" 121 | ) 122 | (assert_invalid 123 | (module binary 124 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 125 | "\01\7d\01\7f\03\82\80\80\80\00\01\00\0a\8b\80\80" 126 | "\80\00\01\85\80\80\80\00\00\20\00\45\0b" 127 | ) 128 | "type mismatch" 129 | ) 130 | (assert_invalid 131 | (module binary 132 | "\00\61\73\6d\01\00\00\00\01\87\80\80\80\00\01\60" 133 | "\02\7c\7e\01\7c\03\82\80\80\80\00\01\00\0a\8b\80" 134 | "\80\80\00\01\85\80\80\80\00\00\20\01\9a\0b" 135 | ) 136 | "type mismatch" 137 | ) 138 | (assert_invalid 139 | (module binary 140 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 141 | "\00\00\03\82\80\80\80\00\01\00\0a\8c\80\80\80\00" 142 | "\01\86\80\80\80\00\01\01\7f\20\00\0b" 143 | ) 144 | "type mismatch" 145 | ) 146 | (assert_invalid 147 | (module binary 148 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 149 | "\00\00\03\82\80\80\80\00\01\00\0a\8c\80\80\80\00" 150 | "\01\86\80\80\80\00\01\01\7e\20\00\0b" 151 | ) 152 | "type mismatch" 153 | ) 154 | (assert_invalid 155 | (module binary 156 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 157 | "\00\00\03\82\80\80\80\00\01\00\0a\8c\80\80\80\00" 158 | "\01\86\80\80\80\00\01\01\7d\20\00\0b" 159 | ) 160 | "type mismatch" 161 | ) 162 | (assert_invalid 163 | (module binary 164 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 165 | "\00\00\03\82\80\80\80\00\01\00\0a\8c\80\80\80\00" 166 | "\01\86\80\80\80\00\01\01\7c\20\00\0b" 167 | ) 168 | "type mismatch" 169 | ) 170 | (assert_invalid 171 | (module binary 172 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 173 | "\00\00\03\82\80\80\80\00\01\00\0a\8e\80\80\80\00" 174 | "\01\88\80\80\80\00\02\01\7f\01\7e\20\03\0b" 175 | ) 176 | "unknown local" 177 | ) 178 | (assert_invalid 179 | (module binary 180 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 181 | "\00\00\03\82\80\80\80\00\01\00\0a\91\80\80\80\00" 182 | "\01\8b\80\80\80\00\02\01\7f\01\7e\20\f7\a4\ea\06" 183 | "\0b" 184 | ) 185 | "unknown local" 186 | ) 187 | (assert_invalid 188 | (module binary 189 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 190 | "\02\7f\7e\00\03\82\80\80\80\00\01\00\0a\8a\80\80" 191 | "\80\00\01\84\80\80\80\00\00\20\02\0b" 192 | ) 193 | "unknown local" 194 | ) 195 | (assert_invalid 196 | (module binary 197 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 198 | "\02\7f\7e\00\03\82\80\80\80\00\01\00\0a\8e\80\80" 199 | "\80\00\01\88\80\80\80\00\00\20\f7\f2\ce\d4\02\0b" 200 | ) 201 | "unknown local" 202 | ) 203 | (assert_invalid 204 | (module binary 205 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 206 | "\01\7f\00\03\82\80\80\80\00\01\00\0a\8e\80\80\80" 207 | "\00\01\88\80\80\80\00\02\01\7f\01\7e\20\03\0b" 208 | ) 209 | "unknown local" 210 | ) 211 | (assert_invalid 212 | (module binary 213 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 214 | "\01\7e\00\03\82\80\80\80\00\01\00\0a\91\80\80\80" 215 | "\00\01\8b\80\80\80\00\02\01\7f\01\7e\20\f7\a8\99" 216 | "\66\0b" 217 | ) 218 | "unknown local" 219 | ) 220 | -------------------------------------------------------------------------------- /tests/suite/memory.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary "\00\61\73\6d\01\00\00\00\05\84\80\80\80\00\01\01" "\00\00") 2 | (module binary "\00\61\73\6d\01\00\00\00\05\84\80\80\80\00\01\01" "\00\01") 3 | (module binary "\00\61\73\6d\01\00\00\00\05\85\80\80\80\00\01\01" "\01\80\02") 4 | (module binary 5 | "\00\61\73\6d\01\00\00\00\05\86\80\80\80\00\01\01" 6 | "\00\80\80\04" 7 | ) 8 | (assert_invalid 9 | (module binary "\00\61\73\6d\01\00\00\00\05\85\80\80\80\00\02\00" "\00\00\00") 10 | "multiple memories" 11 | ) 12 | (assert_invalid 13 | (module binary 14 | "\00\61\73\6d\01\00\00\00\02\94\80\80\80\00\01\08" 15 | "\73\70\65\63\74\65\73\74\06\6d\65\6d\6f\72\79\02" 16 | "\00\00\05\83\80\80\80\00\01\00\00" 17 | ) 18 | "multiple memories" 19 | ) 20 | (module binary 21 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 22 | "\00\01\7f\03\82\80\80\80\00\01\00\05\84\80\80\80" 23 | "\00\01\01\00\00\07\8b\80\80\80\00\01\07\6d\65\6d" 24 | "\73\69\7a\65\00\00\0a\8a\80\80\80\00\01\84\80\80" 25 | "\80\00\00\3f\00\0b\0b\86\80\80\80\00\01\00\41\00" 26 | "\0b\00" 27 | ) 28 | (assert_return (invoke "memsize") (i32.const 0)) 29 | (module binary 30 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 31 | "\00\01\7f\03\82\80\80\80\00\01\00\05\84\80\80\80" 32 | "\00\01\01\00\00\07\8b\80\80\80\00\01\07\6d\65\6d" 33 | "\73\69\7a\65\00\00\0a\8a\80\80\80\00\01\84\80\80" 34 | "\80\00\00\3f\00\0b\0b\86\80\80\80\00\01\00\41\00" 35 | "\0b\00" 36 | ) 37 | (assert_return (invoke "memsize") (i32.const 0)) 38 | (module binary 39 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 40 | "\00\01\7f\03\82\80\80\80\00\01\00\05\84\80\80\80" 41 | "\00\01\01\01\01\07\8b\80\80\80\00\01\07\6d\65\6d" 42 | "\73\69\7a\65\00\00\0a\8a\80\80\80\00\01\84\80\80" 43 | "\80\00\00\3f\00\0b\0b\87\80\80\80\00\01\00\41\00" 44 | "\0b\01\78" 45 | ) 46 | (assert_return (invoke "memsize") (i32.const 1)) 47 | (assert_invalid 48 | (module binary 49 | "\00\61\73\6d\01\00\00\00\0b\86\80\80\80\00\01\00" 50 | "\41\00\0b\00" 51 | ) 52 | "unknown memory" 53 | ) 54 | (assert_invalid 55 | (module binary 56 | "\00\61\73\6d\01\00\00\00\0b\86\80\80\80\00\01\00" 57 | "\41\00\0b\00" 58 | ) 59 | "unknown memory" 60 | ) 61 | (assert_invalid 62 | (module binary 63 | "\00\61\73\6d\01\00\00\00\0b\87\80\80\80\00\01\00" 64 | "\41\00\0b\01\78" 65 | ) 66 | "unknown memory" 67 | ) 68 | (assert_invalid 69 | (module binary 70 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 71 | "\00\00\03\82\80\80\80\00\01\00\0a\8e\80\80\80\00" 72 | "\01\88\80\80\80\00\00\41\00\2a\02\00\1a\0b" 73 | ) 74 | "unknown memory" 75 | ) 76 | (assert_invalid 77 | (module binary 78 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 79 | "\00\00\03\82\80\80\80\00\01\00\0a\92\80\80\80\00" 80 | "\01\8c\80\80\80\00\00\41\00\43\00\00\00\00\38\02" 81 | "\00\0b" 82 | ) 83 | "unknown memory" 84 | ) 85 | (assert_invalid 86 | (module binary 87 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 88 | "\00\00\03\82\80\80\80\00\01\00\0a\8e\80\80\80\00" 89 | "\01\88\80\80\80\00\00\41\00\2c\00\00\1a\0b" 90 | ) 91 | "unknown memory" 92 | ) 93 | (assert_invalid 94 | (module binary 95 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 96 | "\00\00\03\82\80\80\80\00\01\00\0a\8f\80\80\80\00" 97 | "\01\89\80\80\80\00\00\41\00\41\00\3a\00\00\0b" 98 | ) 99 | "unknown memory" 100 | ) 101 | (assert_invalid 102 | (module binary 103 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 104 | "\00\00\03\82\80\80\80\00\01\00\0a\8b\80\80\80\00" 105 | "\01\85\80\80\80\00\00\3f\00\1a\0b" 106 | ) 107 | "unknown memory" 108 | ) 109 | (assert_invalid 110 | (module binary 111 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 112 | "\00\00\03\82\80\80\80\00\01\00\0a\8d\80\80\80\00" 113 | "\01\87\80\80\80\00\00\41\00\40\00\1a\0b" 114 | ) 115 | "unknown memory" 116 | ) 117 | (assert_invalid 118 | (module binary "\00\61\73\6d\01\00\00\00\05\84\80\80\80\00\01\01" "\01\00") 119 | "size minimum must not be greater than maximum" 120 | ) 121 | (assert_invalid 122 | (module binary "\00\61\73\6d\01\00\00\00\05\85\80\80\80\00\01\00" "\81\80\04") 123 | "memory size must be at most 65536 pages (4GiB)" 124 | ) 125 | (assert_invalid 126 | (module binary 127 | "\00\61\73\6d\01\00\00\00\05\87\80\80\80\00\01\00" 128 | "\80\80\80\80\08" 129 | ) 130 | "memory size must be at most 65536 pages (4GiB)" 131 | ) 132 | (assert_invalid 133 | (module binary 134 | "\00\61\73\6d\01\00\00\00\05\87\80\80\80\00\01\00" 135 | "\ff\ff\ff\ff\0f" 136 | ) 137 | "memory size must be at most 65536 pages (4GiB)" 138 | ) 139 | (assert_invalid 140 | (module binary 141 | "\00\61\73\6d\01\00\00\00\05\86\80\80\80\00\01\01" 142 | "\00\81\80\04" 143 | ) 144 | "memory size must be at most 65536 pages (4GiB)" 145 | ) 146 | (assert_invalid 147 | (module binary 148 | "\00\61\73\6d\01\00\00\00\05\88\80\80\80\00\01\01" 149 | "\00\80\80\80\80\08" 150 | ) 151 | "memory size must be at most 65536 pages (4GiB)" 152 | ) 153 | (assert_invalid 154 | (module binary 155 | "\00\61\73\6d\01\00\00\00\05\88\80\80\80\00\01\01" 156 | "\00\ff\ff\ff\ff\0f" 157 | ) 158 | "memory size must be at most 65536 pages (4GiB)" 159 | ) 160 | (module binary 161 | "\00\61\73\6d\01\00\00\00\01\93\80\80\80\00\04\60" 162 | "\00\01\7f\60\00\01\7c\60\01\7f\01\7f\60\01\7e\01" 163 | "\7e\03\8d\80\80\80\00\0c\00\01\02\02\02\02\03\03" 164 | "\03\03\03\03\05\83\80\80\80\00\01\00\01\07\a1\81" 165 | "\80\80\00\0c\04\64\61\74\61\00\00\04\63\61\73\74" 166 | "\00\01\0b\69\33\32\5f\6c\6f\61\64\38\5f\73\00\02" 167 | "\0b\69\33\32\5f\6c\6f\61\64\38\5f\75\00\03\0c\69" 168 | "\33\32\5f\6c\6f\61\64\31\36\5f\73\00\04\0c\69\33" 169 | "\32\5f\6c\6f\61\64\31\36\5f\75\00\05\0b\69\36\34" 170 | "\5f\6c\6f\61\64\38\5f\73\00\06\0b\69\36\34\5f\6c" 171 | "\6f\61\64\38\5f\75\00\07\0c\69\36\34\5f\6c\6f\61" 172 | "\64\31\36\5f\73\00\08\0c\69\36\34\5f\6c\6f\61\64" 173 | "\31\36\5f\75\00\09\0c\69\36\34\5f\6c\6f\61\64\33" 174 | "\32\5f\73\00\0a\0c\69\36\34\5f\6c\6f\61\64\33\32" 175 | "\5f\75\00\0b\0a\cf\82\80\80\00\0c\ce\80\80\80\00" 176 | "\00\41\00\2d\00\00\41\c1\00\46\41\03\2d\00\00\41" 177 | "\a7\01\46\71\41\06\2d\00\00\41\00\46\41\13\2d\00" 178 | "\00\41\00\46\71\71\41\14\2d\00\00\41\d7\00\46\41" 179 | "\17\2d\00\00\41\cd\00\46\71\41\18\2d\00\00\41\00" 180 | "\46\41\ff\07\2d\00\00\41\00\46\71\71\71\0b\b8\80" 181 | "\80\80\00\00\41\08\42\c7\9f\7f\37\03\00\41\08\2b" 182 | "\03\00\42\c7\9f\7f\bf\61\04\40\44\00\00\00\00\00" 183 | "\00\00\00\0f\0b\41\09\42\00\37\00\00\41\0f\41\c5" 184 | "\80\01\3b\00\00\41\09\2b\00\00\0b\8e\80\80\80\00" 185 | "\00\41\08\20\00\3a\00\00\41\08\2c\00\00\0b\8e\80" 186 | "\80\80\00\00\41\08\20\00\3a\00\00\41\08\2d\00\00" 187 | "\0b\8e\80\80\80\00\00\41\08\20\00\3b\01\00\41\08" 188 | "\2e\01\00\0b\8e\80\80\80\00\00\41\08\20\00\3b\01" 189 | "\00\41\08\2f\01\00\0b\8e\80\80\80\00\00\41\08\20" 190 | "\00\3c\00\00\41\08\30\00\00\0b\8e\80\80\80\00\00" 191 | "\41\08\20\00\3c\00\00\41\08\31\00\00\0b\8e\80\80" 192 | "\80\00\00\41\08\20\00\3d\01\00\41\08\32\01\00\0b" 193 | "\8e\80\80\80\00\00\41\08\20\00\3d\01\00\41\08\33" 194 | "\01\00\0b\8e\80\80\80\00\00\41\08\20\00\3e\02\00" 195 | "\41\08\34\02\00\0b\8e\80\80\80\00\00\41\08\20\00" 196 | "\3e\02\00\41\08\35\02\00\0b\0b\94\80\80\80\00\02" 197 | "\00\41\00\0b\05\41\42\43\a7\44\00\41\14\0b\04\57" 198 | "\41\53\4d" 199 | ) 200 | (assert_return (invoke "data") (i32.const 1)) 201 | (assert_return (invoke "cast") (f64.const 42)) 202 | (assert_return (invoke "i32_load8_s" (i32.const -1)) (i32.const -1)) 203 | (assert_return (invoke "i32_load8_u" (i32.const -1)) (i32.const 255)) 204 | (assert_return (invoke "i32_load16_s" (i32.const -1)) (i32.const -1)) 205 | (assert_return (invoke "i32_load16_u" (i32.const -1)) (i32.const 65_535)) 206 | (assert_return (invoke "i32_load8_s" (i32.const 100)) (i32.const 100)) 207 | (assert_return (invoke "i32_load8_u" (i32.const 200)) (i32.const 200)) 208 | (assert_return (invoke "i32_load16_s" (i32.const 20_000)) (i32.const 20_000)) 209 | (assert_return (invoke "i32_load16_u" (i32.const 40_000)) (i32.const 40_000)) 210 | (assert_return (invoke "i32_load8_s" (i32.const -19_110_589)) (i32.const 67)) 211 | (assert_return (invoke "i32_load8_s" (i32.const 878_104_047)) (i32.const -17)) 212 | (assert_return (invoke "i32_load8_u" (i32.const -19_110_589)) (i32.const 67)) 213 | (assert_return (invoke "i32_load8_u" (i32.const 878_104_047)) (i32.const 239)) 214 | (assert_return 215 | (invoke "i32_load16_s" (i32.const -19_110_589)) 216 | (i32.const 25_923) 217 | ) 218 | (assert_return 219 | (invoke "i32_load16_s" (i32.const 878_104_047)) 220 | (i32.const -12_817) 221 | ) 222 | (assert_return 223 | (invoke "i32_load16_u" (i32.const -19_110_589)) 224 | (i32.const 25_923) 225 | ) 226 | (assert_return 227 | (invoke "i32_load16_u" (i32.const 878_104_047)) 228 | (i32.const 52_719) 229 | ) 230 | (assert_return (invoke "i64_load8_s" (i64.const -1)) (i64.const -1)) 231 | (assert_return (invoke "i64_load8_u" (i64.const -1)) (i64.const 255)) 232 | (assert_return (invoke "i64_load16_s" (i64.const -1)) (i64.const -1)) 233 | (assert_return (invoke "i64_load16_u" (i64.const -1)) (i64.const 65_535)) 234 | (assert_return (invoke "i64_load32_s" (i64.const -1)) (i64.const -1)) 235 | (assert_return (invoke "i64_load32_u" (i64.const -1)) (i64.const 4_294_967_295)) 236 | (assert_return (invoke "i64_load8_s" (i64.const 100)) (i64.const 100)) 237 | (assert_return (invoke "i64_load8_u" (i64.const 200)) (i64.const 200)) 238 | (assert_return (invoke "i64_load16_s" (i64.const 20_000)) (i64.const 20_000)) 239 | (assert_return (invoke "i64_load16_u" (i64.const 40_000)) (i64.const 40_000)) 240 | (assert_return (invoke "i64_load32_s" (i64.const 20_000)) (i64.const 20_000)) 241 | (assert_return (invoke "i64_load32_u" (i64.const 40_000)) (i64.const 40_000)) 242 | (assert_return 243 | (invoke "i64_load8_s" (i64.const -81_985_529_755_441_853)) 244 | (i64.const 67) 245 | ) 246 | (assert_return 247 | (invoke "i64_load8_s" (i64.const 3_771_275_841_602_506_223)) 248 | (i64.const -17) 249 | ) 250 | (assert_return 251 | (invoke "i64_load8_u" (i64.const -81_985_529_755_441_853)) 252 | (i64.const 67) 253 | ) 254 | (assert_return 255 | (invoke "i64_load8_u" (i64.const 3_771_275_841_602_506_223)) 256 | (i64.const 239) 257 | ) 258 | (assert_return 259 | (invoke "i64_load16_s" (i64.const -81_985_529_755_441_853)) 260 | (i64.const 25_923) 261 | ) 262 | (assert_return 263 | (invoke "i64_load16_s" (i64.const 3_771_275_841_602_506_223)) 264 | (i64.const -12_817) 265 | ) 266 | (assert_return 267 | (invoke "i64_load16_u" (i64.const -81_985_529_755_441_853)) 268 | (i64.const 25_923) 269 | ) 270 | (assert_return 271 | (invoke "i64_load16_u" (i64.const 3_771_275_841_602_506_223)) 272 | (i64.const 52_719) 273 | ) 274 | (assert_return 275 | (invoke "i64_load32_s" (i64.const -81_985_529_755_441_853)) 276 | (i64.const 1_446_274_371) 277 | ) 278 | (assert_return 279 | (invoke "i64_load32_s" (i64.const 3_771_275_841_602_506_223)) 280 | (i64.const -1_732_588_049) 281 | ) 282 | (assert_return 283 | (invoke "i64_load32_u" (i64.const -81_985_529_755_441_853)) 284 | (i64.const 1_446_274_371) 285 | ) 286 | (assert_return 287 | (invoke "i64_load32_u" (i64.const 3_771_275_841_602_506_223)) 288 | (i64.const 2_562_379_247) 289 | ) 290 | -------------------------------------------------------------------------------- /tests/suite/memory_redundancy.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary 2 | "\00\61\73\6d\01\00\00\00\01\91\80\80\80\00\04\60" 3 | "\00\00\60\00\01\7f\60\00\01\7d\60\01\7f\01\7f\03" 4 | "\87\80\80\80\00\06\00\01\01\02\03\01\05\84\80\80" 5 | "\80\00\01\01\01\01\07\eb\80\80\80\00\06\0f\7a\65" 6 | "\72\6f\5f\65\76\65\72\79\74\68\69\6e\67\00\00\12" 7 | "\74\65\73\74\5f\73\74\6f\72\65\5f\74\6f\5f\6c\6f" 8 | "\61\64\00\01\13\74\65\73\74\5f\72\65\64\75\6e\64" 9 | "\61\6e\74\5f\6c\6f\61\64\00\02\0f\74\65\73\74\5f" 10 | "\64\65\61\64\5f\73\74\6f\72\65\00\03\06\6d\61\6c" 11 | "\6c\6f\63\00\04\0f\6d\61\6c\6c\6f\63\5f\61\6c\69" 12 | "\61\73\69\6e\67\00\05\0a\bd\81\80\80\00\06\9e\80" 13 | "\80\80\00\00\41\00\41\00\36\02\00\41\04\41\00\36" 14 | "\02\00\41\08\41\00\36\02\00\41\0c\41\00\36\02\00" 15 | "\0b\98\80\80\80\00\00\41\08\41\00\36\02\00\41\05" 16 | "\43\00\00\00\80\38\02\00\41\08\28\02\00\0b\a2\80" 17 | "\80\80\00\01\02\7f\41\08\28\02\00\21\00\41\05\41" 18 | "\80\80\80\80\78\36\02\00\41\08\28\02\00\21\01\20" 19 | "\00\20\01\6a\0b\9f\80\80\80\00\01\01\7d\41\08\41" 20 | "\a3\c6\8c\99\02\36\02\00\41\0b\2a\02\00\21\00\41" 21 | "\08\41\00\36\02\00\20\00\0b\84\80\80\80\00\00\41" 22 | "\10\0b\a3\80\80\80\00\01\02\7f\41\04\10\04\21\00" 23 | "\41\04\10\04\21\01\20\00\41\2a\36\02\00\20\01\41" 24 | "\2b\36\02\00\20\00\28\02\00\0b" 25 | ) 26 | (assert_return (invoke "test_store_to_load") (i32.const 128)) 27 | (invoke "zero_everything") 28 | (assert_return (invoke "test_redundant_load") (i32.const 128)) 29 | (invoke "zero_everything") 30 | (assert_return 31 | (invoke "test_dead_store") 32 | (f32.const 4.904_544_625_136_859_7e-44) 33 | ) 34 | (invoke "zero_everything") 35 | (assert_return (invoke "malloc_aliasing") (i32.const 43)) 36 | -------------------------------------------------------------------------------- /tests/suite/memory_size.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary 2 | "\00\61\73\6d\01\00\00\00\01\89\80\80\80\00\02\60" 3 | "\00\01\7f\60\01\7f\00\03\83\80\80\80\00\02\00\01" 4 | "\05\83\80\80\80\00\01\00\00\07\8f\80\80\80\00\02" 5 | "\04\73\69\7a\65\00\00\04\67\72\6f\77\00\01\0a\96" 6 | "\80\80\80\00\02\84\80\80\80\00\00\3f\00\0b\87\80" 7 | "\80\80\00\00\20\00\40\00\1a\0b" 8 | ) 9 | (assert_return (invoke "size") (i32.const 0)) 10 | (assert_return (invoke "grow" (i32.const 1))) 11 | (assert_return (invoke "size") (i32.const 1)) 12 | (assert_return (invoke "grow" (i32.const 4))) 13 | (assert_return (invoke "size") (i32.const 5)) 14 | (assert_return (invoke "grow" (i32.const 0))) 15 | (assert_return (invoke "size") (i32.const 5)) 16 | (module binary 17 | "\00\61\73\6d\01\00\00\00\01\89\80\80\80\00\02\60" 18 | "\00\01\7f\60\01\7f\00\03\83\80\80\80\00\02\00\01" 19 | "\05\83\80\80\80\00\01\00\01\07\8f\80\80\80\00\02" 20 | "\04\73\69\7a\65\00\00\04\67\72\6f\77\00\01\0a\96" 21 | "\80\80\80\00\02\84\80\80\80\00\00\3f\00\0b\87\80" 22 | "\80\80\00\00\20\00\40\00\1a\0b" 23 | ) 24 | (assert_return (invoke "size") (i32.const 1)) 25 | (assert_return (invoke "grow" (i32.const 1))) 26 | (assert_return (invoke "size") (i32.const 2)) 27 | (assert_return (invoke "grow" (i32.const 4))) 28 | (assert_return (invoke "size") (i32.const 6)) 29 | (assert_return (invoke "grow" (i32.const 0))) 30 | (assert_return (invoke "size") (i32.const 6)) 31 | (module binary 32 | "\00\61\73\6d\01\00\00\00\01\89\80\80\80\00\02\60" 33 | "\00\01\7f\60\01\7f\00\03\83\80\80\80\00\02\00\01" 34 | "\05\84\80\80\80\00\01\01\00\02\07\8f\80\80\80\00" 35 | "\02\04\73\69\7a\65\00\00\04\67\72\6f\77\00\01\0a" 36 | "\96\80\80\80\00\02\84\80\80\80\00\00\3f\00\0b\87" 37 | "\80\80\80\00\00\20\00\40\00\1a\0b" 38 | ) 39 | (assert_return (invoke "size") (i32.const 0)) 40 | (assert_return (invoke "grow" (i32.const 3))) 41 | (assert_return (invoke "size") (i32.const 0)) 42 | (assert_return (invoke "grow" (i32.const 1))) 43 | (assert_return (invoke "size") (i32.const 1)) 44 | (assert_return (invoke "grow" (i32.const 0))) 45 | (assert_return (invoke "size") (i32.const 1)) 46 | (assert_return (invoke "grow" (i32.const 4))) 47 | (assert_return (invoke "size") (i32.const 1)) 48 | (assert_return (invoke "grow" (i32.const 1))) 49 | (assert_return (invoke "size") (i32.const 2)) 50 | (module binary 51 | "\00\61\73\6d\01\00\00\00\01\89\80\80\80\00\02\60" 52 | "\00\01\7f\60\01\7f\00\03\83\80\80\80\00\02\00\01" 53 | "\05\84\80\80\80\00\01\01\03\08\07\8f\80\80\80\00" 54 | "\02\04\73\69\7a\65\00\00\04\67\72\6f\77\00\01\0a" 55 | "\96\80\80\80\00\02\84\80\80\80\00\00\3f\00\0b\87" 56 | "\80\80\80\00\00\20\00\40\00\1a\0b" 57 | ) 58 | (assert_return (invoke "size") (i32.const 3)) 59 | (assert_return (invoke "grow" (i32.const 1))) 60 | (assert_return (invoke "size") (i32.const 4)) 61 | (assert_return (invoke "grow" (i32.const 3))) 62 | (assert_return (invoke "size") (i32.const 7)) 63 | (assert_return (invoke "grow" (i32.const 0))) 64 | (assert_return (invoke "size") (i32.const 7)) 65 | (assert_return (invoke "grow" (i32.const 2))) 66 | (assert_return (invoke "size") (i32.const 7)) 67 | (assert_return (invoke "grow" (i32.const 1))) 68 | (assert_return (invoke "size") (i32.const 8)) 69 | (assert_invalid 70 | (module binary 71 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 72 | "\00\00\03\82\80\80\80\00\01\00\05\83\80\80\80\00" 73 | "\01\00\01\0a\8a\80\80\80\00\01\84\80\80\80\00\00" 74 | "\3f\00\0b" 75 | ) 76 | "type mismatch" 77 | ) 78 | (assert_invalid 79 | (module binary 80 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 81 | "\00\01\7d\03\82\80\80\80\00\01\00\05\83\80\80\80" 82 | "\00\01\00\01\0a\8a\80\80\80\00\01\84\80\80\80\00" 83 | "\00\3f\00\0b" 84 | ) 85 | "type mismatch" 86 | ) 87 | -------------------------------------------------------------------------------- /tests/suite/resizing.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary 2 | "\00\61\73\6d\01\00\00\00\01\8d\80\80\80\00\03\60" 3 | "\00\01\7f\60\00\00\60\01\7f\01\7f\03\87\80\80\80" 4 | "\00\06\00\01\00\01\02\00\05\83\80\80\80\00\01\00" 5 | "\00\07\d7\80\80\80\00\06\0c\6c\6f\61\64\5f\61\74" 6 | "\5f\7a\65\72\6f\00\00\0d\73\74\6f\72\65\5f\61\74" 7 | "\5f\7a\65\72\6f\00\01\11\6c\6f\61\64\5f\61\74\5f" 8 | "\70\61\67\65\5f\73\69\7a\65\00\02\12\73\74\6f\72" 9 | "\65\5f\61\74\5f\70\61\67\65\5f\73\69\7a\65\00\03" 10 | "\04\67\72\6f\77\00\04\04\73\69\7a\65\00\05\0a\cd" 11 | "\80\80\80\00\06\87\80\80\80\00\00\41\00\28\02\00" 12 | "\0b\89\80\80\80\00\00\41\00\41\02\36\02\00\0b\89" 13 | "\80\80\80\00\00\41\80\80\04\28\02\00\0b\8b\80\80" 14 | "\80\00\00\41\80\80\04\41\03\36\02\00\0b\86\80\80" 15 | "\80\00\00\20\00\40\00\0b\84\80\80\80\00\00\3f\00" 16 | "\0b" 17 | ) 18 | (assert_return (invoke "size") (i32.const 0)) 19 | (assert_trap (invoke "store_at_zero") "out of bounds memory access") 20 | (assert_trap (invoke "load_at_zero") "out of bounds memory access") 21 | (assert_trap (invoke "store_at_page_size") "out of bounds memory access") 22 | (assert_trap (invoke "load_at_page_size") "out of bounds memory access") 23 | (assert_return (invoke "grow" (i32.const 1)) (i32.const 0)) 24 | (assert_return (invoke "size") (i32.const 1)) 25 | (assert_return (invoke "load_at_zero") (i32.const 0)) 26 | (assert_return (invoke "store_at_zero")) 27 | (assert_return (invoke "load_at_zero") (i32.const 2)) 28 | (assert_trap (invoke "store_at_page_size") "out of bounds memory access") 29 | (assert_trap (invoke "load_at_page_size") "out of bounds memory access") 30 | (assert_return (invoke "grow" (i32.const 4)) (i32.const 1)) 31 | (assert_return (invoke "size") (i32.const 5)) 32 | (assert_return (invoke "load_at_zero") (i32.const 2)) 33 | (assert_return (invoke "store_at_zero")) 34 | (assert_return (invoke "load_at_zero") (i32.const 2)) 35 | (assert_return (invoke "load_at_page_size") (i32.const 0)) 36 | (assert_return (invoke "store_at_page_size")) 37 | (assert_return (invoke "load_at_page_size") (i32.const 3)) 38 | (module binary 39 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 40 | "\01\7f\01\7f\03\82\80\80\80\00\01\00\05\83\80\80" 41 | "\80\00\01\00\00\07\88\80\80\80\00\01\04\67\72\6f" 42 | "\77\00\00\0a\8c\80\80\80\00\01\86\80\80\80\00\00" 43 | "\20\00\40\00\0b" 44 | ) 45 | (assert_return (invoke "grow" (i32.const 0)) (i32.const 0)) 46 | (assert_return (invoke "grow" (i32.const 1)) (i32.const 0)) 47 | (assert_return (invoke "grow" (i32.const 0)) (i32.const 1)) 48 | (assert_return (invoke "grow" (i32.const 2)) (i32.const 1)) 49 | (assert_return (invoke "grow" (i32.const 800)) (i32.const 3)) 50 | (assert_return (invoke "grow" (i32.const 65536)) (i32.const -1)) 51 | (module binary 52 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 53 | "\01\7f\01\7f\03\82\80\80\80\00\01\00\05\84\80\80" 54 | "\80\00\01\01\00\0a\07\88\80\80\80\00\01\04\67\72" 55 | "\6f\77\00\00\0a\8c\80\80\80\00\01\86\80\80\80\00" 56 | "\00\20\00\40\00\0b" 57 | ) 58 | (assert_return (invoke "grow" (i32.const 0)) (i32.const 0)) 59 | (assert_return (invoke "grow" (i32.const 1)) (i32.const 0)) 60 | (assert_return (invoke "grow" (i32.const 1)) (i32.const 1)) 61 | (assert_return (invoke "grow" (i32.const 2)) (i32.const 2)) 62 | (assert_return (invoke "grow" (i32.const 6)) (i32.const 4)) 63 | (assert_return (invoke "grow" (i32.const 0)) (i32.const 10)) 64 | (assert_return (invoke "grow" (i32.const 1)) (i32.const -1)) 65 | (assert_return (invoke "grow" (i32.const 65536)) (i32.const -1)) 66 | -------------------------------------------------------------------------------- /tests/suite/set_local.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary 2 | "\00\61\73\6d\01\00\00\00\01\a5\80\80\80\00\07\60" 3 | "\00\00\60\01\7f\00\60\01\7e\00\60\01\7d\00\60\01" 4 | "\7c\00\60\05\7e\7d\7c\7f\7f\00\60\05\7e\7d\7c\7f" 5 | "\7f\01\7e\03\8b\80\80\80\00\0a\00\00\00\00\01\02" 6 | "\03\04\05\06\07\9e\81\80\80\00\0a\0e\74\79\70\65" 7 | "\2d\6c\6f\63\61\6c\2d\69\33\32\00\00\0e\74\79\70" 8 | "\65\2d\6c\6f\63\61\6c\2d\69\36\34\00\01\0e\74\79" 9 | "\70\65\2d\6c\6f\63\61\6c\2d\66\33\32\00\02\0e\74" 10 | "\79\70\65\2d\6c\6f\63\61\6c\2d\66\36\34\00\03\0e" 11 | "\74\79\70\65\2d\70\61\72\61\6d\2d\69\33\32\00\04" 12 | "\0e\74\79\70\65\2d\70\61\72\61\6d\2d\69\36\34\00" 13 | "\05\0e\74\79\70\65\2d\70\61\72\61\6d\2d\66\33\32" 14 | "\00\06\0e\74\79\70\65\2d\70\61\72\61\6d\2d\66\36" 15 | "\34\00\07\0a\74\79\70\65\2d\6d\69\78\65\64\00\08" 16 | "\05\77\72\69\74\65\00\09\0a\8e\82\80\80\00\0a\88" 17 | "\80\80\80\00\01\01\7f\41\00\21\00\0b\88\80\80\80" 18 | "\00\01\01\7e\42\00\21\00\0b\8b\80\80\80\00\01\01" 19 | "\7d\43\00\00\00\00\21\00\0b\8f\80\80\80\00\01\01" 20 | "\7c\44\00\00\00\00\00\00\00\00\21\00\0b\86\80\80" 21 | "\80\00\00\41\0a\21\00\0b\86\80\80\80\00\00\42\0b" 22 | "\21\00\0b\89\80\80\80\00\00\43\9a\99\31\41\21\00" 23 | "\0b\8d\80\80\80\00\00\44\66\66\66\66\66\66\28\40" 24 | "\21\00\0b\c0\80\80\80\00\03\01\7d\02\7e\01\7c\42" 25 | "\00\21\00\43\00\00\00\00\21\01\44\00\00\00\00\00" 26 | "\00\00\00\21\02\41\00\21\03\41\00\21\04\43\00\00" 27 | "\00\00\21\05\42\00\21\06\42\00\21\07\44\00\00\00" 28 | "\00\00\00\00\00\21\08\0b\cf\80\80\80\00\03\01\7d" 29 | "\02\7e\01\7c\43\9a\99\99\be\21\01\41\28\21\03\41" 30 | "\79\21\04\43\00\00\b0\40\21\05\42\06\21\06\44\00" 31 | "\00\00\00\00\00\20\40\21\08\20\00\ba\20\01\bb\20" 32 | "\02\20\03\b8\20\04\b7\20\05\bb\20\06\ba\20\07\ba" 33 | "\20\08\a0\a0\a0\a0\a0\a0\a0\a0\b0\0b" 34 | ) 35 | (assert_return (invoke "type-local-i32")) 36 | (assert_return (invoke "type-local-i64")) 37 | (assert_return (invoke "type-local-f32")) 38 | (assert_return (invoke "type-local-f64")) 39 | (assert_return (invoke "type-param-i32" (i32.const 2))) 40 | (assert_return (invoke "type-param-i64" (i64.const 3))) 41 | (assert_return (invoke "type-param-f32" (f32.const 0x1.19999ap+2))) 42 | (assert_return (invoke "type-param-f64" (f64.const 0x1.6p+2))) 43 | (assert_return 44 | (invoke "type-mixed" 45 | (i64.const 1) 46 | (f32.const 0x1.19999ap+1) 47 | (f64.const 0x1.a666666666666p+1) 48 | (i32.const 4) 49 | (i32.const 5) 50 | ) 51 | ) 52 | (assert_return 53 | (invoke "write" 54 | (i64.const 1) 55 | (f32.const 0x1p+1) 56 | (f64.const 0x1.a666666666666p+1) 57 | (i32.const 4) 58 | (i32.const 5) 59 | ) 60 | (i64.const 56) 61 | ) 62 | (assert_invalid 63 | (module binary 64 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 65 | "\00\01\7e\03\82\80\80\80\00\01\00\0a\8e\80\80\80" 66 | "\00\01\88\80\80\80\00\01\01\7f\41\00\21\00\0b" 67 | ) 68 | "type mismatch" 69 | ) 70 | (assert_invalid 71 | (module binary 72 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 73 | "\00\00\03\82\80\80\80\00\01\00\0a\92\80\80\80\00" 74 | "\01\8c\80\80\80\00\01\01\7d\43\00\00\00\00\21\00" 75 | "\45\0b" 76 | ) 77 | "type mismatch" 78 | ) 79 | (assert_invalid 80 | (module binary 81 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 82 | "\00\00\03\82\80\80\80\00\01\00\0a\91\80\80\80\00" 83 | "\01\8b\80\80\80\00\02\01\7c\01\7e\42\00\21\01\9a" 84 | "\0b" 85 | ) 86 | "type mismatch" 87 | ) 88 | (assert_invalid 89 | (module binary 90 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 91 | "\00\00\03\82\80\80\80\00\01\00\0a\8d\80\80\80\00" 92 | "\01\87\80\80\80\00\01\01\7f\01\21\00\0b" 93 | ) 94 | "type mismatch" 95 | ) 96 | (assert_invalid 97 | (module binary 98 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 99 | "\00\00\03\82\80\80\80\00\01\00\0a\91\80\80\80\00" 100 | "\01\8b\80\80\80\00\01\01\7f\43\00\00\00\00\21\00" 101 | "\0b" 102 | ) 103 | "type mismatch" 104 | ) 105 | (assert_invalid 106 | (module binary 107 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 108 | "\00\00\03\82\80\80\80\00\01\00\0a\95\80\80\80\00" 109 | "\01\8f\80\80\80\00\01\01\7d\44\00\00\00\00\00\00" 110 | "\00\00\21\00\0b" 111 | ) 112 | "type mismatch" 113 | ) 114 | (assert_invalid 115 | (module binary 116 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 117 | "\00\00\03\82\80\80\80\00\01\00\0a\97\80\80\80\00" 118 | "\01\91\80\80\80\00\02\01\7c\01\7e\44\00\00\00\00" 119 | "\00\00\00\00\21\01\0b" 120 | ) 121 | "type mismatch" 122 | ) 123 | (assert_invalid 124 | (module binary 125 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 126 | "\01\7f\01\7e\03\82\80\80\80\00\01\00\0a\8a\80\80" 127 | "\80\00\01\84\80\80\80\00\00\20\00\0b" 128 | ) 129 | "type mismatch" 130 | ) 131 | (assert_invalid 132 | (module binary 133 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 134 | "\01\7d\00\03\82\80\80\80\00\01\00\0a\8b\80\80\80" 135 | "\00\01\85\80\80\80\00\00\20\00\45\0b" 136 | ) 137 | "type mismatch" 138 | ) 139 | (assert_invalid 140 | (module binary 141 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 142 | "\02\7c\7e\00\03\82\80\80\80\00\01\00\0a\8b\80\80" 143 | "\80\00\01\85\80\80\80\00\00\20\01\9a\0b" 144 | ) 145 | "type mismatch" 146 | ) 147 | (assert_invalid 148 | (module binary 149 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 150 | "\01\7f\00\03\82\80\80\80\00\01\00\0a\8b\80\80\80" 151 | "\00\01\85\80\80\80\00\00\01\21\00\0b" 152 | ) 153 | "type mismatch" 154 | ) 155 | (assert_invalid 156 | (module binary 157 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 158 | "\01\7f\00\03\82\80\80\80\00\01\00\0a\8f\80\80\80" 159 | "\00\01\89\80\80\80\00\00\43\00\00\00\00\21\00\0b" 160 | ) 161 | "type mismatch" 162 | ) 163 | (assert_invalid 164 | (module binary 165 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 166 | "\01\7d\00\03\82\80\80\80\00\01\00\0a\93\80\80\80" 167 | "\00\01\8d\80\80\80\00\00\44\00\00\00\00\00\00\00" 168 | "\00\21\00\0b" 169 | ) 170 | "type mismatch" 171 | ) 172 | (assert_invalid 173 | (module binary 174 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 175 | "\02\7c\7e\00\03\82\80\80\80\00\01\00\0a\93\80\80" 176 | "\80\00\01\8d\80\80\80\00\00\44\00\00\00\00\00\00" 177 | "\00\00\21\01\0b" 178 | ) 179 | "type mismatch" 180 | ) 181 | (assert_invalid 182 | (module binary 183 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 184 | "\00\00\03\82\80\80\80\00\01\00\0a\8e\80\80\80\00" 185 | "\01\88\80\80\80\00\02\01\7f\01\7e\20\03\0b" 186 | ) 187 | "unknown local" 188 | ) 189 | (assert_invalid 190 | (module binary 191 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 192 | "\00\00\03\82\80\80\80\00\01\00\0a\91\80\80\80\00" 193 | "\01\8b\80\80\80\00\02\01\7f\01\7e\20\f7\a4\ea\06" 194 | "\0b" 195 | ) 196 | "unknown local" 197 | ) 198 | (assert_invalid 199 | (module binary 200 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 201 | "\02\7f\7e\00\03\82\80\80\80\00\01\00\0a\8a\80\80" 202 | "\80\00\01\84\80\80\80\00\00\20\02\0b" 203 | ) 204 | "unknown local" 205 | ) 206 | (assert_invalid 207 | (module binary 208 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 209 | "\00\00\03\82\80\80\80\00\01\00\0a\92\80\80\80\00" 210 | "\01\8c\80\80\80\00\02\01\7f\01\7e\20\f7\f2\ce\d4" 211 | "\02\0b" 212 | ) 213 | "unknown local" 214 | ) 215 | (assert_invalid 216 | (module binary 217 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 218 | "\01\7f\00\03\82\80\80\80\00\01\00\0a\8e\80\80\80" 219 | "\00\01\88\80\80\80\00\02\01\7f\01\7e\20\03\0b" 220 | ) 221 | "unknown local" 222 | ) 223 | (assert_invalid 224 | (module binary 225 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 226 | "\01\7e\00\03\82\80\80\80\00\01\00\0a\91\80\80\80" 227 | "\00\01\8b\80\80\80\00\02\01\7f\01\7e\20\f7\a8\99" 228 | "\66\0b" 229 | ) 230 | "unknown local" 231 | ) 232 | (assert_invalid 233 | (module binary 234 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 235 | "\01\7d\00\03\82\80\80\80\00\01\00\0a\91\80\80\80" 236 | "\00\01\8b\80\80\80\00\01\01\7f\43\00\00\00\00\21" 237 | "\01\0b" 238 | ) 239 | "type mismatch" 240 | ) 241 | (assert_invalid 242 | (module binary 243 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 244 | "\02\7e\7f\00\03\82\80\80\80\00\01\00\0a\91\80\80" 245 | "\80\00\01\8b\80\80\80\00\01\01\7d\43\00\00\00\00" 246 | "\21\01\0b" 247 | ) 248 | "type mismatch" 249 | ) 250 | (assert_invalid 251 | (module binary 252 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 253 | "\01\7e\00\03\82\80\80\80\00\01\00\0a\90\80\80\80" 254 | "\00\01\8a\80\80\80\00\02\01\7c\01\7e\42\00\21\01" 255 | "\0b" 256 | ) 257 | "type mismatch" 258 | ) 259 | -------------------------------------------------------------------------------- /tests/suite/stack.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary 2 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 3 | "\01\7e\01\7e\03\86\80\80\80\00\05\00\00\00\00\00" 4 | "\07\c4\80\80\80\00\05\08\66\61\63\2d\65\78\70\72" 5 | "\00\00\09\66\61\63\2d\73\74\61\63\6b\00\01\0d\66" 6 | "\61\63\2d\73\74\61\63\6b\2d\72\61\77\00\02\09\66" 7 | "\61\63\2d\6d\69\78\65\64\00\03\0d\66\61\63\2d\6d" 8 | "\69\78\65\64\2d\72\61\77\00\04\0a\85\82\80\80\00" 9 | "\05\af\80\80\80\00\01\02\7e\20\00\21\01\42\01\21" 10 | "\02\02\40\03\40\20\01\42\00\51\04\40\0c\02\05\20" 11 | "\01\20\02\7e\21\02\20\01\42\01\7d\21\01\0b\0c\00" 12 | "\0b\0b\20\02\0b\af\80\80\80\00\01\02\7e\20\00\21" 13 | "\01\42\01\21\02\02\40\03\40\20\01\42\00\51\04\40" 14 | "\0c\02\05\20\01\20\02\7e\21\02\20\01\42\01\7d\21" 15 | "\01\0b\0c\00\0b\0b\20\02\0b\af\80\80\80\00\01\02" 16 | "\7e\20\00\21\01\42\01\21\02\02\40\03\40\20\01\42" 17 | "\00\51\04\40\0c\02\05\20\01\20\02\7e\21\02\20\01" 18 | "\42\01\7d\21\01\0b\0c\00\0b\0b\20\02\0b\af\80\80" 19 | "\80\00\01\02\7e\20\00\21\01\42\01\21\02\02\40\03" 20 | "\40\20\01\42\00\51\04\40\0c\02\05\20\01\20\02\7e" 21 | "\21\02\20\01\42\01\7d\21\01\0b\0c\00\0b\0b\20\02" 22 | "\0b\af\80\80\80\00\01\02\7e\20\00\21\01\42\01\21" 23 | "\02\02\40\03\40\20\01\42\00\51\04\40\0c\02\05\20" 24 | "\01\20\02\7e\21\02\20\01\42\01\7d\21\01\0b\0c\00" 25 | "\0b\0b\20\02\0b" 26 | ) 27 | (assert_return 28 | (invoke "fac-expr" (i64.const 25)) 29 | (i64.const 7_034_535_277_573_963_776) 30 | ) 31 | (assert_return 32 | (invoke "fac-stack" (i64.const 25)) 33 | (i64.const 7_034_535_277_573_963_776) 34 | ) 35 | (assert_return 36 | (invoke "fac-mixed" (i64.const 25)) 37 | (i64.const 7_034_535_277_573_963_776) 38 | ) 39 | (module binary 40 | "\00\61\73\6d\01\00\00\00\01\8c\80\80\80\00\03\60" 41 | "\00\00\60\00\01\7f\60\01\7f\00\03\82\80\80\80\00" 42 | "\01\00\04\84\80\80\80\00\01\70\00\01\0a\b7\83\80" 43 | "\80\00\01\b1\83\80\80\00\00\02\40\41\00\11\00\00" 44 | "\0b\03\40\41\00\11\00\00\0b\41\00\04\40\41\00\11" 45 | "\00\00\0b\41\00\04\40\41\00\11\00\00\05\41\00\11" 46 | "\00\00\0b\02\40\41\00\11\00\00\0b\03\40\41\00\11" 47 | "\00\00\0b\41\00\04\40\41\00\11\00\00\0b\41\00\04" 48 | "\40\41\00\11\00\00\05\41\00\11\00\00\0b\02\40\41" 49 | "\00\41\00\11\02\00\0b\03\40\41\00\41\00\11\02\00" 50 | "\0b\41\00\04\40\41\00\41\00\11\02\00\0b\41\00\04" 51 | "\40\41\00\41\00\11\02\00\05\41\00\41\00\11\02\00" 52 | "\0b\02\7f\41\00\11\01\00\0b\1a\03\7f\41\00\11\01" 53 | "\00\0b\1a\41\00\04\7f\41\00\11\01\00\05\41\00\11" 54 | "\01\00\0b\1a\02\40\41\00\11\00\00\0b\03\40\41\00" 55 | "\11\00\00\0b\41\00\04\40\41\00\11\00\00\0b\41\00" 56 | "\04\40\41\00\11\00\00\05\41\00\11\00\00\0b\02\40" 57 | "\41\00\11\00\00\0b\03\40\41\00\11\00\00\0b\41\00" 58 | "\04\40\41\00\11\00\00\0b\41\00\04\40\41\00\11\00" 59 | "\00\05\41\00\11\00\00\0b\02\40\41\00\11\00\00\0b" 60 | "\03\40\41\00\11\00\00\0b\41\00\04\40\41\00\11\00" 61 | "\00\0b\41\00\04\40\41\00\11\00\00\05\41\00\11\00" 62 | "\00\0b\02\40\41\00\41\00\11\02\00\0b\03\40\41\00" 63 | "\41\00\11\02\00\0b\41\00\04\40\41\00\41\00\11\02" 64 | "\00\0b\41\00\04\40\41\00\41\00\11\02\00\05\41\00" 65 | "\41\00\11\02\00\0b\02\7f\41\00\11\01\00\0b\1a\03" 66 | "\7f\41\00\11\01\00\0b\1a\41\00\04\7f\41\00\11\01" 67 | "\00\05\41\00\11\01\00\0b\1a\02\40\41\00\11\00\00" 68 | "\0b\03\40\41\00\11\00\00\0b\41\00\04\40\41\00\11" 69 | "\00\00\0b\41\00\04\40\41\00\11\00\00\05\41\00\11" 70 | "\00\00\0b\41\00\11\00\00\0b" 71 | ) 72 | -------------------------------------------------------------------------------- /tests/suite/start.bin.wast: -------------------------------------------------------------------------------- 1 | (assert_invalid 2 | (module binary 3 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 4 | "\00\00\03\82\80\80\80\00\01\00\08\81\80\80\80\00" 5 | "\01\0a\88\80\80\80\00\01\82\80\80\80\00\00\0b" 6 | ) 7 | "unknown function" 8 | ) 9 | (assert_invalid 10 | (module binary 11 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 12 | "\00\01\7f\03\82\80\80\80\00\01\00\08\81\80\80\80" 13 | "\00\00\0a\8b\80\80\80\00\01\85\80\80\80\00\00\41" 14 | "\00\0f\0b" 15 | ) 16 | "start function" 17 | ) 18 | (assert_invalid 19 | (module binary 20 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 21 | "\01\7f\00\03\82\80\80\80\00\01\00\08\81\80\80\80" 22 | "\00\00\0a\88\80\80\80\00\01\82\80\80\80\00\00\0b" 23 | ) 24 | "start function" 25 | ) 26 | (module binary 27 | "\00\61\73\6d\01\00\00\00\01\88\80\80\80\00\02\60" 28 | "\00\00\60\00\01\7f\03\84\80\80\80\00\03\00\01\00" 29 | "\05\84\80\80\80\00\01\01\01\01\07\8d\80\80\80\00" 30 | "\02\03\69\6e\63\00\00\03\67\65\74\00\01\08\81\80" 31 | "\80\80\00\02\0a\af\80\80\80\00\03\8f\80\80\80\00" 32 | "\00\41\00\41\00\2d\00\00\41\01\6a\3a\00\00\0b\88" 33 | "\80\80\80\00\00\41\00\2d\00\00\0f\0b\88\80\80\80" 34 | "\00\00\10\00\10\00\10\00\0b\0b\87\80\80\80\00\01" 35 | "\00\41\00\0b\01\41" 36 | ) 37 | (assert_return (invoke "get") (i32.const 68)) 38 | (invoke "inc") 39 | (assert_return (invoke "get") (i32.const 69)) 40 | (invoke "inc") 41 | (assert_return (invoke "get") (i32.const 70)) 42 | (module binary 43 | "\00\61\73\6d\01\00\00\00\01\88\80\80\80\00\02\60" 44 | "\00\00\60\00\01\7f\03\84\80\80\80\00\03\00\01\00" 45 | "\05\84\80\80\80\00\01\01\01\01\07\8d\80\80\80\00" 46 | "\02\03\69\6e\63\00\00\03\67\65\74\00\01\08\81\80" 47 | "\80\80\00\02\0a\af\80\80\80\00\03\8f\80\80\80\00" 48 | "\00\41\00\41\00\2d\00\00\41\01\6a\3a\00\00\0b\88" 49 | "\80\80\80\00\00\41\00\2d\00\00\0f\0b\88\80\80\80" 50 | "\00\00\10\00\10\00\10\00\0b\0b\87\80\80\80\00\01" 51 | "\00\41\00\0b\01\41" 52 | ) 53 | (assert_return (invoke "get") (i32.const 68)) 54 | (invoke "inc") 55 | (assert_return (invoke "get") (i32.const 69)) 56 | (invoke "inc") 57 | (assert_return (invoke "get") (i32.const 70)) 58 | (module binary 59 | "\00\61\73\6d\01\00\00\00\01\88\80\80\80\00\02\60" 60 | "\01\7f\00\60\00\00\02\96\80\80\80\00\01\08\73\70" 61 | "\65\63\74\65\73\74\09\70\72\69\6e\74\5f\69\33\32" 62 | "\00\00\03\82\80\80\80\00\01\01\08\81\80\80\80\00" 63 | "\01\0a\8c\80\80\80\00\01\86\80\80\80\00\00\41\01" 64 | "\10\00\0b" 65 | ) 66 | (module binary 67 | "\00\61\73\6d\01\00\00\00\01\88\80\80\80\00\02\60" 68 | "\01\7f\00\60\00\00\02\96\80\80\80\00\01\08\73\70" 69 | "\65\63\74\65\73\74\09\70\72\69\6e\74\5f\69\33\32" 70 | "\00\00\03\82\80\80\80\00\01\01\08\81\80\80\80\00" 71 | "\01\0a\8c\80\80\80\00\01\86\80\80\80\00\00\41\02" 72 | "\10\00\0b" 73 | ) 74 | (module binary 75 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 76 | "\00\00\02\92\80\80\80\00\01\08\73\70\65\63\74\65" 77 | "\73\74\05\70\72\69\6e\74\00\00\08\81\80\80\80\00" 78 | "\00" 79 | ) 80 | (assert_trap 81 | (module binary 82 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 83 | "\00\00\03\82\80\80\80\00\01\00\08\81\80\80\80\00" 84 | "\00\0a\89\80\80\80\00\01\83\80\80\80\00\00\00\0b" 85 | ) 86 | "unreachable" 87 | ) 88 | (assert_malformed 89 | (module quote 90 | "(module (func $a (unreachable)) (func $b (unreachable)) (start $a) (start $b))" 91 | ) 92 | "multiple start sections" 93 | ) 94 | -------------------------------------------------------------------------------- /tests/suite/store_retval.bin.wast: -------------------------------------------------------------------------------- 1 | (assert_invalid 2 | (module binary 3 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 4 | "\01\7f\01\7f\03\82\80\80\80\00\01\00\0a\8c\80\80" 5 | "\80\00\01\86\80\80\80\00\00\41\01\21\00\0b" 6 | ) 7 | "type mismatch" 8 | ) 9 | (assert_invalid 10 | (module binary 11 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 12 | "\01\7e\01\7e\03\82\80\80\80\00\01\00\0a\8c\80\80" 13 | "\80\00\01\86\80\80\80\00\00\42\01\21\00\0b" 14 | ) 15 | "type mismatch" 16 | ) 17 | (assert_invalid 18 | (module binary 19 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 20 | "\01\7d\01\7d\03\82\80\80\80\00\01\00\0a\8f\80\80" 21 | "\80\00\01\89\80\80\80\00\00\43\00\00\80\3f\21\00" 22 | "\0b" 23 | ) 24 | "type mismatch" 25 | ) 26 | (assert_invalid 27 | (module binary 28 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 29 | "\01\7c\01\7c\03\82\80\80\80\00\01\00\0a\93\80\80" 30 | "\80\00\01\8d\80\80\80\00\00\44\00\00\00\00\00\00" 31 | "\f0\3f\21\00\0b" 32 | ) 33 | "type mismatch" 34 | ) 35 | (assert_invalid 36 | (module binary 37 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 38 | "\01\7f\01\7f\03\82\80\80\80\00\01\00\05\83\80\80" 39 | "\80\00\01\00\01\0a\8f\80\80\80\00\01\89\80\80\80" 40 | "\00\00\41\00\41\01\36\02\00\0b" 41 | ) 42 | "type mismatch" 43 | ) 44 | (assert_invalid 45 | (module binary 46 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 47 | "\01\7e\01\7e\03\82\80\80\80\00\01\00\05\83\80\80" 48 | "\80\00\01\00\01\0a\8f\80\80\80\00\01\89\80\80\80" 49 | "\00\00\41\00\42\01\37\03\00\0b" 50 | ) 51 | "type mismatch" 52 | ) 53 | (assert_invalid 54 | (module binary 55 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 56 | "\01\7d\01\7d\03\82\80\80\80\00\01\00\05\83\80\80" 57 | "\80\00\01\00\01\0a\92\80\80\80\00\01\8c\80\80\80" 58 | "\00\00\41\00\43\00\00\80\3f\38\02\00\0b" 59 | ) 60 | "type mismatch" 61 | ) 62 | (assert_invalid 63 | (module binary 64 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 65 | "\01\7c\01\7c\03\82\80\80\80\00\01\00\05\83\80\80" 66 | "\80\00\01\00\01\0a\96\80\80\80\00\01\90\80\80\80" 67 | "\00\00\41\00\44\00\00\00\00\00\00\f0\3f\39\03\00" 68 | "\0b" 69 | ) 70 | "type mismatch" 71 | ) 72 | (assert_invalid 73 | (module binary 74 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 75 | "\01\7f\01\7f\03\82\80\80\80\00\01\00\05\83\80\80" 76 | "\80\00\01\00\01\0a\8f\80\80\80\00\01\89\80\80\80" 77 | "\00\00\41\00\41\01\3a\00\00\0b" 78 | ) 79 | "type mismatch" 80 | ) 81 | (assert_invalid 82 | (module binary 83 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 84 | "\01\7f\01\7f\03\82\80\80\80\00\01\00\05\83\80\80" 85 | "\80\00\01\00\01\0a\8f\80\80\80\00\01\89\80\80\80" 86 | "\00\00\41\00\41\01\3b\01\00\0b" 87 | ) 88 | "type mismatch" 89 | ) 90 | (assert_invalid 91 | (module binary 92 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 93 | "\01\7e\01\7e\03\82\80\80\80\00\01\00\05\83\80\80" 94 | "\80\00\01\00\01\0a\8f\80\80\80\00\01\89\80\80\80" 95 | "\00\00\41\00\42\01\3c\00\00\0b" 96 | ) 97 | "type mismatch" 98 | ) 99 | (assert_invalid 100 | (module binary 101 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 102 | "\01\7e\01\7e\03\82\80\80\80\00\01\00\05\83\80\80" 103 | "\80\00\01\00\01\0a\8f\80\80\80\00\01\89\80\80\80" 104 | "\00\00\41\00\42\01\3d\01\00\0b" 105 | ) 106 | "type mismatch" 107 | ) 108 | (assert_invalid 109 | (module binary 110 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 111 | "\01\7e\01\7e\03\82\80\80\80\00\01\00\05\83\80\80" 112 | "\80\00\01\00\01\0a\8f\80\80\80\00\01\89\80\80\80" 113 | "\00\00\41\00\42\01\3e\02\00\0b" 114 | ) 115 | "type mismatch" 116 | ) 117 | -------------------------------------------------------------------------------- /tests/suite/switch.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary 2 | "\00\61\73\6d\01\00\00\00\01\8f\80\80\80\00\03\60" 3 | "\01\7f\01\7f\60\01\7e\01\7e\60\00\01\7f\03\85\80" 4 | "\80\80\00\04\00\01\00\02\07\9e\80\80\80\00\04\04" 5 | "\73\74\6d\74\00\00\04\65\78\70\72\00\01\03\61\72" 6 | "\67\00\02\06\63\6f\72\6e\65\72\00\03\0a\ee\81\80" 7 | "\80\00\04\d7\80\80\80\00\01\01\7f\41\e4\00\21\01" 8 | "\02\40\02\40\02\40\02\40\02\40\02\40\02\40\02\40" 9 | "\02\40\02\40\20\00\0e\08\00\01\02\03\04\05\06\08" 10 | "\07\0b\20\00\0f\0b\01\0b\0b\41\00\20\00\6b\21\01" 11 | "\0c\05\0b\0c\04\0b\41\e5\00\21\01\0c\03\0b\41\e5" 12 | "\00\21\01\0b\41\e6\00\21\01\0b\0b\20\01\0f\0b\cc" 13 | "\80\80\80\00\01\01\7e\42\e4\00\21\01\02\7e\02\40" 14 | "\02\40\02\40\02\40\02\40\02\40\02\40\02\40\02\40" 15 | "\20\00\a7\0e\08\00\01\02\03\06\05\04\08\07\0b\20" 16 | "\00\0f\0b\01\0b\0b\42\00\20\00\7d\0c\05\0b\42\e5" 17 | "\00\21\01\0b\0b\0b\20\01\0c\01\0b\42\7b\0b\0f\0b" 18 | "\aa\80\80\80\00\00\02\7f\41\0a\02\7f\41\e4\00\02" 19 | "\7f\41\e8\07\02\7f\41\02\20\00\6c\41\03\20\00\71" 20 | "\0e\03\01\02\03\00\0b\6a\0b\6a\0b\6a\0b\0f\0b\8c" 21 | "\80\80\80\00\00\02\40\41\00\0e\00\00\0b\41\01\0b" 22 | ) 23 | (assert_return (invoke "stmt" (i32.const 0)) (i32.const 0)) 24 | (assert_return (invoke "stmt" (i32.const 1)) (i32.const -1)) 25 | (assert_return (invoke "stmt" (i32.const 2)) (i32.const -2)) 26 | (assert_return (invoke "stmt" (i32.const 3)) (i32.const -3)) 27 | (assert_return (invoke "stmt" (i32.const 4)) (i32.const 100)) 28 | (assert_return (invoke "stmt" (i32.const 5)) (i32.const 101)) 29 | (assert_return (invoke "stmt" (i32.const 6)) (i32.const 102)) 30 | (assert_return (invoke "stmt" (i32.const 7)) (i32.const 100)) 31 | (assert_return (invoke "stmt" (i32.const -10)) (i32.const 102)) 32 | (assert_return (invoke "expr" (i64.const 0)) (i64.const 0)) 33 | (assert_return (invoke "expr" (i64.const 1)) (i64.const -1)) 34 | (assert_return (invoke "expr" (i64.const 2)) (i64.const -2)) 35 | (assert_return (invoke "expr" (i64.const 3)) (i64.const -3)) 36 | (assert_return (invoke "expr" (i64.const 6)) (i64.const 101)) 37 | (assert_return (invoke "expr" (i64.const 7)) (i64.const -5)) 38 | (assert_return (invoke "expr" (i64.const -10)) (i64.const 100)) 39 | (assert_return (invoke "arg" (i32.const 0)) (i32.const 110)) 40 | (assert_return (invoke "arg" (i32.const 1)) (i32.const 12)) 41 | (assert_return (invoke "arg" (i32.const 2)) (i32.const 4)) 42 | (assert_return (invoke "arg" (i32.const 3)) (i32.const 1_116)) 43 | (assert_return (invoke "arg" (i32.const 4)) (i32.const 118)) 44 | (assert_return (invoke "arg" (i32.const 5)) (i32.const 20)) 45 | (assert_return (invoke "arg" (i32.const 6)) (i32.const 12)) 46 | (assert_return (invoke "arg" (i32.const 7)) (i32.const 1_124)) 47 | (assert_return (invoke "arg" (i32.const 8)) (i32.const 126)) 48 | (assert_return (invoke "corner") (i32.const 1)) 49 | (assert_invalid 50 | (module binary 51 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 52 | "\00\00\03\82\80\80\80\00\01\00\0a\8d\80\80\80\00" 53 | "\01\87\80\80\80\00\00\41\00\0e\00\03\0b" 54 | ) 55 | "unknown label" 56 | ) 57 | -------------------------------------------------------------------------------- /tests/suite/tee_local.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary 2 | "\00\61\73\6d\01\00\00\00\01\bf\80\80\80\00\0b\60" 3 | "\00\01\7f\60\00\01\7e\60\00\01\7d\60\00\01\7c\60" 4 | "\01\7f\01\7f\60\01\7e\01\7e\60\01\7d\01\7d\60\01" 5 | "\7c\01\7c\60\05\7e\7d\7c\7f\7f\00\60\05\7e\7d\7c" 6 | "\7f\7f\01\7e\60\05\7e\7d\7c\7f\7f\01\7c\03\8c\80" 7 | "\80\80\00\0b\00\01\02\03\04\05\06\07\08\09\0a\07" 8 | "\a7\81\80\80\00\0b\0e\74\79\70\65\2d\6c\6f\63\61" 9 | "\6c\2d\69\33\32\00\00\0e\74\79\70\65\2d\6c\6f\63" 10 | "\61\6c\2d\69\36\34\00\01\0e\74\79\70\65\2d\6c\6f" 11 | "\63\61\6c\2d\66\33\32\00\02\0e\74\79\70\65\2d\6c" 12 | "\6f\63\61\6c\2d\66\36\34\00\03\0e\74\79\70\65\2d" 13 | "\70\61\72\61\6d\2d\69\33\32\00\04\0e\74\79\70\65" 14 | "\2d\70\61\72\61\6d\2d\69\36\34\00\05\0e\74\79\70" 15 | "\65\2d\70\61\72\61\6d\2d\66\33\32\00\06\0e\74\79" 16 | "\70\65\2d\70\61\72\61\6d\2d\66\36\34\00\07\0a\74" 17 | "\79\70\65\2d\6d\69\78\65\64\00\08\05\77\72\69\74" 18 | "\65\00\09\06\72\65\73\75\6c\74\00\0a\0a\fa\82\80" 19 | "\80\00\0b\88\80\80\80\00\01\01\7f\41\00\22\00\0b" 20 | "\88\80\80\80\00\01\01\7e\42\00\22\00\0b\8b\80\80" 21 | "\80\00\01\01\7d\43\00\00\00\00\22\00\0b\8f\80\80" 22 | "\80\00\01\01\7c\44\00\00\00\00\00\00\00\00\22\00" 23 | "\0b\86\80\80\80\00\00\41\0a\22\00\0b\86\80\80\80" 24 | "\00\00\42\0b\22\00\0b\89\80\80\80\00\00\43\9a\99" 25 | "\31\41\22\00\0b\8d\80\80\80\00\00\44\66\66\66\66" 26 | "\66\66\28\40\22\00\0b\d2\80\80\80\00\03\01\7d\02" 27 | "\7e\01\7c\42\00\22\00\50\1a\43\00\00\00\00\22\01" 28 | "\8c\1a\44\00\00\00\00\00\00\00\00\22\02\9a\1a\41" 29 | "\00\22\03\45\1a\41\00\22\04\45\1a\43\00\00\00\00" 30 | "\22\05\8c\1a\42\00\22\06\50\1a\42\00\22\07\50\1a" 31 | "\44\00\00\00\00\00\00\00\00\22\08\9a\1a\0b\d5\80" 32 | "\80\80\00\03\01\7d\02\7e\01\7c\43\9a\99\99\be\22" 33 | "\01\1a\41\28\22\03\1a\41\79\22\04\1a\43\00\00\b0" 34 | "\40\22\05\1a\42\06\22\06\1a\44\00\00\00\00\00\00" 35 | "\20\40\22\08\1a\20\00\ba\20\01\bb\20\02\20\03\b8" 36 | "\20\04\b7\20\05\bb\20\06\ba\20\07\ba\20\08\a0\a0" 37 | "\a0\a0\a0\a0\a0\a0\b0\0b\cf\80\80\80\00\03\01\7d" 38 | "\02\7e\01\7c\42\01\22\00\ba\43\00\00\00\40\22\01" 39 | "\bb\44\66\66\66\66\66\66\0a\40\22\02\41\04\22\03" 40 | "\b8\41\05\22\04\b7\43\00\00\b0\40\22\05\bb\42\06" 41 | "\22\06\ba\42\00\22\07\ba\44\00\00\00\00\00\00\20" 42 | "\40\22\08\a0\a0\a0\a0\a0\a0\a0\a0\0b" 43 | ) 44 | (assert_return (invoke "type-local-i32") (i32.const 0)) 45 | (assert_return (invoke "type-local-i64") (i64.const 0)) 46 | (assert_return (invoke "type-local-f32") (f32.const 0x0p+0)) 47 | (assert_return (invoke "type-local-f64") (f64.const 0x0p+0)) 48 | (assert_return (invoke "type-param-i32" (i32.const 2)) (i32.const 10)) 49 | (assert_return (invoke "type-param-i64" (i64.const 3)) (i64.const 11)) 50 | (assert_return 51 | (invoke "type-param-f32" (f32.const 0x1.19999ap+2)) 52 | (f32.const 0x1.633334p+3) 53 | ) 54 | (assert_return 55 | (invoke "type-param-f64" (f64.const 0x1.6p+2)) 56 | (f64.const 0x1.8666666666666p+3) 57 | ) 58 | (assert_return 59 | (invoke "type-mixed" 60 | (i64.const 1) 61 | (f32.const 0x1.19999ap+1) 62 | (f64.const 0x1.a666666666666p+1) 63 | (i32.const 4) 64 | (i32.const 5) 65 | ) 66 | ) 67 | (assert_return 68 | (invoke "write" 69 | (i64.const 1) 70 | (f32.const 0x1p+1) 71 | (f64.const 0x1.a666666666666p+1) 72 | (i32.const 4) 73 | (i32.const 5) 74 | ) 75 | (i64.const 56) 76 | ) 77 | (assert_return 78 | (invoke "result" 79 | (i64.const -1) 80 | (f32.const -0x1p+1) 81 | (f64.const -0x1.a666666666666p+1) 82 | (i32.const -4) 83 | (i32.const -5) 84 | ) 85 | (f64.const 0x1.1666666666666p+5) 86 | ) 87 | (assert_invalid 88 | (module binary 89 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 90 | "\00\01\7e\03\82\80\80\80\00\01\00\0a\8e\80\80\80" 91 | "\00\01\88\80\80\80\00\01\01\7f\41\00\22\00\0b" 92 | ) 93 | "type mismatch" 94 | ) 95 | (assert_invalid 96 | (module binary 97 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 98 | "\00\00\03\82\80\80\80\00\01\00\0a\92\80\80\80\00" 99 | "\01\8c\80\80\80\00\01\01\7d\43\00\00\00\00\22\00" 100 | "\45\0b" 101 | ) 102 | "type mismatch" 103 | ) 104 | (assert_invalid 105 | (module binary 106 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 107 | "\00\00\03\82\80\80\80\00\01\00\0a\91\80\80\80\00" 108 | "\01\8b\80\80\80\00\02\01\7c\01\7e\42\00\22\01\9a" 109 | "\0b" 110 | ) 111 | "type mismatch" 112 | ) 113 | (assert_invalid 114 | (module binary 115 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 116 | "\00\00\03\82\80\80\80\00\01\00\0a\8d\80\80\80\00" 117 | "\01\87\80\80\80\00\01\01\7f\01\22\00\0b" 118 | ) 119 | "type mismatch" 120 | ) 121 | (assert_invalid 122 | (module binary 123 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 124 | "\00\00\03\82\80\80\80\00\01\00\0a\91\80\80\80\00" 125 | "\01\8b\80\80\80\00\01\01\7f\43\00\00\00\00\22\00" 126 | "\0b" 127 | ) 128 | "type mismatch" 129 | ) 130 | (assert_invalid 131 | (module binary 132 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 133 | "\00\00\03\82\80\80\80\00\01\00\0a\95\80\80\80\00" 134 | "\01\8f\80\80\80\00\01\01\7d\44\00\00\00\00\00\00" 135 | "\00\00\22\00\0b" 136 | ) 137 | "type mismatch" 138 | ) 139 | (assert_invalid 140 | (module binary 141 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 142 | "\00\00\03\82\80\80\80\00\01\00\0a\97\80\80\80\00" 143 | "\01\91\80\80\80\00\02\01\7c\01\7e\44\00\00\00\00" 144 | "\00\00\00\00\22\01\0b" 145 | ) 146 | "type mismatch" 147 | ) 148 | (assert_invalid 149 | (module binary 150 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 151 | "\01\7f\01\7e\03\82\80\80\80\00\01\00\0a\8a\80\80" 152 | "\80\00\01\84\80\80\80\00\00\20\00\0b" 153 | ) 154 | "type mismatch" 155 | ) 156 | (assert_invalid 157 | (module binary 158 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 159 | "\01\7d\00\03\82\80\80\80\00\01\00\0a\8b\80\80\80" 160 | "\00\01\85\80\80\80\00\00\20\00\45\0b" 161 | ) 162 | "type mismatch" 163 | ) 164 | (assert_invalid 165 | (module binary 166 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 167 | "\02\7c\7e\00\03\82\80\80\80\00\01\00\0a\8b\80\80" 168 | "\80\00\01\85\80\80\80\00\00\20\01\9a\0b" 169 | ) 170 | "type mismatch" 171 | ) 172 | (assert_invalid 173 | (module binary 174 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 175 | "\01\7f\00\03\82\80\80\80\00\01\00\0a\8b\80\80\80" 176 | "\00\01\85\80\80\80\00\00\01\22\00\0b" 177 | ) 178 | "type mismatch" 179 | ) 180 | (assert_invalid 181 | (module binary 182 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 183 | "\01\7f\00\03\82\80\80\80\00\01\00\0a\8f\80\80\80" 184 | "\00\01\89\80\80\80\00\00\43\00\00\00\00\22\00\0b" 185 | ) 186 | "type mismatch" 187 | ) 188 | (assert_invalid 189 | (module binary 190 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 191 | "\01\7d\00\03\82\80\80\80\00\01\00\0a\93\80\80\80" 192 | "\00\01\8d\80\80\80\00\00\44\00\00\00\00\00\00\00" 193 | "\00\22\00\0b" 194 | ) 195 | "type mismatch" 196 | ) 197 | (assert_invalid 198 | (module binary 199 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 200 | "\02\7c\7e\00\03\82\80\80\80\00\01\00\0a\93\80\80" 201 | "\80\00\01\8d\80\80\80\00\00\44\00\00\00\00\00\00" 202 | "\00\00\22\01\0b" 203 | ) 204 | "type mismatch" 205 | ) 206 | (assert_invalid 207 | (module binary 208 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 209 | "\00\00\03\82\80\80\80\00\01\00\0a\8e\80\80\80\00" 210 | "\01\88\80\80\80\00\02\01\7f\01\7e\20\03\0b" 211 | ) 212 | "unknown local" 213 | ) 214 | (assert_invalid 215 | (module binary 216 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 217 | "\00\00\03\82\80\80\80\00\01\00\0a\91\80\80\80\00" 218 | "\01\8b\80\80\80\00\02\01\7f\01\7e\20\f7\a4\ea\06" 219 | "\0b" 220 | ) 221 | "unknown local" 222 | ) 223 | (assert_invalid 224 | (module binary 225 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 226 | "\02\7f\7e\00\03\82\80\80\80\00\01\00\0a\8a\80\80" 227 | "\80\00\01\84\80\80\80\00\00\20\02\0b" 228 | ) 229 | "unknown local" 230 | ) 231 | (assert_invalid 232 | (module binary 233 | "\00\61\73\6d\01\00\00\00\01\84\80\80\80\00\01\60" 234 | "\00\00\03\82\80\80\80\00\01\00\0a\92\80\80\80\00" 235 | "\01\8c\80\80\80\00\02\01\7f\01\7e\20\f7\f2\ce\d4" 236 | "\02\0b" 237 | ) 238 | "unknown local" 239 | ) 240 | (assert_invalid 241 | (module binary 242 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 243 | "\01\7f\00\03\82\80\80\80\00\01\00\0a\8e\80\80\80" 244 | "\00\01\88\80\80\80\00\02\01\7f\01\7e\20\03\0b" 245 | ) 246 | "unknown local" 247 | ) 248 | (assert_invalid 249 | (module binary 250 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 251 | "\01\7e\00\03\82\80\80\80\00\01\00\0a\91\80\80\80" 252 | "\00\01\8b\80\80\80\00\02\01\7f\01\7e\20\f7\a8\99" 253 | "\66\0b" 254 | ) 255 | "unknown local" 256 | ) 257 | (assert_invalid 258 | (module binary 259 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 260 | "\01\7d\00\03\82\80\80\80\00\01\00\0a\91\80\80\80" 261 | "\00\01\8b\80\80\80\00\01\01\7f\43\00\00\00\00\22" 262 | "\01\0b" 263 | ) 264 | "type mismatch" 265 | ) 266 | (assert_invalid 267 | (module binary 268 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 269 | "\02\7e\7f\00\03\82\80\80\80\00\01\00\0a\91\80\80" 270 | "\80\00\01\8b\80\80\80\00\01\01\7d\43\00\00\00\00" 271 | "\22\01\0b" 272 | ) 273 | "type mismatch" 274 | ) 275 | (assert_invalid 276 | (module binary 277 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 278 | "\01\7e\00\03\82\80\80\80\00\01\00\0a\90\80\80\80" 279 | "\00\01\8a\80\80\80\00\02\01\7c\01\7e\42\00\22\01" 280 | "\0b" 281 | ) 282 | "type mismatch" 283 | ) 284 | -------------------------------------------------------------------------------- /tests/suite/token.bin.wast: -------------------------------------------------------------------------------- 1 | (assert_malformed 2 | (module quote "(func (drop (i32.const0)))") 3 | "unknown operator" 4 | ) 5 | (assert_malformed (module quote "(func br 0drop)") "unknown operator") 6 | -------------------------------------------------------------------------------- /tests/suite/traps.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary 2 | "\00\61\73\6d\01\00\00\00\01\8b\80\80\80\00\02\60" 3 | "\02\7f\7f\00\60\02\7e\7e\00\03\85\80\80\80\00\04" 4 | "\00\00\01\01\07\cd\80\80\80\00\04\10\6e\6f\5f\64" 5 | "\63\65\2e\69\33\32\2e\64\69\76\5f\73\00\00\10\6e" 6 | "\6f\5f\64\63\65\2e\69\33\32\2e\64\69\76\5f\75\00" 7 | "\01\10\6e\6f\5f\64\63\65\2e\69\36\34\2e\64\69\76" 8 | "\5f\73\00\02\10\6e\6f\5f\64\63\65\2e\69\36\34\2e" 9 | "\64\69\76\5f\75\00\03\0a\b5\80\80\80\00\04\88\80" 10 | "\80\80\00\00\20\00\20\01\6d\1a\0b\88\80\80\80\00" 11 | "\00\20\00\20\01\6e\1a\0b\88\80\80\80\00\00\20\00" 12 | "\20\01\7f\1a\0b\88\80\80\80\00\00\20\00\20\01\80" 13 | "\1a\0b" 14 | ) 15 | (assert_trap 16 | (invoke "no_dce.i32.div_s" (i32.const 1) (i32.const 0)) 17 | "integer divide by zero" 18 | ) 19 | (assert_trap 20 | (invoke "no_dce.i32.div_u" (i32.const 1) (i32.const 0)) 21 | "integer divide by zero" 22 | ) 23 | (assert_trap 24 | (invoke "no_dce.i64.div_s" (i64.const 1) (i64.const 0)) 25 | "integer divide by zero" 26 | ) 27 | (assert_trap 28 | (invoke "no_dce.i64.div_u" (i64.const 1) (i64.const 0)) 29 | "integer divide by zero" 30 | ) 31 | (assert_trap 32 | (invoke "no_dce.i32.div_s" (i32.const -2_147_483_648) (i32.const -1)) 33 | "integer overflow" 34 | ) 35 | (assert_trap 36 | (invoke "no_dce.i64.div_s" 37 | (i64.const -9_223_372_036_854_775_808) 38 | (i64.const -1) 39 | ) 40 | "integer overflow" 41 | ) 42 | (module binary 43 | "\00\61\73\6d\01\00\00\00\01\8b\80\80\80\00\02\60" 44 | "\02\7f\7f\00\60\02\7e\7e\00\03\85\80\80\80\00\04" 45 | "\00\00\01\01\07\cd\80\80\80\00\04\10\6e\6f\5f\64" 46 | "\63\65\2e\69\33\32\2e\72\65\6d\5f\73\00\00\10\6e" 47 | "\6f\5f\64\63\65\2e\69\33\32\2e\72\65\6d\5f\75\00" 48 | "\01\10\6e\6f\5f\64\63\65\2e\69\36\34\2e\72\65\6d" 49 | "\5f\73\00\02\10\6e\6f\5f\64\63\65\2e\69\36\34\2e" 50 | "\72\65\6d\5f\75\00\03\0a\b5\80\80\80\00\04\88\80" 51 | "\80\80\00\00\20\00\20\01\6f\1a\0b\88\80\80\80\00" 52 | "\00\20\00\20\01\70\1a\0b\88\80\80\80\00\00\20\00" 53 | "\20\01\81\1a\0b\88\80\80\80\00\00\20\00\20\01\82" 54 | "\1a\0b" 55 | ) 56 | (assert_trap 57 | (invoke "no_dce.i32.rem_s" (i32.const 1) (i32.const 0)) 58 | "integer divide by zero" 59 | ) 60 | (assert_trap 61 | (invoke "no_dce.i32.rem_u" (i32.const 1) (i32.const 0)) 62 | "integer divide by zero" 63 | ) 64 | (assert_trap 65 | (invoke "no_dce.i64.rem_s" (i64.const 1) (i64.const 0)) 66 | "integer divide by zero" 67 | ) 68 | (assert_trap 69 | (invoke "no_dce.i64.rem_u" (i64.const 1) (i64.const 0)) 70 | "integer divide by zero" 71 | ) 72 | (module binary 73 | "\00\61\73\6d\01\00\00\00\01\89\80\80\80\00\02\60" 74 | "\01\7d\00\60\01\7c\00\03\89\80\80\80\00\08\00\00" 75 | "\01\01\00\00\01\01\07\c9\81\80\80\00\08\16\6e\6f" 76 | "\5f\64\63\65\2e\69\33\32\2e\74\72\75\6e\63\5f\66" 77 | "\33\32\5f\73\00\00\16\6e\6f\5f\64\63\65\2e\69\33" 78 | "\32\2e\74\72\75\6e\63\5f\66\33\32\5f\75\00\01\16" 79 | "\6e\6f\5f\64\63\65\2e\69\33\32\2e\74\72\75\6e\63" 80 | "\5f\66\36\34\5f\73\00\02\16\6e\6f\5f\64\63\65\2e" 81 | "\69\33\32\2e\74\72\75\6e\63\5f\66\36\34\5f\75\00" 82 | "\03\16\6e\6f\5f\64\63\65\2e\69\36\34\2e\74\72\75" 83 | "\6e\63\5f\66\33\32\5f\73\00\04\16\6e\6f\5f\64\63" 84 | "\65\2e\69\36\34\2e\74\72\75\6e\63\5f\66\33\32\5f" 85 | "\75\00\05\16\6e\6f\5f\64\63\65\2e\69\36\34\2e\74" 86 | "\72\75\6e\63\5f\66\36\34\5f\73\00\06\16\6e\6f\5f" 87 | "\64\63\65\2e\69\36\34\2e\74\72\75\6e\63\5f\66\36" 88 | "\34\5f\75\00\07\0a\d9\80\80\80\00\08\86\80\80\80" 89 | "\00\00\20\00\a8\1a\0b\86\80\80\80\00\00\20\00\a9" 90 | "\1a\0b\86\80\80\80\00\00\20\00\aa\1a\0b\86\80\80" 91 | "\80\00\00\20\00\ab\1a\0b\86\80\80\80\00\00\20\00" 92 | "\ae\1a\0b\86\80\80\80\00\00\20\00\af\1a\0b\86\80" 93 | "\80\80\00\00\20\00\b0\1a\0b\86\80\80\80\00\00\20" 94 | "\00\b1\1a\0b" 95 | ) 96 | (assert_trap 97 | (invoke "no_dce.i32.trunc_f32_s" (f32.const nan:0x400000)) 98 | "invalid conversion to integer" 99 | ) 100 | (assert_trap 101 | (invoke "no_dce.i32.trunc_f32_u" (f32.const nan:0x400000)) 102 | "invalid conversion to integer" 103 | ) 104 | (assert_trap 105 | (invoke "no_dce.i32.trunc_f64_s" (f64.const nan:0x8000000000000)) 106 | "invalid conversion to integer" 107 | ) 108 | (assert_trap 109 | (invoke "no_dce.i32.trunc_f64_u" (f64.const nan:0x8000000000000)) 110 | "invalid conversion to integer" 111 | ) 112 | (assert_trap 113 | (invoke "no_dce.i64.trunc_f32_s" (f32.const nan:0x400000)) 114 | "invalid conversion to integer" 115 | ) 116 | (assert_trap 117 | (invoke "no_dce.i64.trunc_f32_u" (f32.const nan:0x400000)) 118 | "invalid conversion to integer" 119 | ) 120 | (assert_trap 121 | (invoke "no_dce.i64.trunc_f64_s" (f64.const nan:0x8000000000000)) 122 | "invalid conversion to integer" 123 | ) 124 | (assert_trap 125 | (invoke "no_dce.i64.trunc_f64_u" (f64.const nan:0x8000000000000)) 126 | "invalid conversion to integer" 127 | ) 128 | (module binary 129 | "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" 130 | "\01\7f\00\03\8f\80\80\80\00\0e\00\00\00\00\00\00" 131 | "\00\00\00\00\00\00\00\00\05\83\80\80\80\00\01\00" 132 | "\01\07\a1\82\80\80\00\0e\0f\6e\6f\5f\64\63\65\2e" 133 | "\69\33\32\2e\6c\6f\61\64\00\00\13\6e\6f\5f\64\63" 134 | "\65\2e\69\33\32\2e\6c\6f\61\64\31\36\5f\73\00\01" 135 | "\13\6e\6f\5f\64\63\65\2e\69\33\32\2e\6c\6f\61\64" 136 | "\31\36\5f\75\00\02\12\6e\6f\5f\64\63\65\2e\69\33" 137 | "\32\2e\6c\6f\61\64\38\5f\73\00\03\12\6e\6f\5f\64" 138 | "\63\65\2e\69\33\32\2e\6c\6f\61\64\38\5f\75\00\04" 139 | "\0f\6e\6f\5f\64\63\65\2e\69\36\34\2e\6c\6f\61\64" 140 | "\00\05\13\6e\6f\5f\64\63\65\2e\69\36\34\2e\6c\6f" 141 | "\61\64\33\32\5f\73\00\06\13\6e\6f\5f\64\63\65\2e" 142 | "\69\36\34\2e\6c\6f\61\64\33\32\5f\75\00\07\13\6e" 143 | "\6f\5f\64\63\65\2e\69\36\34\2e\6c\6f\61\64\31\36" 144 | "\5f\73\00\08\13\6e\6f\5f\64\63\65\2e\69\36\34\2e" 145 | "\6c\6f\61\64\31\36\5f\75\00\09\12\6e\6f\5f\64\63" 146 | "\65\2e\69\36\34\2e\6c\6f\61\64\38\5f\73\00\0a\12" 147 | "\6e\6f\5f\64\63\65\2e\69\36\34\2e\6c\6f\61\64\38" 148 | "\5f\75\00\0b\0f\6e\6f\5f\64\63\65\2e\66\33\32\2e" 149 | "\6c\6f\61\64\00\0c\0f\6e\6f\5f\64\63\65\2e\66\36" 150 | "\34\2e\6c\6f\61\64\00\0d\0a\b7\81\80\80\00\0e\88" 151 | "\80\80\80\00\00\20\00\28\02\00\1a\0b\88\80\80\80" 152 | "\00\00\20\00\2e\01\00\1a\0b\88\80\80\80\00\00\20" 153 | "\00\2f\01\00\1a\0b\88\80\80\80\00\00\20\00\2c\00" 154 | "\00\1a\0b\88\80\80\80\00\00\20\00\2d\00\00\1a\0b" 155 | "\88\80\80\80\00\00\20\00\29\03\00\1a\0b\88\80\80" 156 | "\80\00\00\20\00\34\02\00\1a\0b\88\80\80\80\00\00" 157 | "\20\00\35\02\00\1a\0b\88\80\80\80\00\00\20\00\32" 158 | "\01\00\1a\0b\88\80\80\80\00\00\20\00\33\01\00\1a" 159 | "\0b\88\80\80\80\00\00\20\00\30\00\00\1a\0b\88\80" 160 | "\80\80\00\00\20\00\31\00\00\1a\0b\88\80\80\80\00" 161 | "\00\20\00\2a\02\00\1a\0b\88\80\80\80\00\00\20\00" 162 | "\2b\03\00\1a\0b" 163 | ) 164 | (assert_trap 165 | (invoke "no_dce.i32.load" (i32.const 65_536)) 166 | "out of bounds memory access" 167 | ) 168 | (assert_trap 169 | (invoke "no_dce.i32.load16_s" (i32.const 65_536)) 170 | "out of bounds memory access" 171 | ) 172 | (assert_trap 173 | (invoke "no_dce.i32.load16_u" (i32.const 65_536)) 174 | "out of bounds memory access" 175 | ) 176 | (assert_trap 177 | (invoke "no_dce.i32.load8_s" (i32.const 65_536)) 178 | "out of bounds memory access" 179 | ) 180 | (assert_trap 181 | (invoke "no_dce.i32.load8_u" (i32.const 65_536)) 182 | "out of bounds memory access" 183 | ) 184 | (assert_trap 185 | (invoke "no_dce.i64.load" (i32.const 65_536)) 186 | "out of bounds memory access" 187 | ) 188 | (assert_trap 189 | (invoke "no_dce.i64.load32_s" (i32.const 65_536)) 190 | "out of bounds memory access" 191 | ) 192 | (assert_trap 193 | (invoke "no_dce.i64.load32_u" (i32.const 65_536)) 194 | "out of bounds memory access" 195 | ) 196 | (assert_trap 197 | (invoke "no_dce.i64.load16_s" (i32.const 65_536)) 198 | "out of bounds memory access" 199 | ) 200 | (assert_trap 201 | (invoke "no_dce.i64.load16_u" (i32.const 65_536)) 202 | "out of bounds memory access" 203 | ) 204 | (assert_trap 205 | (invoke "no_dce.i64.load8_s" (i32.const 65_536)) 206 | "out of bounds memory access" 207 | ) 208 | (assert_trap 209 | (invoke "no_dce.i64.load8_u" (i32.const 65_536)) 210 | "out of bounds memory access" 211 | ) 212 | (assert_trap 213 | (invoke "no_dce.f32.load" (i32.const 65_536)) 214 | "out of bounds memory access" 215 | ) 216 | (assert_trap 217 | (invoke "no_dce.f64.load" (i32.const 65_536)) 218 | "out of bounds memory access" 219 | ) 220 | -------------------------------------------------------------------------------- /tests/suite/type.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary 2 | "\00\61\73\6d\01\00\00\00\01\c5\80\80\80\00\0e\60" 3 | "\00\00\60\00\00\60\01\7f\00\60\01\7f\00\60\00\01" 4 | "\7f\60\01\7f\01\7f\60\01\7f\01\7f\60\02\7d\7c\00" 5 | "\60\02\7d\7c\00\60\02\7d\7c\00\60\02\7d\7c\00\60" 6 | "\02\7d\7c\00\60\06\7d\7c\7f\7c\7f\7f\00\60\03\7d" 7 | "\7c\7f\00" 8 | ) 9 | (assert_malformed 10 | (module quote "(type (func (result i32) (param i32)))") 11 | "result before parameter" 12 | ) 13 | (assert_malformed 14 | (module quote "(type (func (result $x i32)))") 15 | "unexpected token" 16 | ) 17 | (assert_invalid 18 | (module binary 19 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 20 | "\00\02\7f\7f" 21 | ) 22 | "invalid result arity" 23 | ) 24 | (assert_invalid 25 | (module binary 26 | "\00\61\73\6d\01\00\00\00\01\86\80\80\80\00\01\60" 27 | "\00\02\7f\7f" 28 | ) 29 | "invalid result arity" 30 | ) 31 | -------------------------------------------------------------------------------- /tests/suite/unreachable.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary 2 | "\00\61\73\6d\01\00\00\00\01\a0\80\80\80\00\07\60" 3 | "\03\7f\7f\7f\00\60\00\00\60\00\01\7f\60\00\01\7c" 4 | "\60\00\01\7e\60\02\7f\7f\01\7f\60\00\01\7d\03\bd" 5 | "\80\80\80\00\3c\01\00\02\02\03\03\02\02\01\02\02" 6 | "\02\01\02\02\02\02\01\02\02\01\02\02\01\02\02\02" 7 | "\02\04\02\05\05\05\05\05\02\01\01\01\01\01\01\01" 8 | "\01\06\06\06\04\01\01\01\01\06\02\04\02\02\02\02" 9 | "\02\04\85\80\80\80\00\01\70\01\01\01\05\83\80\80" 10 | "\80\00\01\00\01\06\89\80\80\80\00\01\7d\01\43\00" 11 | "\00\00\00\0b\07\8c\88\80\80\00\3a\08\74\79\70\65" 12 | "\2d\69\33\32\00\02\08\74\79\70\65\2d\69\36\34\00" 13 | "\03\08\74\79\70\65\2d\66\33\32\00\04\08\74\79\70" 14 | "\65\2d\66\36\34\00\05\0d\61\73\2d\66\75\6e\63\2d" 15 | "\66\69\72\73\74\00\06\0b\61\73\2d\66\75\6e\63\2d" 16 | "\6d\69\64\00\07\0c\61\73\2d\66\75\6e\63\2d\6c\61" 17 | "\73\74\00\08\0d\61\73\2d\66\75\6e\63\2d\76\61\6c" 18 | "\75\65\00\09\0e\61\73\2d\62\6c\6f\63\6b\2d\66\69" 19 | "\72\73\74\00\0a\0c\61\73\2d\62\6c\6f\63\6b\2d\6d" 20 | "\69\64\00\0b\0d\61\73\2d\62\6c\6f\63\6b\2d\6c\61" 21 | "\73\74\00\0c\0e\61\73\2d\62\6c\6f\63\6b\2d\76\61" 22 | "\6c\75\65\00\0d\0e\61\73\2d\62\6c\6f\63\6b\2d\62" 23 | "\72\6f\6b\65\00\0e\0d\61\73\2d\6c\6f\6f\70\2d\66" 24 | "\69\72\73\74\00\0f\0b\61\73\2d\6c\6f\6f\70\2d\6d" 25 | "\69\64\00\10\0c\61\73\2d\6c\6f\6f\70\2d\6c\61\73" 26 | "\74\00\11\0d\61\73\2d\6c\6f\6f\70\2d\62\72\6f\6b" 27 | "\65\00\12\0b\61\73\2d\62\72\2d\76\61\6c\75\65\00" 28 | "\13\0d\61\73\2d\62\72\5f\69\66\2d\63\6f\6e\64\00" 29 | "\14\0e\61\73\2d\62\72\5f\69\66\2d\76\61\6c\75\65" 30 | "\00\15\13\61\73\2d\62\72\5f\69\66\2d\76\61\6c\75" 31 | "\65\2d\63\6f\6e\64\00\16\11\61\73\2d\62\72\5f\74" 32 | "\61\62\6c\65\2d\69\6e\64\65\78\00\17\11\61\73\2d" 33 | "\62\72\5f\74\61\62\6c\65\2d\76\61\6c\75\65\00\18" 34 | "\13\61\73\2d\62\72\5f\74\61\62\6c\65\2d\76\61\6c" 35 | "\75\65\2d\32\00\19\17\61\73\2d\62\72\5f\74\61\62" 36 | "\6c\65\2d\76\61\6c\75\65\2d\69\6e\64\65\78\00\1a" 37 | "\1b\61\73\2d\62\72\5f\74\61\62\6c\65\2d\76\61\6c" 38 | "\75\65\2d\61\6e\64\2d\69\6e\64\65\78\00\1b\0f\61" 39 | "\73\2d\72\65\74\75\72\6e\2d\76\61\6c\75\65\00\1c" 40 | "\0a\61\73\2d\69\66\2d\63\6f\6e\64\00\1d\0a\61\73" 41 | "\2d\69\66\2d\74\68\65\6e\00\1e\0a\61\73\2d\69\66" 42 | "\2d\65\6c\73\65\00\1f\12\61\73\2d\69\66\2d\74\68" 43 | "\65\6e\2d\6e\6f\2d\65\6c\73\65\00\20\0f\61\73\2d" 44 | "\73\65\6c\65\63\74\2d\66\69\72\73\74\00\21\10\61" 45 | "\73\2d\73\65\6c\65\63\74\2d\73\65\63\6f\6e\64\00" 46 | "\22\0e\61\73\2d\73\65\6c\65\63\74\2d\63\6f\6e\64" 47 | "\00\23\0d\61\73\2d\63\61\6c\6c\2d\66\69\72\73\74" 48 | "\00\24\0b\61\73\2d\63\61\6c\6c\2d\6d\69\64\00\25" 49 | "\0c\61\73\2d\63\61\6c\6c\2d\6c\61\73\74\00\26\15" 50 | "\61\73\2d\63\61\6c\6c\5f\69\6e\64\69\72\65\63\74" 51 | "\2d\66\75\6e\63\00\27\16\61\73\2d\63\61\6c\6c\5f" 52 | "\69\6e\64\69\72\65\63\74\2d\66\69\72\73\74\00\28" 53 | "\14\61\73\2d\63\61\6c\6c\5f\69\6e\64\69\72\65\63" 54 | "\74\2d\6d\69\64\00\29\15\61\73\2d\63\61\6c\6c\5f" 55 | "\69\6e\64\69\72\65\63\74\2d\6c\61\73\74\00\2a\12" 56 | "\61\73\2d\6c\6f\63\61\6c\2e\73\65\74\2d\76\61\6c" 57 | "\75\65\00\2b\12\61\73\2d\6c\6f\63\61\6c\2e\74\65" 58 | "\65\2d\76\61\6c\75\65\00\2c\13\61\73\2d\67\6c\6f" 59 | "\62\61\6c\2e\73\65\74\2d\76\61\6c\75\65\00\2d\0f" 60 | "\61\73\2d\6c\6f\61\64\2d\61\64\64\72\65\73\73\00" 61 | "\2e\10\61\73\2d\6c\6f\61\64\4e\2d\61\64\64\72\65" 62 | "\73\73\00\2f\10\61\73\2d\73\74\6f\72\65\2d\61\64" 63 | "\64\72\65\73\73\00\30\0e\61\73\2d\73\74\6f\72\65" 64 | "\2d\76\61\6c\75\65\00\31\11\61\73\2d\73\74\6f\72" 65 | "\65\4e\2d\61\64\64\72\65\73\73\00\32\0f\61\73\2d" 66 | "\73\74\6f\72\65\4e\2d\76\61\6c\75\65\00\33\10\61" 67 | "\73\2d\75\6e\61\72\79\2d\6f\70\65\72\61\6e\64\00" 68 | "\34\0e\61\73\2d\62\69\6e\61\72\79\2d\6c\65\66\74" 69 | "\00\35\0f\61\73\2d\62\69\6e\61\72\79\2d\72\69\67" 70 | "\68\74\00\36\0f\61\73\2d\74\65\73\74\2d\6f\70\65" 71 | "\72\61\6e\64\00\37\0f\61\73\2d\63\6f\6d\70\61\72" 72 | "\65\2d\6c\65\66\74\00\38\10\61\73\2d\63\6f\6d\70" 73 | "\61\72\65\2d\72\69\67\68\74\00\39\12\61\73\2d\63" 74 | "\6f\6e\76\65\72\74\2d\6f\70\65\72\61\6e\64\00\3a" 75 | "\13\61\73\2d\6d\65\6d\6f\72\79\2e\67\72\6f\77\2d" 76 | "\73\69\7a\65\00\3b\09\87\80\80\80\00\01\00\41\00" 77 | "\0b\01\01\0a\a5\86\80\80\00\3c\82\80\80\80\00\00" 78 | "\0b\82\80\80\80\00\00\0b\83\80\80\80\00\00\00\0b" 79 | "\83\80\80\80\00\00\00\0b\83\80\80\80\00\00\00\0b" 80 | "\83\80\80\80\00\00\00\0b\85\80\80\80\00\00\00\41" 81 | "\7f\0b\87\80\80\80\00\00\10\00\00\41\7f\0b\85\80" 82 | "\80\80\00\00\10\00\00\0b\85\80\80\80\00\00\10\00" 83 | "\00\0b\88\80\80\80\00\00\02\7f\00\41\02\0b\0b\8a" 84 | "\80\80\80\00\00\02\7f\10\00\00\41\02\0b\0b\89\80" 85 | "\80\80\00\00\02\40\01\10\00\00\0b\0b\89\80\80\80" 86 | "\00\00\02\7f\01\10\00\00\0b\0b\8c\80\80\80\00\00" 87 | "\02\7f\10\00\41\01\0c\00\00\0b\0b\88\80\80\80\00" 88 | "\00\03\7f\00\41\02\0b\0b\8a\80\80\80\00\00\03\7f" 89 | "\10\00\00\41\02\0b\0b\89\80\80\80\00\00\03\40\01" 90 | "\10\00\00\0b\0b\8f\80\80\80\00\00\02\7f\03\7f\10" 91 | "\00\41\01\0c\01\00\0b\0b\0b\88\80\80\80\00\00\02" 92 | "\7f\00\0c\00\0b\0b\88\80\80\80\00\00\02\40\00\0d" 93 | "\00\0b\0b\8d\80\80\80\00\00\02\7f\00\41\01\0d\00" 94 | "\1a\41\07\0b\0b\8d\80\80\80\00\00\02\7f\41\06\00" 95 | "\0d\00\1a\41\07\0b\0b\8b\80\80\80\00\00\02\40\00" 96 | "\0e\02\00\00\00\0b\0b\8f\80\80\80\00\00\02\7f\00" 97 | "\41\01\0e\02\00\00\00\41\07\0b\0b\8f\80\80\80\00" 98 | "\00\02\7f\02\7f\00\41\01\0e\01\00\01\0b\0b\0b\8e" 99 | "\80\80\80\00\00\02\7f\41\06\00\0e\01\00\00\41\07" 100 | "\0b\0b\8c\80\80\80\00\00\02\7f\00\0e\01\00\00\41" 101 | "\08\0b\0b\84\80\80\80\00\00\00\0f\0b\8b\80\80\80" 102 | "\00\00\00\04\7f\41\00\05\41\01\0b\0b\8b\80\80\80" 103 | "\00\00\20\00\04\7f\00\05\20\01\0b\0b\8b\80\80\80" 104 | "\00\00\20\00\04\7f\20\01\05\00\0b\0b\8a\80\80\80" 105 | "\00\00\20\00\04\40\00\0b\20\01\0b\88\80\80\80\00" 106 | "\00\00\20\00\20\01\1b\0b\88\80\80\80\00\00\20\00" 107 | "\00\20\01\1b\0b\88\80\80\80\00\00\41\00\41\01\00" 108 | "\1b\0b\89\80\80\80\00\00\00\41\02\41\03\10\01\0b" 109 | "\89\80\80\80\00\00\41\01\00\41\03\10\01\0b\89\80" 110 | "\80\80\00\00\41\01\41\02\00\10\01\0b\8c\80\80\80" 111 | "\00\00\00\41\01\41\02\41\03\11\00\00\0b\8c\80\80" 112 | "\80\00\00\41\00\00\41\02\41\03\11\00\00\0b\8c\80" 113 | "\80\80\00\00\41\00\41\01\00\41\03\11\00\00\0b\8c" 114 | "\80\80\80\00\00\41\00\41\01\41\02\00\11\00\00\0b" 115 | "\87\80\80\80\00\01\01\7d\00\21\00\0b\87\80\80\80" 116 | "\00\01\01\7d\00\22\00\0b\85\80\80\80\00\00\00\24" 117 | "\00\0b\86\80\80\80\00\00\00\2a\02\00\0b\86\80\80" 118 | "\80\00\00\00\30\00\00\0b\8f\80\80\80\00\00\00\44" 119 | "\00\00\00\00\00\00\1c\40\39\03\00\0b\88\80\80\80" 120 | "\00\00\41\02\00\37\03\00\0b\88\80\80\80\00\00\00" 121 | "\41\07\3a\00\00\0b\88\80\80\80\00\00\41\02\00\3d" 122 | "\01\00\0b\84\80\80\80\00\00\00\8c\0b\86\80\80\80" 123 | "\00\00\00\41\0a\6a\0b\86\80\80\80\00\00\42\0a\00" 124 | "\7d\0b\84\80\80\80\00\00\00\45\0b\8d\80\80\80\00" 125 | "\00\00\44\00\00\00\00\00\00\24\40\65\0b\89\80\80" 126 | "\80\00\00\43\00\00\20\41\00\5c\0b\84\80\80\80\00" 127 | "\00\00\a7\0b\85\80\80\80\00\00\00\40\00\0b" 128 | ) 129 | (assert_trap (invoke "type-i32") "unreachable") 130 | (assert_trap (invoke "type-i64") "unreachable") 131 | (assert_trap (invoke "type-f32") "unreachable") 132 | (assert_trap (invoke "type-f64") "unreachable") 133 | (assert_trap (invoke "as-func-first") "unreachable") 134 | (assert_trap (invoke "as-func-mid") "unreachable") 135 | (assert_trap (invoke "as-func-last") "unreachable") 136 | (assert_trap (invoke "as-func-value") "unreachable") 137 | (assert_trap (invoke "as-block-first") "unreachable") 138 | (assert_trap (invoke "as-block-mid") "unreachable") 139 | (assert_trap (invoke "as-block-last") "unreachable") 140 | (assert_trap (invoke "as-block-value") "unreachable") 141 | (assert_return (invoke "as-block-broke") (i32.const 1)) 142 | (assert_trap (invoke "as-loop-first") "unreachable") 143 | (assert_trap (invoke "as-loop-mid") "unreachable") 144 | (assert_trap (invoke "as-loop-last") "unreachable") 145 | (assert_return (invoke "as-loop-broke") (i32.const 1)) 146 | (assert_trap (invoke "as-br-value") "unreachable") 147 | (assert_trap (invoke "as-br_if-cond") "unreachable") 148 | (assert_trap (invoke "as-br_if-value") "unreachable") 149 | (assert_trap (invoke "as-br_if-value-cond") "unreachable") 150 | (assert_trap (invoke "as-br_table-index") "unreachable") 151 | (assert_trap (invoke "as-br_table-value") "unreachable") 152 | (assert_trap (invoke "as-br_table-value-2") "unreachable") 153 | (assert_trap (invoke "as-br_table-value-index") "unreachable") 154 | (assert_trap (invoke "as-br_table-value-and-index") "unreachable") 155 | (assert_trap (invoke "as-return-value") "unreachable") 156 | (assert_trap (invoke "as-if-cond") "unreachable") 157 | (assert_trap (invoke "as-if-then" (i32.const 1) (i32.const 6)) "unreachable") 158 | (assert_return (invoke "as-if-then" (i32.const 0) (i32.const 6)) (i32.const 6)) 159 | (assert_trap (invoke "as-if-else" (i32.const 0) (i32.const 6)) "unreachable") 160 | (assert_return (invoke "as-if-else" (i32.const 1) (i32.const 6)) (i32.const 6)) 161 | (assert_trap 162 | (invoke "as-if-then-no-else" (i32.const 1) (i32.const 6)) 163 | "unreachable" 164 | ) 165 | (assert_return 166 | (invoke "as-if-then-no-else" (i32.const 0) (i32.const 6)) 167 | (i32.const 6) 168 | ) 169 | (assert_trap 170 | (invoke "as-select-first" (i32.const 0) (i32.const 6)) 171 | "unreachable" 172 | ) 173 | (assert_trap 174 | (invoke "as-select-first" (i32.const 1) (i32.const 6)) 175 | "unreachable" 176 | ) 177 | (assert_trap 178 | (invoke "as-select-second" (i32.const 0) (i32.const 6)) 179 | "unreachable" 180 | ) 181 | (assert_trap 182 | (invoke "as-select-second" (i32.const 1) (i32.const 6)) 183 | "unreachable" 184 | ) 185 | (assert_trap (invoke "as-select-cond") "unreachable") 186 | (assert_trap (invoke "as-call-first") "unreachable") 187 | (assert_trap (invoke "as-call-mid") "unreachable") 188 | (assert_trap (invoke "as-call-last") "unreachable") 189 | (assert_trap (invoke "as-call_indirect-func") "unreachable") 190 | (assert_trap (invoke "as-call_indirect-first") "unreachable") 191 | (assert_trap (invoke "as-call_indirect-mid") "unreachable") 192 | (assert_trap (invoke "as-call_indirect-last") "unreachable") 193 | (assert_trap (invoke "as-local.set-value") "unreachable") 194 | (assert_trap (invoke "as-local.tee-value") "unreachable") 195 | (assert_trap (invoke "as-global.set-value") "unreachable") 196 | (assert_trap (invoke "as-load-address") "unreachable") 197 | (assert_trap (invoke "as-loadN-address") "unreachable") 198 | (assert_trap (invoke "as-store-address") "unreachable") 199 | (assert_trap (invoke "as-store-value") "unreachable") 200 | (assert_trap (invoke "as-storeN-address") "unreachable") 201 | (assert_trap (invoke "as-storeN-value") "unreachable") 202 | (assert_trap (invoke "as-unary-operand") "unreachable") 203 | (assert_trap (invoke "as-binary-left") "unreachable") 204 | (assert_trap (invoke "as-binary-right") "unreachable") 205 | (assert_trap (invoke "as-test-operand") "unreachable") 206 | (assert_trap (invoke "as-compare-left") "unreachable") 207 | (assert_trap (invoke "as-compare-right") "unreachable") 208 | (assert_trap (invoke "as-convert-operand") "unreachable") 209 | (assert_trap (invoke "as-memory.grow-size") "unreachable") 210 | -------------------------------------------------------------------------------- /tests/suite/unwind.bin.wast: -------------------------------------------------------------------------------- 1 | (module binary 2 | "\00\61\73\6d\01\00\00\00\01\88\80\80\80\00\02\60" 3 | "\00\00\60\00\01\7f\03\b2\80\80\80\00\31\00\00\01" 4 | "\00\01\00\01\01\00\01\01\01\01\01\01\01\01\01\01" 5 | "\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01" 6 | "\01\01\01\01\01\01\01\01\01\01\01\01\01\01\07\94" 7 | "\8a\80\80\00\31\1a\66\75\6e\63\2d\75\6e\77\69\6e" 8 | "\64\2d\62\79\2d\75\6e\72\65\61\63\68\61\62\6c\65" 9 | "\00\00\11\66\75\6e\63\2d\75\6e\77\69\6e\64\2d\62" 10 | "\79\2d\62\72\00\01\17\66\75\6e\63\2d\75\6e\77\69" 11 | "\6e\64\2d\62\79\2d\62\72\2d\76\61\6c\75\65\00\02" 12 | "\14\66\75\6e\63\2d\75\6e\77\69\6e\64\2d\62\79\2d" 13 | "\62\72\5f\69\66\00\03\1a\66\75\6e\63\2d\75\6e\77" 14 | "\69\6e\64\2d\62\79\2d\62\72\5f\69\66\2d\76\61\6c" 15 | "\75\65\00\04\17\66\75\6e\63\2d\75\6e\77\69\6e\64" 16 | "\2d\62\79\2d\62\72\5f\74\61\62\6c\65\00\05\1d\66" 17 | "\75\6e\63\2d\75\6e\77\69\6e\64\2d\62\79\2d\62\72" 18 | "\5f\74\61\62\6c\65\2d\76\61\6c\75\65\00\06\15\66" 19 | "\75\6e\63\2d\75\6e\77\69\6e\64\2d\62\79\2d\72\65" 20 | "\74\75\72\6e\00\07\1b\62\6c\6f\63\6b\2d\75\6e\77" 21 | "\69\6e\64\2d\62\79\2d\75\6e\72\65\61\63\68\61\62" 22 | "\6c\65\00\08\12\62\6c\6f\63\6b\2d\75\6e\77\69\6e" 23 | "\64\2d\62\79\2d\62\72\00\09\18\62\6c\6f\63\6b\2d" 24 | "\75\6e\77\69\6e\64\2d\62\79\2d\62\72\2d\76\61\6c" 25 | "\75\65\00\0a\15\62\6c\6f\63\6b\2d\75\6e\77\69\6e" 26 | "\64\2d\62\79\2d\62\72\5f\69\66\00\0b\1b\62\6c\6f" 27 | "\63\6b\2d\75\6e\77\69\6e\64\2d\62\79\2d\62\72\5f" 28 | "\69\66\2d\76\61\6c\75\65\00\0c\18\62\6c\6f\63\6b" 29 | "\2d\75\6e\77\69\6e\64\2d\62\79\2d\62\72\5f\74\61" 30 | "\62\6c\65\00\0d\1e\62\6c\6f\63\6b\2d\75\6e\77\69" 31 | "\6e\64\2d\62\79\2d\62\72\5f\74\61\62\6c\65\2d\76" 32 | "\61\6c\75\65\00\0e\16\62\6c\6f\63\6b\2d\75\6e\77" 33 | "\69\6e\64\2d\62\79\2d\72\65\74\75\72\6e\00\0f\22" 34 | "\62\6c\6f\63\6b\2d\6e\65\73\74\65\64\2d\75\6e\77" 35 | "\69\6e\64\2d\62\79\2d\75\6e\72\65\61\63\68\61\62" 36 | "\6c\65\00\10\19\62\6c\6f\63\6b\2d\6e\65\73\74\65" 37 | "\64\2d\75\6e\77\69\6e\64\2d\62\79\2d\62\72\00\11" 38 | "\1f\62\6c\6f\63\6b\2d\6e\65\73\74\65\64\2d\75\6e" 39 | "\77\69\6e\64\2d\62\79\2d\62\72\2d\76\61\6c\75\65" 40 | "\00\12\1c\62\6c\6f\63\6b\2d\6e\65\73\74\65\64\2d" 41 | "\75\6e\77\69\6e\64\2d\62\79\2d\62\72\5f\69\66\00" 42 | "\13\22\62\6c\6f\63\6b\2d\6e\65\73\74\65\64\2d\75" 43 | "\6e\77\69\6e\64\2d\62\79\2d\62\72\5f\69\66\2d\76" 44 | "\61\6c\75\65\00\14\1f\62\6c\6f\63\6b\2d\6e\65\73" 45 | "\74\65\64\2d\75\6e\77\69\6e\64\2d\62\79\2d\62\72" 46 | "\5f\74\61\62\6c\65\00\15\25\62\6c\6f\63\6b\2d\6e" 47 | "\65\73\74\65\64\2d\75\6e\77\69\6e\64\2d\62\79\2d" 48 | "\62\72\5f\74\61\62\6c\65\2d\76\61\6c\75\65\00\16" 49 | "\1d\62\6c\6f\63\6b\2d\6e\65\73\74\65\64\2d\75\6e" 50 | "\77\69\6e\64\2d\62\79\2d\72\65\74\75\72\6e\00\17" 51 | "\17\75\6e\61\72\79\2d\61\66\74\65\72\2d\75\6e\72" 52 | "\65\61\63\68\61\62\6c\65\00\18\0e\75\6e\61\72\79" 53 | "\2d\61\66\74\65\72\2d\62\72\00\19\11\75\6e\61\72" 54 | "\79\2d\61\66\74\65\72\2d\62\72\5f\69\66\00\1a\14" 55 | "\75\6e\61\72\79\2d\61\66\74\65\72\2d\62\72\5f\74" 56 | "\61\62\6c\65\00\1b\12\75\6e\61\72\79\2d\61\66\74" 57 | "\65\72\2d\72\65\74\75\72\6e\00\1c\18\62\69\6e\61" 58 | "\72\79\2d\61\66\74\65\72\2d\75\6e\72\65\61\63\68" 59 | "\61\62\6c\65\00\1d\0f\62\69\6e\61\72\79\2d\61\66" 60 | "\74\65\72\2d\62\72\00\1e\12\62\69\6e\61\72\79\2d" 61 | "\61\66\74\65\72\2d\62\72\5f\69\66\00\1f\15\62\69" 62 | "\6e\61\72\79\2d\61\66\74\65\72\2d\62\72\5f\74\61" 63 | "\62\6c\65\00\20\13\62\69\6e\61\72\79\2d\61\66\74" 64 | "\65\72\2d\72\65\74\75\72\6e\00\21\18\73\65\6c\65" 65 | "\63\74\2d\61\66\74\65\72\2d\75\6e\72\65\61\63\68" 66 | "\61\62\6c\65\00\22\0f\73\65\6c\65\63\74\2d\61\66" 67 | "\74\65\72\2d\62\72\00\23\12\73\65\6c\65\63\74\2d" 68 | "\61\66\74\65\72\2d\62\72\5f\69\66\00\24\15\73\65" 69 | "\6c\65\63\74\2d\61\66\74\65\72\2d\62\72\5f\74\61" 70 | "\62\6c\65\00\25\13\73\65\6c\65\63\74\2d\61\66\74" 71 | "\65\72\2d\72\65\74\75\72\6e\00\26\1d\62\6c\6f\63" 72 | "\6b\2d\76\61\6c\75\65\2d\61\66\74\65\72\2d\75\6e" 73 | "\72\65\61\63\68\61\62\6c\65\00\27\14\62\6c\6f\63" 74 | "\6b\2d\76\61\6c\75\65\2d\61\66\74\65\72\2d\62\72" 75 | "\00\28\17\62\6c\6f\63\6b\2d\76\61\6c\75\65\2d\61" 76 | "\66\74\65\72\2d\62\72\5f\69\66\00\29\1a\62\6c\6f" 77 | "\63\6b\2d\76\61\6c\75\65\2d\61\66\74\65\72\2d\62" 78 | "\72\5f\74\61\62\6c\65\00\2a\18\62\6c\6f\63\6b\2d" 79 | "\76\61\6c\75\65\2d\61\66\74\65\72\2d\72\65\74\75" 80 | "\72\6e\00\2b\1c\6c\6f\6f\70\2d\76\61\6c\75\65\2d" 81 | "\61\66\74\65\72\2d\75\6e\72\65\61\63\68\61\62\6c" 82 | "\65\00\2c\13\6c\6f\6f\70\2d\76\61\6c\75\65\2d\61" 83 | "\66\74\65\72\2d\62\72\00\2d\16\6c\6f\6f\70\2d\76" 84 | "\61\6c\75\65\2d\61\66\74\65\72\2d\62\72\5f\69\66" 85 | "\00\2e\19\6c\6f\6f\70\2d\76\61\6c\75\65\2d\61\66" 86 | "\74\65\72\2d\62\72\5f\74\61\62\6c\65\00\2f\17\6c" 87 | "\6f\6f\70\2d\76\61\6c\75\65\2d\61\66\74\65\72\2d" 88 | "\72\65\74\75\72\6e\00\30\0a\80\88\80\80\00\31\87" 89 | "\80\80\80\00\00\41\03\42\01\00\0b\88\80\80\80\00" 90 | "\00\41\03\42\01\0c\00\0b\8a\80\80\80\00\00\41\03" 91 | "\42\01\41\09\0c\00\0b\8c\80\80\80\00\00\41\03\42" 92 | "\01\41\01\0d\00\1a\1a\0b\8e\80\80\80\00\00\41\03" 93 | "\42\01\41\09\41\01\0d\00\1a\1a\0b\8b\80\80\80\00" 94 | "\00\41\03\42\01\41\00\0e\00\00\0b\8d\80\80\80\00" 95 | "\00\41\03\42\01\41\09\41\00\0e\00\00\0b\89\80\80" 96 | "\80\00\00\41\03\42\01\41\09\0f\0b\8a\80\80\80\00" 97 | "\00\02\40\41\03\42\01\00\0b\0b\8d\80\80\80\00\00" 98 | "\02\40\41\03\42\01\0c\00\0b\41\09\0b\8d\80\80\80" 99 | "\00\00\02\7f\41\03\42\01\41\09\0c\00\0b\0b\91\80" 100 | "\80\80\00\00\02\40\41\03\42\01\41\01\0d\00\1a\1a" 101 | "\0b\41\09\0b\91\80\80\80\00\00\02\7f\41\03\42\01" 102 | "\41\09\41\01\0d\00\1a\1a\0b\0b\90\80\80\80\00\00" 103 | "\02\40\41\03\42\01\41\00\0e\00\00\0b\41\09\0b\90" 104 | "\80\80\80\00\00\02\7f\41\03\42\01\41\09\41\00\0e" 105 | "\00\00\0b\0b\8c\80\80\80\00\00\02\7f\41\03\42\01" 106 | "\41\09\0f\0b\0b\8d\80\80\80\00\00\02\7f\41\03\02" 107 | "\40\42\01\00\0b\0b\0b\91\80\80\80\00\00\02\40\41" 108 | "\03\02\40\42\01\0c\01\0b\1a\0b\41\09\0b\90\80\80" 109 | "\80\00\00\02\7f\41\03\02\40\42\01\41\09\0c\01\0b" 110 | "\0b\0b\94\80\80\80\00\00\02\40\41\03\02\40\42\01" 111 | "\41\01\0d\01\1a\0b\1a\0b\41\09\0b\94\80\80\80\00" 112 | "\00\02\7f\41\03\02\40\42\01\41\09\41\01\0d\01\1a" 113 | "\1a\0b\0b\0b\94\80\80\80\00\00\02\40\41\03\02\40" 114 | "\42\01\41\01\0e\00\01\0b\1a\0b\41\09\0b\93\80\80" 115 | "\80\00\00\02\7f\41\03\02\40\42\01\41\09\41\01\0e" 116 | "\00\01\0b\0b\0b\8f\80\80\80\00\00\02\7f\41\03\02" 117 | "\40\42\01\41\09\0f\0b\0b\0b\89\80\80\80\00\00\43" 118 | "\00\00\00\00\00\50\0b\8f\80\80\80\00\00\02\7f\43" 119 | "\00\00\00\00\41\09\0c\00\50\0b\0b\8f\80\80\80\00" 120 | "\00\02\7f\42\00\41\09\41\01\0d\00\1a\50\0b\0b\93" 121 | "\80\80\80\00\00\02\7f\43\00\00\00\00\41\09\41\00" 122 | "\0e\01\00\00\50\0b\0b\8b\80\80\80\00\00\43\00\00" 123 | "\00\00\41\09\0f\50\0b\92\80\80\80\00\00\43\00\00" 124 | "\00\00\44\00\00\00\00\00\00\f0\3f\00\51\0b\98\80" 125 | "\80\80\00\00\02\7f\43\00\00\00\00\44\00\00\00\00" 126 | "\00\00\f0\3f\41\09\0c\00\51\0b\0b\91\80\80\80\00" 127 | "\00\02\7f\42\00\42\01\41\09\41\01\0d\00\1a\51\0b" 128 | "\0b\9b\80\80\80\00\00\02\7f\43\00\00\00\00\44\00" 129 | "\00\00\00\00\00\f0\3f\41\09\41\00\0e\00\00\51\0b" 130 | "\0b\94\80\80\80\00\00\43\00\00\00\00\44\00\00\00" 131 | "\00\00\00\f0\3f\41\09\0f\51\0b\94\80\80\80\00\00" 132 | "\43\00\00\00\00\44\00\00\00\00\00\00\f0\3f\42\00" 133 | "\00\1b\0b\9a\80\80\80\00\00\02\7f\43\00\00\00\00" 134 | "\44\00\00\00\00\00\00\f0\3f\42\00\41\09\0c\00\1b" 135 | "\0b\0b\93\80\80\80\00\00\02\7f\41\00\41\01\41\00" 136 | "\41\09\41\01\0d\00\1a\1b\0b\0b\9d\80\80\80\00\00" 137 | "\02\7f\43\00\00\00\00\44\00\00\00\00\00\00\f0\3f" 138 | "\42\00\41\09\41\00\0e\00\00\1b\0b\0b\96\80\80\80" 139 | "\00\00\43\00\00\00\00\44\00\00\00\00\00\00\f0\3f" 140 | "\42\01\41\09\0f\1b\0b\8b\80\80\80\00\00\02\7f\43" 141 | "\00\00\00\00\00\0b\0b\8e\80\80\80\00\00\02\7f\43" 142 | "\00\00\00\00\41\09\0c\00\0b\0b\8e\80\80\80\00\00" 143 | "\02\7f\41\00\41\09\41\01\0d\00\1a\0b\0b\92\80\80" 144 | "\80\00\00\02\7f\43\00\00\00\00\41\09\41\00\0e\01" 145 | "\00\00\0b\0b\8d\80\80\80\00\00\02\7f\43\00\00\00" 146 | "\00\41\09\0f\0b\0b\8b\80\80\80\00\00\03\7f\43\00" 147 | "\00\00\00\00\0b\0b\91\80\80\80\00\00\02\7f\03\7f" 148 | "\43\00\00\00\00\41\09\0c\01\0b\0b\0b\91\80\80\80" 149 | "\00\00\02\7f\03\7f\41\00\41\09\41\01\0d\01\1a\0b" 150 | "\0b\0b\95\80\80\80\00\00\02\7f\03\7f\43\00\00\00" 151 | "\00\41\09\41\00\0e\01\01\01\0b\0b\0b\8d\80\80\80" 152 | "\00\00\03\7f\43\00\00\00\00\41\09\0f\0b\0b" 153 | ) 154 | (assert_trap (invoke "func-unwind-by-unreachable") "unreachable") 155 | (assert_return (invoke "func-unwind-by-br")) 156 | (assert_return (invoke "func-unwind-by-br-value") (i32.const 9)) 157 | (assert_return (invoke "func-unwind-by-br_if")) 158 | (assert_return (invoke "func-unwind-by-br_if-value") (i32.const 9)) 159 | (assert_return (invoke "func-unwind-by-br_table")) 160 | (assert_return (invoke "func-unwind-by-br_table-value") (i32.const 9)) 161 | (assert_return (invoke "func-unwind-by-return") (i32.const 9)) 162 | (assert_trap (invoke "block-unwind-by-unreachable") "unreachable") 163 | (assert_return (invoke "block-unwind-by-br") (i32.const 9)) 164 | (assert_return (invoke "block-unwind-by-br-value") (i32.const 9)) 165 | (assert_return (invoke "block-unwind-by-br_if") (i32.const 9)) 166 | (assert_return (invoke "block-unwind-by-br_if-value") (i32.const 9)) 167 | (assert_return (invoke "block-unwind-by-br_table") (i32.const 9)) 168 | (assert_return (invoke "block-unwind-by-br_table-value") (i32.const 9)) 169 | (assert_return (invoke "block-unwind-by-return") (i32.const 9)) 170 | (assert_trap (invoke "block-nested-unwind-by-unreachable") "unreachable") 171 | (assert_return (invoke "block-nested-unwind-by-br") (i32.const 9)) 172 | (assert_return (invoke "block-nested-unwind-by-br-value") (i32.const 9)) 173 | (assert_return (invoke "block-nested-unwind-by-br_if") (i32.const 9)) 174 | (assert_return (invoke "block-nested-unwind-by-br_if-value") (i32.const 9)) 175 | (assert_return (invoke "block-nested-unwind-by-br_table") (i32.const 9)) 176 | (assert_return (invoke "block-nested-unwind-by-br_table-value") (i32.const 9)) 177 | (assert_return (invoke "block-nested-unwind-by-return") (i32.const 9)) 178 | (assert_trap (invoke "unary-after-unreachable") "unreachable") 179 | (assert_return (invoke "unary-after-br") (i32.const 9)) 180 | (assert_return (invoke "unary-after-br_if") (i32.const 9)) 181 | (assert_return (invoke "unary-after-br_table") (i32.const 9)) 182 | (assert_return (invoke "unary-after-return") (i32.const 9)) 183 | (assert_trap (invoke "binary-after-unreachable") "unreachable") 184 | (assert_return (invoke "binary-after-br") (i32.const 9)) 185 | (assert_return (invoke "binary-after-br_if") (i32.const 9)) 186 | (assert_return (invoke "binary-after-br_table") (i32.const 9)) 187 | (assert_return (invoke "binary-after-return") (i32.const 9)) 188 | (assert_trap (invoke "select-after-unreachable") "unreachable") 189 | (assert_return (invoke "select-after-br") (i32.const 9)) 190 | (assert_return (invoke "select-after-br_if") (i32.const 9)) 191 | (assert_return (invoke "select-after-br_table") (i32.const 9)) 192 | (assert_return (invoke "select-after-return") (i32.const 9)) 193 | (assert_trap (invoke "block-value-after-unreachable") "unreachable") 194 | (assert_return (invoke "block-value-after-br") (i32.const 9)) 195 | (assert_return (invoke "block-value-after-br_if") (i32.const 9)) 196 | (assert_return (invoke "block-value-after-br_table") (i32.const 9)) 197 | (assert_return (invoke "block-value-after-return") (i32.const 9)) 198 | (assert_trap (invoke "loop-value-after-unreachable") "unreachable") 199 | (assert_return (invoke "loop-value-after-br") (i32.const 9)) 200 | (assert_return (invoke "loop-value-after-br_if") (i32.const 9)) 201 | (assert_return (invoke "loop-value-after-br_table") (i32.const 9)) 202 | (assert_return (invoke "loop-value-after-return") (i32.const 9)) 203 | --------------------------------------------------------------------------------