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

Function gc_with_exnref_global

tests/all/exceptions.rs:220–247  ·  view source on GitHub ↗
(config: &mut Config)

Source from the content-addressed store, hash-verified

218#[wasmtime_test(wasm_features(gc, exceptions))]
219#[cfg_attr(miri, ignore)]
220fn gc_with_exnref_global(config: &mut Config) -> Result<()> {
221 let engine = Engine::new(config)?;
222 let mut store = Store::new(&engine, ());
223
224 let module = Module::new(
225 &engine,
226 r#"
227 (module
228 (global (export "g") (mut exnref) (ref.null exn)))
229 "#,
230 )?;
231
232 let instance = Instance::new(&mut store, &module, &[])?;
233
234 let functy = FuncType::new(&engine, [], []);
235 let tagty = TagType::new(functy.clone());
236 let exnty = ExnType::from_tag_type(&tagty).unwrap();
237 let exnpre = ExnRefPre::new(&mut store, exnty);
238 let tag = Tag::new(&mut store, &tagty)?;
239 let exn = ExnRef::new(&mut store, &exnpre, &tag, &[])?;
240
241 let global = instance.get_global(&mut store, "g").unwrap();
242 global.set(&mut store, Val::ExnRef(Some(exn)))?;
243
244 store.gc(None)?;
245
246 Ok(())
247}
248
249#[wasmtime_test(wasm_features(exceptions))]
250#[cfg_attr(miri, ignore)]

Callers

nothing calls this directly

Calls 8

OkFunction · 0.85
newFunction · 0.50
ExnRefClass · 0.50
cloneMethod · 0.45
unwrapMethod · 0.45
get_globalMethod · 0.45
setMethod · 0.45
gcMethod · 0.45

Tested by

no test coverage detected