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

Function table_drops_externref

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

Source from the content-addressed store, hash-verified

327#[test]
328#[cfg_attr(miri, ignore)]
329fn table_drops_externref() -> Result<()> {
330 let _ = env_logger::try_init();
331 test_engine(&Engine::default())?;
332
333 let mut config = Config::new();
334 config.allocation_strategy(crate::small_pool_config());
335 test_engine(&Engine::new(&config)?)?;
336
337 return Ok(());
338
339 fn test_engine(engine: &Engine) -> Result<()> {
340 let mut store = Store::new(&engine, ());
341 let flag = Arc::new(AtomicBool::new(false));
342 let externref = ExternRef::new(&mut store, SetFlagOnDrop(flag.clone()))?;
343 Table::new(
344 &mut store,
345 TableType::new(RefType::EXTERNREF, 1, None),
346 externref.into(),
347 )?;
348 drop(store);
349 assert!(flag.load(SeqCst));
350
351 let mut store = Store::new(&engine, ());
352 let module = Module::new(
353 &engine,
354 r#"
355 (module
356 (table 1 externref)
357
358 (func (export "run") (param externref)
359 i32.const 0
360 local.get 0
361 table.set 0
362 )
363 )
364 "#,
365 )?;
366 let instance = Instance::new(&mut store, &module, &[])?;
367 let run = instance.get_typed_func::<Option<Rooted<ExternRef>>, ()>(&mut store, "run")?;
368 let flag = Arc::new(AtomicBool::new(false));
369 let externref = ExternRef::new(&mut store, SetFlagOnDrop(flag.clone()))?;
370 run.call(&mut store, Some(externref))?;
371 drop(store);
372 assert!(flag.load(SeqCst));
373 Ok(())
374 }
375}
376
377#[test]
378#[cfg_attr(miri, ignore)]

Callers

nothing calls this directly

Calls 5

test_engineFunction · 0.85
OkFunction · 0.85
allocation_strategyMethod · 0.80
small_pool_configFunction · 0.70
newFunction · 0.50

Tested by

no test coverage detected