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

Function stack_values_two_frames

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

Source from the content-addressed store, hash-verified

72#[test]
73#[cfg_attr(miri, ignore)]
74fn stack_values_two_frames() -> wasmtime::Result<()> {
75 let _ = env_logger::try_init();
76
77 for inlining in [Inlining::No, Inlining::Yes] {
78 test_stack_values(
79 r#"
80 (module
81 (import "" "host" (func))
82 (func (export "main")
83 i32.const 1
84 i32.const 2
85 call 2
86 drop)
87 (func (param i32 i32) (result i32)
88 local.get 0
89 local.get 1
90 call 0
91 i32.add))
92 "#,
93 |config| {
94 config.compiler_inlining(inlining);
95 },
96 |mut caller: Caller<'_, ()>| {
97 let stack = caller.debug_exit_frames().next().unwrap();
98 assert_eq!(
99 stack
100 .wasm_function_index_and_pc(&mut caller)?
101 .unwrap()
102 .0
103 .as_u32(),
104 1
105 );
106 assert_eq!(
107 stack
108 .wasm_function_index_and_pc(&mut caller)?
109 .unwrap()
110 .1
111 .raw(),
112 67
113 );
114
115 assert_eq!(stack.num_locals(&mut caller)?, 2);
116 assert_eq!(stack.num_stacks(&mut caller)?, 2);
117 assert_eq!(stack.local(&mut caller, 0)?.unwrap_i32(), 1);
118 assert_eq!(stack.local(&mut caller, 1)?.unwrap_i32(), 2);
119 assert_eq!(stack.stack(&mut caller, 0)?.unwrap_i32(), 1);
120 assert_eq!(stack.stack(&mut caller, 1)?.unwrap_i32(), 2);
121
122 let stack = stack.parent(&mut caller)?.unwrap();
123 assert_eq!(
124 stack
125 .wasm_function_index_and_pc(&mut caller)?
126 .unwrap()
127 .0
128 .as_u32(),
129 0
130 );
131 assert_eq!(

Callers

nothing calls this directly

Calls 7

test_stack_valuesFunction · 0.85
OkFunction · 0.85
compiler_inliningMethod · 0.80
debug_exit_framesMethod · 0.80
unwrapMethod · 0.45
nextMethod · 0.45
parentMethod · 0.45

Tested by

no test coverage detected