wasmtime: Add support for func.ref and table.grow with funcrefs
`funcref`s are implemented as `NonNull<VMCallerCheckedAnyfunc>`. This should be more efficient than using a `VMExternRef` that points at a `VMCallerCheckedAnyfunc` because it gets rid of an indirection, dynamic allocation, and some reference counting. Note that the null function reference is *NOT* a null pointer; it is a `VMCallerCheckedAnyfunc` that has a null `func_ptr` member. Part of #929
This commit is contained in:
@@ -35,7 +35,7 @@ pub fn link_spectest(linker: &mut Linker) -> Result<()> {
|
||||
linker.define("spectest", "global_f64", g)?;
|
||||
|
||||
let ty = TableType::new(ValType::FuncRef, Limits::new(10, Some(20)));
|
||||
let table = Table::new(linker.store(), ty, Val::ExternRef(None))?;
|
||||
let table = Table::new(linker.store(), ty, Val::FuncRef(None))?;
|
||||
linker.define("spectest", "table", table)?;
|
||||
|
||||
let ty = MemoryType::new(Limits::new(1, Some(2)));
|
||||
|
||||
@@ -23,6 +23,7 @@ fn runtime_value(store: &Store, v: &wast::Expression<'_>) -> Result<Val> {
|
||||
F64Const(x) => Val::F64(x.bits),
|
||||
V128Const(x) => Val::V128(u128::from_le_bytes(x.to_le_bytes())),
|
||||
RefNull(RefType::Extern) => Val::ExternRef(None),
|
||||
RefNull(RefType::Func) => Val::FuncRef(None),
|
||||
RefExtern(x) => Val::ExternRef(Some(ExternRef::new(store, *x))),
|
||||
other => bail!("couldn't convert {:?} to a runtime value", other),
|
||||
})
|
||||
@@ -420,6 +421,7 @@ fn val_matches(actual: &Val, expected: &wast::AssertExpression) -> Result<bool>
|
||||
false
|
||||
}
|
||||
}
|
||||
(Val::FuncRef(x), wast::AssertExpression::RefNull(wast::RefType::Func)) => x.is_none(),
|
||||
_ => bail!(
|
||||
"don't know how to compare {:?} and {:?} yet",
|
||||
actual,
|
||||
|
||||
Reference in New Issue
Block a user