MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / module

Function module

tests/all/memory.rs:9–44  ·  view source on GitHub ↗
(engine: &Engine)

Source from the content-addressed store, hash-verified

7use wasmtime_test_macros::wasmtime_test;
8
9fn module(engine: &Engine) -> Result<Module> {
10 let mut wat = format!("(module\n");
11 wat.push_str("(import \"\" \"\" (memory 0))\n");
12 for i in 0..=33 {
13 let offset = if i == 0 {
14 0
15 } else if i == 33 {
16 !0
17 } else {
18 1u32 << (i - 1)
19 };
20
21 for (width, instr) in [
22 (1, &["i32.load8_s"][..]),
23 (2, &["i32.load16_s"]),
24 (4, &["i32.load" /*, "f32.load"*/]),
25 (8, &["i64.load" /*, "f64.load"*/]),
26 #[cfg(not(any(target_arch = "s390x", target_arch = "riscv64")))]
27 (16, &["v128.load"]),
28 ]
29 .iter()
30 {
31 for (j, instr) in instr.iter().enumerate() {
32 wat.push_str(&format!(
33 "(func (export \"{width} {offset} v{j}\") (param i32)\n"
34 ));
35 wat.push_str("local.get 0\n");
36 wat.push_str(instr);
37 wat.push_str(&format!(" offset={offset}\n"));
38 wat.push_str("drop\n)");
39 }
40 }
41 }
42 wat.push_str(")");
43 Module::new(engine, &wat)
44}
45
46struct TestFunc {
47 width: u32,

Callers 1

Calls 3

newFunction · 0.50
push_strMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected