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:
@@ -56,3 +56,14 @@ pub use crate::vmcontext::{
|
||||
|
||||
/// Version number of this crate.
|
||||
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
/// The Cranelift IR type used for reference types for this target architecture.
|
||||
pub fn ref_type() -> wasmtime_environ::ir::Type {
|
||||
if cfg!(target_pointer_width = "32") {
|
||||
wasmtime_environ::ir::types::R32
|
||||
} else if cfg!(target_pointer_width = "64") {
|
||||
wasmtime_environ::ir::types::R64
|
||||
} else {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user