diff --git a/src/core/reader/types/data.rs b/src/core/reader/types/data.rs index 41b9ef6b..df707164 100644 --- a/src/core/reader/types/data.rs +++ b/src/core/reader/types/data.rs @@ -47,7 +47,7 @@ impl Debug for DataSegment { /// ```wasm /// (module /// (memory 1) ;; memory starting with 1 page -/// (data (i32.const 0) "wtf") ;; writing the array of byte "wtf" in the first memory (0) at offset 0 +/// (data (i32.const 0) "abc") ;; writing the array of byte "abc" in the first memory (0) at offset 0 /// ;; for hardcoded offsets, we'll usually use i32.const because of wasm being x86 arch /// ) /// ``` diff --git a/src/execution/interpreter_loop.rs b/src/execution/interpreter_loop.rs index 9e9cee6a..82979fc8 100644 --- a/src/execution/interpreter_loop.rs +++ b/src/execution/interpreter_loop.rs @@ -129,7 +129,7 @@ pub(super) fn run( global.value = stack.pop_value(global.global.ty.ty) } I32_LOAD => { - let memarg = MemArg::read_unvalidated(&mut wasm); + let memarg = MemArg::read(&mut wasm).unwrap(); let relative_address: u32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); let mem = store.mems.first().unwrap_validated(); // there is only one memory allowed as of now @@ -155,7 +155,7 @@ pub(super) fn run( trace!("Instruction: i32.load [{relative_address}] -> [{data}]"); } I64_LOAD => { - let memarg = MemArg::read_unvalidated(&mut wasm); + let memarg = MemArg::read(&mut wasm).unwrap(); let relative_address: u32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); let mem = store.mems.first().unwrap_validated(); @@ -182,7 +182,7 @@ pub(super) fn run( trace!("Instruction: i64.load [{relative_address}] -> [{data}]"); } F32_LOAD => { - let memarg = MemArg::read_unvalidated(&mut wasm); + let memarg = MemArg::read(&mut wasm).unwrap(); let relative_address: u32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); let mem = store.mems.first().unwrap_validated(); // there is only one memory allowed as of now @@ -208,7 +208,7 @@ pub(super) fn run( trace!("Instruction: f32.load [{relative_address}] -> [{data}]"); } F64_LOAD => { - let memarg = MemArg::read_unvalidated(&mut wasm); + let memarg = MemArg::read(&mut wasm).unwrap(); let relative_address: u32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); let mem = store.mems.first().unwrap_validated(); @@ -235,7 +235,7 @@ pub(super) fn run( trace!("Instruction: f64.load [{relative_address}] -> [{data}]"); } I32_LOAD8_S => { - let memarg = MemArg::read_unvalidated(&mut wasm); + let memarg = MemArg::read(&mut wasm).unwrap(); let relative_address: u32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); let mem = store.mems.first().unwrap_validated(); // there is only one memory allowed as of now @@ -263,7 +263,7 @@ pub(super) fn run( trace!("Instruction: i32.load8_s [{relative_address}] -> [{data}]"); } I32_LOAD8_U => { - let memarg = MemArg::read_unvalidated(&mut wasm); + let memarg = MemArg::read(&mut wasm).unwrap(); let relative_address: u32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); let mem = store.mems.first().unwrap_validated(); // there is only one memory allowed as of now @@ -291,7 +291,7 @@ pub(super) fn run( trace!("Instruction: i32.load8_u [{relative_address}] -> [{data}]"); } I32_LOAD16_S => { - let memarg = MemArg::read_unvalidated(&mut wasm); + let memarg = MemArg::read(&mut wasm).unwrap(); let relative_address: u32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); let mem = store.mems.first().unwrap_validated(); // there is only one memory allowed as of now @@ -318,7 +318,7 @@ pub(super) fn run( trace!("Instruction: i32.load16_s [{relative_address}] -> [{data}]"); } I32_LOAD16_U => { - let memarg = MemArg::read_unvalidated(&mut wasm); + let memarg = MemArg::read(&mut wasm).unwrap(); let relative_address: u32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); let mem = store.mems.first().unwrap_validated(); // there is only one memory allowed as of now @@ -345,7 +345,7 @@ pub(super) fn run( trace!("Instruction: i32.load16_u [{relative_address}] -> [{data}]"); } I64_LOAD8_S => { - let memarg = MemArg::read_unvalidated(&mut wasm); + let memarg = MemArg::read(&mut wasm).unwrap(); let relative_address: u32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); let mem = store.mems.first().unwrap_validated(); // there is only one memory allowed as of now @@ -373,7 +373,7 @@ pub(super) fn run( trace!("Instruction: i64.load8_s [{relative_address}] -> [{data}]"); } I64_LOAD8_U => { - let memarg = MemArg::read_unvalidated(&mut wasm); + let memarg = MemArg::read(&mut wasm).unwrap(); let relative_address: u32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); let mem = store.mems.first().unwrap_validated(); // there is only one memory allowed as of now @@ -401,7 +401,7 @@ pub(super) fn run( trace!("Instruction: i64.load8_u [{relative_address}] -> [{data}]"); } I64_LOAD16_S => { - let memarg = MemArg::read_unvalidated(&mut wasm); + let memarg = MemArg::read(&mut wasm).unwrap(); let relative_address: u32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); let mem = store.mems.first().unwrap_validated(); // there is only one memory allowed as of now @@ -428,7 +428,7 @@ pub(super) fn run( trace!("Instruction: i64.load16_s [{relative_address}] -> [{data}]"); } I64_LOAD16_U => { - let memarg = MemArg::read_unvalidated(&mut wasm); + let memarg = MemArg::read(&mut wasm).unwrap(); let relative_address: u32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); let mem = store.mems.first().unwrap_validated(); // there is only one memory allowed as of now @@ -455,7 +455,7 @@ pub(super) fn run( trace!("Instruction: i64.load16_u [{relative_address}] -> [{data}]"); } I64_LOAD32_S => { - let memarg = MemArg::read_unvalidated(&mut wasm); + let memarg = MemArg::read(&mut wasm).unwrap(); let relative_address: u32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); let mem = store.mems.first().unwrap_validated(); // there is only one memory allowed as of now @@ -482,7 +482,7 @@ pub(super) fn run( trace!("Instruction: i64.load32_s [{relative_address}] -> [{data}]"); } I64_LOAD32_U => { - let memarg = MemArg::read_unvalidated(&mut wasm); + let memarg = MemArg::read(&mut wasm).unwrap(); let relative_address: u32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); let mem = store.mems.first().unwrap_validated(); // there is only one memory allowed as of now @@ -509,7 +509,7 @@ pub(super) fn run( trace!("Instruction: i64.load32_u [{relative_address}] -> [{data}]"); } I32_STORE => { - let memarg = MemArg::read_unvalidated(&mut wasm); + let memarg = MemArg::read(&mut wasm).unwrap(); let data_to_store: u32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); let relative_address: u32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); @@ -530,7 +530,7 @@ pub(super) fn run( trace!("Instruction: i32.store [{relative_address} {data_to_store}] -> []"); } I64_STORE => { - let memarg = MemArg::read_unvalidated(&mut wasm); + let memarg = MemArg::read(&mut wasm).unwrap(); let data_to_store: u32 = stack.pop_value(ValType::NumType(NumType::I64)).into(); let relative_address: u32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); @@ -551,7 +551,7 @@ pub(super) fn run( trace!("Instruction: i64.store [{relative_address} {data_to_store}] -> []"); } F32_STORE => { - let memarg = MemArg::read_unvalidated(&mut wasm); + let memarg = MemArg::read(&mut wasm).unwrap(); let data_to_store: f32 = stack.pop_value(ValType::NumType(NumType::F32)).into(); let relative_address: u32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); @@ -572,7 +572,7 @@ pub(super) fn run( trace!("Instruction: f32.store [{relative_address} {data_to_store}] -> []"); } F64_STORE => { - let memarg = MemArg::read_unvalidated(&mut wasm); + let memarg = MemArg::read(&mut wasm).unwrap(); let data_to_store: f64 = stack.pop_value(ValType::NumType(NumType::F64)).into(); let relative_address: u32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); @@ -593,7 +593,7 @@ pub(super) fn run( trace!("Instruction: f64.store [{relative_address} {data_to_store}] -> []"); } I32_STORE8 => { - let memarg = MemArg::read_unvalidated(&mut wasm); + let memarg = MemArg::read(&mut wasm).unwrap(); let data_to_store: i32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); let relative_address: u32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); @@ -615,7 +615,7 @@ pub(super) fn run( trace!("Instruction: i32.store8 [{relative_address} {data_to_store}] -> []"); } I32_STORE16 => { - let memarg = MemArg::read_unvalidated(&mut wasm); + let memarg = MemArg::read(&mut wasm).unwrap(); let data_to_store: i32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); let relative_address: u32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); @@ -637,7 +637,7 @@ pub(super) fn run( trace!("Instruction: i32.store16 [{relative_address} {data_to_store}] -> []"); } I64_STORE8 => { - let memarg = MemArg::read_unvalidated(&mut wasm); + let memarg = MemArg::read(&mut wasm).unwrap(); let data_to_store: i64 = stack.pop_value(ValType::NumType(NumType::I64)).into(); let relative_address: u32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); @@ -659,7 +659,7 @@ pub(super) fn run( trace!("Instruction: i64.store8 [{relative_address} {data_to_store}] -> []"); } I64_STORE16 => { - let memarg = MemArg::read_unvalidated(&mut wasm); + let memarg = MemArg::read(&mut wasm).unwrap(); let data_to_store: i64 = stack.pop_value(ValType::NumType(NumType::I64)).into(); let relative_address: u32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); @@ -681,7 +681,7 @@ pub(super) fn run( trace!("Instruction: i64.store16 [{relative_address} {data_to_store}] -> []"); } I64_STORE32 => { - let memarg = MemArg::read_unvalidated(&mut wasm); + let memarg = MemArg::read(&mut wasm).unwrap(); let data_to_store: i64 = stack.pop_value(ValType::NumType(NumType::I64)).into(); let relative_address: u32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); @@ -703,26 +703,14 @@ pub(super) fn run( trace!("Instruction: i64.store32 [{relative_address} {data_to_store}] -> []"); } MEMORY_SIZE => { - let mem_idx = - // if multi_memory_is_enabled { - // wasm.read_var_u32().unwrap_validated() as usize - // } else { - wasm.read_u8().unwrap_validated() as usize - // } - ; + let mem_idx = wasm.read_u8().unwrap_validated() as usize; let mem = store.mems.get(mem_idx).unwrap_validated(); let size = mem.size() as u32; stack.push_value(Value::I32(size)); trace!("Instruction: memory.size [] -> [{}]", size); } MEMORY_GROW => { - let mem_idx = - // if multi_memory_is_enabled { - // wasm.read_var_u32().unwrap_validated() as usize - // } else { - wasm.read_u8().unwrap_validated() as usize - // } - ; + let mem_idx = wasm.read_u8().unwrap_validated() as usize; let mem = store.mems.get_mut(mem_idx).unwrap_validated(); let delta: i32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); @@ -2038,13 +2026,7 @@ pub(super) fn run( MEMORY_INIT => { let data_idx = wasm.read_var_u32().unwrap_validated() as DataIdx; let data = unsafe { store.data.get_unchecked_mut(data_idx) }; - let mem_idx = - // if multi_memory_is_enabled { - // wasm.read_var_u32().unwrap_validated() as usize - // } else { - wasm.read_u8().unwrap_validated() as usize - // } - ; + let mem_idx = wasm.read_u8().unwrap_validated() as usize; let mem = store.mems.get(mem_idx).unwrap_validated(); let mut n: i32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); let mut s: i32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); @@ -2205,13 +2187,7 @@ pub(super) fn run( trace!("Instruction: memory.copy"); } MEMORY_FILL => { - let mem_idx = - // if multi_memory_is_enabled { - // wasm.read_var_u32().unwrap_validated() as usize - // } else { - wasm.read_u8().unwrap_validated() as usize - // } - ; + let mem_idx = wasm.read_u8().unwrap_validated() as usize; let mem = store.mems.get(mem_idx).unwrap_validated(); let mut n: i32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); let val: i32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); diff --git a/src/execution/mod.rs b/src/execution/mod.rs index d4f2bc90..fba7d0fc 100644 --- a/src/execution/mod.rs +++ b/src/execution/mod.rs @@ -5,7 +5,6 @@ use const_interpreter_loop::run_const; use function_ref::FunctionRef; use interpreter_loop::run; use locals::Locals; -use store::TableInst; use value_stack::Stack; use crate::core::reader::types::data::DataSegment; @@ -343,15 +342,6 @@ where .collect() }; - let table_instances = validation_info - .tables - .iter() - .map(|ty| TableInst { - ty: *ty, - elem: Vec::new(), - }) - .collect(); - let mut memory_instances: Vec = validation_info .memories .iter() @@ -425,7 +415,6 @@ where Store { funcs: function_instances, - tables: table_instances, mems: memory_instances, globals: global_instances, data: data_sections, diff --git a/src/execution/store.rs b/src/execution/store.rs index 2c7a83bf..146bf6f8 100644 --- a/src/execution/store.rs +++ b/src/execution/store.rs @@ -16,7 +16,6 @@ use crate::execution::value::{Ref, Value}; /// pub struct Store { pub funcs: Vec, - pub tables: Vec, pub mems: Vec, pub globals: Vec, pub data: Vec, diff --git a/src/validation/code.rs b/src/validation/code.rs index f29d5be2..44f1198f 100644 --- a/src/validation/code.rs +++ b/src/validation/code.rs @@ -237,7 +237,7 @@ fn read_instructions( !memories.is_empty(), "C.mems[0] is NOT defined when it should be" ); - let memarg = MemArg::read_unvalidated(wasm); + let memarg = MemArg::read(wasm)?; assert!( memarg.align <= 4, @@ -253,7 +253,7 @@ fn read_instructions( !memories.is_empty(), "C.mems[0] is NOT defined when it should be" ); - let memarg = MemArg::read_unvalidated(wasm); + let memarg = MemArg::read(wasm)?; assert!( memarg.align <= 8, @@ -270,7 +270,7 @@ fn read_instructions( !memories.is_empty(), "C.mems[0] is NOT defined when it should be" ); - let memarg = MemArg::read_unvalidated(wasm); + let memarg = MemArg::read(wasm)?; assert!( memarg.align <= 4, @@ -287,7 +287,7 @@ fn read_instructions( !memories.is_empty(), "C.mems[0] is NOT defined when it should be" ); - let memarg = MemArg::read_unvalidated(wasm); + let memarg = MemArg::read(wasm)?; assert!( memarg.align <= 8, @@ -305,7 +305,7 @@ fn read_instructions( "C.mems[0] is NOT defined when it should be" ); - let memarg = MemArg::read_unvalidated(wasm); + let memarg = MemArg::read(wasm)?; assert!( memarg.align <= 1, "i32.load8_s: alignment is not less or equal to 1" @@ -320,7 +320,7 @@ fn read_instructions( "C.mems[0] is NOT defined when it should be" ); - let memarg = MemArg::read_unvalidated(wasm); + let memarg = MemArg::read(wasm)?; assert!( memarg.align <= 1, "i32.load8_u: alignment is not less or equal to 1" @@ -335,7 +335,7 @@ fn read_instructions( "C.mems[0] is NOT defined when it should be" ); - let memarg = MemArg::read_unvalidated(wasm); + let memarg = MemArg::read(wasm)?; assert!( memarg.align <= 2, "i32.load16_s: alignment is not less or equal to 2" @@ -350,7 +350,7 @@ fn read_instructions( "C.mems[0] is NOT defined when it should be" ); - let memarg = MemArg::read_unvalidated(wasm); + let memarg = MemArg::read(wasm)?; assert!( memarg.align <= 2, "i32.load16_u: alignment is not less or equal to 2" @@ -365,7 +365,7 @@ fn read_instructions( "C.mems[0] is NOT defined when it should be" ); - let memarg = MemArg::read_unvalidated(wasm); + let memarg = MemArg::read(wasm)?; assert!( memarg.align <= 1, "i64.load8_s: alignment is not less or equal to 1" @@ -380,7 +380,7 @@ fn read_instructions( "C.mems[0] is NOT defined when it should be" ); - let memarg = MemArg::read_unvalidated(wasm); + let memarg = MemArg::read(wasm)?; assert!( memarg.align <= 1, "i64.load8_u: alignment is not less or equal to 1" @@ -395,7 +395,7 @@ fn read_instructions( "C.mems[0] is NOT defined when it should be" ); - let memarg = MemArg::read_unvalidated(wasm); + let memarg = MemArg::read(wasm)?; assert!( memarg.align <= 2, "i64.load16_s: alignment is not less or equal to 2" @@ -410,7 +410,7 @@ fn read_instructions( "C.mems[0] is NOT defined when it should be" ); - let memarg = MemArg::read_unvalidated(wasm); + let memarg = MemArg::read(wasm)?; assert!( memarg.align <= 2, "i64.load16_u: alignment is not less or equal to 2" @@ -425,7 +425,7 @@ fn read_instructions( "C.mems[0] is NOT defined when it should be" ); - let memarg = MemArg::read_unvalidated(wasm); + let memarg = MemArg::read(wasm)?; assert!( memarg.align <= 4, "i64.load32_s: alignment is not less or equal to 4" @@ -440,7 +440,7 @@ fn read_instructions( "C.mems[0] is NOT defined when it should be" ); - let memarg = MemArg::read_unvalidated(wasm); + let memarg = MemArg::read(wasm)?; assert!( memarg.align <= 4, "i64.load32_u: alignment is not less or equal to 4" @@ -455,7 +455,7 @@ fn read_instructions( !memories.is_empty(), "C.mems[0] is NOT defined when it should be" ); - let memarg = MemArg::read_unvalidated(wasm); + let memarg = MemArg::read(wasm)?; assert!( memarg.align < 4, @@ -473,7 +473,7 @@ fn read_instructions( "C.mems[0] is NOT defined when it should be" ); - let memarg = MemArg::read_unvalidated(wasm); + let memarg = MemArg::read(wasm)?; assert!( memarg.align <= 8, "i64.store: alignment is not less or equal to 8" @@ -491,7 +491,7 @@ fn read_instructions( "C.mems[0] is NOT defined when it should be" ); - let memarg = MemArg::read_unvalidated(wasm); + let memarg = MemArg::read(wasm)?; assert!( memarg.align < 4, "f32.store: alignment is not less or equal to 4" @@ -508,7 +508,7 @@ fn read_instructions( "C.mems[0] is NOT defined when it should be" ); - let memarg = MemArg::read_unvalidated(wasm); + let memarg = MemArg::read(wasm)?; assert!( memarg.align <= 8, "f64.store: alignment is not less or equal to 8" @@ -525,7 +525,7 @@ fn read_instructions( "C.mems[0] is NOT defined when it should be" ); - let memarg = MemArg::read_unvalidated(wasm); + let memarg = MemArg::read(wasm)?; assert!( memarg.align <= 1, "i32.store8: alignment is not less or equal to 1" @@ -540,7 +540,7 @@ fn read_instructions( "C.mems[0] is NOT defined when it should be" ); - let memarg = MemArg::read_unvalidated(wasm); + let memarg = MemArg::read(wasm)?; assert!( memarg.align <= 2, "i32.store16: alignment is not less or equal to 2" @@ -555,7 +555,7 @@ fn read_instructions( "C.mems[0] is NOT defined when it should be" ); - let memarg = MemArg::read_unvalidated(wasm); + let memarg = MemArg::read(wasm)?; assert!( memarg.align <= 1, "i64.store8: alignment is not less or equal to 1" @@ -570,7 +570,7 @@ fn read_instructions( "C.mems[0] is NOT defined when it should be" ); - let memarg = MemArg::read_unvalidated(wasm); + let memarg = MemArg::read(wasm)?; assert!( memarg.align <= 2, "i64.store16: alignment is not less or equal to 2" @@ -585,7 +585,7 @@ fn read_instructions( "C.mems[0] is NOT defined when it should be" ); - let memarg = MemArg::read_unvalidated(wasm); + let memarg = MemArg::read(wasm)?; assert!( memarg.align <= 4, "i64.store16: alignment is not less or equal to 4" @@ -595,13 +595,7 @@ fn read_instructions( stack.assert_pop_val_type(ValType::NumType(NumType::I32))?; } MEMORY_SIZE => { - let mem_idx = - // if multi_memory_is_enabled { - // wasm.read_var_u32()? as MemIdx - // } else { - wasm.read_u8()? as MemIdx - // } - ; + let mem_idx = wasm.read_u8()? as MemIdx; assert!( memories.len() > mem_idx, "C.mems[{}] is NOT defined when it should be", @@ -610,13 +604,7 @@ fn read_instructions( stack.push_valtype(ValType::NumType(NumType::I32)); } MEMORY_GROW => { - let mem_idx = - // if multi_memory_is_enabled { - // wasm.read_var_u32()? as MemIdx - // } else { - wasm.read_u8()? as MemIdx - // } - ; + let mem_idx = wasm.read_u8()? as MemIdx; assert!( memories.len() > mem_idx, "C.mems[{}] is NOT defined when it should be", @@ -849,13 +837,7 @@ fn read_instructions( } MEMORY_INIT => { let data_idx = wasm.read_var_u32()? as DataIdx; - let mem_idx = - // if multi_memory_is_enabled { - // wasm.read_var_u32()? as MemIdx - // } else { - wasm.read_u8()? as MemIdx - // } - ; + let mem_idx = wasm.read_u8()? as MemIdx; assert!( memories.len() > mem_idx, "C.mems[{}] is NOT defined when it should be", @@ -897,13 +879,7 @@ fn read_instructions( stack.assert_pop_val_type(ValType::NumType(NumType::I32))?; } MEMORY_FILL => { - let mem_idx = - // if multi_memory_is_enabled { - // wasm.read_var_u32()? as MemIdx - // } else { - wasm.read_u8()? as MemIdx - // } - ; + let mem_idx = wasm.read_u8()? as MemIdx; assert!( memories.len() > mem_idx, "C.mems[{}] is NOT defined when it should be", diff --git a/tests/table.rs b/tests/table.rs deleted file mode 100644 index 546fb99b..00000000 --- a/tests/table.rs +++ /dev/null @@ -1,38 +0,0 @@ -// (module -// (table $fns 2 funcref) - -// (elem (i32.const 0) $add) ;; add function reference at index 0 -// (func $add (param $x i32) (param $y i32) (result i32) -// local.get $x -// local.get $y -// i32.add -// ) -// ) -use wasm::{validate, Limits, RefType, RuntimeInstance}; - -#[test_log::test] -fn table_basic() { - let wat = r#" -(module - (table $fns 2 funcref) - - ;; (elem (i32.const 0) $add) ;; add function reference at index 0 - - ;;(func $add (param $x i32) (param $y i32) (result i32) - ;; local.get $x - ;; local.get $y - ;; i32.add - ;;) - ) -"#; - - let wasm_bytes = wat::parse_str(wat).unwrap(); - let validation_info = validate(&wasm_bytes).expect("validation failed"); - let instance = RuntimeInstance::new(&validation_info).expect("instantiation failed"); - - let tables = instance.store.tables; - assert_eq!(tables.len(), 1); - let table1 = tables.first().unwrap(); - assert_eq!(table1.ty.lim, Limits { min: 2, max: None }); - assert_eq!(table1.ty.et, RefType::FuncRef); -}