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

Function same_module_multiple_stores

tests/all/traps.rs:1539–1658  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1537
1538#[test]
1539fn same_module_multiple_stores() -> Result<()> {
1540 let _ = env_logger::try_init();
1541
1542 let engine = Engine::default();
1543
1544 let module = Module::new(
1545 &engine,
1546 r#"
1547 (module
1548 (import "" "f" (func $f))
1549 (import "" "call_ref" (func $call_ref (param funcref)))
1550 (global $g (mut i32) (i32.const 0))
1551 (func $a (export "a")
1552 call $b
1553 )
1554 (func $b
1555 call $c
1556 )
1557 (func $c
1558 global.get $g
1559 if
1560 call $f
1561 else
1562 i32.const 1
1563 global.set $g
1564 ref.func $a
1565 call $call_ref
1566 end
1567 )
1568 )
1569 "#,
1570 )?;
1571
1572 let stacks = Arc::new(Mutex::new(vec![]));
1573
1574 let mut store3 = Store::new(&engine, ());
1575 let f3 = Func::new(&mut store3, FuncType::new(&engine, [], []), {
1576 let stacks = stacks.clone();
1577 move |caller, _params, _results| {
1578 stacks
1579 .lock()
1580 .unwrap()
1581 .push(WasmBacktrace::force_capture(caller));
1582 Ok(())
1583 }
1584 });
1585 let call_ref3 = Func::wrap(&mut store3, |caller: Caller<'_, _>, f: Option<Func>| {
1586 f.unwrap().call(caller, &[], &mut [])
1587 });
1588 let instance3 = Instance::new(&mut store3, &module, &[f3.into(), call_ref3.into()])?;
1589
1590 let mut store2 = Store::new(&engine, store3);
1591 let f2 = Func::new(&mut store2, FuncType::new(&engine, [], []), {
1592 let stacks = stacks.clone();
1593 move |mut caller, _params, _results| {
1594 stacks
1595 .lock()
1596 .unwrap()

Callers

nothing calls this directly

Calls 11

OkFunction · 0.85
newFunction · 0.50
cloneMethod · 0.45
pushMethod · 0.45
unwrapMethod · 0.45
lockMethod · 0.45
callMethod · 0.45
data_mutMethod · 0.45
into_iterMethod · 0.45
iterMethod · 0.45
framesMethod · 0.45

Tested by

no test coverage detected