()
| 223 | #[test] |
| 224 | #[cfg_attr(miri, ignore)] |
| 225 | fn drop_externref_via_table_set() -> Result<()> { |
| 226 | let (mut store, module) = ref_types_module( |
| 227 | false, |
| 228 | r#" |
| 229 | (module |
| 230 | (table $t 1 externref) |
| 231 | |
| 232 | (func (export "table-set") (param externref) |
| 233 | (table.set $t (i32.const 0) (local.get 0)) |
| 234 | ) |
| 235 | ) |
| 236 | "#, |
| 237 | )?; |
| 238 | |
| 239 | let instance = Instance::new(&mut store, &module, &[])?; |
| 240 | let table_set = instance.get_func(&mut store, "table-set").unwrap(); |
| 241 | |
| 242 | let foo_is_dropped = Arc::new(AtomicBool::new(false)); |
| 243 | let bar_is_dropped = Arc::new(AtomicBool::new(false)); |
| 244 | |
| 245 | { |
| 246 | let mut scope = RootScope::new(&mut store); |
| 247 | |
| 248 | let foo = ExternRef::new(&mut scope, SetFlagOnDrop(foo_is_dropped.clone()))?; |
| 249 | let bar = ExternRef::new(&mut scope, SetFlagOnDrop(bar_is_dropped.clone()))?; |
| 250 | |
| 251 | { |
| 252 | let args = vec![Val::ExternRef(Some(foo))]; |
| 253 | table_set.call(&mut scope, &args, &mut [])?; |
| 254 | } |
| 255 | |
| 256 | scope.as_context_mut().gc(None)?; |
| 257 | assert!(!foo_is_dropped.load(SeqCst)); |
| 258 | assert!(!bar_is_dropped.load(SeqCst)); |
| 259 | |
| 260 | { |
| 261 | let args = vec![Val::ExternRef(Some(bar))]; |
| 262 | table_set.call(&mut scope, &args, &mut [])?; |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | store.gc(None)?; |
| 267 | assert!(foo_is_dropped.load(SeqCst)); |
| 268 | assert!(!bar_is_dropped.load(SeqCst)); |
| 269 | |
| 270 | table_set.call(&mut store, &[Val::ExternRef(None)], &mut [])?; |
| 271 | store.gc(None)?; |
| 272 | assert!(foo_is_dropped.load(SeqCst)); |
| 273 | assert!(bar_is_dropped.load(SeqCst)); |
| 274 | |
| 275 | Ok(()) |
| 276 | } |
| 277 | |
| 278 | #[test] |
| 279 | #[cfg_attr(miri, ignore)] |
nothing calls this directly
no test coverage detected