Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / metadata / object-offsets.h
1
2 /**
3 \file
4 This is a parameterized header. It's supposed/ok to be included multiple times.
5
6 Input defines: (those to be defined by the includer file)
7
8 Required:
9 DECL_OFFSET(struct,field)
10 DECL_OFFSET2(struct,field,offset)
11 DECL_ALIGN(name,type)
12 DECL_ALIGN2(name,alignment)
13
14 Optional:
15 USE_CROSS_COMPILE_OFFSETS - if defined, force the cross compiler offsets to be used, otherwise
16         they will only be used if MONO_CROSS_COMPILE is defined
17 DISABLE_METADATA_OFFSETS - Disable the definition of offsets for structures defined in metadata/.
18 DISABLE_JIT_OFFSETS - Disable the definition of offsets for structures defined in mini/.
19
20 The last two are needed because metadata shouldn't include JIT offsets since the structures
21 are not defined, while the JIT shouldn't include metadata offsets, since some of them
22 are GC specific, and the JIT needs to remain GC agnostic.
23
24 Output defines:
25
26 HAS_CROSS_COMPILER_OFFSETS - if set, it means we found some cross offsets, it doesnt mean we'll use it.
27 USED_CROSS_COMPILER_OFFSETS - if set, it means we used the cross offsets
28
29 Environment defines (from config.h and CFLAGS):
30
31 MONO_GENERATING_OFFSETS - Set by an offsets generating tool to disable the usage of any (possibly non-existing) generated header.
32 MONO_OFFSETS_FILE - Name of the header file containing the offsets to be used.
33
34 */
35
36
37 #undef HAS_CROSS_COMPILER_OFFSETS
38 #undef USED_CROSS_COMPILER_OFFSETS
39
40 #if !defined (MONO_GENERATING_OFFSETS) && defined (MONO_OFFSETS_FILE)
41 #include MONO_OFFSETS_FILE
42 #endif
43
44 #ifndef USED_CROSS_COMPILER_OFFSETS
45
46 DECL_ALIGN(gint8)
47 DECL_ALIGN(gint16)
48 DECL_ALIGN(gint32)
49 DECL_ALIGN(gint64)
50 DECL_ALIGN(float)
51 DECL_ALIGN(double)
52 DECL_ALIGN(gpointer)
53
54 DECL_SIZE(gint8)
55 DECL_SIZE(gint16)
56 DECL_SIZE(gint32)
57 DECL_SIZE(gint64)
58 DECL_SIZE(float)
59 DECL_SIZE(double)
60 DECL_SIZE(gpointer)
61
62 // Offsets for structures defined in metadata/
63 #ifndef DISABLE_METADATA_OFFSETS
64 DECL_OFFSET(MonoObject, vtable)
65 DECL_OFFSET(MonoObject, synchronisation)
66
67 DECL_OFFSET(MonoObjectHandlePayload, __raw)
68
69 DECL_OFFSET(MonoClass, interface_bitmap)
70 DECL_OFFSET(MonoClass, byval_arg)
71 DECL_OFFSET(MonoClass, cast_class)
72 DECL_OFFSET(MonoClass, element_class)
73 DECL_OFFSET(MonoClass, idepth)
74 DECL_OFFSET(MonoClass, instance_size)
75 DECL_OFFSET(MonoClass, interface_id)
76 DECL_OFFSET(MonoClass, max_interface_id)
77 DECL_OFFSET(MonoClass, parent)
78 DECL_OFFSET(MonoClass, rank)
79 DECL_OFFSET(MonoClass, sizes)
80 DECL_OFFSET(MonoClass, supertypes)
81
82 DECL_OFFSET(MonoVTable, klass)
83 DECL_OFFSET(MonoVTable, max_interface_id)
84 DECL_OFFSET(MonoVTable, interface_bitmap)
85 DECL_OFFSET(MonoVTable, vtable)
86 DECL_OFFSET(MonoVTable, rank)
87 DECL_OFFSET(MonoVTable, initialized)
88 DECL_OFFSET(MonoVTable, type)
89 DECL_OFFSET(MonoVTable, runtime_generic_context)
90
91 DECL_OFFSET(MonoDomain, stack_overflow_ex)
92
93 DECL_OFFSET(MonoDelegate, target)
94 DECL_OFFSET(MonoDelegate, method_ptr)
95 DECL_OFFSET(MonoDelegate, invoke_impl)
96 DECL_OFFSET(MonoDelegate, method)
97 DECL_OFFSET(MonoDelegate, method_code)
98 DECL_OFFSET(MonoDelegate, method_is_virtual)
99 DECL_OFFSET(MonoDelegate, extra_arg)
100
101 DECL_OFFSET(MonoInternalThread, tid)
102 DECL_OFFSET(MonoInternalThread, small_id)
103 DECL_OFFSET(MonoInternalThread, static_data)
104 DECL_OFFSET(MonoInternalThread, last)
105
106 DECL_OFFSET(MonoMulticastDelegate, delegates)
107
108 DECL_OFFSET(MonoTransparentProxy, rp)
109 DECL_OFFSET(MonoTransparentProxy, remote_class)
110 DECL_OFFSET(MonoTransparentProxy, custom_type_info)
111
112 DECL_OFFSET(MonoRealProxy, target_domain_id)
113 DECL_OFFSET(MonoRealProxy, context)
114 DECL_OFFSET(MonoRealProxy, unwrapped_server)
115
116 DECL_OFFSET(MonoRemoteClass, proxy_class)
117
118 DECL_OFFSET(MonoArray, vector)
119 DECL_OFFSET(MonoArray, max_length)
120 DECL_OFFSET(MonoArray, bounds)
121
122 DECL_OFFSET(MonoArrayBounds, lower_bound)
123 DECL_OFFSET(MonoArrayBounds, length)
124
125 DECL_OFFSET(MonoSafeHandle, handle)
126
127 DECL_OFFSET(MonoHandleRef, handle)
128
129 DECL_OFFSET(MonoComInteropProxy, com_object)
130
131 DECL_OFFSET(MonoString, length)
132 DECL_OFFSET(MonoString, chars)
133
134 DECL_OFFSET(MonoException, message)
135
136 DECL_OFFSET(MonoTypedRef, type)
137 DECL_OFFSET(MonoTypedRef, klass)
138 DECL_OFFSET(MonoTypedRef, value)
139
140 //Internal structs
141 DECL_OFFSET(MonoThreadsSync, status)
142 DECL_OFFSET(MonoThreadsSync, nest)
143
144 DECL_OFFSET(MonoProfilerCallContext, method)
145 DECL_OFFSET(MonoProfilerCallContext, return_value)
146
147 #ifdef HAVE_SGEN_GC
148 DECL_OFFSET(SgenClientThreadInfo, in_critical_region)
149 DECL_OFFSET(SgenThreadInfo, tlab_next)
150 DECL_OFFSET(SgenThreadInfo, tlab_temp_end)
151 #endif
152
153 #endif //DISABLE METADATA OFFSETS
154
155 // Offsets for structures defined in mini/
156 #ifndef DISABLE_JIT_OFFSETS
157 DECL_OFFSET(MonoLMF, previous_lmf)
158
159 DECL_OFFSET(MonoMethodRuntimeGenericContext, class_vtable)
160
161 DECL_OFFSET(MonoJitTlsData, lmf)
162 DECL_OFFSET(MonoJitTlsData, class_cast_from)
163 DECL_OFFSET(MonoJitTlsData, class_cast_to)
164 DECL_OFFSET(MonoJitTlsData, restore_stack_prot)
165
166 DECL_OFFSET(MonoGSharedVtMethodRuntimeInfo, locals_size)
167 DECL_OFFSET(MonoGSharedVtMethodRuntimeInfo, entries) //XXX more to fix here
168
169 DECL_OFFSET(MonoContinuation, stack_used_size)
170 DECL_OFFSET(MonoContinuation, saved_stack)
171 DECL_OFFSET(MonoContinuation, return_sp)
172 DECL_OFFSET(MonoContinuation, lmf)
173 DECL_OFFSET(MonoContinuation, return_ip)
174
175 DECL_OFFSET(MonoDelegateTrampInfo, invoke_impl)
176 DECL_OFFSET(MonoDelegateTrampInfo, method_ptr)
177
178 // Architecture-specific offsets
179 // -----------------------------
180
181 #if defined(TARGET_WASM)
182 DECL_OFFSET(MonoContext, wasm_ip)
183 DECL_OFFSET(MonoContext, wasm_bp)
184 DECL_OFFSET(MonoContext, wasm_sp)
185 DECL_OFFSET(MonoContext, llvm_exc_reg)
186
187 DECL_OFFSET(MonoLMF, method)
188 DECL_OFFSET(MonoLMF, lmf_addr)
189
190 #elif defined(TARGET_X86)
191 DECL_OFFSET(MonoContext, eax)
192 DECL_OFFSET(MonoContext, ebx)
193 DECL_OFFSET(MonoContext, ecx)
194 DECL_OFFSET(MonoContext, edx)
195 DECL_OFFSET(MonoContext, edi)
196 DECL_OFFSET(MonoContext, esi)
197 DECL_OFFSET(MonoContext, esp)
198 DECL_OFFSET(MonoContext, ebp)
199 DECL_OFFSET(MonoContext, eip)
200
201 DECL_OFFSET(MonoLMF, method)
202 DECL_OFFSET(MonoLMF, lmf_addr)
203 DECL_OFFSET(MonoLMF, esp)
204 DECL_OFFSET(MonoLMF, ebx)
205 DECL_OFFSET(MonoLMF, edi)
206 DECL_OFFSET(MonoLMF, esi)
207 DECL_OFFSET(MonoLMF, ebp)
208 DECL_OFFSET(MonoLMF, eip)
209 #elif defined(TARGET_AMD64)
210 DECL_OFFSET(MonoContext, gregs)
211 DECL_OFFSET(MonoContext, fregs)
212
213 DECL_OFFSET(MonoLMF, rsp)
214 DECL_OFFSET(MonoLMF, rbp)
215 DECL_OFFSET(MonoLMF, rip)
216
217 DECL_OFFSET(DynCallArgs, res)
218
219 DECL_OFFSET(MonoLMFTramp, ctx)
220 DECL_OFFSET(MonoLMFTramp, lmf_addr)
221 #elif defined(TARGET_ARM)
222 DECL_OFFSET(MonoLMF, sp)
223 DECL_OFFSET(MonoLMF, fp)
224 DECL_OFFSET(MonoLMF, ip)
225 DECL_OFFSET(MonoLMF, iregs)
226 DECL_OFFSET(MonoLMF, fregs)
227 DECL_OFFSET(DynCallArgs, fpregs)
228 DECL_OFFSET(DynCallArgs, has_fpregs)
229 DECL_OFFSET(SeqPointInfo, ss_tramp_addr)
230 #elif defined(TARGET_ARM64)
231 DECL_OFFSET(MonoLMF, pc)
232 DECL_OFFSET(MonoLMF, gregs)
233 DECL_OFFSET(DynCallArgs, regs)
234 DECL_OFFSET(DynCallArgs, fpregs)
235 DECL_OFFSET(DynCallArgs, n_stackargs)
236 DECL_OFFSET(DynCallArgs, n_fpargs)
237 DECL_OFFSET(DynCallArgs, n_fpret)
238 #endif
239
240 // Shared architecture offfsets
241 // ----------------------------
242
243 #if defined(TARGET_ARM) || defined(TARGET_ARM64)
244 DECL_OFFSET (MonoContext, pc)
245 DECL_OFFSET (MonoContext, regs)
246 DECL_OFFSET (MonoContext, fregs)
247
248 DECL_OFFSET(MonoLMF, lmf_addr)
249
250 DECL_OFFSET(SeqPointInfo, ss_trigger_page)
251
252 DECL_OFFSET(DynCallArgs, res)
253 DECL_OFFSET(DynCallArgs, res2)
254 #endif
255
256 #if defined(TARGET_ARM)
257 DECL_OFFSET(MonoLMF, method)
258 DECL_OFFSET(GSharedVtCallInfo, stack_usage)
259 DECL_OFFSET(GSharedVtCallInfo, vret_arg_reg)
260 DECL_OFFSET(GSharedVtCallInfo, ret_marshal)
261 DECL_OFFSET(GSharedVtCallInfo, vret_slot)
262 DECL_OFFSET(GSharedVtCallInfo, gsharedvt_in)
263 #endif
264
265 #if defined(TARGET_ARM64)
266 DECL_OFFSET (MonoContext, has_fregs)
267
268 DECL_OFFSET(GSharedVtCallInfo, stack_usage)
269 DECL_OFFSET(GSharedVtCallInfo, gsharedvt_in)
270 DECL_OFFSET(GSharedVtCallInfo, ret_marshal)
271 DECL_OFFSET(GSharedVtCallInfo, vret_slot)
272 #endif
273
274 #if defined(TARGET_AMD64) || defined(TARGET_ARM64)
275 DECL_OFFSET(SeqPointInfo, ss_tramp_addr)
276 #endif
277
278 #if defined(TARGET_AMD64) || defined(TARGET_ARM) || defined(TARGET_ARM64)
279 DECL_OFFSET(SeqPointInfo, bp_addrs)
280 #endif
281
282 #ifdef ENABLE_INTERPRETER
283 DECL_OFFSET(InterpMethodArguments, ilen)
284 DECL_OFFSET(InterpMethodArguments, iargs)
285 DECL_OFFSET(InterpMethodArguments, flen)
286 DECL_OFFSET(InterpMethodArguments, fargs)
287 DECL_OFFSET(InterpMethodArguments, retval)
288 DECL_OFFSET(InterpMethodArguments, is_float_ret)
289 #endif
290
291 #endif //DISABLE_JIT_OFFSETS
292
293 #endif //USED_CROSS_COMPILER_OFFSETS
294
295 #undef DECL_OFFSET
296 #undef DECL_OFFSET2
297 #undef DECL_ALIGN
298 #undef DECL_ALIGN2
299 #undef DECL_SIZE
300 #undef DECL_SIZE2
301 #undef USE_CROSS_COMPILE_OFFSETS