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

Function stack_values_two_activations

tests/all/debug.rs:249–373  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

247#[test]
248#[cfg_attr(miri, ignore)]
249fn stack_values_two_activations() -> wasmtime::Result<()> {
250 let _ = env_logger::try_init();
251
252 let mut config = Config::default();
253 config.guest_debug(true);
254 config.wasm_exceptions(true);
255 let engine = Engine::new(&config)?;
256 let module1 = Module::new(
257 &engine,
258 r#"
259 (module
260 (import "" "host1" (func (param i32 i32) (result i32)))
261 (func (export "main") (result i32)
262 i32.const 1
263 i32.const 2
264 call 0))
265 "#,
266 )?;
267 let module2 = Module::new(
268 &engine,
269 r#"
270 (module
271 (import "" "host2" (func))
272 (func (export "inner") (param i32 i32) (result i32)
273 local.get 0
274 local.get 1
275 call 0
276 i32.add))
277 "#,
278 )?;
279 let mut store = Store::new(&engine, ());
280
281 let module1_clone = module1.clone();
282 let module2_clone = module2.clone();
283 let host2 = Func::wrap(&mut store, move |mut caller: Caller<'_, ()>| {
284 let exits = caller.debug_exit_frames().collect::<Vec<_>>();
285 assert_eq!(exits.len(), 2);
286 let stack = exits[0].clone();
287 assert_eq!(
288 stack
289 .wasm_function_index_and_pc(&mut caller)?
290 .unwrap()
291 .0
292 .as_u32(),
293 0
294 );
295 assert_eq!(
296 stack
297 .wasm_function_index_and_pc(&mut caller)?
298 .unwrap()
299 .1
300 .raw(),
301 58
302 );
303 assert!(Module::same(
304 stack.module(&mut caller)?.unwrap(),
305 &module2_clone
306 ));

Callers

nothing calls this directly

Calls 13

OkFunction · 0.85
guest_debugMethod · 0.80
debug_exit_framesMethod · 0.80
newFunction · 0.50
FuncEnum · 0.50
wasm_exceptionsMethod · 0.45
cloneMethod · 0.45
instanceMethod · 0.45
parentMethod · 0.45
unwrapMethod · 0.45
get_funcMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected