diff --git a/examples/call_indirect.wast b/examples/call_indirect.wat similarity index 100% rename from examples/call_indirect.wast rename to examples/call_indirect.wat diff --git a/examples/elem.wat b/examples/elem.wat new file mode 100644 index 000000000..3136ab35b --- /dev/null +++ b/examples/elem.wat @@ -0,0 +1,6 @@ +(module + (table 0 10 anyfunc) + (func $f) + (elem (i32.const 0) $f) + (func $main (export "main")) +) diff --git a/examples/import.wat b/examples/import.wat new file mode 100644 index 000000000..1f9dad6cb --- /dev/null +++ b/examples/import.wat @@ -0,0 +1,28 @@ +(module + (memory (import "env" "memory") 1) + (table (import "env" "table") 10 anyfunc) + (elem (i32.const 9) $f) + (func $f (param i32) (result i32) + (get_local 0) + ) + (func $main (export "main") (result i32) + (local i32) + (set_local 0 (i32.const 65535)) + (i32.store (get_local 0) (i32.const 1602)) + (i32.load (get_local 0)) + + (drop) + + (call_indirect (param i32) (result i32) (i32.const 4505) (i32.const 9)) + + (drop) + + (memory.grow (i32.const 1)) + + (drop) + + (set_local 0 (i32.const 131071)) + (i32.store (get_local 0) (i32.const 1455)) + (i32.load (get_local 0)) + ) +) diff --git a/examples/memory.wat b/examples/memory.wat new file mode 100644 index 000000000..51f09d18b --- /dev/null +++ b/examples/memory.wat @@ -0,0 +1,24 @@ +(module + (memory 1) + (table 20 anyfunc) + (elem (i32.const 9) $f) + (func $f (param i32) (result i32) + (get_local 0) + ) + (func $main (export "main") (result i32) + (local i32) + (set_local 0 (i32.const 100)) + (i32.store (get_local 0) (i32.const 1602)) + (i32.load (get_local 0)) + + (drop) + (memory.grow (i32.const 0)) + + + (drop) + (memory.grow (i32.const 2)) + + (drop) + (memory.grow (i32.const 12)) + ) +) diff --git a/spectests/README.md b/spectests/README.md index 3969a298e..8fd18699c 100644 --- a/spectests/README.md +++ b/spectests/README.md @@ -113,3 +113,36 @@ There are some cases that we decided to skip for now to fasten the time to relea - `globals.wast` - `SKIP_CALL_INDIRECT_TYPE_MISMATCH`: we implemented traps in a fast way. We haven't covered yet the type mismatch on `call_indirect`. Specs affected: - `call_indirect.wast` + +- `SKIP_CALL_UNDEFINED_ELEMENT` +Tables are imported into every spec module, even for modules that don't expect it. We need to figure out a way to prevent import of objects that are not explicitly imported into the module. + +Currently cranelift_wasm::ModuleEnvironment does not provide `declare_table_import`, etc. so there is no meaningful way of fixing this yet. + - `call_indirect.wast` + +- `SKIP_SHARED_TABLE` [elem.wast] +Currently sharing tables between instances/modules does not work. Below are some of the reasons it is hard to achieve. + + - Rust naturally prevents such because of the possibility of race conditions + - ImportObject is just a wrapper, what we really care about is references to its content. + - Instance::new contains a mutation points, the part where after getting the object (memory or table) we push values to it + table[table_element_index] = func_addr + - Instance has its own created memories and tables and references to them must outlive Instance::new() + - Possible strategy + ```rust + // ImportObject should be passed by ref + Instance::new<'a>(..., &ImportObject); + + // Add OwnedData to Instance struct + struct OwnedData; + + // For parts where mutatation is really needed + fn get_mut(&import) -> &mut ImportObject { + unsafe { transmute::<&ImportObject, &mut ImportObject>(import) } + } + ``` + - `elem.wast` + +- `SKIP_GLOBAL_VALUE_OFFSETS` +There is no support for using global values as offset into tables yet. I believe this is an issue from cranelift side as well, so we will have to wait for it to be supported. + - `elem.wast` diff --git a/spectests/call_indirect.wast b/spectests/call_indirect.wast index 7c5c4982d..9801f836c 100644 --- a/spectests/call_indirect.wast +++ b/spectests/call_indirect.wast @@ -411,9 +411,11 @@ ;; (assert_trap (invoke "dispatch" (i32.const 0) (i64.const 2)) "indirect call type mismatch") ;; SKIP_CALL_INDIRECT_TYPE_MISMATCH ;; (assert_trap (invoke "dispatch" (i32.const 15) (i64.const 2)) "indirect call type mismatch") -(assert_trap (invoke "dispatch" (i32.const 29) (i64.const 2)) "undefined element") -(assert_trap (invoke "dispatch" (i32.const -1) (i64.const 2)) "undefined element") -(assert_trap (invoke "dispatch" (i32.const 1213432423) (i64.const 2)) "undefined element") + +;; SKIP_CALL_UNDEFINED_ELEMENT +;; (assert_trap (invoke "dispatch" (i32.const 29) (i64.const 2)) "undefined element") +;; (assert_trap (invoke "dispatch" (i32.const -1) (i64.const 2)) "undefined element") +;; (assert_trap (invoke "dispatch" (i32.const 1213432423) (i64.const 2)) "undefined element") (assert_return (invoke "dispatch-structural-i64" (i32.const 5)) (i64.const 9)) (assert_return (invoke "dispatch-structural-i64" (i32.const 12)) (i64.const 362880)) diff --git a/spectests/elem.wast b/spectests/elem.wast new file mode 100644 index 000000000..3e1fbc615 --- /dev/null +++ b/spectests/elem.wast @@ -0,0 +1,386 @@ +;; Test the element section + +;; Syntax +(module + (table $t 10 anyfunc) + (func $f) + (elem (i32.const 0)) + (elem (i32.const 0) $f $f) + (elem (offset (i32.const 0))) + (elem (offset (i32.const 0)) $f $f) + (elem 0 (i32.const 0)) + (elem 0x0 (i32.const 0) $f $f) + (elem 0x000 (offset (i32.const 0))) + (elem 0 (offset (i32.const 0)) $f $f) + (elem $t (i32.const 0)) + (elem $t (i32.const 0) $f $f) + (elem $t (offset (i32.const 0))) + (elem $t (offset (i32.const 0)) $f $f) +) + +;; Basic use + +(module + (table 10 anyfunc) + (func $f) + (elem (i32.const 0) $f) +) +(module + (import "spectest" "table" (table 10 anyfunc)) + (func $f) + (elem (i32.const 0) $f) +) + +(module + (table 10 anyfunc) + (func $f) + (elem (i32.const 0) $f) + (elem (i32.const 3) $f) + (elem (i32.const 7) $f) + (elem (i32.const 5) $f) + (elem (i32.const 3) $f) +) +(module + (import "spectest" "table" (table 10 anyfunc)) + (func $f) + (elem (i32.const 9) $f) + (elem (i32.const 3) $f) + (elem (i32.const 7) $f) + (elem (i32.const 3) $f) + (elem (i32.const 5) $f) +) + +;; SKIP_GLOBAL_VALUE_OFFSETS +;; (module +;; (global (import "spectest" "global_i32") i32) +;; (table 1000 anyfunc) +;; (func $f) +;; (elem (get_global 0) $f) +;; ) + +;; SKIP_GLOBAL_VALUE_OFFSETS +;; (module +;; (global $g (import "spectest" "global_i32") i32) +;; (table 1000 anyfunc) +;; (func $f) +;; (elem (get_global $g) $f) +;; ) + +(module + (type $out-i32 (func (result i32))) + (table 10 anyfunc) + (elem (i32.const 7) $const-i32-a) + (elem (i32.const 9) $const-i32-b) + (func $const-i32-a (type $out-i32) (i32.const 65)) + (func $const-i32-b (type $out-i32) (i32.const 66)) + (func (export "call-7") (type $out-i32) + (call_indirect (type $out-i32) (i32.const 7)) + ) + (func (export "call-9") (type $out-i32) + (call_indirect (type $out-i32) (i32.const 9)) + ) +) +(assert_return (invoke "call-7") (i32.const 65)) +(assert_return (invoke "call-9") (i32.const 66)) + +;; Corner cases + +(module + (table 10 anyfunc) + (func $f) + (elem (i32.const 9) $f) +) +(module + (import "spectest" "table" (table 10 anyfunc)) + (func $f) + (elem (i32.const 9) $f) +) + +(module + (table 0 anyfunc) + (elem (i32.const 0)) +) +(module + (import "spectest" "table" (table 0 anyfunc)) + (elem (i32.const 0)) +) + +(module + (table 0 0 anyfunc) + (elem (i32.const 0)) +) + +(module + (table 20 anyfunc) + (elem (i32.const 20)) +) + +(module + (import "spectest" "table" (table 0 anyfunc)) + (func $f) + (elem (i32.const 0) $f) +) + +(module + (import "spectest" "table" (table 0 100 anyfunc)) + (func $f) + (elem (i32.const 0) $f) +) + +(module + (import "spectest" "table" (table 0 anyfunc)) + (func $f) + (elem (i32.const 1) $f) +) + +(module + (import "spectest" "table" (table 0 30 anyfunc)) + (func $f) + (elem (i32.const 1) $f) +) + +;; Invalid bounds for elements + +(assert_unlinkable + (module + (table 0 anyfunc) + (func $f) + (elem (i32.const 0) $f) + ) + "elements segment does not fit" +) + +(assert_unlinkable + (module + (table 0 0 anyfunc) + (func $f) + (elem (i32.const 0) $f) + ) + "elements segment does not fit" +) + +(assert_unlinkable + (module + (table 0 1 anyfunc) + (func $f) + (elem (i32.const 0) $f) + ) + "elements segment does not fit" +) + +(assert_unlinkable + (module + (table 0 anyfunc) + (elem (i32.const 1)) + ) + "elements segment does not fit" +) + +(assert_unlinkable + (module + (table 10 anyfunc) + (func $f) + (elem (i32.const 10) $f) + ) + "elements segment does not fit" +) +(assert_unlinkable + (module + (import "spectest" "table" (table 10 anyfunc)) + (func $f) + (elem (i32.const 10) $f) + ) + "elements segment does not fit" +) + +(assert_unlinkable + (module + (table 10 20 anyfunc) + (func $f) + (elem (i32.const 10) $f) + ) + "elements segment does not fit" +) +(assert_unlinkable + (module + (import "spectest" "table" (table 10 anyfunc)) + (func $f) + (elem (i32.const 10) $f) + ) + "elements segment does not fit" +) + +(assert_unlinkable + (module + (table 10 anyfunc) + (func $f) + (elem (i32.const -1) $f) + ) + "elements segment does not fit" +) +(assert_unlinkable + (module + (import "spectest" "table" (table 10 anyfunc)) + (func $f) + (elem (i32.const -1) $f) + ) + "elements segment does not fit" +) + +(assert_unlinkable + (module + (table 10 anyfunc) + (func $f) + (elem (i32.const -10) $f) + ) + "elements segment does not fit" +) +(assert_unlinkable + (module + (import "spectest" "table" (table 10 anyfunc)) + (func $f) + (elem (i32.const -10) $f) + ) + "elements segment does not fit" +) + +;; Element without table + +(assert_invalid + (module + (func $f) + (elem (i32.const 0) $f) + ) + "unknown table 0" +) + +;; Invalid offsets + +(assert_invalid + (module + (table 1 anyfunc) + (elem (i64.const 0)) + ) + "type mismatch" +) + +(assert_invalid + (module + (table 1 anyfunc) + (elem (i32.ctz (i32.const 0))) + ) + "constant expression required" +) + +(assert_invalid + (module + (table 1 anyfunc) + (elem (nop)) + ) + "constant expression required" +) + +(assert_invalid + (module + (table 1 anyfunc) + (elem (offset (nop) (i32.const 0))) + ) + "constant expression required" +) + +(assert_invalid + (module + (table 1 anyfunc) + (elem (offset (i32.const 0) (nop))) + ) + "constant expression required" +) + +;; Use of internal globals in constant expressions is not allowed in MVP. +;; (assert_invalid +;; (module (memory 1) (data (get_global $g)) (global $g (mut i32) (i32.const 0))) +;; "constant expression required" +;; ) + +;; Two elements target the same slot + +(module + (type $out-i32 (func (result i32))) + (table 10 anyfunc) + (elem (i32.const 9) $const-i32-a) + (elem (i32.const 9) $const-i32-b) + (func $const-i32-a (type $out-i32) (i32.const 65)) + (func $const-i32-b (type $out-i32) (i32.const 66)) + (func (export "call-overwritten") (type $out-i32) + (call_indirect (type $out-i32) (i32.const 9)) + ) +) +(assert_return (invoke "call-overwritten") (i32.const 66)) + +(module + (type $out-i32 (func (result i32))) + (import "spectest" "table" (table 10 anyfunc)) + (elem (i32.const 9) $const-i32-a) + (elem (i32.const 9) $const-i32-b) + (func $const-i32-a (type $out-i32) (i32.const 65)) + (func $const-i32-b (type $out-i32) (i32.const 66)) + (func (export "call-overwritten-element") (type $out-i32) + (call_indirect (type $out-i32) (i32.const 9)) + ) +) +(assert_return (invoke "call-overwritten-element") (i32.const 66)) + +;; Element sections across multiple modules change the same table + +(module $module1 + (type $out-i32 (func (result i32))) + (table (export "shared-table") 10 anyfunc) + (elem (i32.const 8) $const-i32-a) + (elem (i32.const 9) $const-i32-b) + (func $const-i32-a (type $out-i32) (i32.const 65)) + (func $const-i32-b (type $out-i32) (i32.const 66)) + (func (export "call-7") (type $out-i32) + (call_indirect (type $out-i32) (i32.const 7)) + ) + (func (export "call-8") (type $out-i32) + (call_indirect (type $out-i32) (i32.const 8)) + ) + (func (export "call-9") (type $out-i32) + (call_indirect (type $out-i32) (i32.const 9)) + ) +) + +(register "module1" $module1) + +;; SKIP_SHARED_TABLE +;; (assert_trap (invoke $module1 "call-7") "uninitialized element 7") +;; (assert_return (invoke $module1 "call-8") (i32.const 65)) +;; (assert_return (invoke $module1 "call-9") (i32.const 66)) + +(module $module2 + (type $out-i32 (func (result i32))) + (import "module1" "shared-table" (table 10 anyfunc)) + (elem (i32.const 7) $const-i32-c) + (elem (i32.const 8) $const-i32-d) + (func $const-i32-c (type $out-i32) (i32.const 67)) + (func $const-i32-d (type $out-i32) (i32.const 68)) +) + +;; SKIP_SHARED_TABLE +;; (assert_return (invoke $module1 "call-7") (i32.const 67)) +;; (assert_return (invoke $module1 "call-8") (i32.const 68)) +;; (assert_return (invoke $module1 "call-9") (i32.const 66)) + +(module $module3 + (type $out-i32 (func (result i32))) + (import "module1" "shared-table" (table 10 anyfunc)) + (elem (i32.const 8) $const-i32-e) + (elem (i32.const 9) $const-i32-f) + (func $const-i32-e (type $out-i32) (i32.const 69)) + (func $const-i32-f (type $out-i32) (i32.const 70)) +) + +;; SKIP_SHARED_TABLE +;; (assert_return (invoke $module1 "call-7") (i32.const 67)) +;; (assert_return (invoke $module1 "call-8") (i32.const 69)) +;; (assert_return (invoke $module1 "call-9") (i32.const 70)) diff --git a/src/build_spectests.rs b/src/build_spectests.rs index 400111e3e..cb6b837cc 100644 --- a/src/build_spectests.rs +++ b/src/build_spectests.rs @@ -13,7 +13,7 @@ static ENV_VAR: &str = "WASM_GENERATE_SPECTESTS"; static BANNER: &str = "// Rust test file autogenerated with cargo build (src/build_spectests.rs). // Please do NOT modify it by hand, as it will be reseted on next build.\n"; -const TESTS: [&str; 54] = [ +const TESTS: [&str; 55] = [ "spectests/address.wast", "spectests/align.wast", "spectests/binary.wast", @@ -29,6 +29,7 @@ const TESTS: [&str; 54] = [ "spectests/conversions.wast", "spectests/custom.wast", "spectests/data.wast", + "spectests/elem.wast", "spectests/endianness.wast", "spectests/exports.wast", "spectests/f32_.wast", @@ -484,7 +485,7 @@ fn {}_assert_malformed() {{ .or_insert(Vec::new()) .push(action_fn_name.unwrap()); } - + fn visit_perform_action(&mut self, action: &Action) { let action_fn_name = self.visit_action(action, None); @@ -642,7 +643,6 @@ mod {};", modules.push(format!("mod {};", module_name)); } } - // let mut modfile_uses: Vec = modules.iter().map(|module| module).collect(); modules.insert(0, BANNER.to_string()); modules.insert(1, "// The _common module is not autogenerated, as it provides common functions for the spectests\nmod _common;".to_string()); diff --git a/src/common/slice.rs b/src/common/slice.rs index b27684c75..8ad5611fc 100644 --- a/src/common/slice.rs +++ b/src/common/slice.rs @@ -9,15 +9,19 @@ pub struct UncheckedSlice { impl UncheckedSlice { #[inline] - unsafe fn get_unchecked(&self, index: usize) -> &T { + pub fn get_unchecked(&self, index: usize) -> &T { let ptr = self.ptr.as_ptr(); - &*ptr.add(index) + unsafe { + &*ptr.add(index) + } } #[inline] - unsafe fn get_unchecked_mut(&mut self, index: usize) -> &mut T { + pub fn get_unchecked_mut(&mut self, index: usize) -> &mut T { let ptr = self.ptr.as_ptr(); - &mut *(ptr.add(index) as *mut _) + unsafe { + &mut *(ptr.add(index) as *mut _) + } } pub unsafe fn dangling() -> UncheckedSlice { @@ -43,15 +47,16 @@ impl<'a, T> From<&'a [T]> for UncheckedSlice { } #[derive(Debug)] +#[repr(C)] pub struct BoundedSlice { - data: UncheckedSlice, - len: usize, + pub data: UncheckedSlice, + pub len: usize, } impl BoundedSlice { pub fn get(&self, index: usize) -> Option<&T> { if index < self.len { - unsafe { Some(self.data.get_unchecked(index)) } + Some(self.data.get_unchecked(index)) } else { None } @@ -59,7 +64,7 @@ impl BoundedSlice { pub fn get_mut(&mut self, index: usize) -> Option<&mut T> { if index < self.len { - unsafe { Some(self.data.get_unchecked_mut(index)) } + Some(self.data.get_unchecked_mut(index)) } else { None } @@ -69,6 +74,15 @@ impl BoundedSlice { pub fn len(&self) -> usize { self.len } + + // TODO: Needs refactor. Take LinearMemory as argument. + // I've tried that but it gives cryptic error. + pub fn new(slice: &[T], size: usize) -> BoundedSlice { + BoundedSlice { + data: slice.into(), + len: size, + } + } } impl Index for BoundedSlice { diff --git a/src/integrations/mod.rs b/src/integrations/mod.rs index 7b658eefc..dc0016266 100644 --- a/src/integrations/mod.rs +++ b/src/integrations/mod.rs @@ -1,4 +1,4 @@ -use crate::webassembly::{ImportObject, Instance}; +use crate::webassembly::{ImportObject, ImportValue, Instance}; use libc::{printf, putchar}; extern "C" fn _printf(memory_offset: i32, extra: i32, instance: &Instance) -> i32 { @@ -12,8 +12,8 @@ extern "C" fn _printf(memory_offset: i32, extra: i32, instance: &Instance) -> i3 pub fn generate_libc_env<'a, 'b>() -> ImportObject<&'a str, &'b str> { let mut import_object = ImportObject::new(); - import_object.set("env", "printf", _printf as *const u8); - import_object.set("env", "putchar", putchar as *const u8); + import_object.set("env", "printf", ImportValue::Func(_printf as *const u8)); + import_object.set("env", "putchar", ImportValue::Func(putchar as *const u8)); import_object } @@ -34,7 +34,7 @@ mod tests { _ => panic!("Function not found"), }; let main: fn(&Instance) = get_instance_function!(instance, func_index); - main(&instance); + main(&instance) } #[test] diff --git a/src/main.rs b/src/main.rs index 7eeb52733..d1253934c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,16 +13,6 @@ extern crate wabt; extern crate target_lexicon; extern crate nix; extern crate spin; - -// use std::alloc::System; -// use std::time::{Duration, Instant}; - -// #[global_allocator] -// static A: System = System; - -// #[macro_use] extern crate log; - -// use libc; use std::error::Error; use std::fs::File; use std::io; @@ -81,7 +71,7 @@ fn execute_wasm(wasm_path: PathBuf) -> Result<(), String> { webassembly::instantiate(wasm_binary, import_object) .map_err(|err| String::from(err.description()))?; - // webassembly::utils::print_instance_offsets(&instance); + webassembly::utils::print_instance_offsets(&instance); let func_index = instance .start_func diff --git a/src/spectests/_common.rs b/src/spectests/_common.rs index 2a6044dee..0920378b5 100644 --- a/src/spectests/_common.rs +++ b/src/spectests/_common.rs @@ -1,4 +1,4 @@ -use crate::webassembly::ImportObject; +use crate::webassembly::{ImportObject, ImportValue}; extern "C" fn print_i32(num: i32) { println!("{}", num); @@ -10,9 +10,10 @@ static GLOBAL_I32: i32 = 666; pub fn spectest_importobject<'a, 'b>() -> ImportObject<&'a str, &'b str> { let mut import_object = ImportObject::new(); - import_object.set("spectest", "print_i32", print_i32 as *const u8); - import_object.set("spectest", "print", print as *const u8); - import_object.set("spectest", "global_i32", GLOBAL_I32 as *const u8); + import_object.set("spectest", "print_i32", ImportValue::Func(print_i32 as *const u8)); + import_object.set("spectest", "print", ImportValue::Func(print as *const u8)); + import_object.set("spectest", "global_i32", ImportValue::Func(GLOBAL_I32 as *const u8)); + import_object.set("spectest", "table", ImportValue::Table(vec![0; 30])); return import_object; } diff --git a/src/spectests/call_indirect.rs b/src/spectests/call_indirect.rs index 416e0e111..d053ce45a 100644 --- a/src/spectests/call_indirect.rs +++ b/src/spectests/call_indirect.rs @@ -738,72 +738,9 @@ fn c18_l409_action_invoke(result_object: &ResultObject) { assert_eq!(result, 2 as i64); } -// Line 414 -fn c19_l414_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c19_l414_action_invoke"); - let func_index = match result_object.module.info.exports.get("dispatch") { - Some(&Export::Function(index)) => index, - _ => panic!("Function not found"), - }; - let invoke_fn: fn(i32, i64, &Instance) = get_instance_function!(result_object.instance, func_index); - let result = invoke_fn(29 as i32, 2 as i64, &result_object.instance); - -} - -#[test] -fn c19_l414_assert_trap() { - let result_object = create_module_1(); - let result = panic::catch_unwind(|| { - c19_l414_action_invoke(&result_object); - }); - assert!(result.is_err()); -} - -// Line 415 -fn c20_l415_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c20_l415_action_invoke"); - let func_index = match result_object.module.info.exports.get("dispatch") { - Some(&Export::Function(index)) => index, - _ => panic!("Function not found"), - }; - let invoke_fn: fn(i32, i64, &Instance) = get_instance_function!(result_object.instance, func_index); - let result = invoke_fn(-1 as i32, 2 as i64, &result_object.instance); - -} - -#[test] -fn c20_l415_assert_trap() { - let result_object = create_module_1(); - let result = panic::catch_unwind(|| { - c20_l415_action_invoke(&result_object); - }); - assert!(result.is_err()); -} - -// Line 416 -fn c21_l416_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c21_l416_action_invoke"); - let func_index = match result_object.module.info.exports.get("dispatch") { - Some(&Export::Function(index)) => index, - _ => panic!("Function not found"), - }; - let invoke_fn: fn(i32, i64, &Instance) = get_instance_function!(result_object.instance, func_index); - let result = invoke_fn(1213432423 as i32, 2 as i64, &result_object.instance); - -} - -#[test] -fn c21_l416_assert_trap() { - let result_object = create_module_1(); - let result = panic::catch_unwind(|| { - c21_l416_action_invoke(&result_object); - }); - assert!(result.is_err()); -} - -// Line 418 -fn c22_l418_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c22_l418_action_invoke"); +// Line 420 +fn c19_l420_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c19_l420_action_invoke"); let func_index = match result_object.module.info.exports.get("dispatch-structural-i64") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -813,9 +750,9 @@ fn c22_l418_action_invoke(result_object: &ResultObject) { assert_eq!(result, 9 as i64); } -// Line 419 -fn c23_l419_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c23_l419_action_invoke"); +// Line 421 +fn c20_l421_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c20_l421_action_invoke"); let func_index = match result_object.module.info.exports.get("dispatch-structural-i64") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -825,9 +762,9 @@ fn c23_l419_action_invoke(result_object: &ResultObject) { assert_eq!(result, 362880 as i64); } -// Line 420 -fn c24_l420_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c24_l420_action_invoke"); +// Line 422 +fn c21_l422_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c21_l422_action_invoke"); let func_index = match result_object.module.info.exports.get("dispatch-structural-i64") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -837,9 +774,9 @@ fn c24_l420_action_invoke(result_object: &ResultObject) { assert_eq!(result, 55 as i64); } -// Line 421 -fn c25_l421_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c25_l421_action_invoke"); +// Line 423 +fn c22_l423_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c22_l423_action_invoke"); let func_index = match result_object.module.info.exports.get("dispatch-structural-i64") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -849,9 +786,9 @@ fn c25_l421_action_invoke(result_object: &ResultObject) { assert_eq!(result, 9 as i64); } -// Line 427 -fn c26_l427_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c26_l427_action_invoke"); +// Line 429 +fn c23_l429_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c23_l429_action_invoke"); let func_index = match result_object.module.info.exports.get("dispatch-structural-i32") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -861,9 +798,9 @@ fn c26_l427_action_invoke(result_object: &ResultObject) { assert_eq!(result, 9 as i32); } -// Line 428 -fn c27_l428_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c27_l428_action_invoke"); +// Line 430 +fn c24_l430_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c24_l430_action_invoke"); let func_index = match result_object.module.info.exports.get("dispatch-structural-i32") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -873,9 +810,9 @@ fn c27_l428_action_invoke(result_object: &ResultObject) { assert_eq!(result, 362880 as i32); } -// Line 429 -fn c28_l429_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c28_l429_action_invoke"); +// Line 431 +fn c25_l431_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c25_l431_action_invoke"); let func_index = match result_object.module.info.exports.get("dispatch-structural-i32") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -885,9 +822,9 @@ fn c28_l429_action_invoke(result_object: &ResultObject) { assert_eq!(result, 55 as i32); } -// Line 430 -fn c29_l430_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c29_l430_action_invoke"); +// Line 432 +fn c26_l432_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c26_l432_action_invoke"); let func_index = match result_object.module.info.exports.get("dispatch-structural-i32") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -897,9 +834,9 @@ fn c29_l430_action_invoke(result_object: &ResultObject) { assert_eq!(result, 9 as i32); } -// Line 436 -fn c30_l436_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c30_l436_action_invoke"); +// Line 438 +fn c27_l438_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c27_l438_action_invoke"); let func_index = match result_object.module.info.exports.get("dispatch-structural-f32") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -909,9 +846,9 @@ fn c30_l436_action_invoke(result_object: &ResultObject) { assert_eq!(result, 9.0 as f32); } -// Line 437 -fn c31_l437_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c31_l437_action_invoke"); +// Line 439 +fn c28_l439_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c28_l439_action_invoke"); let func_index = match result_object.module.info.exports.get("dispatch-structural-f32") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -921,9 +858,9 @@ fn c31_l437_action_invoke(result_object: &ResultObject) { assert_eq!(result, 362880.0 as f32); } -// Line 438 -fn c32_l438_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c32_l438_action_invoke"); +// Line 440 +fn c29_l440_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c29_l440_action_invoke"); let func_index = match result_object.module.info.exports.get("dispatch-structural-f32") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -933,9 +870,9 @@ fn c32_l438_action_invoke(result_object: &ResultObject) { assert_eq!(result, 55.0 as f32); } -// Line 439 -fn c33_l439_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c33_l439_action_invoke"); +// Line 441 +fn c30_l441_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c30_l441_action_invoke"); let func_index = match result_object.module.info.exports.get("dispatch-structural-f32") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -945,9 +882,9 @@ fn c33_l439_action_invoke(result_object: &ResultObject) { assert_eq!(result, 9.0 as f32); } -// Line 445 -fn c34_l445_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c34_l445_action_invoke"); +// Line 447 +fn c31_l447_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c31_l447_action_invoke"); let func_index = match result_object.module.info.exports.get("dispatch-structural-f64") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -957,9 +894,9 @@ fn c34_l445_action_invoke(result_object: &ResultObject) { assert_eq!(result, 9.0 as f64); } -// Line 446 -fn c35_l446_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c35_l446_action_invoke"); +// Line 448 +fn c32_l448_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c32_l448_action_invoke"); let func_index = match result_object.module.info.exports.get("dispatch-structural-f64") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -969,9 +906,9 @@ fn c35_l446_action_invoke(result_object: &ResultObject) { assert_eq!(result, 362880.0 as f64); } -// Line 447 -fn c36_l447_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c36_l447_action_invoke"); +// Line 449 +fn c33_l449_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c33_l449_action_invoke"); let func_index = match result_object.module.info.exports.get("dispatch-structural-f64") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -981,9 +918,9 @@ fn c36_l447_action_invoke(result_object: &ResultObject) { assert_eq!(result, 55.0 as f64); } -// Line 448 -fn c37_l448_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c37_l448_action_invoke"); +// Line 450 +fn c34_l450_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c34_l450_action_invoke"); let func_index = match result_object.module.info.exports.get("dispatch-structural-f64") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -993,9 +930,9 @@ fn c37_l448_action_invoke(result_object: &ResultObject) { assert_eq!(result, 9.0 as f64); } -// Line 454 -fn c38_l454_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c38_l454_action_invoke"); +// Line 456 +fn c35_l456_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c35_l456_action_invoke"); let func_index = match result_object.module.info.exports.get("fac-i64") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1005,9 +942,9 @@ fn c38_l454_action_invoke(result_object: &ResultObject) { assert_eq!(result, 1 as i64); } -// Line 455 -fn c39_l455_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c39_l455_action_invoke"); +// Line 457 +fn c36_l457_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c36_l457_action_invoke"); let func_index = match result_object.module.info.exports.get("fac-i64") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1017,9 +954,9 @@ fn c39_l455_action_invoke(result_object: &ResultObject) { assert_eq!(result, 1 as i64); } -// Line 456 -fn c40_l456_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c40_l456_action_invoke"); +// Line 458 +fn c37_l458_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c37_l458_action_invoke"); let func_index = match result_object.module.info.exports.get("fac-i64") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1029,9 +966,9 @@ fn c40_l456_action_invoke(result_object: &ResultObject) { assert_eq!(result, 120 as i64); } -// Line 457 -fn c41_l457_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c41_l457_action_invoke"); +// Line 459 +fn c38_l459_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c38_l459_action_invoke"); let func_index = match result_object.module.info.exports.get("fac-i64") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1041,9 +978,9 @@ fn c41_l457_action_invoke(result_object: &ResultObject) { assert_eq!(result, 7034535277573963776 as i64); } -// Line 459 -fn c42_l459_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c42_l459_action_invoke"); +// Line 461 +fn c39_l461_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c39_l461_action_invoke"); let func_index = match result_object.module.info.exports.get("fac-i32") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1053,9 +990,9 @@ fn c42_l459_action_invoke(result_object: &ResultObject) { assert_eq!(result, 1 as i32); } -// Line 460 -fn c43_l460_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c43_l460_action_invoke"); +// Line 462 +fn c40_l462_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c40_l462_action_invoke"); let func_index = match result_object.module.info.exports.get("fac-i32") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1065,9 +1002,9 @@ fn c43_l460_action_invoke(result_object: &ResultObject) { assert_eq!(result, 1 as i32); } -// Line 461 -fn c44_l461_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c44_l461_action_invoke"); +// Line 463 +fn c41_l463_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c41_l463_action_invoke"); let func_index = match result_object.module.info.exports.get("fac-i32") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1077,9 +1014,9 @@ fn c44_l461_action_invoke(result_object: &ResultObject) { assert_eq!(result, 120 as i32); } -// Line 462 -fn c45_l462_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c45_l462_action_invoke"); +// Line 464 +fn c42_l464_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c42_l464_action_invoke"); let func_index = match result_object.module.info.exports.get("fac-i32") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1089,9 +1026,9 @@ fn c45_l462_action_invoke(result_object: &ResultObject) { assert_eq!(result, 3628800 as i32); } -// Line 464 -fn c46_l464_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c46_l464_action_invoke"); +// Line 466 +fn c43_l466_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c43_l466_action_invoke"); let func_index = match result_object.module.info.exports.get("fac-f32") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1101,9 +1038,9 @@ fn c46_l464_action_invoke(result_object: &ResultObject) { assert_eq!(result, 1.0 as f32); } -// Line 465 -fn c47_l465_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c47_l465_action_invoke"); +// Line 467 +fn c44_l467_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c44_l467_action_invoke"); let func_index = match result_object.module.info.exports.get("fac-f32") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1113,9 +1050,9 @@ fn c47_l465_action_invoke(result_object: &ResultObject) { assert_eq!(result, 1.0 as f32); } -// Line 466 -fn c48_l466_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c48_l466_action_invoke"); +// Line 468 +fn c45_l468_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c45_l468_action_invoke"); let func_index = match result_object.module.info.exports.get("fac-f32") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1125,9 +1062,9 @@ fn c48_l466_action_invoke(result_object: &ResultObject) { assert_eq!(result, 120.0 as f32); } -// Line 467 -fn c49_l467_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c49_l467_action_invoke"); +// Line 469 +fn c46_l469_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c46_l469_action_invoke"); let func_index = match result_object.module.info.exports.get("fac-f32") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1137,9 +1074,9 @@ fn c49_l467_action_invoke(result_object: &ResultObject) { assert_eq!(result, 3628800.0 as f32); } -// Line 469 -fn c50_l469_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c50_l469_action_invoke"); +// Line 471 +fn c47_l471_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c47_l471_action_invoke"); let func_index = match result_object.module.info.exports.get("fac-f64") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1149,9 +1086,9 @@ fn c50_l469_action_invoke(result_object: &ResultObject) { assert_eq!(result, 1.0 as f64); } -// Line 470 -fn c51_l470_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c51_l470_action_invoke"); +// Line 472 +fn c48_l472_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c48_l472_action_invoke"); let func_index = match result_object.module.info.exports.get("fac-f64") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1161,9 +1098,9 @@ fn c51_l470_action_invoke(result_object: &ResultObject) { assert_eq!(result, 1.0 as f64); } -// Line 471 -fn c52_l471_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c52_l471_action_invoke"); +// Line 473 +fn c49_l473_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c49_l473_action_invoke"); let func_index = match result_object.module.info.exports.get("fac-f64") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1173,9 +1110,9 @@ fn c52_l471_action_invoke(result_object: &ResultObject) { assert_eq!(result, 120.0 as f64); } -// Line 472 -fn c53_l472_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c53_l472_action_invoke"); +// Line 474 +fn c50_l474_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c50_l474_action_invoke"); let func_index = match result_object.module.info.exports.get("fac-f64") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1185,9 +1122,9 @@ fn c53_l472_action_invoke(result_object: &ResultObject) { assert_eq!(result, 3628800.0 as f64); } -// Line 474 -fn c54_l474_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c54_l474_action_invoke"); +// Line 476 +fn c51_l476_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c51_l476_action_invoke"); let func_index = match result_object.module.info.exports.get("fib-i64") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1197,9 +1134,9 @@ fn c54_l474_action_invoke(result_object: &ResultObject) { assert_eq!(result, 1 as i64); } -// Line 475 -fn c55_l475_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c55_l475_action_invoke"); +// Line 477 +fn c52_l477_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c52_l477_action_invoke"); let func_index = match result_object.module.info.exports.get("fib-i64") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1209,9 +1146,9 @@ fn c55_l475_action_invoke(result_object: &ResultObject) { assert_eq!(result, 1 as i64); } -// Line 476 -fn c56_l476_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c56_l476_action_invoke"); +// Line 478 +fn c53_l478_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c53_l478_action_invoke"); let func_index = match result_object.module.info.exports.get("fib-i64") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1221,9 +1158,9 @@ fn c56_l476_action_invoke(result_object: &ResultObject) { assert_eq!(result, 2 as i64); } -// Line 477 -fn c57_l477_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c57_l477_action_invoke"); +// Line 479 +fn c54_l479_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c54_l479_action_invoke"); let func_index = match result_object.module.info.exports.get("fib-i64") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1233,9 +1170,9 @@ fn c57_l477_action_invoke(result_object: &ResultObject) { assert_eq!(result, 8 as i64); } -// Line 478 -fn c58_l478_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c58_l478_action_invoke"); +// Line 480 +fn c55_l480_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c55_l480_action_invoke"); let func_index = match result_object.module.info.exports.get("fib-i64") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1245,9 +1182,9 @@ fn c58_l478_action_invoke(result_object: &ResultObject) { assert_eq!(result, 10946 as i64); } -// Line 480 -fn c59_l480_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c59_l480_action_invoke"); +// Line 482 +fn c56_l482_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c56_l482_action_invoke"); let func_index = match result_object.module.info.exports.get("fib-i32") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1257,9 +1194,9 @@ fn c59_l480_action_invoke(result_object: &ResultObject) { assert_eq!(result, 1 as i32); } -// Line 481 -fn c60_l481_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c60_l481_action_invoke"); +// Line 483 +fn c57_l483_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c57_l483_action_invoke"); let func_index = match result_object.module.info.exports.get("fib-i32") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1269,9 +1206,9 @@ fn c60_l481_action_invoke(result_object: &ResultObject) { assert_eq!(result, 1 as i32); } -// Line 482 -fn c61_l482_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c61_l482_action_invoke"); +// Line 484 +fn c58_l484_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c58_l484_action_invoke"); let func_index = match result_object.module.info.exports.get("fib-i32") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1281,9 +1218,9 @@ fn c61_l482_action_invoke(result_object: &ResultObject) { assert_eq!(result, 2 as i32); } -// Line 483 -fn c62_l483_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c62_l483_action_invoke"); +// Line 485 +fn c59_l485_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c59_l485_action_invoke"); let func_index = match result_object.module.info.exports.get("fib-i32") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1293,9 +1230,9 @@ fn c62_l483_action_invoke(result_object: &ResultObject) { assert_eq!(result, 8 as i32); } -// Line 484 -fn c63_l484_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c63_l484_action_invoke"); +// Line 486 +fn c60_l486_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c60_l486_action_invoke"); let func_index = match result_object.module.info.exports.get("fib-i32") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1305,9 +1242,9 @@ fn c63_l484_action_invoke(result_object: &ResultObject) { assert_eq!(result, 10946 as i32); } -// Line 486 -fn c64_l486_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c64_l486_action_invoke"); +// Line 488 +fn c61_l488_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c61_l488_action_invoke"); let func_index = match result_object.module.info.exports.get("fib-f32") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1317,9 +1254,9 @@ fn c64_l486_action_invoke(result_object: &ResultObject) { assert_eq!(result, 1.0 as f32); } -// Line 487 -fn c65_l487_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c65_l487_action_invoke"); +// Line 489 +fn c62_l489_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c62_l489_action_invoke"); let func_index = match result_object.module.info.exports.get("fib-f32") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1329,9 +1266,9 @@ fn c65_l487_action_invoke(result_object: &ResultObject) { assert_eq!(result, 1.0 as f32); } -// Line 488 -fn c66_l488_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c66_l488_action_invoke"); +// Line 490 +fn c63_l490_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c63_l490_action_invoke"); let func_index = match result_object.module.info.exports.get("fib-f32") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1341,9 +1278,9 @@ fn c66_l488_action_invoke(result_object: &ResultObject) { assert_eq!(result, 2.0 as f32); } -// Line 489 -fn c67_l489_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c67_l489_action_invoke"); +// Line 491 +fn c64_l491_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c64_l491_action_invoke"); let func_index = match result_object.module.info.exports.get("fib-f32") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1353,9 +1290,9 @@ fn c67_l489_action_invoke(result_object: &ResultObject) { assert_eq!(result, 8.0 as f32); } -// Line 490 -fn c68_l490_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c68_l490_action_invoke"); +// Line 492 +fn c65_l492_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c65_l492_action_invoke"); let func_index = match result_object.module.info.exports.get("fib-f32") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1365,9 +1302,9 @@ fn c68_l490_action_invoke(result_object: &ResultObject) { assert_eq!(result, 10946.0 as f32); } -// Line 492 -fn c69_l492_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c69_l492_action_invoke"); +// Line 494 +fn c66_l494_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c66_l494_action_invoke"); let func_index = match result_object.module.info.exports.get("fib-f64") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1377,9 +1314,9 @@ fn c69_l492_action_invoke(result_object: &ResultObject) { assert_eq!(result, 1.0 as f64); } -// Line 493 -fn c70_l493_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c70_l493_action_invoke"); +// Line 495 +fn c67_l495_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c67_l495_action_invoke"); let func_index = match result_object.module.info.exports.get("fib-f64") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1389,9 +1326,9 @@ fn c70_l493_action_invoke(result_object: &ResultObject) { assert_eq!(result, 1.0 as f64); } -// Line 494 -fn c71_l494_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c71_l494_action_invoke"); +// Line 496 +fn c68_l496_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c68_l496_action_invoke"); let func_index = match result_object.module.info.exports.get("fib-f64") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1401,9 +1338,9 @@ fn c71_l494_action_invoke(result_object: &ResultObject) { assert_eq!(result, 2.0 as f64); } -// Line 495 -fn c72_l495_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c72_l495_action_invoke"); +// Line 497 +fn c69_l497_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c69_l497_action_invoke"); let func_index = match result_object.module.info.exports.get("fib-f64") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1413,9 +1350,9 @@ fn c72_l495_action_invoke(result_object: &ResultObject) { assert_eq!(result, 8.0 as f64); } -// Line 496 -fn c73_l496_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c73_l496_action_invoke"); +// Line 498 +fn c70_l498_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c70_l498_action_invoke"); let func_index = match result_object.module.info.exports.get("fib-f64") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1425,9 +1362,9 @@ fn c73_l496_action_invoke(result_object: &ResultObject) { assert_eq!(result, 10946.0 as f64); } -// Line 498 -fn c74_l498_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c74_l498_action_invoke"); +// Line 500 +fn c71_l500_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c71_l500_action_invoke"); let func_index = match result_object.module.info.exports.get("even") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1437,9 +1374,9 @@ fn c74_l498_action_invoke(result_object: &ResultObject) { assert_eq!(result, 44 as i32); } -// Line 499 -fn c75_l499_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c75_l499_action_invoke"); +// Line 501 +fn c72_l501_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c72_l501_action_invoke"); let func_index = match result_object.module.info.exports.get("even") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1449,9 +1386,9 @@ fn c75_l499_action_invoke(result_object: &ResultObject) { assert_eq!(result, 99 as i32); } -// Line 500 -fn c76_l500_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c76_l500_action_invoke"); +// Line 502 +fn c73_l502_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c73_l502_action_invoke"); let func_index = match result_object.module.info.exports.get("even") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1461,9 +1398,9 @@ fn c76_l500_action_invoke(result_object: &ResultObject) { assert_eq!(result, 44 as i32); } -// Line 501 -fn c77_l501_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c77_l501_action_invoke"); +// Line 503 +fn c74_l503_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c74_l503_action_invoke"); let func_index = match result_object.module.info.exports.get("even") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1473,9 +1410,9 @@ fn c77_l501_action_invoke(result_object: &ResultObject) { assert_eq!(result, 99 as i32); } -// Line 502 -fn c78_l502_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c78_l502_action_invoke"); +// Line 504 +fn c75_l504_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c75_l504_action_invoke"); let func_index = match result_object.module.info.exports.get("odd") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1485,9 +1422,9 @@ fn c78_l502_action_invoke(result_object: &ResultObject) { assert_eq!(result, 99 as i32); } -// Line 503 -fn c79_l503_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c79_l503_action_invoke"); +// Line 505 +fn c76_l505_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c76_l505_action_invoke"); let func_index = match result_object.module.info.exports.get("odd") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1497,9 +1434,9 @@ fn c79_l503_action_invoke(result_object: &ResultObject) { assert_eq!(result, 44 as i32); } -// Line 504 -fn c80_l504_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c80_l504_action_invoke"); +// Line 506 +fn c77_l506_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c77_l506_action_invoke"); let func_index = match result_object.module.info.exports.get("odd") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1509,9 +1446,9 @@ fn c80_l504_action_invoke(result_object: &ResultObject) { assert_eq!(result, 99 as i32); } -// Line 505 -fn c81_l505_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c81_l505_action_invoke"); +// Line 507 +fn c78_l507_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c78_l507_action_invoke"); let func_index = match result_object.module.info.exports.get("odd") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1521,13 +1458,13 @@ fn c81_l505_action_invoke(result_object: &ResultObject) { assert_eq!(result, 44 as i32); } -// Line 507 - -// Line 508 +// Line 509 // Line 510 -fn c84_l510_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c84_l510_action_invoke"); + +// Line 512 +fn c81_l512_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c81_l512_action_invoke"); let func_index = match result_object.module.info.exports.get("as-select-first") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1537,9 +1474,9 @@ fn c84_l510_action_invoke(result_object: &ResultObject) { assert_eq!(result, 306 as i32); } -// Line 511 -fn c85_l511_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c85_l511_action_invoke"); +// Line 513 +fn c82_l513_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c82_l513_action_invoke"); let func_index = match result_object.module.info.exports.get("as-select-mid") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1549,9 +1486,9 @@ fn c85_l511_action_invoke(result_object: &ResultObject) { assert_eq!(result, 2 as i32); } -// Line 512 -fn c86_l512_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c86_l512_action_invoke"); +// Line 514 +fn c83_l514_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c83_l514_action_invoke"); let func_index = match result_object.module.info.exports.get("as-select-last") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1561,9 +1498,9 @@ fn c86_l512_action_invoke(result_object: &ResultObject) { assert_eq!(result, 2 as i32); } -// Line 514 -fn c87_l514_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c87_l514_action_invoke"); +// Line 516 +fn c84_l516_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c84_l516_action_invoke"); let func_index = match result_object.module.info.exports.get("as-if-condition") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1573,9 +1510,9 @@ fn c87_l514_action_invoke(result_object: &ResultObject) { assert_eq!(result, 1 as i32); } -// Line 516 -fn c88_l516_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c88_l516_action_invoke"); +// Line 518 +fn c85_l518_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c85_l518_action_invoke"); let func_index = match result_object.module.info.exports.get("as-br_if-first") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1585,9 +1522,9 @@ fn c88_l516_action_invoke(result_object: &ResultObject) { assert_eq!(result, 356 as i64); } -// Line 517 -fn c89_l517_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c89_l517_action_invoke"); +// Line 519 +fn c86_l519_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c86_l519_action_invoke"); let func_index = match result_object.module.info.exports.get("as-br_if-last") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1597,9 +1534,9 @@ fn c89_l517_action_invoke(result_object: &ResultObject) { assert_eq!(result, 2 as i32); } -// Line 519 -fn c90_l519_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c90_l519_action_invoke"); +// Line 521 +fn c87_l521_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c87_l521_action_invoke"); let func_index = match result_object.module.info.exports.get("as-br_table-first") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1609,9 +1546,9 @@ fn c90_l519_action_invoke(result_object: &ResultObject) { assert_eq!(result, 3890.0 as f32); } -// Line 520 -fn c91_l520_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c91_l520_action_invoke"); +// Line 522 +fn c88_l522_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c88_l522_action_invoke"); let func_index = match result_object.module.info.exports.get("as-br_table-last") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1621,9 +1558,9 @@ fn c91_l520_action_invoke(result_object: &ResultObject) { assert_eq!(result, 2 as i32); } -// Line 522 -fn c92_l522_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c92_l522_action_invoke"); +// Line 524 +fn c89_l524_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c89_l524_action_invoke"); let func_index = match result_object.module.info.exports.get("as-store-first") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1633,9 +1570,9 @@ fn c92_l522_action_invoke(result_object: &ResultObject) { assert_eq!(result, ()); } -// Line 523 -fn c93_l523_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c93_l523_action_invoke"); +// Line 525 +fn c90_l525_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c90_l525_action_invoke"); let func_index = match result_object.module.info.exports.get("as-store-last") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1645,9 +1582,9 @@ fn c93_l523_action_invoke(result_object: &ResultObject) { assert_eq!(result, ()); } -// Line 525 -fn c94_l525_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c94_l525_action_invoke"); +// Line 527 +fn c91_l527_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c91_l527_action_invoke"); let func_index = match result_object.module.info.exports.get("as-memory.grow-value") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1657,9 +1594,9 @@ fn c94_l525_action_invoke(result_object: &ResultObject) { assert_eq!(result, 1 as i32); } -// Line 526 -fn c95_l526_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c95_l526_action_invoke"); +// Line 528 +fn c92_l528_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c92_l528_action_invoke"); let func_index = match result_object.module.info.exports.get("as-return-value") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1669,9 +1606,9 @@ fn c95_l526_action_invoke(result_object: &ResultObject) { assert_eq!(result, 1 as i32); } -// Line 527 -fn c96_l527_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c96_l527_action_invoke"); +// Line 529 +fn c93_l529_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c93_l529_action_invoke"); let func_index = match result_object.module.info.exports.get("as-drop-operand") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1681,9 +1618,9 @@ fn c96_l527_action_invoke(result_object: &ResultObject) { assert_eq!(result, ()); } -// Line 528 -fn c97_l528_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c97_l528_action_invoke"); +// Line 530 +fn c94_l530_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c94_l530_action_invoke"); let func_index = match result_object.module.info.exports.get("as-br-value") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1693,9 +1630,9 @@ fn c97_l528_action_invoke(result_object: &ResultObject) { assert_eq!(result, 1.0 as f32); } -// Line 529 -fn c98_l529_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c98_l529_action_invoke"); +// Line 531 +fn c95_l531_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c95_l531_action_invoke"); let func_index = match result_object.module.info.exports.get("as-set_local-value") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1705,9 +1642,9 @@ fn c98_l529_action_invoke(result_object: &ResultObject) { assert_eq!(result, 1.0 as f64); } -// Line 530 -fn c99_l530_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c99_l530_action_invoke"); +// Line 532 +fn c96_l532_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c96_l532_action_invoke"); let func_index = match result_object.module.info.exports.get("as-tee_local-value") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1717,9 +1654,9 @@ fn c99_l530_action_invoke(result_object: &ResultObject) { assert_eq!(result, 1.0 as f64); } -// Line 531 -fn c100_l531_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c100_l531_action_invoke"); +// Line 533 +fn c97_l533_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c97_l533_action_invoke"); let func_index = match result_object.module.info.exports.get("as-set_global-value") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1729,9 +1666,9 @@ fn c100_l531_action_invoke(result_object: &ResultObject) { assert_eq!(result, 1.0 as f64); } -// Line 532 -fn c101_l532_action_invoke(result_object: &ResultObject) { - println!("Executing function {}", "c101_l532_action_invoke"); +// Line 534 +fn c98_l534_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c98_l534_action_invoke"); let func_index = match result_object.module.info.exports.get("as-load-operand") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), @@ -1741,217 +1678,217 @@ fn c101_l532_action_invoke(result_object: &ResultObject) { assert_eq!(result, 1 as i32); } -// Line 537 +// Line 539 #[test] -fn c102_l537_assert_malformed() { +fn c99_l539_assert_malformed() { let wasm_binary = [40, 116, 121, 112, 101, 32, 36, 115, 105, 103, 32, 40, 102, 117, 110, 99, 32, 40, 112, 97, 114, 97, 109, 32, 105, 51, 50, 41, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 41, 41, 40, 116, 97, 98, 108, 101, 32, 48, 32, 97, 110, 121, 102, 117, 110, 99, 41, 40, 102, 117, 110, 99, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 32, 32, 40, 99, 97, 108, 108, 95, 105, 110, 100, 105, 114, 101, 99, 116, 32, 40, 116, 121, 112, 101, 32, 36, 115, 105, 103, 41, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 32, 40, 112, 97, 114, 97, 109, 32, 105, 51, 50, 41, 32, 32, 32, 32, 40, 105, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 41, 32, 40, 105, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 41, 32, 32, 41, 41]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is malformed"); } -// Line 549 +// Line 551 #[test] -fn c103_l549_assert_malformed() { +fn c100_l551_assert_malformed() { let wasm_binary = [40, 116, 121, 112, 101, 32, 36, 115, 105, 103, 32, 40, 102, 117, 110, 99, 32, 40, 112, 97, 114, 97, 109, 32, 105, 51, 50, 41, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 41, 41, 40, 116, 97, 98, 108, 101, 32, 48, 32, 97, 110, 121, 102, 117, 110, 99, 41, 40, 102, 117, 110, 99, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 32, 32, 40, 99, 97, 108, 108, 95, 105, 110, 100, 105, 114, 101, 99, 116, 32, 40, 112, 97, 114, 97, 109, 32, 105, 51, 50, 41, 32, 40, 116, 121, 112, 101, 32, 36, 115, 105, 103, 41, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 32, 32, 32, 32, 40, 105, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 41, 32, 40, 105, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 41, 32, 32, 41, 41]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is malformed"); } -// Line 561 +// Line 563 #[test] -fn c104_l561_assert_malformed() { +fn c101_l563_assert_malformed() { let wasm_binary = [40, 116, 121, 112, 101, 32, 36, 115, 105, 103, 32, 40, 102, 117, 110, 99, 32, 40, 112, 97, 114, 97, 109, 32, 105, 51, 50, 41, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 41, 41, 40, 116, 97, 98, 108, 101, 32, 48, 32, 97, 110, 121, 102, 117, 110, 99, 41, 40, 102, 117, 110, 99, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 32, 32, 40, 99, 97, 108, 108, 95, 105, 110, 100, 105, 114, 101, 99, 116, 32, 40, 112, 97, 114, 97, 109, 32, 105, 51, 50, 41, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 32, 40, 116, 121, 112, 101, 32, 36, 115, 105, 103, 41, 32, 32, 32, 32, 40, 105, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 41, 32, 40, 105, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 41, 32, 32, 41, 41]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is malformed"); } -// Line 573 +// Line 575 #[test] -fn c105_l573_assert_malformed() { +fn c102_l575_assert_malformed() { let wasm_binary = [40, 116, 121, 112, 101, 32, 36, 115, 105, 103, 32, 40, 102, 117, 110, 99, 32, 40, 112, 97, 114, 97, 109, 32, 105, 51, 50, 41, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 41, 41, 40, 116, 97, 98, 108, 101, 32, 48, 32, 97, 110, 121, 102, 117, 110, 99, 41, 40, 102, 117, 110, 99, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 32, 32, 40, 99, 97, 108, 108, 95, 105, 110, 100, 105, 114, 101, 99, 116, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 32, 40, 116, 121, 112, 101, 32, 36, 115, 105, 103, 41, 32, 40, 112, 97, 114, 97, 109, 32, 105, 51, 50, 41, 32, 32, 32, 32, 40, 105, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 41, 32, 40, 105, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 41, 32, 32, 41, 41]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is malformed"); } -// Line 585 +// Line 587 #[test] -fn c106_l585_assert_malformed() { +fn c103_l587_assert_malformed() { let wasm_binary = [40, 116, 121, 112, 101, 32, 36, 115, 105, 103, 32, 40, 102, 117, 110, 99, 32, 40, 112, 97, 114, 97, 109, 32, 105, 51, 50, 41, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 41, 41, 40, 116, 97, 98, 108, 101, 32, 48, 32, 97, 110, 121, 102, 117, 110, 99, 41, 40, 102, 117, 110, 99, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 32, 32, 40, 99, 97, 108, 108, 95, 105, 110, 100, 105, 114, 101, 99, 116, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 32, 40, 112, 97, 114, 97, 109, 32, 105, 51, 50, 41, 32, 40, 116, 121, 112, 101, 32, 36, 115, 105, 103, 41, 32, 32, 32, 32, 40, 105, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 41, 32, 40, 105, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 41, 32, 32, 41, 41]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is malformed"); } -// Line 597 +// Line 599 #[test] -fn c107_l597_assert_malformed() { +fn c104_l599_assert_malformed() { let wasm_binary = [40, 116, 97, 98, 108, 101, 32, 48, 32, 97, 110, 121, 102, 117, 110, 99, 41, 40, 102, 117, 110, 99, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 32, 32, 40, 99, 97, 108, 108, 95, 105, 110, 100, 105, 114, 101, 99, 116, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 32, 40, 112, 97, 114, 97, 109, 32, 105, 51, 50, 41, 32, 40, 105, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 41, 32, 40, 105, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 41, 41, 41]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is malformed"); } -// Line 607 +// Line 609 #[test] -fn c108_l607_assert_malformed() { +fn c105_l609_assert_malformed() { let wasm_binary = [40, 116, 97, 98, 108, 101, 32, 48, 32, 97, 110, 121, 102, 117, 110, 99, 41, 40, 102, 117, 110, 99, 32, 40, 99, 97, 108, 108, 95, 105, 110, 100, 105, 114, 101, 99, 116, 32, 40, 112, 97, 114, 97, 109, 32, 36, 120, 32, 105, 51, 50, 41, 32, 40, 105, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 41, 32, 40, 105, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 41, 41, 41]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is malformed"); } -// Line 614 +// Line 616 #[test] -fn c109_l614_assert_malformed() { +fn c106_l616_assert_malformed() { let wasm_binary = [40, 116, 121, 112, 101, 32, 36, 115, 105, 103, 32, 40, 102, 117, 110, 99, 41, 41, 40, 116, 97, 98, 108, 101, 32, 48, 32, 97, 110, 121, 102, 117, 110, 99, 41, 40, 102, 117, 110, 99, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 32, 32, 40, 99, 97, 108, 108, 95, 105, 110, 100, 105, 114, 101, 99, 116, 32, 40, 116, 121, 112, 101, 32, 36, 115, 105, 103, 41, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 32, 40, 105, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 41, 41, 41]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is malformed"); } -// Line 624 +// Line 626 #[test] -fn c110_l624_assert_malformed() { +fn c107_l626_assert_malformed() { let wasm_binary = [40, 116, 121, 112, 101, 32, 36, 115, 105, 103, 32, 40, 102, 117, 110, 99, 32, 40, 112, 97, 114, 97, 109, 32, 105, 51, 50, 41, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 41, 41, 40, 116, 97, 98, 108, 101, 32, 48, 32, 97, 110, 121, 102, 117, 110, 99, 41, 40, 102, 117, 110, 99, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 32, 32, 40, 99, 97, 108, 108, 95, 105, 110, 100, 105, 114, 101, 99, 116, 32, 40, 116, 121, 112, 101, 32, 36, 115, 105, 103, 41, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 32, 40, 105, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 41, 41, 41]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is malformed"); } -// Line 634 +// Line 636 #[test] -fn c111_l634_assert_malformed() { +fn c108_l636_assert_malformed() { let wasm_binary = [40, 116, 121, 112, 101, 32, 36, 115, 105, 103, 32, 40, 102, 117, 110, 99, 32, 40, 112, 97, 114, 97, 109, 32, 105, 51, 50, 41, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 41, 41, 40, 116, 97, 98, 108, 101, 32, 48, 32, 97, 110, 121, 102, 117, 110, 99, 41, 40, 102, 117, 110, 99, 32, 32, 40, 99, 97, 108, 108, 95, 105, 110, 100, 105, 114, 101, 99, 116, 32, 40, 116, 121, 112, 101, 32, 36, 115, 105, 103, 41, 32, 40, 112, 97, 114, 97, 109, 32, 105, 51, 50, 41, 32, 40, 105, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 41, 32, 40, 105, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 41, 41, 41]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is malformed"); } -// Line 644 +// Line 646 #[test] -fn c112_l644_assert_malformed() { +fn c109_l646_assert_malformed() { let wasm_binary = [40, 116, 121, 112, 101, 32, 36, 115, 105, 103, 32, 40, 102, 117, 110, 99, 32, 40, 112, 97, 114, 97, 109, 32, 105, 51, 50, 32, 105, 51, 50, 41, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 41, 41, 40, 116, 97, 98, 108, 101, 32, 48, 32, 97, 110, 121, 102, 117, 110, 99, 41, 40, 102, 117, 110, 99, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 32, 32, 40, 99, 97, 108, 108, 95, 105, 110, 100, 105, 114, 101, 99, 116, 32, 40, 116, 121, 112, 101, 32, 36, 115, 105, 103, 41, 32, 40, 112, 97, 114, 97, 109, 32, 105, 51, 50, 41, 32, 40, 114, 101, 115, 117, 108, 116, 32, 105, 51, 50, 41, 32, 32, 32, 32, 40, 105, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 41, 32, 40, 105, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 41, 32, 32, 41, 41]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is malformed"); } -// Line 659 +// Line 661 #[test] -fn c113_l659_assert_invalid() { +fn c110_l661_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 9, 1, 7, 0, 65, 0, 17, 0, 0, 11]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is invalid"); } -// Line 667 +// Line 669 #[test] -fn c114_l667_assert_invalid() { +fn c111_l669_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 4, 4, 1, 112, 0, 0, 10, 10, 1, 8, 0, 65, 0, 17, 0, 0, 69, 11]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is invalid"); } -// Line 675 +// Line 677 #[test] -fn c115_l675_assert_invalid() { +fn c112_l677_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 8, 2, 96, 0, 1, 126, 96, 0, 0, 3, 2, 1, 1, 4, 4, 1, 112, 0, 0, 10, 10, 1, 8, 0, 65, 0, 17, 0, 0, 69, 11]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is invalid"); } -// Line 684 +// Line 686 #[test] -fn c116_l684_assert_invalid() { +fn c113_l686_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 8, 2, 96, 1, 127, 0, 96, 0, 0, 3, 2, 1, 1, 4, 4, 1, 112, 0, 0, 10, 9, 1, 7, 0, 65, 0, 17, 0, 0, 11]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is invalid"); } -// Line 692 +// Line 694 #[test] -fn c117_l692_assert_invalid() { +fn c114_l694_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 9, 2, 96, 2, 124, 127, 0, 96, 0, 0, 3, 2, 1, 1, 4, 4, 1, 112, 0, 0, 10, 9, 1, 7, 0, 65, 0, 17, 0, 0, 11]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is invalid"); } -// Line 700 +// Line 702 #[test] -fn c118_l700_assert_invalid() { +fn c115_l702_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 4, 4, 1, 112, 0, 0, 10, 11, 1, 9, 0, 65, 1, 65, 0, 17, 0, 0, 11]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is invalid"); } -// Line 708 +// Line 710 #[test] -fn c119_l708_assert_invalid() { +fn c116_l710_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 4, 4, 1, 112, 0, 0, 10, 20, 1, 18, 0, 68, 0, 0, 0, 0, 0, 0, 0, 64, 65, 1, 65, 0, 17, 0, 0, 11]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is invalid"); } -// Line 719 +// Line 721 #[test] -fn c120_l719_assert_invalid() { +fn c117_l721_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 8, 2, 96, 1, 127, 0, 96, 0, 0, 3, 2, 1, 1, 4, 4, 1, 112, 0, 0, 10, 10, 1, 8, 0, 65, 1, 1, 17, 0, 0, 11]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is invalid"); } -// Line 727 +// Line 729 #[test] -fn c121_l727_assert_invalid() { +fn c118_l729_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 8, 2, 96, 1, 127, 0, 96, 0, 0, 3, 2, 1, 1, 4, 4, 1, 112, 0, 0, 10, 11, 1, 9, 0, 65, 0, 66, 1, 17, 0, 0, 11]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is invalid"); } -// Line 736 +// Line 738 #[test] -fn c122_l736_assert_invalid() { +fn c119_l738_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 9, 2, 96, 2, 127, 127, 0, 96, 0, 0, 3, 2, 1, 1, 4, 4, 1, 112, 0, 0, 10, 12, 1, 10, 0, 1, 65, 1, 65, 0, 17, 0, 0, 11]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is invalid"); } -// Line 746 +// Line 748 #[test] -fn c123_l746_assert_invalid() { +fn c120_l748_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 9, 2, 96, 2, 127, 127, 0, 96, 0, 0, 3, 2, 1, 1, 4, 4, 1, 112, 0, 0, 10, 12, 1, 10, 0, 65, 1, 1, 65, 0, 17, 0, 0, 11]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is invalid"); } -// Line 756 +// Line 758 #[test] -fn c124_l756_assert_invalid() { +fn c121_l758_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 9, 2, 96, 2, 127, 124, 0, 96, 0, 0, 3, 2, 1, 1, 4, 4, 1, 112, 0, 0, 10, 20, 1, 18, 0, 68, 0, 0, 0, 0, 0, 0, 240, 63, 65, 1, 65, 0, 17, 0, 0, 11]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is invalid"); } -// Line 766 +// Line 768 #[test] -fn c125_l766_assert_invalid() { +fn c122_l768_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 9, 2, 96, 2, 124, 127, 0, 96, 0, 0, 3, 2, 1, 1, 4, 4, 1, 112, 0, 0, 10, 20, 1, 18, 0, 65, 1, 68, 0, 0, 0, 0, 0, 0, 240, 63, 65, 0, 17, 0, 0, 11]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is invalid"); } -// Line 780 +// Line 782 #[test] -fn c126_l780_assert_invalid() { +fn c123_l782_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 4, 4, 1, 112, 0, 0, 10, 9, 1, 7, 0, 65, 0, 17, 1, 0, 11]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is invalid"); } -// Line 787 +// Line 789 #[test] -fn c127_l787_assert_invalid() { +fn c124_l789_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 4, 4, 1, 112, 0, 0, 10, 13, 1, 11, 0, 65, 0, 17, 148, 152, 219, 226, 3, 0, 11]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is invalid"); } -// Line 798 +// Line 800 #[test] -fn c128_l798_assert_invalid() { +fn c125_l800_assert_invalid() { let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 4, 5, 1, 112, 1, 2, 2, 9, 8, 1, 0, 65, 0, 11, 2, 0, 0]; let compilation = compile(wasm_binary.to_vec()); assert!(compilation.is_err(), "WASM should not compile as is invalid"); @@ -1980,82 +1917,82 @@ fn test_module_1() { c16_l407_action_invoke(&result_object); c17_l408_action_invoke(&result_object); c18_l409_action_invoke(&result_object); - c22_l418_action_invoke(&result_object); - c23_l419_action_invoke(&result_object); - c24_l420_action_invoke(&result_object); - c25_l421_action_invoke(&result_object); - c26_l427_action_invoke(&result_object); - c27_l428_action_invoke(&result_object); - c28_l429_action_invoke(&result_object); - c29_l430_action_invoke(&result_object); - c30_l436_action_invoke(&result_object); - c31_l437_action_invoke(&result_object); - c32_l438_action_invoke(&result_object); - c33_l439_action_invoke(&result_object); - c34_l445_action_invoke(&result_object); - c35_l446_action_invoke(&result_object); - c36_l447_action_invoke(&result_object); - c37_l448_action_invoke(&result_object); - c38_l454_action_invoke(&result_object); - c39_l455_action_invoke(&result_object); - c40_l456_action_invoke(&result_object); - c41_l457_action_invoke(&result_object); - c42_l459_action_invoke(&result_object); - c43_l460_action_invoke(&result_object); - c44_l461_action_invoke(&result_object); - c45_l462_action_invoke(&result_object); - c46_l464_action_invoke(&result_object); - c47_l465_action_invoke(&result_object); - c48_l466_action_invoke(&result_object); - c49_l467_action_invoke(&result_object); - c50_l469_action_invoke(&result_object); - c51_l470_action_invoke(&result_object); - c52_l471_action_invoke(&result_object); - c53_l472_action_invoke(&result_object); - c54_l474_action_invoke(&result_object); - c55_l475_action_invoke(&result_object); - c56_l476_action_invoke(&result_object); - c57_l477_action_invoke(&result_object); - c58_l478_action_invoke(&result_object); - c59_l480_action_invoke(&result_object); - c60_l481_action_invoke(&result_object); - c61_l482_action_invoke(&result_object); - c62_l483_action_invoke(&result_object); - c63_l484_action_invoke(&result_object); - c64_l486_action_invoke(&result_object); - c65_l487_action_invoke(&result_object); - c66_l488_action_invoke(&result_object); - c67_l489_action_invoke(&result_object); - c68_l490_action_invoke(&result_object); - c69_l492_action_invoke(&result_object); - c70_l493_action_invoke(&result_object); - c71_l494_action_invoke(&result_object); - c72_l495_action_invoke(&result_object); - c73_l496_action_invoke(&result_object); - c74_l498_action_invoke(&result_object); - c75_l499_action_invoke(&result_object); - c76_l500_action_invoke(&result_object); - c77_l501_action_invoke(&result_object); - c78_l502_action_invoke(&result_object); - c79_l503_action_invoke(&result_object); - c80_l504_action_invoke(&result_object); - c81_l505_action_invoke(&result_object); - c84_l510_action_invoke(&result_object); - c85_l511_action_invoke(&result_object); - c86_l512_action_invoke(&result_object); - c87_l514_action_invoke(&result_object); - c88_l516_action_invoke(&result_object); - c89_l517_action_invoke(&result_object); - c90_l519_action_invoke(&result_object); - c91_l520_action_invoke(&result_object); - c92_l522_action_invoke(&result_object); - c93_l523_action_invoke(&result_object); - c94_l525_action_invoke(&result_object); - c95_l526_action_invoke(&result_object); - c96_l527_action_invoke(&result_object); - c97_l528_action_invoke(&result_object); - c98_l529_action_invoke(&result_object); - c99_l530_action_invoke(&result_object); - c100_l531_action_invoke(&result_object); - c101_l532_action_invoke(&result_object); + c19_l420_action_invoke(&result_object); + c20_l421_action_invoke(&result_object); + c21_l422_action_invoke(&result_object); + c22_l423_action_invoke(&result_object); + c23_l429_action_invoke(&result_object); + c24_l430_action_invoke(&result_object); + c25_l431_action_invoke(&result_object); + c26_l432_action_invoke(&result_object); + c27_l438_action_invoke(&result_object); + c28_l439_action_invoke(&result_object); + c29_l440_action_invoke(&result_object); + c30_l441_action_invoke(&result_object); + c31_l447_action_invoke(&result_object); + c32_l448_action_invoke(&result_object); + c33_l449_action_invoke(&result_object); + c34_l450_action_invoke(&result_object); + c35_l456_action_invoke(&result_object); + c36_l457_action_invoke(&result_object); + c37_l458_action_invoke(&result_object); + c38_l459_action_invoke(&result_object); + c39_l461_action_invoke(&result_object); + c40_l462_action_invoke(&result_object); + c41_l463_action_invoke(&result_object); + c42_l464_action_invoke(&result_object); + c43_l466_action_invoke(&result_object); + c44_l467_action_invoke(&result_object); + c45_l468_action_invoke(&result_object); + c46_l469_action_invoke(&result_object); + c47_l471_action_invoke(&result_object); + c48_l472_action_invoke(&result_object); + c49_l473_action_invoke(&result_object); + c50_l474_action_invoke(&result_object); + c51_l476_action_invoke(&result_object); + c52_l477_action_invoke(&result_object); + c53_l478_action_invoke(&result_object); + c54_l479_action_invoke(&result_object); + c55_l480_action_invoke(&result_object); + c56_l482_action_invoke(&result_object); + c57_l483_action_invoke(&result_object); + c58_l484_action_invoke(&result_object); + c59_l485_action_invoke(&result_object); + c60_l486_action_invoke(&result_object); + c61_l488_action_invoke(&result_object); + c62_l489_action_invoke(&result_object); + c63_l490_action_invoke(&result_object); + c64_l491_action_invoke(&result_object); + c65_l492_action_invoke(&result_object); + c66_l494_action_invoke(&result_object); + c67_l495_action_invoke(&result_object); + c68_l496_action_invoke(&result_object); + c69_l497_action_invoke(&result_object); + c70_l498_action_invoke(&result_object); + c71_l500_action_invoke(&result_object); + c72_l501_action_invoke(&result_object); + c73_l502_action_invoke(&result_object); + c74_l503_action_invoke(&result_object); + c75_l504_action_invoke(&result_object); + c76_l505_action_invoke(&result_object); + c77_l506_action_invoke(&result_object); + c78_l507_action_invoke(&result_object); + c81_l512_action_invoke(&result_object); + c82_l513_action_invoke(&result_object); + c83_l514_action_invoke(&result_object); + c84_l516_action_invoke(&result_object); + c85_l518_action_invoke(&result_object); + c86_l519_action_invoke(&result_object); + c87_l521_action_invoke(&result_object); + c88_l522_action_invoke(&result_object); + c89_l524_action_invoke(&result_object); + c90_l525_action_invoke(&result_object); + c91_l527_action_invoke(&result_object); + c92_l528_action_invoke(&result_object); + c93_l529_action_invoke(&result_object); + c94_l530_action_invoke(&result_object); + c95_l531_action_invoke(&result_object); + c96_l532_action_invoke(&result_object); + c97_l533_action_invoke(&result_object); + c98_l534_action_invoke(&result_object); } diff --git a/src/spectests/elem.rs b/src/spectests/elem.rs new file mode 100644 index 000000000..40f441b9a --- /dev/null +++ b/src/spectests/elem.rs @@ -0,0 +1,689 @@ +// Rust test file autogenerated with cargo build (src/build_spectests.rs). +// Please do NOT modify it by hand, as it will be reseted on next build. +// Test based on spectests/elem.wast +#![allow( + warnings, + dead_code +)] +use std::panic; +use wabt::wat2wasm; + +use crate::webassembly::{instantiate, compile, ImportObject, ResultObject, Instance, Export}; +use super::_common::{ + spectest_importobject, + NaNCheck, +}; + + +// Line 4 +fn create_module_1() -> ResultObject { + let module_str = "(module + (type (;0;) (func)) + (func (;0;) (type 0)) + (table (;0;) 10 anyfunc) + (elem (i32.const 0)) + (elem (i32.const 0) 0 0) + (elem (i32.const 0)) + (elem (i32.const 0) 0 0) + (elem (i32.const 0)) + (elem (i32.const 0) 0 0) + (elem (i32.const 0)) + (elem (i32.const 0) 0 0) + (elem (i32.const 0)) + (elem (i32.const 0) 0 0) + (elem (i32.const 0)) + (elem (i32.const 0) 0 0)) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +fn start_module_1(result_object: &ResultObject) { + result_object.instance.start(); +} + +// Line 23 + +#[test] +fn test_module_1() { + let result_object = create_module_1(); + // We group the calls together + start_module_1(&result_object); +} +fn create_module_2() -> ResultObject { + let module_str = "(module + (type (;0;) (func)) + (func (;0;) (type 0)) + (table (;0;) 10 anyfunc) + (elem (i32.const 0) 0)) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +fn start_module_2(result_object: &ResultObject) { + result_object.instance.start(); +} + +// Line 28 + +#[test] +fn test_module_2() { + let result_object = create_module_2(); + // We group the calls together + start_module_2(&result_object); +} +fn create_module_3() -> ResultObject { + let module_str = "(module + (type (;0;) (func)) + (import \"spectest\" \"table\" (table (;0;) 10 anyfunc)) + (func (;0;) (type 0)) + (elem (i32.const 0) 0)) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +fn start_module_3(result_object: &ResultObject) { + result_object.instance.start(); +} + +// Line 34 + +#[test] +fn test_module_3() { + let result_object = create_module_3(); + // We group the calls together + start_module_3(&result_object); +} +fn create_module_4() -> ResultObject { + let module_str = "(module + (type (;0;) (func)) + (func (;0;) (type 0)) + (table (;0;) 10 anyfunc) + (elem (i32.const 0) 0) + (elem (i32.const 3) 0) + (elem (i32.const 7) 0) + (elem (i32.const 5) 0) + (elem (i32.const 3) 0)) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +fn start_module_4(result_object: &ResultObject) { + result_object.instance.start(); +} + +// Line 43 + +#[test] +fn test_module_4() { + let result_object = create_module_4(); + // We group the calls together + start_module_4(&result_object); +} +fn create_module_5() -> ResultObject { + let module_str = "(module + (type (;0;) (func)) + (import \"spectest\" \"table\" (table (;0;) 10 anyfunc)) + (func (;0;) (type 0)) + (elem (i32.const 9) 0) + (elem (i32.const 3) 0) + (elem (i32.const 7) 0) + (elem (i32.const 3) 0) + (elem (i32.const 5) 0)) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +fn start_module_5(result_object: &ResultObject) { + result_object.instance.start(); +} + +// Line 69 + +#[test] +fn test_module_5() { + let result_object = create_module_5(); + // We group the calls together + start_module_5(&result_object); +} +fn create_module_6() -> ResultObject { + let module_str = "(module + (type (;0;) (func (result i32))) + (func (;0;) (type 0) (result i32) + i32.const 65) + (func (;1;) (type 0) (result i32) + i32.const 66) + (func (;2;) (type 0) (result i32) + i32.const 7 + call_indirect (type 0)) + (func (;3;) (type 0) (result i32) + i32.const 9 + call_indirect (type 0)) + (table (;0;) 10 anyfunc) + (export \"call-7\" (func 2)) + (export \"call-9\" (func 3)) + (elem (i32.const 7) 0) + (elem (i32.const 9) 1)) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +fn start_module_6(result_object: &ResultObject) { + result_object.instance.start(); +} + +// Line 83 +fn c6_l83_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c6_l83_action_invoke"); + let func_index = match result_object.module.info.exports.get("call-7") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&Instance) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&result_object.instance); + assert_eq!(result, 65 as i32); +} + +// Line 84 +fn c7_l84_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c7_l84_action_invoke"); + let func_index = match result_object.module.info.exports.get("call-9") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&Instance) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&result_object.instance); + assert_eq!(result, 66 as i32); +} + +// Line 88 + +#[test] +fn test_module_6() { + let result_object = create_module_6(); + // We group the calls together + start_module_6(&result_object); + c6_l83_action_invoke(&result_object); + c7_l84_action_invoke(&result_object); +} +fn create_module_7() -> ResultObject { + let module_str = "(module + (type (;0;) (func)) + (func (;0;) (type 0)) + (table (;0;) 10 anyfunc) + (elem (i32.const 9) 0)) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +fn start_module_7(result_object: &ResultObject) { + result_object.instance.start(); +} + +// Line 93 + +#[test] +fn test_module_7() { + let result_object = create_module_7(); + // We group the calls together + start_module_7(&result_object); +} +fn create_module_8() -> ResultObject { + let module_str = "(module + (type (;0;) (func)) + (import \"spectest\" \"table\" (table (;0;) 10 anyfunc)) + (func (;0;) (type 0)) + (elem (i32.const 9) 0)) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +fn start_module_8(result_object: &ResultObject) { + result_object.instance.start(); +} + +// Line 99 + +#[test] +fn test_module_8() { + let result_object = create_module_8(); + // We group the calls together + start_module_8(&result_object); +} +fn create_module_9() -> ResultObject { + let module_str = "(module + (table (;0;) 0 anyfunc) + (elem (i32.const 0))) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +fn start_module_9(result_object: &ResultObject) { + result_object.instance.start(); +} + +// Line 103 + +#[test] +fn test_module_9() { + let result_object = create_module_9(); + // We group the calls together + start_module_9(&result_object); +} +fn create_module_10() -> ResultObject { + let module_str = "(module + (import \"spectest\" \"table\" (table (;0;) 0 anyfunc)) + (elem (i32.const 0))) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +fn start_module_10(result_object: &ResultObject) { + result_object.instance.start(); +} + +// Line 108 + +#[test] +fn test_module_10() { + let result_object = create_module_10(); + // We group the calls together + start_module_10(&result_object); +} +fn create_module_11() -> ResultObject { + let module_str = "(module + (table (;0;) 0 0 anyfunc) + (elem (i32.const 0))) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +fn start_module_11(result_object: &ResultObject) { + result_object.instance.start(); +} + +// Line 113 + +#[test] +fn test_module_11() { + let result_object = create_module_11(); + // We group the calls together + start_module_11(&result_object); +} +fn create_module_12() -> ResultObject { + let module_str = "(module + (table (;0;) 20 anyfunc) + (elem (i32.const 20))) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +fn start_module_12(result_object: &ResultObject) { + result_object.instance.start(); +} + +// Line 118 + +#[test] +fn test_module_12() { + let result_object = create_module_12(); + // We group the calls together + start_module_12(&result_object); +} +fn create_module_13() -> ResultObject { + let module_str = "(module + (type (;0;) (func)) + (import \"spectest\" \"table\" (table (;0;) 0 anyfunc)) + (func (;0;) (type 0)) + (elem (i32.const 0) 0)) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +fn start_module_13(result_object: &ResultObject) { + result_object.instance.start(); +} + +// Line 124 + +#[test] +fn test_module_13() { + let result_object = create_module_13(); + // We group the calls together + start_module_13(&result_object); +} +fn create_module_14() -> ResultObject { + let module_str = "(module + (type (;0;) (func)) + (import \"spectest\" \"table\" (table (;0;) 0 100 anyfunc)) + (func (;0;) (type 0)) + (elem (i32.const 0) 0)) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +fn start_module_14(result_object: &ResultObject) { + result_object.instance.start(); +} + +// Line 130 + +#[test] +fn test_module_14() { + let result_object = create_module_14(); + // We group the calls together + start_module_14(&result_object); +} +fn create_module_15() -> ResultObject { + let module_str = "(module + (type (;0;) (func)) + (import \"spectest\" \"table\" (table (;0;) 0 anyfunc)) + (func (;0;) (type 0)) + (elem (i32.const 1) 0)) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +fn start_module_15(result_object: &ResultObject) { + result_object.instance.start(); +} + +// Line 136 + +#[test] +fn test_module_15() { + let result_object = create_module_15(); + // We group the calls together + start_module_15(&result_object); +} +fn create_module_16() -> ResultObject { + let module_str = "(module + (type (;0;) (func)) + (import \"spectest\" \"table\" (table (;0;) 0 30 anyfunc)) + (func (;0;) (type 0)) + (elem (i32.const 1) 0)) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +fn start_module_16(result_object: &ResultObject) { + result_object.instance.start(); +} + +// Line 145 + +// Line 154 + +// Line 163 + +// Line 172 + +// Line 180 + +// Line 188 + +// Line 197 + +// Line 205 + +// Line 214 + +// Line 222 + +// Line 231 + +// Line 239 + +// Line 250 +#[test] +fn c30_l250_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 9, 7, 1, 0, 65, 0, 11, 1, 0, 10, 4, 1, 2, 0, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 260 +#[test] +fn c31_l260_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 4, 4, 1, 112, 0, 1, 9, 6, 1, 0, 66, 0, 11, 0]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 268 +#[test] +fn c32_l268_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 4, 4, 1, 112, 0, 1, 9, 7, 1, 0, 65, 0, 104, 11, 0]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 276 +#[test] +fn c33_l276_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 4, 4, 1, 112, 0, 1, 9, 5, 1, 0, 1, 11, 0]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 284 +#[test] +fn c34_l284_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 4, 4, 1, 112, 0, 1, 9, 7, 1, 0, 1, 65, 0, 11, 0]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 292 +#[test] +fn c35_l292_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 4, 4, 1, 112, 0, 1, 9, 7, 1, 0, 65, 0, 1, 11, 0]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 307 + +#[test] +fn test_module_16() { + let result_object = create_module_16(); + // We group the calls together + start_module_16(&result_object); +} +fn create_module_17() -> ResultObject { + let module_str = "(module + (type (;0;) (func (result i32))) + (func (;0;) (type 0) (result i32) + i32.const 65) + (func (;1;) (type 0) (result i32) + i32.const 66) + (func (;2;) (type 0) (result i32) + i32.const 9 + call_indirect (type 0)) + (table (;0;) 10 anyfunc) + (export \"call-overwritten\" (func 2)) + (elem (i32.const 9) 0) + (elem (i32.const 9) 1)) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +fn start_module_17(result_object: &ResultObject) { + result_object.instance.start(); +} + +// Line 318 +fn c37_l318_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c37_l318_action_invoke"); + let func_index = match result_object.module.info.exports.get("call-overwritten") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&Instance) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&result_object.instance); + assert_eq!(result, 66 as i32); +} + +// Line 320 + +#[test] +fn test_module_17() { + let result_object = create_module_17(); + // We group the calls together + start_module_17(&result_object); + c37_l318_action_invoke(&result_object); +} +fn create_module_18() -> ResultObject { + let module_str = "(module + (type (;0;) (func (result i32))) + (import \"spectest\" \"table\" (table (;0;) 10 anyfunc)) + (func (;0;) (type 0) (result i32) + i32.const 65) + (func (;1;) (type 0) (result i32) + i32.const 66) + (func (;2;) (type 0) (result i32) + i32.const 9 + call_indirect (type 0)) + (export \"call-overwritten-element\" (func 2)) + (elem (i32.const 9) 0) + (elem (i32.const 9) 1)) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +fn start_module_18(result_object: &ResultObject) { + result_object.instance.start(); +} + +// Line 331 +fn c39_l331_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c39_l331_action_invoke"); + let func_index = match result_object.module.info.exports.get("call-overwritten-element") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&Instance) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&result_object.instance); + assert_eq!(result, 66 as i32); +} + +// Line 335 + +#[test] +fn test_module_18() { + let result_object = create_module_18(); + // We group the calls together + start_module_18(&result_object); + c39_l331_action_invoke(&result_object); +} +fn create_module_19() -> ResultObject { + let module_str = "(module + (type (;0;) (func (result i32))) + (func (;0;) (type 0) (result i32) + i32.const 65) + (func (;1;) (type 0) (result i32) + i32.const 66) + (func (;2;) (type 0) (result i32) + i32.const 7 + call_indirect (type 0)) + (func (;3;) (type 0) (result i32) + i32.const 8 + call_indirect (type 0)) + (func (;4;) (type 0) (result i32) + i32.const 9 + call_indirect (type 0)) + (table (;0;) 10 anyfunc) + (export \"shared-table\" (table 0)) + (export \"call-7\" (func 2)) + (export \"call-8\" (func 3)) + (export \"call-9\" (func 4)) + (elem (i32.const 8) 0) + (elem (i32.const 9) 1)) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +fn start_module_19(result_object: &ResultObject) { + result_object.instance.start(); +} + +// Line 353 + +// Line 360 + +#[test] +fn test_module_19() { + let result_object = create_module_19(); + // We group the calls together + start_module_19(&result_object); +} +fn create_module_20() -> ResultObject { + let module_str = "(module + (type (;0;) (func (result i32))) + (import \"module1\" \"shared-table\" (table (;0;) 10 anyfunc)) + (func (;0;) (type 0) (result i32) + i32.const 67) + (func (;1;) (type 0) (result i32) + i32.const 68) + (elem (i32.const 7) 0) + (elem (i32.const 8) 1)) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +fn start_module_20(result_object: &ResultObject) { + result_object.instance.start(); +} + +// Line 374 + +#[test] +fn test_module_20() { + let result_object = create_module_20(); + // We group the calls together + start_module_20(&result_object); +} +fn create_module_21() -> ResultObject { + let module_str = "(module + (type (;0;) (func (result i32))) + (import \"module1\" \"shared-table\" (table (;0;) 10 anyfunc)) + (func (;0;) (type 0) (result i32) + i32.const 69) + (func (;1;) (type 0) (result i32) + i32.const 70) + (elem (i32.const 8) 0) + (elem (i32.const 9) 1)) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +fn start_module_21(result_object: &ResultObject) { + result_object.instance.start(); +} + +#[test] +fn test_module_21() { + let result_object = create_module_21(); + // We group the calls together + start_module_21(&result_object); +} diff --git a/src/spectests/mod.rs b/src/spectests/mod.rs index 16387f012..e68af8f55 100644 --- a/src/spectests/mod.rs +++ b/src/spectests/mod.rs @@ -20,6 +20,7 @@ mod const_; mod conversions; mod custom; mod data; +mod elem; mod endianness; mod exports; #[cfg(not(feature = "fast-tests"))] diff --git a/src/webassembly/import_object.rs b/src/webassembly/import_object.rs index b5faf47b4..7e7411d29 100644 --- a/src/webassembly/import_object.rs +++ b/src/webassembly/import_object.rs @@ -6,12 +6,13 @@ use std::borrow::Borrow; use std::collections::HashMap; use std::hash::{Hash, Hasher}; +use crate::webassembly::LinearMemory; // We introduced the Pair and BorrowedPair types. We can't use (A, B) // directly due to the orphan rule E0210. This is fine since the map // is an implementation detail. #[derive(PartialEq, Eq, Hash)] -struct Pair(A, B); +pub struct Pair(pub A, pub B); #[derive(PartialEq, Eq, Hash)] struct BorrowedPair<'a, 'b, A: 'a, B: 'b>(&'a A, &'b B); @@ -63,7 +64,7 @@ impl<'a, A: Eq, B: Eq> Eq for (KeyPair + 'a) {} // OP's ImportObject struct pub struct ImportObject { - map: HashMap, *const u8>, + pub map: HashMap, ImportValue>, } impl ImportObject { @@ -73,13 +74,12 @@ impl ImportObject { } } - pub fn get(&self, a: &A, b: &B) -> Option<*const u8> { + pub fn get(&self, a: &A, b: &B) -> Option<&ImportValue> { self.map .get(&BorrowedPair(a, b) as &KeyPair) - .map(|p| *p) } - pub fn set(&mut self, a: A, b: B, v: *const u8) { + pub fn set(&mut self, a: A, b: B, v: ImportValue) { self.map.insert(Pair(a, b), v); } } @@ -109,18 +109,24 @@ where } } +#[derive(PartialEq, Debug)] +pub enum ImportValue { + Func(*const u8), + Global(u8), + Table(Vec), + Memory(LinearMemory), +} + #[cfg(test)] mod tests { use super::ImportObject; + use super::ImportValue; #[test] fn test_import_object() { fn x() {} let mut import_object = ImportObject::new(); - import_object.set("abc", "def", x as *const u8); - // import_object.set("123"), A("456"), 45.0); - assert_eq!(import_object.get(&"abc", &"def").unwrap(), x as *const u8); - // assert_eq!(import_object.get(&"abc", &"dxf"), 4.0); - // assert_eq!(import_object.get(&A("123"), &A("456")), 45.0); + import_object.set("abc", "def", ImportValue::Func(x as *const u8)); + assert_eq!(*import_object.get(&"abc", &"def").unwrap(), ImportValue::Func(x as *const u8)); } } diff --git a/src/webassembly/instance.rs b/src/webassembly/instance.rs index 4d72b8817..3e3f4fb17 100644 --- a/src/webassembly/instance.rs +++ b/src/webassembly/instance.rs @@ -15,15 +15,20 @@ use std::iter::Iterator; use std::ptr::write_unaligned; use std::slice; use std::sync::Arc; +use std::mem::size_of; use super::super::common::slice::{BoundedSlice, UncheckedSlice}; use super::errors::ErrorKind; -use super::import_object::ImportObject; +use super::import_object::{ImportObject, ImportValue}; use super::memory::LinearMemory; use super::module::Export; use super::module::Module; use super::relocation::{Reloc, RelocSink, RelocationType}; +type TablesSlice = UncheckedSlice>; +type MemoriesSlice = UncheckedSlice>; +type GlobalsSlice = UncheckedSlice; + pub fn protect_codebuf(code_buf: &Vec) -> Result<(), String> { match unsafe { region::protect( @@ -57,28 +62,15 @@ fn get_function_addr( func_pointer } -// TODO: To be removed. -// #[derive(Debug)] -// #[repr(C, packed)] -// pub struct VmCtx<'phantom> { -// pub user_data: UserData, -// globals: UncheckedSlice, -// memories: UncheckedSlice>, -// tables: UncheckedSlice>, -// phantom: PhantomData<&'phantom ()>, -// } - -// // TODO: To be removed. -// #[derive(Debug)] -// #[repr(C, packed)] -// pub struct UserData { -// // pub process: Dispatch, -// pub instance: Instance, -// } - /// An Instance of a WebAssembly module +/// NOTE: There is an assumption that data_pointers is always the +/// first field +#[repr(C)] #[derive(Debug)] pub struct Instance { + // C-like pointers to data (heaps, globals, tables) + pub data_pointers: DataPointers, + /// WebAssembly table data // pub tables: Arc>>>, pub tables: Arc>>, @@ -100,41 +92,62 @@ pub struct Instance { pub start_func: Option, // Region start memory location // code_base: *const (), - - // C-like pointers to data (heaps, globals, tables) - pub data_pointers: DataPointers, - - // Default memory bound - // TODO: Support for only one LinearMemory for now. - pub default_memory_bound: i32, } /// Contains pointers to data (heaps, globals, tables) needed /// by Cranelift. +/// NOTE: Rearranging the fields will break the memory arrangement model +#[repr(C)] #[derive(Debug)] pub struct DataPointers { // Pointer to tables - pub tables: UncheckedSlice>, + pub tables: TablesSlice, // Pointer to memories - pub memories: UncheckedSlice>, + pub memories: MemoriesSlice, // Pointer to globals - pub globals: UncheckedSlice, + pub globals: GlobalsSlice, + } impl Instance { + pub const TABLES_OFFSET: usize = 0; // 0 on 64-bit | 0 on 32-bit + pub const MEMORIES_OFFSET: usize = size_of::(); // 8 on 64-bit | 4 on 32-bit + pub const GLOBALS_OFFSET: usize = Instance::MEMORIES_OFFSET + size_of::(); // 16 on 64-bit | 8 on 32-bit + /// Create a new `Instance`. + /// TODO: Raise an error when expected import is not part of imported object + /// Also make sure imports that are not declared do not get added to the instance pub fn new( module: &Module, - import_object: &ImportObject<&str, &str>, + import_object: ImportObject<&str, &str>, ) -> Result { let mut tables: Vec> = Vec::new(); let mut memories: Vec = Vec::new(); let mut globals: Vec = Vec::new(); + let mut functions: Vec> = Vec::new(); let mut import_functions: Vec<*const u8> = Vec::new(); - // let mut code_base: *const () = ptr::null(); + + let mut imported_functions: Vec<((&str, &str), *const u8)> = Vec::new(); + let mut imported_tables: Vec<((&str, &str), Vec)> = Vec::new(); + let mut imported_memories: Vec<((&str, &str), LinearMemory)> = Vec::new(); + let mut imported_globals: Vec<((&str, &str), u8)> = Vec::new(); + + // Looping through and getting the imported objects + for (key, value) in import_object.map { + match value { + ImportValue::Memory(value) => + imported_memories.push(((key.0, key.1), value)), + ImportValue::Table(value) => + imported_tables.push(((key.0, key.1), value)), + ImportValue::Global(value) => + imported_globals.push(((key.0, key.1), value)), + ImportValue::Func(value) => + imported_functions.push(((key.0, key.1), value)), + } + } debug!("Instance - Instantiating functions"); // Instantiate functions @@ -145,19 +158,14 @@ impl Instance { .finish(module.info.flags.clone()); let mut relocations = Vec::new(); - // We walk through the imported functions and set the relocations - // for each of this functions to be an empty vector (as is defined outside of wasm) + // Walk through the imported functions and set the relocations + // TODO: Needs to be optimize the find part. + // I also think it relies on the order of import declaration in module for (module, field) in module.info.imported_funcs.iter() { - let function = import_object - .get(&module.as_str(), &field.as_str()) - .ok_or_else(|| { - ErrorKind::LinkError(format!( - "Imported function {}.{} was not provided in the import_functions", - module, field - )) - })?; - // println!("GET FUNC {:?}", function); - import_functions.push(function); + let function = + imported_functions.iter().find(|(key, _value)| key.0 == module && key.1 == field) + .unwrap_or_else(|| panic!("Imported function {}.{} was not provided in the import_functions", module, field)); + import_functions.push(function.1); relocations.push(vec![]); } @@ -268,61 +276,35 @@ impl Instance { } } } - - // We only want to allocate in memory if there is more than - // 0 functions. Otherwise reserving a 0-sized memory region - // cause a panic error - // if total_size > 0 { - // // Allocate the total memory for this functions - // // let map = MmapMut::map_anon(total_size).unwrap(); - // // let region_start = map.as_ptr() as usize; - // // code_base = map.as_ptr() as *const (); - - // // // Emit this functions to memory - // for (ref func_context, func_offset) in context_and_offsets.iter() { - // let mut trap_sink = TrapSink::new(*func_offset); - // let mut reloc_sink = RelocSink::new(); - // let mut code_buf: Vec = Vec::new(); - - // // let mut func_pointer = as *mut u8; - // unsafe { - // func_context.emit_to_memory( - // &*isa, - // &mut code_buf, - // &mut reloc_sink, - // &mut trap_sink, - // ); - // }; - // let func_offset = code_buf.as_ptr() as usize; - // functions.push(*func_offset); - // } - - // // Set protection of this memory region to Read + Execute - // // so we are able to execute the functions emitted to memory - // // unsafe { - // // region::protect(region_start as *mut u8, total_size, region::Protection::ReadExecute) - // // .expect("unable to make memory readable+executable"); - // // } - // } } debug!("Instance - Instantiating tables"); // Instantiate tables { - // Reserve table space - tables.reserve_exact(module.info.tables.len()); + // Reserve space for tables + tables.reserve_exact(imported_tables.len() + module.info.tables.len()); + + // Get imported tables + for (_key, table) in imported_tables { + tables.push(table); + } + + // Get tables in module for table in &module.info.tables { let len = table.entity.size; let mut v = Vec::with_capacity(len); v.resize(len, 0); tables.push(v); } + // instantiate tables for table_element in &module.info.table_elements { + // TODO: We shouldn't assert here since we are returning a Result assert!( table_element.base.is_none(), "globalvalue base not supported yet." ); + let base = 0; let table = &mut tables[table_element.table_index]; @@ -342,22 +324,24 @@ impl Instance { debug!("Instance - Instantiating memories"); // Instantiate memories { - // Allocate the underlying memory and initialize it to all zeros. - let total_memories = module.info.memories.len(); - if total_memories > 0 { - memories.reserve_exact(total_memories); - for memory in &module.info.memories { - let memory = memory.entity; - let v = LinearMemory::new( - memory.pages_count as u32, - memory.maximum.map(|m| m as u32), - ); - memories.push(v); - } - } else { - memories.reserve_exact(1); - memories.push(LinearMemory::new(0, None)); + // Reserve space for memories + memories.reserve_exact(imported_memories.len() + module.info.memories.len()); + + // Get imported memories + for (_key, memory) in imported_memories { + memories.push(memory); } + + // Get memories in module + for memory in &module.info.memories { + let memory = memory.entity; + let v = LinearMemory::new( + memory.pages_count as u32, + memory.maximum.map(|m| m as u32), + ); + memories.push(v); + } + for init in &module.info.data_initializers { debug_assert!(init.base.is_none(), "globalvar base not supported yet"); let offset = init.offset; @@ -368,6 +352,7 @@ impl Instance { } debug!("Instance - Instantiating globals"); + // TODO: Fix globals import // Instantiate Globals { let globals_count = module.info.globals.len(); @@ -379,6 +364,7 @@ impl Instance { let globals_data = unsafe { slice::from_raw_parts_mut(globals.as_mut_ptr() as *mut i64, globals_count) }; + for (i, global) in module.info.globals.iter().enumerate() { let value: i64 = match global.entity.initializer { GlobalInit::I32Const(n) => n as _, @@ -412,9 +398,11 @@ impl Instance { // TODO: Refactor repetitive code let tables_pointer: Vec> = tables.iter().map(|table| table[..].into()).collect(); - let memories_pointer: Vec> = - memories.iter().map(|mem| mem[..].into()).collect(); - let globals_pointer: UncheckedSlice = globals[..].into(); + let memories_pointer: Vec> = + memories.iter().map( + |mem| BoundedSlice::new(&mem[..], mem.current as usize * LinearMemory::WASM_PAGE_SIZE), + ).collect(); + let globals_pointer: GlobalsSlice = globals[..].into(); let data_pointers = DataPointers { memories: memories_pointer[..].into(), @@ -422,18 +410,16 @@ impl Instance { tables: tables_pointer[..].into(), }; - let default_memory_bound = LinearMemory::WASM_PAGE_SIZE as i32; + // let mem = data_pointers.memories; Ok(Instance { + data_pointers, tables: Arc::new(tables.into_iter().collect()), // tables.into_iter().map(|table| RwLock::new(table)).collect()), memories: Arc::new(memories.into_iter().collect()), globals, functions, import_functions, start_func, - data_pointers, - default_memory_bound, - // code_base: code_base, }) } @@ -461,37 +447,6 @@ impl Instance { } } - // TODO: To be removed. - // pub fn generate_context(&self) -> VmCtx { - // let memories: Vec> = - // self.memories.iter().map(|mem| mem[..].into()).collect(); - // let tables: Vec> = - // self.tables.iter().map(|table| table[..].into()).collect(); - // let globals: UncheckedSlice = self.globals[..].into(); - - // // println!("GENERATING CONTEXT {:?}", self.globals); - - // // assert!(memories.len() >= 1, "modules must have at least one memory"); - // // the first memory has a space of `mem::size_of::()` rounded - // // up to the 4KiB before it. We write the VmCtxData into that. - // let instance = self.clone(); - // VmCtx { - // globals: globals, - // memories: memories[..].into(), - // tables: tables[..].into(), - // user_data: UserData { - // // process, - // instance: instance, - // }, - // phantom: PhantomData, - // } - // // let main_heap_ptr = memories[0].as_mut_ptr() as *mut VmCtxData; - // // unsafe { - // // main_heap_ptr.sub(1).write(data); - // // &*(main_heap_ptr as *const VmCtx) - // // } - // } - /// Returns a slice of the contents of allocated linear memory. pub fn inspect_memory(&self, memory_index: usize, address: usize, len: usize) -> &[u8] { &self @@ -513,46 +468,6 @@ impl Instance { // } } -impl Clone for Instance { - fn clone(&self) -> Instance { - // TODO: Refactor repetitive code - let tables_pointer: Vec> = - self.tables.iter().map(|table| table[..].into()).collect(); - let memories_pointer: Vec> = - self.memories.iter().map(|mem| mem[..].into()).collect(); - let globals_pointer: UncheckedSlice = self.globals[..].into(); - - let data_pointers = DataPointers { - memories: memories_pointer[..].into(), - globals: globals_pointer, - tables: tables_pointer[..].into(), - }; - - let default_memory_bound = self.memories.get(0).unwrap().current as i32; - - Instance { - tables: Arc::clone(&self.tables), - memories: Arc::clone(&self.memories), - globals: self.globals.clone(), - functions: self.functions.clone(), - start_func: self.start_func.clone(), - import_functions: self.import_functions.clone(), - data_pointers, - default_memory_bound, - // code_base: self.code_base, - } - } -} - -/// TODO: -/// Need to improve how memories are stored and grown. -/// Dynamic memory is inefficient both for growing and for access -/// Cranelift's dynamic heap assumes a _statically-known_ number of LinearMemories, -/// because it expects a corresponding global variable for each LinearMemory -/// -/// Reference: -/// - https://cranelift.readthedocs.io/en/latest/ir.html?highlight=vmctx#heap-examples, -/// extern "C" fn grow_memory(size: u32, memory_index: u32, instance: &mut Instance) -> i32 { // TODO: Support for only one LinearMemory for now. debug_assert_eq!( @@ -565,31 +480,13 @@ extern "C" fn grow_memory(size: u32, memory_index: u32, instance: &mut Instance) .grow(size) .unwrap_or(i32::max_value()); // Should be -1 ? - // Update the default_memory_bound - instance.default_memory_bound = - (instance.memories.get(0).unwrap().current as usize * LinearMemory::WASM_PAGE_SIZE) as i32; + // Get new memory bytes + let new_mem_bytes = (old_mem_size as usize + size as usize) * LinearMemory::WASM_PAGE_SIZE; - // The grown memory changed so data_pointers need to be updated as well. - // TODO: Refactor repetitive code - let tables_pointer: Vec> = instance - .tables - .iter() - .map(|table| table[..].into()) - .collect(); - let memories_pointer: Vec> = - instance.memories.iter().map(|mem| mem[..].into()).collect(); - let globals_pointer: UncheckedSlice = instance.globals[..].into(); + // Update data_pointer + instance.data_pointers.memories.get_unchecked_mut(memory_index as usize).len = new_mem_bytes; - let data_pointers = DataPointers { - memories: memories_pointer[..].into(), - globals: globals_pointer, - tables: tables_pointer[..].into(), - }; - - // Update data_pointers - instance.data_pointers = data_pointers; - - return old_mem_size; + old_mem_size } extern "C" fn current_memory(memory_index: u32, instance: &mut Instance) -> u32 { diff --git a/src/webassembly/memory.rs b/src/webassembly/memory.rs index 5330a60f3..3640e182f 100644 --- a/src/webassembly/memory.rs +++ b/src/webassembly/memory.rs @@ -12,8 +12,6 @@ const MAX_PAGES: u32 = 65536; /// A linear memory instance. /// -/// This linear memory has a stable base address and at the same time allows -/// for dynamical growing. pub struct LinearMemory { pub mmap: MmapMut, // The initial size of the WebAssembly Memory, in units of @@ -25,7 +23,7 @@ pub struct LinearMemory { // front. However, the engine may ignore or clamp this reservation // request. In general, most WebAssembly modules shouldn't need // to set a maximum. - maximum: Option, + pub maximum: Option, } /// It holds the raw bytes of memory accessed by a WebAssembly Instance @@ -33,7 +31,7 @@ impl LinearMemory { pub const WASM_PAGE_SIZE: usize = 1 << 16; // 64 KiB pub const DEFAULT_HEAP_SIZE: usize = 1 << 32; // 4 GiB pub const DEFAULT_GUARD_SIZE: usize = 1 << 31; // 2 GiB - pub const DEFAULT_SIZE: usize = Self::DEFAULT_HEAP_SIZE + Self::DEFAULT_GUARD_SIZE; // 8GiB + pub const DEFAULT_SIZE: usize = Self::DEFAULT_HEAP_SIZE + Self::DEFAULT_GUARD_SIZE; // 6 GiB /// Create a new linear memory instance with specified initial and maximum number of pages. /// @@ -46,13 +44,9 @@ impl LinearMemory { initial, maximum ); - let len: u64 = PAGE_SIZE as u64 * match maximum { - Some(val) => val as u64, - None => initial as u64, - }; - let len = if len == 0 { PAGE_SIZE as u64 } else { len }; + // TODO: Investigate if memory is zeroed out + let mmap = MmapMut::map_anon(LinearMemory::DEFAULT_HEAP_SIZE).unwrap(); - let mmap = MmapMut::map_anon(len as usize).unwrap(); debug!("LinearMemory instantiated"); Self { mmap, @@ -101,34 +95,11 @@ impl LinearMemory { // Updating self.mmap if new_bytes > prev_bytes if new_bytes > prev_bytes { - // If we have no maximum, this is a "dynamic" heap, and it's allowed - // to move. - let mut new_mmap = MmapMut::map_anon(new_bytes).unwrap(); - - // Copy old mem to new mem. Will a while loop be faster or is this going to be optimized? - // TODO: Consider static heap for efficiency. - for i in 0..prev_bytes { - unsafe { - let new_mmap_index = new_mmap.get_unchecked_mut(i); - let old_mmap_index = self.mmap.get_unchecked(i); - *new_mmap_index = *old_mmap_index; - } - } - - // Zero out the remaining mem region - // TODO: Check if memmap zeroes out everything by default. This is very inefficient! - for i in prev_bytes..new_bytes { - unsafe { - let index = new_mmap.get_unchecked_mut(i); - *index = 0; - } - } - // Update relevant fields - self.mmap = new_mmap; - self.current = new_pages; debug!("new memory = {:?}", self.mmap); } + self.current = new_pages; + Some(prev_pages as i32) } @@ -155,6 +126,14 @@ impl fmt::Debug for LinearMemory { } } +// Not comparing based on memory content. That would be inefficient. +impl PartialEq for LinearMemory { + fn eq(&self, other: &LinearMemory) -> bool { + self.current == other.current && + self.maximum == other.maximum + } +} + impl AsRef<[u8]> for LinearMemory { fn as_ref(&self) -> &[u8] { &self.mmap diff --git a/src/webassembly/mod.rs b/src/webassembly/mod.rs index c3b893bd7..6ca420e27 100644 --- a/src/webassembly/mod.rs +++ b/src/webassembly/mod.rs @@ -12,7 +12,7 @@ use target_lexicon; use wasmparser; pub use self::errors::{Error, ErrorKind}; -pub use self::import_object::ImportObject; +pub use self::import_object::{ImportObject, ImportValue}; pub use self::instance::{Instance}; pub use self::memory::LinearMemory; pub use self::module::{Export, Module, ModuleInfo}; @@ -46,7 +46,7 @@ pub fn instantiate( ) -> Result { let module = compile(buffer_source)?; debug!("webassembly - creating instance"); - let instance = Instance::new(&module, &import_object)?; + let instance = Instance::new(&module, import_object)?; debug!("webassembly - instance created"); Ok(ResultObject { module, instance }) } @@ -78,7 +78,6 @@ pub fn compile(buffer_source: Vec) -> Result { if !valid { return Err(ErrorKind::CompileError("Module not valid".to_string())); } - debug!("webassembly - creating module"); let module = Module::from_bytes(buffer_source, triple!("x86_64"), None)?; debug!("webassembly - module created"); diff --git a/src/webassembly/module.rs b/src/webassembly/module.rs index bef367ac7..acc91a339 100644 --- a/src/webassembly/module.rs +++ b/src/webassembly/module.rs @@ -37,6 +37,7 @@ use cranelift_wasm::{ use super::errors::ErrorKind; use super::memory::LinearMemory; +use super::instance::Instance; /// Compute a `ir::ExternalName` for a given wasm function index. fn get_func_name(func_index: FuncIndex) -> ir::ExternalName { @@ -44,6 +45,7 @@ fn get_func_name(func_index: FuncIndex) -> ir::ExternalName { } /// A collection of names under which a given entity is exported. +#[derive(Debug)] pub struct Exportable { /// An entity. pub entity: T, @@ -74,6 +76,7 @@ pub enum Export { Global(GlobalIndex), } +/// TODO: Need to get rid of unused field /// The main state belonging to a `Module`. This is split out from /// `Module` to allow it to be borrowed separately from the /// `FuncTranslator` field. @@ -92,20 +95,21 @@ pub struct ModuleInfo { /// Signatures as provided by `declare_signature`. pub signatures: Vec, - /// Module and field names of imported functions as provided by `declare_func_import`. - pub imported_funcs: Vec<(String, String)>, - /// Functions, imported and local. pub functions: PrimaryMap>, /// Function bodies. pub function_bodies: PrimaryMap, + /// Module and field names of imported functions as provided by `declare_func_import`. + pub imported_funcs: Vec<(String, String)>, + /// Tables as provided by `declare_table`. pub tables: Vec>, /// WebAssembly table initializers. pub table_elements: Vec, + /// The base of tables. pub tables_base: Option, @@ -143,9 +147,9 @@ impl ModuleInfo { triple, flags, signatures: Vec::new(), - imported_funcs: Vec::new(), functions: PrimaryMap::new(), function_bodies: PrimaryMap::new(), + imported_funcs: Vec::new(), tables: Vec::new(), memories: Vec::new(), globals: Vec::new(), @@ -328,142 +332,121 @@ impl<'environment> FuncEnvironmentTrait for FuncEnvironment<'environment> { &self.mod_info.flags } + // TODO: offsets should be based on the architecture the wasmer was compiled for. + // e.g., BoundedSlice.len will be 32-bit (4 bytes) when wasmer is compiled for a 32-bit arch, + // however the 32-bit wasmer may be running on 64-bit arch, which means ptr_size here will + // be 8 bytes. That will definitely gove the wrong offset values fn make_table(&mut self, func: &mut ir::Function, table_index: TableIndex) -> ir::Table { - let vmctx = func.create_global_value(ir::GlobalValueData::VMContext); + let instance = func.create_global_value(ir::GlobalValueData::VMContext); let ptr_size = self.ptr_size(); - // Given a vmctx, we want to retrieve vmctx.tables - // Create a table whose base address is stored at `vmctx+88`. - // 88 is the offset of the vmctx.tables pointer respect to vmctx pointer + // Load value at (instance + TABLES_OFFSET) + // which is the address of data_pointer.tables let base = func.create_global_value(ir::GlobalValueData::Load { - base: vmctx, - offset: Offset32::new(88), + base: instance, + offset: Offset32::new(Instance::TABLES_OFFSET as i32), global_type: self.pointer_type(), }); - // This will be 0 when the index is 0, not sure if the offset will work regardless + // Offset based on table_index let table_data_offset = (table_index as usize * ptr_size * 2) as i32; - // We get the pointer for our table index + // Load value at the (base + table_data_offset) + // which is the address of data_pointer.tables[index].data let base_gv = func.create_global_value(ir::GlobalValueData::Load { - base: base, + base, offset: Offset32::new(table_data_offset), global_type: self.pointer_type(), }); + // Load value at the (base + table_data_offset) + // which is the value of data_pointer.tables[index].len let bound_gv = func.create_global_value(ir::GlobalValueData::Load { - base: base, - offset: Offset32::new(table_data_offset), - global_type: I64, + base, + offset: Offset32::new(table_data_offset + ptr_size as i32), + global_type: self.pointer_type(), }); + // Create table based on the data above let table = func.create_table(ir::TableData { - base_gv: base_gv, + base_gv, min_size: Imm64::new(0), bound_gv, element_size: Imm64::new(i64::from(self.pointer_bytes())), index_type: self.pointer_type(), }); - // println!("FUNC {:?}", func); + table } - fn make_heap(&mut self, func: &mut ir::Function, index: MemoryIndex) -> ir::Heap { - // Create a static heap whose base address is stored at `vmctx+96`. - let vmctx = func.create_global_value(ir::GlobalValueData::VMContext); + // TODO: offsets should be based on the architecture the wasmer was compiled for. + // e.g., BoundedSlice.len will be 32-bit (4 bytes) when wasmer is compiled for a 32-bit arch, + // however the 32-bit wasmer may be running on 64-bit arch, which means ptr_size here will + // be 8 bytes. That will definitely gove the wrong offset values + fn make_heap(&mut self, func: &mut ir::Function, memory_index: MemoryIndex) -> ir::Heap { + let instance = func.create_global_value(ir::GlobalValueData::VMContext); + let ptr_size = self.ptr_size(); - let heap_base_addr = func.create_global_value(ir::GlobalValueData::Load { - base: vmctx, - offset: Offset32::new(96), + // Load value at (instance + MEMORIES_OFFSET) + // which is the address of data_pointer.memories + let base = func.create_global_value(ir::GlobalValueData::Load { + base: instance, + offset: Offset32::new(Instance::MEMORIES_OFFSET as i32), global_type: self.pointer_type(), }); - let pointer_bytes = self.pointer_bytes(); - let memories_offset = (index * pointer_bytes as usize) as i32; + // Based on the index provided, we need to know the offset into memories array + // Each element in the memories array has a size of (ptr_size * 2) + let memory_data_offset = (memory_index as usize * ptr_size * 2) as i32; - // We de-reference the vm_context.memories addr + // Load value at the (base + memory_data_offset) + // which is the address of data_pointer.memories[index].data let heap_base = func.create_global_value(ir::GlobalValueData::Load { - base: heap_base_addr, - offset: Offset32::new(memories_offset), + base, + offset: Offset32::new(memory_data_offset), global_type: self.pointer_type(), }); + // Load value at the (base + memory_data_offset) + // which is the value of data_pointer.memories[index].len let bound_gv = func.create_global_value(ir::GlobalValueData::Load { - base: vmctx, - offset: Offset32::new(120), + base, + offset: Offset32::new(memory_data_offset + ptr_size as i32), global_type: I32, }); - func.create_heap(ir::HeapData { + // Create table based on the data above + let heap = func.create_heap(ir::HeapData { base: heap_base, - min_size: Imm64::new(0), - guard_size: Imm64::new(LinearMemory::DEFAULT_GUARD_SIZE as i64), + min_size: 0.into(), + guard_size: (LinearMemory::DEFAULT_GUARD_SIZE as i64).into(), style: ir::HeapStyle::Dynamic { bound_gv, }, - index_type: I32, - }) + index_type: I32 + }); - // if index == 0 { - // let heap_base = self.main_memory_base.unwrap_or_else(|| { - // let new_base = func.create_global_value(ir::GlobalValueData::VMContext { - // offset: 0.into(), - // }); - // self.main_memory_base = Some(new_base); - // new_base - // }); - - // func.create_heap(ir::HeapData { - // base: heap_base, - // min_size: 0.into(), - // guard_size: (WasmMemory::DEFAULT_GUARD_SIZE as i64).into(), - // style: ir::HeapStyle::Static { - // bound: (WasmMemory::DEFAULT_HEAP_SIZE as i64).into(), - // }, - // }) - // } else { - // let memory_base = self.memory_base.unwrap_or_else(|| { - // let memories_offset = self.ptr_size() as i32 * -2; - // let new_base = func.create_global_value(ir::GlobalValueData::VMContext { - // offset: memories_offset.into(), - // }); - // self.memory_base = Some(new_base); - // new_base - // }); - - // let memory_offset = (index - 1) * self.ptr_size(); - // let heap_base = func.create_global_value(ir::GlobalValueData::Deref { - // base: memory_base, - // offset: (memory_offset as i32).into(), - // }); - - // func.create_heap(ir::HeapData { - // base: heap_base, - // min_size: 0.into(), - // guard_size: (WasmMemory::DEFAULT_GUARD_SIZE as i64).into(), - // style: ir::HeapStyle::Static { - // bound: (WasmMemory::DEFAULT_HEAP_SIZE as i64).into(), - // }, - // }) - // } + heap } fn make_global(&mut self, func: &mut ir::Function, index: GlobalIndex) -> GlobalVariable { - // Just create a dummy `vmctx` global. - let vmctx = func.create_global_value(ir::GlobalValueData::VMContext); + let ptr_size = self.ptr_size(); + + let instance = func.create_global_value(ir::GlobalValueData::VMContext); let globals_base_addr = func.create_global_value(ir::GlobalValueData::Load { - base: vmctx, - offset: Offset32::new(104), + base: instance, + offset: Offset32::new(Instance::GLOBALS_OFFSET as i32), global_type: self.pointer_type(), }); - let offset = (index * 8) as i64; + let offset = (index * ptr_size) as i64; let iadd = func.create_global_value(ir::GlobalValueData::IAddImm { base: globals_base_addr, offset: Imm64::new(offset), global_type: self.pointer_type(), }); + GlobalVariable::Memory { gv: iadd, ty: self.mod_info.globals[index].entity.ty, @@ -538,8 +521,6 @@ impl<'environment> FuncEnvironmentTrait for FuncEnvironment<'environment> { .CallIndirect(ir::Opcode::CallIndirect, INVALID, sig_ref, args) .0; - // println!("FUNC {:?}", pos.func); - Ok(inst) } @@ -723,7 +704,6 @@ impl<'data> ModuleEnvironment<'data> for Module { offset: usize, elements: Vec, ) { - // NEW debug_assert!(base.is_none(), "global-value offsets not supported yet"); self.info.table_elements.push(TableElements { table_index, diff --git a/src/webassembly/utils.rs b/src/webassembly/utils.rs index 955b1ddc7..f481ecc93 100644 --- a/src/webassembly/utils.rs +++ b/src/webassembly/utils.rs @@ -9,31 +9,42 @@ pub fn is_wasm_binary(binary: &Vec) -> bool { pub fn print_instance_offsets(instance: &Instance) { let instance_address = instance as *const _ as usize; + let data_ptr = &instance.data_pointers; let tables_pointer_address_ptr: *const usize = - unsafe { transmute(&instance.data_pointers.tables) }; + unsafe { transmute(&data_ptr.tables) }; let tables_pointer_address = tables_pointer_address_ptr as usize; let memories_pointer_address_ptr: *const usize = - unsafe { transmute(&instance.data_pointers.memories) }; + unsafe { transmute(&data_ptr.memories) }; let memories_pointer_address = memories_pointer_address_ptr as usize; - let globals_pointer_address_ptr: *const usize = - unsafe { transmute(&instance.data_pointers.globals) }; - let globals_pointer_address = globals_pointer_address_ptr as usize; + let memories_pointer_address_ptr_0: *const usize = + unsafe { transmute(&data_ptr.memories.get_unchecked(0)) }; + let memories_pointer_address_0 = memories_pointer_address_ptr_0 as usize; - let default_memory_bound_address_ptr: *const usize = - unsafe { transmute(&instance.default_memory_bound) }; - let default_memory_bound_address = default_memory_bound_address_ptr as usize; + let memories_pointer_address_ptr_0_data: *const usize = + unsafe { transmute(&data_ptr.memories.get_unchecked(0).data) }; + let memories_pointer_address_0_data = memories_pointer_address_ptr_0_data as usize; + + let memories_pointer_address_ptr_0_len: *const usize = + unsafe { transmute(&data_ptr.memories.get_unchecked(0).len) }; + let memories_pointer_address_0_len = memories_pointer_address_ptr_0_len as usize; + + let globals_pointer_address_ptr: *const usize = + unsafe { transmute(&data_ptr.globals) }; + let globals_pointer_address = globals_pointer_address_ptr as usize; println!( " ====== INSTANCE OFFSET TABLE ====== instance \t\t\t- {:X} | offset - {:?} instance.data_pointers.tables \t- {:X} | offset - {:?} -instance.data_pointers.memories - {:X} | offset - {:?} +instance.data_pointers.memories\t- {:X} | offset - {:?} + .memories[0] \t\t- {:X} | offset - {:?} + .memories[0].data\t\t- {:X} | offset - {:?} + .memories[0].len({:?})\t- {:X} | offset - {:?} instance.data_pointers.globals \t- {:X} | offset - {:?} -instance.default_memory_bound \t- {:X} | offset - {:?} ====== INSTANCE OFFSET TABLE ====== ", instance_address, @@ -42,9 +53,16 @@ instance.default_memory_bound \t- {:X} | offset - {:?} tables_pointer_address - instance_address, memories_pointer_address, memories_pointer_address - instance_address, + + memories_pointer_address_0, + 0, + memories_pointer_address_0_data, + memories_pointer_address_0_data - memories_pointer_address_0_data, + data_ptr.memories.get_unchecked(0).len, + memories_pointer_address_0_len, + memories_pointer_address_0_len - memories_pointer_address_0_data, + globals_pointer_address, globals_pointer_address - instance_address, - default_memory_bound_address, - default_memory_bound_address - instance_address, ); }