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

Function gc_access_during_call

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

Source from the content-addressed store, hash-verified

204#[test]
205#[cfg_attr(miri, ignore)]
206fn gc_access_during_call() -> wasmtime::Result<()> {
207 test_stack_values(
208 r#"
209 (module
210 (type $s (struct (field i32)))
211 (import "" "host" (func))
212 (func (export "main")
213 (local $l (ref null $s))
214 (local.set $l (struct.new $s (i32.const 42)))
215 (call 0)))
216 "#,
217 |config| {
218 config.wasm_gc(true);
219 },
220 |mut caller: Caller<'_, ()>| {
221 let stack = caller.debug_exit_frames().next().unwrap();
222
223 // Do a GC while we hold the stack cursor.
224 caller.as_context_mut().gc(None).unwrap();
225
226 assert_eq!(stack.num_stacks(&mut caller)?, 0);
227 assert_eq!(stack.num_locals(&mut caller)?, 1);
228 // Note that this struct is dead during the call, and the
229 // ref could otherwise be optimized away (no longer in the
230 // stackmap at this point); but we verify it is still
231 // alive here because it is rooted in the
232 // debug-instrumentation slot.
233 let s = stack
234 .local(&mut caller, 0)?
235 .unwrap_any_ref()
236 .unwrap()
237 .unwrap_struct(&caller)
238 .unwrap();
239 assert_eq!(s.field(&mut caller, 0).unwrap().unwrap_i32(), 42);
240 let stack = stack.parent(&mut caller)?;
241 assert!(stack.is_none());
242 Ok(())
243 },
244 )
245}
246
247#[test]
248#[cfg_attr(miri, ignore)]

Callers

nothing calls this directly

Calls 11

test_stack_valuesFunction · 0.85
OkFunction · 0.85
debug_exit_framesMethod · 0.80
wasm_gcMethod · 0.45
unwrapMethod · 0.45
nextMethod · 0.45
gcMethod · 0.45
as_context_mutMethod · 0.45
unwrap_structMethod · 0.45
localMethod · 0.45
parentMethod · 0.45

Tested by

no test coverage detected