2
2
// Attributions: https://github.com/wasmerio/wasmer/blob/master/ATTRIBUTIONS.md
3
3
4
4
use crate :: global:: Global ;
5
+ use crate :: instance:: InstanceAllocator ;
5
6
use crate :: memory:: { Memory , MemoryStyle } ;
6
7
use crate :: table:: { Table , TableStyle } ;
7
8
use crate :: vmcontext:: { VMFunctionBody , VMFunctionEnvironment , VMFunctionKind , VMTrampoline } ;
@@ -29,15 +30,27 @@ pub enum VMExport {
29
30
pub struct VMExportFunction {
30
31
/// The address of the native-code function.
31
32
pub address : * const VMFunctionBody ,
33
+
32
34
/// Pointer to the containing `VMContext`.
33
35
pub vmctx : VMFunctionEnvironment ,
36
+
34
37
/// The function type, used for compatibility checking.
35
38
pub signature : FunctionType ,
36
- /// The function kind (specifies the calling convention for the function).
39
+
40
+ /// The function kind (specifies the calling convention for the
41
+ /// function).
37
42
pub kind : VMFunctionKind ,
38
- /// Address of the function call trampoline owned by the same VMContext that owns the VMFunctionBody.
39
- /// May be None when the function is a host-function (FunctionType == Dynamic or vmctx == nullptr).
43
+
44
+ /// Address of the function call trampoline owned by the same
45
+ /// VMContext that owns the VMFunctionBody.
46
+ ///
47
+ /// May be `None` when the function is a host function (`FunctionType`
48
+ /// == `Dynamic` or `vmctx` == `nullptr`).
40
49
pub call_trampoline : Option < VMTrampoline > ,
50
+
51
+ /// A “reference” to the instance through the
52
+ /// `InstanceAllocator`. `None` if it is a host function.
53
+ pub instance_allocator : Option < InstanceAllocator > ,
41
54
}
42
55
43
56
/// # Safety
@@ -59,13 +72,18 @@ impl From<VMExportFunction> for VMExport {
59
72
pub struct VMExportTable {
60
73
/// Pointer to the containing `Table`.
61
74
pub from : Arc < dyn Table > ,
75
+
76
+ /// A “reference” to the instance through the
77
+ /// `InstanceAllocator`. `None` if it is a host function.
78
+ pub instance_allocator : Option < InstanceAllocator > ,
62
79
}
63
80
64
81
/// # Safety
65
82
/// This is correct because there is no non-threadsafe logic directly in this type;
66
83
/// correct use of the raw table from multiple threads via `definition` requires `unsafe`
67
84
/// and is the responsibilty of the user of this type.
68
85
unsafe impl Send for VMExportTable { }
86
+
69
87
/// # Safety
70
88
/// This is correct because the values directly in `definition` should be considered immutable
71
89
/// and the type is both `Send` and `Clone` (thus marking it `Sync` adds no new behavior, it
@@ -100,13 +118,18 @@ impl From<VMExportTable> for VMExport {
100
118
pub struct VMExportMemory {
101
119
/// Pointer to the containing `Memory`.
102
120
pub from : Arc < dyn Memory > ,
121
+
122
+ /// A “reference” to the instance through the
123
+ /// `InstanceAllocator`. `None` if it is a host function.
124
+ pub instance_allocator : Option < InstanceAllocator > ,
103
125
}
104
126
105
127
/// # Safety
106
128
/// This is correct because there is no non-threadsafe logic directly in this type;
107
129
/// correct use of the raw memory from multiple threads via `definition` requires `unsafe`
108
130
/// and is the responsibilty of the user of this type.
109
131
unsafe impl Send for VMExportMemory { }
132
+
110
133
/// # Safety
111
134
/// This is correct because the values directly in `definition` should be considered immutable
112
135
/// and the type is both `Send` and `Clone` (thus marking it `Sync` adds no new behavior, it
@@ -141,13 +164,18 @@ impl From<VMExportMemory> for VMExport {
141
164
pub struct VMExportGlobal {
142
165
/// The global declaration, used for compatibility checking.
143
166
pub from : Arc < Global > ,
167
+
168
+ /// A “reference” to the instance through the
169
+ /// `InstanceAllocator`. `None` if it is a host function.
170
+ pub instance_allocator : Option < InstanceAllocator > ,
144
171
}
145
172
146
173
/// # Safety
147
174
/// This is correct because there is no non-threadsafe logic directly in this type;
148
175
/// correct use of the raw global from multiple threads via `definition` requires `unsafe`
149
176
/// and is the responsibilty of the user of this type.
150
177
unsafe impl Send for VMExportGlobal { }
178
+
151
179
/// # Safety
152
180
/// This is correct because the values directly in `definition` should be considered immutable
153
181
/// from the perspective of users of this type and the type is both `Send` and `Clone` (thus
0 commit comments