1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
use crate::vmcontext::VMCallerCheckedAnyfunc;
use loupe::MemoryUsage;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, MemoryUsage)]
pub struct VMFuncRef(pub(crate) *const VMCallerCheckedAnyfunc);
impl wasmer_types::NativeWasmType for VMFuncRef {
const WASM_TYPE: wasmer_types::Type = wasmer_types::Type::FuncRef;
type Abi = Self;
#[inline]
fn from_abi(abi: Self::Abi) -> Self {
abi
}
#[inline]
fn into_abi(self) -> Self::Abi {
self
}
#[inline]
fn to_binary(self) -> i128 {
self.0 as _
}
#[inline]
fn from_binary(bits: i128) -> Self {
Self(bits as _)
}
}
impl VMFuncRef {
pub fn is_null(&self) -> bool {
self.0.is_null()
}
pub const fn null() -> Self {
Self(std::ptr::null())
}
}
impl std::ops::Deref for VMFuncRef {
type Target = *const VMCallerCheckedAnyfunc;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl std::ops::DerefMut for VMFuncRef {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
unsafe impl Send for VMFuncRef {}
unsafe impl Sync for VMFuncRef {}