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

Function table_init_with_externref_global_get

tests/all/gc.rs:703–733  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

701#[test]
702#[cfg_attr(miri, ignore)]
703fn table_init_with_externref_global_get() -> wasmtime::Result<()> {
704 let dropped = Arc::new(AtomicBool::new(false));
705
706 let mut config = Config::new();
707 config.wasm_function_references(true);
708 let engine = Engine::new(&config)?;
709 let mut store = Store::new(&engine, ());
710 let module = Module::new(
711 &engine,
712 r#"
713 (module
714 (import "" "" (global $init externref))
715 (table $t 1 externref (global.get $init))
716 )
717 "#,
718 )?;
719
720 let externref = ExternRef::new(&mut store, SetFlagOnDrop(dropped.clone()))?;
721 let global = Global::new(
722 &mut store,
723 GlobalType::new(ValType::EXTERNREF, Mutability::Const),
724 externref.into(),
725 )?;
726
727 Instance::new(&mut store, &module, &[global.into()])?;
728
729 drop(store);
730
731 assert!(dropped.load(SeqCst));
732 Ok(())
733}
734
735#[test]
736fn rooted_gets_collected_after_scope_exit() -> Result<()> {

Callers

nothing calls this directly

Calls 6

OkFunction · 0.85
SetFlagOnDropClass · 0.70
newFunction · 0.50
dropFunction · 0.50
cloneMethod · 0.45

Tested by

no test coverage detected