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:
@@ -67,10 +67,18 @@ entity_impl!(DataIndex);
|
||||
pub struct ElemIndex(u32);
|
||||
entity_impl!(ElemIndex);
|
||||
|
||||
/// WebAssembly global.
|
||||
/// A WebAssembly global.
|
||||
///
|
||||
/// Note that we record both the original Wasm type and the Cranelift IR type
|
||||
/// used to represent it. This is because multiple different kinds of Wasm types
|
||||
/// might be represented with the same Cranelift IR type. For example, both a
|
||||
/// Wasm `i64` and a `funcref` might be represented with a Cranelift `i64` on
|
||||
/// 64-bit architectures, and when GC is not required for func refs.
|
||||
#[derive(Debug, Clone, Copy, Hash, Eq, PartialEq)]
|
||||
pub struct Global {
|
||||
/// The type of the value stored in the global.
|
||||
/// The Wasm type of the value stored in the global.
|
||||
pub wasm_ty: crate::WasmType,
|
||||
/// The Cranelift IR type of the value stored in the global.
|
||||
pub ty: ir::Type,
|
||||
/// A flag indicating whether the value may change at runtime.
|
||||
pub mutability: bool,
|
||||
|
||||
Reference in New Issue
Block a user