| 330 | #[wasmtime_test] |
| 331 | #[cfg_attr(miri, ignore)] |
| 332 | fn call_indirect_native_from_exported_table(config: &mut Config) -> Result<()> { |
| 333 | let wasm = wat::parse_str( |
| 334 | r#" |
| 335 | (module |
| 336 | (table (export "table") 1 1 funcref) |
| 337 | (func (export "run") (result i32 i32 i32) |
| 338 | i32.const 0 |
| 339 | call_indirect (result i32 i32 i32) |
| 340 | ) |
| 341 | ) |
| 342 | "#, |
| 343 | )?; |
| 344 | let engine = Engine::new(&config)?; |
| 345 | let mut store = Store::<()>::new(&engine, ()); |
| 346 | let module = Module::new(store.engine(), &wasm)?; |
| 347 | let func = Func::wrap(&mut store, || -> (i32, i32, i32) { (10, 20, 30) }); |
| 348 | let instance = Instance::new(&mut store, &module, &[])?; |
| 349 | let table = instance.get_table(&mut store, "table").unwrap(); |
| 350 | table.set(&mut store, 0, func.into())?; |
| 351 | let run = instance.get_typed_func::<(), (i32, i32, i32)>(&mut store, "run")?; |
| 352 | let results = run.call(&mut store, ())?; |
| 353 | assert_eq!(results, (10, 20, 30)); |
| 354 | Ok(()) |
| 355 | } |
| 356 | |
| 357 | // wasm exports global, host puts native-call funcref in global, wasm calls funcref |
| 358 | #[wasmtime_test(wasm_features(reference_types))] |