[metadata] Fix leaks when handling a few attributes (#16675)
[mono-project.git] / mono / metadata / object-offsets.h
blob185028b9de8b487ec072999b73a9306605ea4506
2 /**
3 \file
4 This is a parameterized header. It's supposed/ok to be included multiple times.
6 Input defines: (those to be defined by the includer file)
8 Required:
9 DECL_OFFSET(struct,field)
10 DECL_OFFSET2(struct,field,offset)
11 DECL_ALIGN2(name,alignment)
13 Optional:
14 USE_CROSS_COMPILE_OFFSETS - if defined, force the cross compiler offsets to be used, otherwise
15 they will only be used if MONO_CROSS_COMPILE is defined
16 DISABLE_METADATA_OFFSETS - Disable the definition of offsets for structures defined in metadata/.
17 DISABLE_JIT_OFFSETS - Disable the definition of offsets for structures defined in mini/.
19 The last two are needed because metadata shouldn't include JIT offsets since the structures
20 are not defined, while the JIT shouldn't include metadata offsets, since some of them
21 are GC specific, and the JIT needs to remain GC agnostic.
23 Output defines:
25 HAS_CROSS_COMPILER_OFFSETS - if set, it means we found some cross offsets, it doesnt mean we'll use it.
26 USED_CROSS_COMPILER_OFFSETS - if set, it means we used the cross offsets
28 Environment defines (from config.h and CFLAGS):
30 MONO_GENERATING_OFFSETS - Set by an offsets generating tool to disable the usage of any (possibly non-existing) generated header.
31 MONO_OFFSETS_FILE - Name of the header file containing the offsets to be used.
36 #undef HAS_CROSS_COMPILER_OFFSETS
37 #undef USED_CROSS_COMPILER_OFFSETS
39 #if !defined (MONO_GENERATING_OFFSETS) && defined (MONO_OFFSETS_FILE)
40 #include MONO_OFFSETS_FILE
41 #endif
43 #ifndef USED_CROSS_COMPILER_OFFSETS
45 DECL_SIZE(gint8)
46 DECL_SIZE(gint16)
47 DECL_SIZE(gint32)
48 DECL_SIZE(gint64)
49 DECL_SIZE(float)
50 DECL_SIZE(double)
51 DECL_SIZE(gpointer)
53 // Offsets for structures defined in metadata/
54 #ifndef DISABLE_METADATA_OFFSETS
55 DECL_OFFSET(MonoObject, vtable)
56 DECL_OFFSET(MonoObject, synchronisation)
58 DECL_OFFSET(MonoClass, interface_bitmap)
59 DECL_OFFSET(MonoClass, _byval_arg)
60 DECL_OFFSET(MonoClass, cast_class)
61 DECL_OFFSET(MonoClass, element_class)
62 DECL_OFFSET(MonoClass, idepth)
63 DECL_OFFSET(MonoClass, instance_size)
64 DECL_OFFSET(MonoClass, interface_id)
65 DECL_OFFSET(MonoClass, max_interface_id)
66 DECL_OFFSET(MonoClass, parent)
67 DECL_OFFSET(MonoClass, rank)
68 DECL_OFFSET(MonoClass, sizes)
69 DECL_OFFSET(MonoClass, supertypes)
70 DECL_OFFSET(MonoClass, class_kind)
72 DECL_OFFSET(MonoVTable, klass)
73 DECL_OFFSET(MonoVTable, max_interface_id)
74 DECL_OFFSET(MonoVTable, interface_bitmap)
75 DECL_OFFSET(MonoVTable, vtable)
76 DECL_OFFSET(MonoVTable, rank)
77 DECL_OFFSET(MonoVTable, initialized)
78 DECL_OFFSET(MonoVTable, flags)
79 DECL_OFFSET(MonoVTable, type)
80 DECL_OFFSET(MonoVTable, runtime_generic_context)
82 DECL_OFFSET(MonoDomain, stack_overflow_ex)
84 DECL_OFFSET(MonoDelegate, target)
85 DECL_OFFSET(MonoDelegate, method_ptr)
86 DECL_OFFSET(MonoDelegate, invoke_impl)
87 DECL_OFFSET(MonoDelegate, method)
88 DECL_OFFSET(MonoDelegate, method_code)
89 DECL_OFFSET(MonoDelegate, method_is_virtual)
90 DECL_OFFSET(MonoDelegate, extra_arg)
92 DECL_OFFSET(MonoInternalThread, tid)
93 DECL_OFFSET(MonoInternalThread, small_id)
94 DECL_OFFSET(MonoInternalThread, static_data)
95 DECL_OFFSET(MonoInternalThread, last)
97 DECL_OFFSET(MonoMulticastDelegate, delegates)
99 DECL_OFFSET(MonoTransparentProxy, rp)
100 DECL_OFFSET(MonoTransparentProxy, remote_class)
101 DECL_OFFSET(MonoTransparentProxy, custom_type_info)
103 DECL_OFFSET(MonoRealProxy, target_domain_id)
104 DECL_OFFSET(MonoRealProxy, context)
105 DECL_OFFSET(MonoRealProxy, unwrapped_server)
107 DECL_OFFSET(MonoRemoteClass, proxy_class)
109 DECL_OFFSET(MonoArray, vector)
110 DECL_OFFSET(MonoArray, max_length)
111 DECL_OFFSET(MonoArray, bounds)
113 DECL_OFFSET(MonoArrayBounds, lower_bound)
114 DECL_OFFSET(MonoArrayBounds, length)
116 DECL_OFFSET(MonoSafeHandle, handle)
118 DECL_OFFSET(MonoHandleRef, handle)
120 DECL_OFFSET(MonoComInteropProxy, com_object)
122 DECL_OFFSET(MonoString, length)
123 DECL_OFFSET(MonoString, chars)
125 DECL_OFFSET(MonoException, message)
127 DECL_OFFSET(MonoTypedRef, type)
128 DECL_OFFSET(MonoTypedRef, klass)
129 DECL_OFFSET(MonoTypedRef, value)
131 //Internal structs
132 DECL_OFFSET(MonoThreadsSync, status)
133 DECL_OFFSET(MonoThreadsSync, nest)
135 DECL_OFFSET(MonoProfilerCallContext, method)
136 DECL_OFFSET(MonoProfilerCallContext, return_value)
137 DECL_OFFSET(MonoProfilerCallContext, args)
139 DECL_OFFSET(MonoErrorExternal, init)
141 #ifdef HAVE_SGEN_GC
142 DECL_OFFSET(SgenClientThreadInfo, in_critical_region)
143 DECL_OFFSET(SgenThreadInfo, tlab_next)
144 DECL_OFFSET(SgenThreadInfo, tlab_temp_end)
145 #endif
147 #endif //DISABLE METADATA OFFSETS
149 // Offsets for structures defined in mini/
150 #ifndef DISABLE_JIT_OFFSETS
151 DECL_SIZE(MonoMethodRuntimeGenericContext)
152 DECL_SIZE(MonoLMF)
153 DECL_SIZE(MonoTypedRef)
154 DECL_SIZE(CallContext)
155 DECL_SIZE(MonoContext)
157 DECL_OFFSET(MonoLMF, previous_lmf)
159 DECL_OFFSET(MonoMethodRuntimeGenericContext, class_vtable)
161 DECL_OFFSET(MonoJitTlsData, lmf)
162 DECL_OFFSET(MonoJitTlsData, class_cast_from)
163 DECL_OFFSET(MonoJitTlsData, class_cast_to)
165 DECL_OFFSET(MonoGSharedVtMethodRuntimeInfo, locals_size)
166 DECL_OFFSET(MonoGSharedVtMethodRuntimeInfo, entries) //XXX more to fix here
168 DECL_OFFSET(MonoContinuation, stack_used_size)
169 DECL_OFFSET(MonoContinuation, saved_stack)
170 DECL_OFFSET(MonoContinuation, return_sp)
171 DECL_OFFSET(MonoContinuation, lmf)
172 DECL_OFFSET(MonoContinuation, return_ip)
174 DECL_OFFSET(MonoDelegateTrampInfo, method)
175 DECL_OFFSET(MonoDelegateTrampInfo, invoke_impl)
176 DECL_OFFSET(MonoDelegateTrampInfo, method_ptr)
178 // Architecture-specific offsets
179 // -----------------------------
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)
187 DECL_OFFSET(MonoLMF, lmf_addr)
189 #elif defined(TARGET_X86)
190 DECL_OFFSET(MonoContext, eax)
191 DECL_OFFSET(MonoContext, ebx)
192 DECL_OFFSET(MonoContext, ecx)
193 DECL_OFFSET(MonoContext, edx)
194 DECL_OFFSET(MonoContext, edi)
195 DECL_OFFSET(MonoContext, esi)
196 DECL_OFFSET(MonoContext, esp)
197 DECL_OFFSET(MonoContext, ebp)
198 DECL_OFFSET(MonoContext, eip)
200 DECL_OFFSET(MonoLMF, method)
201 DECL_OFFSET(MonoLMF, lmf_addr)
202 DECL_OFFSET(MonoLMF, esp)
203 DECL_OFFSET(MonoLMF, ebx)
204 DECL_OFFSET(MonoLMF, edi)
205 DECL_OFFSET(MonoLMF, esi)
206 DECL_OFFSET(MonoLMF, ebp)
207 DECL_OFFSET(MonoLMF, eip)
208 #elif defined(TARGET_AMD64)
209 DECL_OFFSET(MonoContext, gregs)
210 DECL_OFFSET(MonoContext, fregs)
212 DECL_OFFSET(MonoLMF, rsp)
213 DECL_OFFSET(MonoLMF, rbp)
215 DECL_OFFSET(DynCallArgs, res)
217 DECL_OFFSET(MonoLMFTramp, ctx)
218 DECL_OFFSET(MonoLMFTramp, lmf_addr)
219 #elif defined(TARGET_ARM)
220 DECL_OFFSET(MonoLMF, sp)
221 DECL_OFFSET(MonoLMF, fp)
222 DECL_OFFSET(MonoLMF, ip)
223 DECL_OFFSET(MonoLMF, iregs)
224 DECL_OFFSET(MonoLMF, fregs)
225 DECL_OFFSET(DynCallArgs, fpregs)
226 DECL_OFFSET(DynCallArgs, has_fpregs)
227 DECL_OFFSET(DynCallArgs, regs)
228 DECL_OFFSET(DynCallArgs, n_stackargs)
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
240 // Shared architecture offfsets
241 // ----------------------------
243 #if defined(TARGET_ARM) || defined(TARGET_ARM64)
244 DECL_OFFSET (MonoContext, pc)
245 DECL_OFFSET (MonoContext, regs)
246 DECL_OFFSET (MonoContext, fregs)
248 DECL_OFFSET(MonoLMF, lmf_addr)
250 DECL_OFFSET(DynCallArgs, res)
251 DECL_OFFSET(DynCallArgs, res2)
252 #endif
254 #if defined(TARGET_ARM)
255 DECL_OFFSET(MonoLMF, method)
256 DECL_OFFSET(GSharedVtCallInfo, stack_usage)
257 DECL_OFFSET(GSharedVtCallInfo, vret_arg_reg)
258 DECL_OFFSET(GSharedVtCallInfo, ret_marshal)
259 DECL_OFFSET(GSharedVtCallInfo, vret_slot)
260 DECL_OFFSET(GSharedVtCallInfo, gsharedvt_in)
262 DECL_OFFSET(SeqPointInfo, ss_trigger_page)
263 #endif
265 #if defined(TARGET_ARM64)
266 DECL_OFFSET (MonoContext, has_fregs)
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
274 #if defined(TARGET_AMD64) || defined(TARGET_ARM64)
275 DECL_OFFSET(SeqPointInfo, ss_tramp_addr)
276 #endif
278 #if defined(TARGET_AMD64) || defined(TARGET_ARM) || defined(TARGET_ARM64)
279 DECL_OFFSET(SeqPointInfo, bp_addrs)
281 DECL_OFFSET(CallContext, gregs)
282 DECL_OFFSET(CallContext, fregs)
283 DECL_OFFSET(CallContext, stack_size)
284 DECL_OFFSET(CallContext, stack)
285 #endif
287 #if defined(TARGET_X86)
288 DECL_OFFSET(GSharedVtCallInfo, stack_usage)
289 DECL_OFFSET(GSharedVtCallInfo, vret_slot)
290 DECL_OFFSET(GSharedVtCallInfo, vret_arg_slot)
291 DECL_OFFSET(GSharedVtCallInfo, ret_marshal)
292 DECL_OFFSET(GSharedVtCallInfo, gsharedvt_in)
293 #endif
295 DECL_OFFSET(MonoFtnDesc, arg)
296 DECL_OFFSET(MonoFtnDesc, addr)
298 #endif //DISABLE_JIT_OFFSETS
300 #endif //USED_CROSS_COMPILER_OFFSETS
302 #undef DECL_OFFSET
303 #undef DECL_OFFSET2
304 #undef DECL_ALIGN2
305 #undef DECL_SIZE
306 #undef DECL_SIZE2
307 #undef USE_CROSS_COMPILE_OFFSETS