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

Function recursively_build_tree

tests/all/gc.rs:1245–1263  ·  view source on GitHub ↗
(
        mut store: &mut RootScope<&mut Store<()>>,
        pre: &ArrayRefPre,
        num_refs_dropped: &Arc<AtomicUsize>,
        expected: &mut usize,
        depth: u32,
    )

Source from the content-addressed store, hash-verified

1243 let mut expected = 0;
1244
1245 fn recursively_build_tree(
1246 mut store: &mut RootScope<&mut Store<()>>,
1247 pre: &ArrayRefPre,
1248 num_refs_dropped: &Arc<AtomicUsize>,
1249 expected: &mut usize,
1250 depth: u32,
1251 ) -> Result<Rooted<AnyRef>> {
1252 let max = if cfg!(miri) { 1 } else { 3 };
1253 if depth >= max {
1254 *expected += 1;
1255 let e = ExternRef::new(&mut store, CountDrops(num_refs_dropped.clone()))?;
1256 AnyRef::convert_extern(&mut store, e)
1257 } else {
1258 let left = recursively_build_tree(store, pre, num_refs_dropped, expected, depth + 1)?;
1259 let right = recursively_build_tree(store, pre, num_refs_dropped, expected, depth + 1)?;
1260 let arr = ArrayRef::new_fixed(store, pre, &[left.into(), right.into()])?;
1261 Ok(arr.to_anyref())
1262 }
1263 }
1264
1265 {
1266 let mut store = RootScope::new(&mut store);

Calls 5

OkFunction · 0.85
CountDropsClass · 0.70
newFunction · 0.50
cloneMethod · 0.45
to_anyrefMethod · 0.45

Tested by 1