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

Function non_stacky_async_activations

tests/all/async_functions.rs:835–968  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

833#[tokio::test]
834#[cfg_attr(miri, ignore)]
835async fn non_stacky_async_activations() -> Result<()> {
836 let engine = Engine::default();
837 let mut store1: Store<Option<Pin<Box<dyn Future<Output = Result<()>> + Send>>>> =
838 Store::new(&engine, None);
839 let mut linker1 = Linker::new(&engine);
840
841 let module1 = Module::new(
842 &engine,
843 r#"
844 (module $m1
845 (import "" "host_capture_stack" (func $host_capture_stack))
846 (import "" "start_async_instance" (func $start_async_instance))
847 (func $capture_stack (export "capture_stack")
848 call $host_capture_stack
849 )
850 (func $run_sync (export "run_sync")
851 call $start_async_instance
852 )
853 )
854 "#,
855 )?;
856
857 let module2 = Module::new(
858 &engine,
859 r#"
860 (module $m2
861 (import "" "yield" (func $yield))
862
863 (func $run_async (export "run_async")
864 call $yield
865 )
866 )
867 "#,
868 )?;
869
870 let stacks = Arc::new(Mutex::new(vec![]));
871 fn capture_stack(stacks: &Arc<Mutex<Vec<WasmBacktrace>>>, store: impl AsContext) {
872 let mut stacks = stacks.lock().unwrap();
873 stacks.push(wasmtime::WasmBacktrace::force_capture(store));
874 }
875
876 linker1.func_wrap_async("", "host_capture_stack", {
877 let stacks = stacks.clone();
878 move |caller, _: ()| {
879 capture_stack(&stacks, &caller);
880 Box::new(async { Ok(()) })
881 }
882 })?;
883
884 linker1.func_wrap_async("", "start_async_instance", {
885 let stacks = stacks.clone();
886 move |mut caller, _: ()| {
887 let stacks = stacks.clone();
888 capture_stack(&stacks, &caller);
889
890 let module2 = module2.clone();
891 let mut store2 = Store::new(caller.engine(), ());
892 let mut linker2 = Linker::<()>::new(caller.engine());

Callers

nothing calls this directly

Calls 15

capture_stackFunction · 0.85
OkFunction · 0.85
yield_nowFunction · 0.85
newFunction · 0.50
func_wrap_asyncMethod · 0.45
cloneMethod · 0.45
engineMethod · 0.45
unwrapMethod · 0.45
errMethod · 0.45
instantiate_asyncMethod · 0.45
call_asyncMethod · 0.45
get_funcMethod · 0.45

Tested by

no test coverage detected