Process declared element segments for "possibly exported funcs" (#2851)
Now that we're using "possibly exported" as an impactful decision for codegen (which trampolines to generate and which ABI a function has) it's important that we calculate this property of a wasm function correctly! Previously Wasmtime forgot to processed "declared" elements in apart from active/passive element segments, but this updates Wasmtime to ensure that these entries are processed and all the functions contained within are flagged as "possibly exported". Closes #2850
This commit is contained in:
@@ -774,3 +774,30 @@ fn wrap_multiple_results() -> anyhow::Result<()> {
|
||||
f64 "f64" F64 f64::from_bits(a),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn trampoline_for_declared_elem() -> anyhow::Result<()> {
|
||||
let engine = Engine::default();
|
||||
|
||||
let module = Module::new(
|
||||
&engine,
|
||||
r#"
|
||||
(module
|
||||
(elem declare func $f)
|
||||
(func $f)
|
||||
(func (export "g") (result funcref)
|
||||
(ref.func $f)
|
||||
)
|
||||
)
|
||||
"#,
|
||||
)?;
|
||||
|
||||
let store = Store::new(&engine);
|
||||
let instance = Instance::new(&store, &module, &[])?;
|
||||
|
||||
let g = instance.get_typed_func::<(), Option<Func>>("g")?;
|
||||
|
||||
let func = g.call(())?;
|
||||
func.unwrap().call(&[])?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user