Fix a panic with Func::new and reference types (#2039)
Currently `Func::new` will panic if one of the arguments of the function is a reference type and the `Store` doesn't have reference types enabled. This happens because cranelift isn't configure to enable stack maps but the register allocators expects them to exist when reference types are seen. The fix here is to always enable reference types in cranelift for our trampoline generation and `Func::new`. This should hopefully ensure that trampolines are generated correctly and they'll just not be able to get hooked up to an `Instance` because validation will prevent reference types from being used elsewhere.
This commit is contained in:
@@ -507,3 +507,18 @@ fn pass_cross_store_arg() -> anyhow::Result<()> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn externref_signature_no_reference_types() -> anyhow::Result<()> {
|
||||
let store = Store::default();
|
||||
Func::wrap(&store, |_: Option<Func>| {});
|
||||
Func::new(
|
||||
&store,
|
||||
FuncType::new(
|
||||
Box::new([ValType::FuncRef, ValType::ExternRef]),
|
||||
Box::new([ValType::FuncRef, ValType::ExternRef]),
|
||||
),
|
||||
|_, _, _| Ok(()),
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user