1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | // See the LICENSE file in the project root for more information. |
4 | // |
5 | // See makefile.inc. During the build, this file is converted into a .inc |
6 | // file for inclusion by .asm files. The #defines are converted into EQU's. |
7 | // |
8 | // Allow multiple inclusion. |
9 | |
10 | |
11 | #ifndef _TARGET_AMD64_ |
12 | #error this file should only be used on an AMD64 platform |
13 | #endif // _TARGET_AMD64_ |
14 | |
15 | #include "../../inc/switches.h" |
16 | |
17 | #ifndef ASMCONSTANTS_C_ASSERT |
18 | #define ASMCONSTANTS_C_ASSERT(cond) |
19 | #endif |
20 | |
21 | #ifndef ASMCONSTANTS_RUNTIME_ASSERT |
22 | #define ASMCONSTANTS_RUNTIME_ASSERT(cond) |
23 | #endif |
24 | |
25 | |
26 | // Some contants are different in _DEBUG builds. This macro factors out |
27 | // ifdefs from below. |
28 | #ifdef _DEBUG |
29 | #define DBG_FRE(dbg,fre) dbg |
30 | #else |
31 | #define DBG_FRE(dbg,fre) fre |
32 | #endif |
33 | |
34 | #define DynamicHelperFrameFlags_Default 0 |
35 | #define DynamicHelperFrameFlags_ObjectArg 1 |
36 | #define DynamicHelperFrameFlags_ObjectArg2 2 |
37 | |
38 | #define ASMCONSTANT_OFFSETOF_ASSERT(struct, member) \ |
39 | ASMCONSTANTS_C_ASSERT(OFFSETOF__##struct##__##member == offsetof(struct, member)); |
40 | |
41 | #define ASMCONSTANT_SIZEOF_ASSERT(classname) \ |
42 | ASMCONSTANTS_C_ASSERT(SIZEOF__##classname == sizeof(classname)); |
43 | |
44 | #define ASM_ELEMENT_TYPE_R4 0xC |
45 | ASMCONSTANTS_C_ASSERT(ASM_ELEMENT_TYPE_R4 == ELEMENT_TYPE_R4); |
46 | |
47 | #define ASM_ELEMENT_TYPE_R8 0xD |
48 | ASMCONSTANTS_C_ASSERT(ASM_ELEMENT_TYPE_R8 == ELEMENT_TYPE_R8); |
49 | |
50 | |
51 | #define METHODDESC_REGNUM 10 |
52 | #define METHODDESC_REGISTER r10 |
53 | |
54 | #define PINVOKE_CALLI_TARGET_REGNUM 10 |
55 | #define PINVOKE_CALLI_TARGET_REGISTER r10 |
56 | |
57 | #define PINVOKE_CALLI_SIGTOKEN_REGNUM 11 |
58 | #define PINVOKE_CALLI_SIGTOKEN_REGISTER r11 |
59 | |
60 | #ifdef UNIX_AMD64_ABI |
61 | // rdi, rsi, rdx, rcx, r8, r9 |
62 | #define SIZEOF_MAX_INT_ARG_SPILL 0x30 |
63 | // xmm0...xmm7 |
64 | #define SIZEOF_MAX_FP_ARG_SPILL 0x80 |
65 | #else |
66 | // rcx, rdx, r8, r9 |
67 | #define SIZEOF_MAX_OUTGOING_ARGUMENT_HOMES 0x20 |
68 | // xmm0...xmm3 |
69 | #define SIZEOF_MAX_FP_ARG_SPILL 0x40 |
70 | #endif |
71 | |
72 | |
73 | |
74 | #ifndef UNIX_AMD64_ABI |
75 | #define SIZEOF_CalleeSavedRegisters 0x40 |
76 | ASMCONSTANTS_C_ASSERT(SIZEOF_CalleeSavedRegisters == sizeof(CalleeSavedRegisters)); |
77 | #else |
78 | #define SIZEOF_CalleeSavedRegisters 0x30 |
79 | ASMCONSTANTS_C_ASSERT(SIZEOF_CalleeSavedRegisters == sizeof(CalleeSavedRegisters)); |
80 | #endif |
81 | |
82 | #define SIZEOF_GSCookie 0x8 |
83 | ASMCONSTANTS_C_ASSERT(SIZEOF_GSCookie == sizeof(GSCookie)); |
84 | |
85 | #define OFFSETOF__Frame____VFN_table 0 |
86 | |
87 | #define OFFSETOF__Frame__m_Next 0x8 |
88 | ASMCONSTANTS_C_ASSERT(OFFSETOF__Frame__m_Next |
89 | == offsetof(Frame, m_Next)); |
90 | |
91 | #define SIZEOF__Frame 0x10 |
92 | |
93 | #ifdef FEATURE_COMINTEROP |
94 | #define SIZEOF__ComPrestubMethodFrame 0x20 |
95 | ASMCONSTANTS_C_ASSERT(SIZEOF__ComPrestubMethodFrame |
96 | == sizeof(ComPrestubMethodFrame)); |
97 | |
98 | #define SIZEOF__ComMethodFrame 0x20 |
99 | ASMCONSTANTS_C_ASSERT(SIZEOF__ComMethodFrame |
100 | == sizeof(ComMethodFrame)); |
101 | #endif // FEATURE_COMINTEROP |
102 | |
103 | #define OFFSETOF__UMEntryThunk__m_pUMThunkMarshInfo 0x18 |
104 | ASMCONSTANTS_C_ASSERT(OFFSETOF__UMEntryThunk__m_pUMThunkMarshInfo |
105 | == offsetof(UMEntryThunk, m_pUMThunkMarshInfo)); |
106 | |
107 | #define OFFSETOF__UMEntryThunk__m_dwDomainId 0x20 |
108 | ASMCONSTANTS_C_ASSERT(OFFSETOF__UMEntryThunk__m_dwDomainId |
109 | == offsetof(UMEntryThunk, m_dwDomainId)); |
110 | |
111 | #define OFFSETOF__UMThunkMarshInfo__m_pILStub 0x00 |
112 | ASMCONSTANTS_C_ASSERT(OFFSETOF__UMThunkMarshInfo__m_pILStub |
113 | == offsetof(UMThunkMarshInfo, m_pILStub)); |
114 | |
115 | #define OFFSETOF__UMThunkMarshInfo__m_cbActualArgSize 0x08 |
116 | ASMCONSTANTS_C_ASSERT(OFFSETOF__UMThunkMarshInfo__m_cbActualArgSize |
117 | == offsetof(UMThunkMarshInfo, m_cbActualArgSize)); |
118 | |
119 | #ifdef FEATURE_COMINTEROP |
120 | |
121 | #define OFFSETOF__ComPlusCallMethodDesc__m_pComPlusCallInfo DBG_FRE(0x30, 0x08) |
122 | ASMCONSTANTS_C_ASSERT(OFFSETOF__ComPlusCallMethodDesc__m_pComPlusCallInfo |
123 | == offsetof(ComPlusCallMethodDesc, m_pComPlusCallInfo)); |
124 | |
125 | #define OFFSETOF__ComPlusCallInfo__m_pILStub 0x0 |
126 | ASMCONSTANTS_C_ASSERT(OFFSETOF__ComPlusCallInfo__m_pILStub |
127 | == offsetof(ComPlusCallInfo, m_pILStub)); |
128 | |
129 | #endif // FEATURE_COMINTEROP |
130 | |
131 | #define OFFSETOF__Thread__m_fPreemptiveGCDisabled 0x0C |
132 | #ifndef CROSSGEN_COMPILE |
133 | ASMCONSTANTS_C_ASSERT(OFFSETOF__Thread__m_fPreemptiveGCDisabled |
134 | == offsetof(Thread, m_fPreemptiveGCDisabled)); |
135 | #endif |
136 | #define Thread_m_fPreemptiveGCDisabled OFFSETOF__Thread__m_fPreemptiveGCDisabled |
137 | |
138 | #define OFFSETOF__Thread__m_pFrame 0x10 |
139 | #ifndef CROSSGEN_COMPILE |
140 | ASMCONSTANTS_C_ASSERT(OFFSETOF__Thread__m_pFrame |
141 | == offsetof(Thread, m_pFrame)); |
142 | #endif |
143 | #define Thread_m_pFrame OFFSETOF__Thread__m_pFrame |
144 | |
145 | #ifndef CROSSGEN_COMPILE |
146 | #define OFFSETOF__Thread__m_State 0x8 |
147 | ASMCONSTANTS_C_ASSERT(OFFSETOF__Thread__m_State |
148 | == offsetof(Thread, m_State)); |
149 | |
150 | #define OFFSETOF__Thread__m_pDomain 0x18 |
151 | ASMCONSTANTS_C_ASSERT(OFFSETOF__Thread__m_pDomain |
152 | == offsetof(Thread, m_pDomain)); |
153 | |
154 | #define OFFSETOF__Thread__m_dwLockCount 0x20 |
155 | ASMCONSTANTS_C_ASSERT(OFFSETOF__Thread__m_dwLockCount |
156 | == offsetof(Thread, m_dwLockCount)); |
157 | |
158 | #define OFFSETOF__Thread__m_ThreadId 0x24 |
159 | ASMCONSTANTS_C_ASSERT(OFFSETOF__Thread__m_ThreadId |
160 | == offsetof(Thread, m_ThreadId)); |
161 | |
162 | #define OFFSET__Thread__m_alloc_context__alloc_ptr 0x58 |
163 | ASMCONSTANTS_C_ASSERT(OFFSET__Thread__m_alloc_context__alloc_ptr == offsetof(Thread, m_alloc_context) + offsetof(gc_alloc_context, alloc_ptr)); |
164 | |
165 | #define OFFSET__Thread__m_alloc_context__alloc_limit 0x60 |
166 | ASMCONSTANTS_C_ASSERT(OFFSET__Thread__m_alloc_context__alloc_limit == offsetof(Thread, m_alloc_context) + offsetof(gc_alloc_context, alloc_limit)); |
167 | |
168 | #define OFFSETOF__gc_alloc_context__alloc_ptr 0x0 |
169 | ASMCONSTANT_OFFSETOF_ASSERT(gc_alloc_context, alloc_ptr); |
170 | |
171 | #define OFFSETOF__gc_alloc_context__alloc_limit 0x8 |
172 | ASMCONSTANT_OFFSETOF_ASSERT(gc_alloc_context, alloc_limit); |
173 | |
174 | #define OFFSETOF__ThreadExceptionState__m_pCurrentTracker 0x000 |
175 | ASMCONSTANTS_C_ASSERT(OFFSETOF__ThreadExceptionState__m_pCurrentTracker |
176 | == offsetof(ThreadExceptionState, m_pCurrentTracker)); |
177 | |
178 | #endif // CROSSGEN_COMPILE |
179 | |
180 | |
181 | |
182 | #define OFFSETOF__NDirectMethodDesc__m_pWriteableData DBG_FRE(0x48, 0x20) |
183 | ASMCONSTANTS_C_ASSERT(OFFSETOF__NDirectMethodDesc__m_pWriteableData == offsetof(NDirectMethodDesc, ndirect.m_pWriteableData)); |
184 | |
185 | #define OFFSETOF__DelegateObject___methodPtr 0x18 |
186 | ASMCONSTANT_OFFSETOF_ASSERT(DelegateObject, _methodPtr); |
187 | |
188 | #define OFFSETOF__DelegateObject___target 0x08 |
189 | ASMCONSTANT_OFFSETOF_ASSERT(DelegateObject, _target); |
190 | |
191 | #define OFFSETOF__MethodTable__m_dwFlags 0x00 |
192 | ASMCONSTANTS_C_ASSERT(OFFSETOF__MethodTable__m_dwFlags |
193 | == offsetof(MethodTable, m_dwFlags)); |
194 | |
195 | #define OFFSET__MethodTable__m_BaseSize 0x04 |
196 | ASMCONSTANTS_C_ASSERT(OFFSET__MethodTable__m_BaseSize |
197 | == offsetof(MethodTable, m_BaseSize)); |
198 | |
199 | #define OFFSETOF__MethodTable__m_wNumInterfaces 0x0E |
200 | ASMCONSTANTS_C_ASSERT(OFFSETOF__MethodTable__m_wNumInterfaces |
201 | == offsetof(MethodTable, m_wNumInterfaces)); |
202 | |
203 | #define OFFSETOF__MethodTable__m_pParentMethodTable DBG_FRE(0x18, 0x10) |
204 | ASMCONSTANTS_C_ASSERT(OFFSETOF__MethodTable__m_pParentMethodTable |
205 | == offsetof(MethodTable, m_pParentMethodTable)); |
206 | |
207 | #define OFFSETOF__MethodTable__m_pWriteableData DBG_FRE(0x28, 0x20) |
208 | ASMCONSTANTS_C_ASSERT(OFFSETOF__MethodTable__m_pWriteableData |
209 | == offsetof(MethodTable, m_pWriteableData)); |
210 | |
211 | #define OFFSETOF__MethodTable__m_pEEClass DBG_FRE(0x30, 0x28) |
212 | ASMCONSTANTS_C_ASSERT(OFFSETOF__MethodTable__m_pEEClass |
213 | == offsetof(MethodTable, m_pEEClass)); |
214 | |
215 | #define METHODTABLE_OFFSET_VTABLE DBG_FRE(0x48, 0x40) |
216 | ASMCONSTANTS_C_ASSERT(METHODTABLE_OFFSET_VTABLE == sizeof(MethodTable)); |
217 | |
218 | #define OFFSETOF__MethodTable__m_ElementType DBG_FRE(0x38, 0x30) |
219 | ASMCONSTANTS_C_ASSERT(OFFSETOF__MethodTable__m_ElementType |
220 | == offsetof(MethodTable, m_pMultipurposeSlot1)); |
221 | |
222 | #define OFFSETOF__MethodTable__m_pInterfaceMap DBG_FRE(0x40, 0x38) |
223 | ASMCONSTANTS_C_ASSERT(OFFSETOF__MethodTable__m_pInterfaceMap |
224 | == offsetof(MethodTable, m_pMultipurposeSlot2)); |
225 | |
226 | |
227 | #define MethodTable_VtableSlotsPerChunk 8 |
228 | ASMCONSTANTS_C_ASSERT(MethodTable_VtableSlotsPerChunk == VTABLE_SLOTS_PER_CHUNK) |
229 | |
230 | #define MethodTable_VtableSlotsPerChunkLog2 3 |
231 | ASMCONSTANTS_C_ASSERT(MethodTable_VtableSlotsPerChunkLog2 == VTABLE_SLOTS_PER_CHUNK_LOG2) |
232 | |
233 | #if defined(FEATURE_TYPEEQUIVALENCE) |
234 | #define METHODTABLE_EQUIVALENCE_FLAGS 0x02000000 |
235 | ASMCONSTANTS_C_ASSERT(METHODTABLE_EQUIVALENCE_FLAGS |
236 | == MethodTable::enum_flag_HasTypeEquivalence); |
237 | #else |
238 | #define METHODTABLE_EQUIVALENCE_FLAGS 0x0 |
239 | #endif |
240 | |
241 | #define METHODTABLE_NONTRIVIALINTERFACECAST_FLAGS (0x00080000 + 0x40000000 + 0x00400000) |
242 | ASMCONSTANTS_C_ASSERT(METHODTABLE_NONTRIVIALINTERFACECAST_FLAGS |
243 | == MethodTable::enum_flag_NonTrivialInterfaceCast); |
244 | |
245 | #define MethodTable__enum_flag_ContainsPointers 0x01000000 |
246 | ASMCONSTANTS_C_ASSERT(MethodTable__enum_flag_ContainsPointers |
247 | == MethodTable::enum_flag_ContainsPointers); |
248 | |
249 | #define OFFSETOF__MethodTableWriteableData__m_dwFlags 0 |
250 | ASMCONSTANTS_C_ASSERT(OFFSETOF__MethodTableWriteableData__m_dwFlags |
251 | == offsetof(MethodTableWriteableData, m_dwFlags)); |
252 | |
253 | #define MethodTableWriteableData__enum_flag_Unrestored 0x04 |
254 | ASMCONSTANTS_C_ASSERT(MethodTableWriteableData__enum_flag_Unrestored |
255 | == MethodTableWriteableData::enum_flag_Unrestored); |
256 | |
257 | #define OFFSETOF__InterfaceInfo_t__m_pMethodTable 0 |
258 | ASMCONSTANTS_C_ASSERT(OFFSETOF__InterfaceInfo_t__m_pMethodTable |
259 | == offsetof(InterfaceInfo_t, m_pMethodTable)); |
260 | |
261 | #define SIZEOF__InterfaceInfo_t 0x8 |
262 | ASMCONSTANTS_C_ASSERT(SIZEOF__InterfaceInfo_t |
263 | == sizeof(InterfaceInfo_t)); |
264 | |
265 | #define OFFSETOF__AppDomain__m_dwId 0x8 |
266 | ASMCONSTANTS_C_ASSERT(OFFSETOF__AppDomain__m_dwId |
267 | == offsetof(AppDomain, m_dwId)); |
268 | |
269 | #define OFFSETOF__AppDomain__m_sDomainLocalBlock DBG_FRE(0x10, 0x10) |
270 | ASMCONSTANTS_C_ASSERT(OFFSETOF__AppDomain__m_sDomainLocalBlock |
271 | == offsetof(AppDomain, m_sDomainLocalBlock)); |
272 | |
273 | #define OFFSETOF__DomainLocalBlock__m_pModuleSlots 0x8 |
274 | ASMCONSTANTS_C_ASSERT(OFFSETOF__DomainLocalBlock__m_pModuleSlots |
275 | == offsetof(DomainLocalBlock, m_pModuleSlots)); |
276 | |
277 | #define OFFSETOF__DomainLocalModule__m_pDataBlob 0x030 |
278 | ASMCONSTANTS_C_ASSERT(OFFSETOF__DomainLocalModule__m_pDataBlob |
279 | == offsetof(DomainLocalModule, m_pDataBlob)); |
280 | |
281 | // If this changes then we can't just test one bit in the assembly code. |
282 | ASMCONSTANTS_C_ASSERT(ClassInitFlags::INITIALIZED_FLAG == 1); |
283 | |
284 | // End for JIT_GetSharedNonGCStaticBaseWorker |
285 | |
286 | // For JIT_GetSharedGCStaticBaseWorker |
287 | |
288 | #define OFFSETOF__DomainLocalModule__m_pGCStatics 0x020 |
289 | ASMCONSTANTS_C_ASSERT(OFFSETOF__DomainLocalModule__m_pGCStatics |
290 | == offsetof(DomainLocalModule, m_pGCStatics)); |
291 | |
292 | // End for JIT_GetSharedGCStaticBaseWorker |
293 | |
294 | #define CORINFO_NullReferenceException_ASM 0 |
295 | ASMCONSTANTS_C_ASSERT( CORINFO_NullReferenceException_ASM |
296 | == CORINFO_NullReferenceException); |
297 | |
298 | #define CORINFO_InvalidCastException_ASM 2 |
299 | ASMCONSTANTS_C_ASSERT( CORINFO_InvalidCastException_ASM |
300 | == CORINFO_InvalidCastException); |
301 | |
302 | #define CORINFO_IndexOutOfRangeException_ASM 3 |
303 | ASMCONSTANTS_C_ASSERT( CORINFO_IndexOutOfRangeException_ASM |
304 | == CORINFO_IndexOutOfRangeException); |
305 | |
306 | #define CORINFO_ArrayTypeMismatchException_ASM 6 |
307 | ASMCONSTANTS_C_ASSERT( CORINFO_ArrayTypeMismatchException_ASM |
308 | == CORINFO_ArrayTypeMismatchException); |
309 | |
310 | #define CORINFO_ArgumentNullException_ASM 8 |
311 | ASMCONSTANTS_C_ASSERT( CORINFO_ArgumentNullException_ASM |
312 | == CORINFO_ArgumentNullException); |
313 | |
314 | #define CORINFO_ArgumentException_ASM 9 |
315 | ASMCONSTANTS_C_ASSERT( CORINFO_ArgumentException_ASM |
316 | == CORINFO_ArgumentException); |
317 | |
318 | |
319 | // MachState offsets (AMD64\gmscpu.h) |
320 | |
321 | #define OFFSETOF__MachState__m_Rip 0x00 |
322 | ASMCONSTANTS_C_ASSERT(OFFSETOF__MachState__m_Rip |
323 | == offsetof(MachState, m_Rip)); |
324 | |
325 | #define OFFSETOF__MachState__m_Rsp 0x08 |
326 | ASMCONSTANTS_C_ASSERT(OFFSETOF__MachState__m_Rsp |
327 | == offsetof(MachState, m_Rsp)); |
328 | |
329 | #define OFFSETOF__MachState__m_Capture 0x10 |
330 | ASMCONSTANTS_C_ASSERT(OFFSETOF__MachState__m_Capture |
331 | == offsetof(MachState, m_Capture)); |
332 | |
333 | #ifdef UNIX_AMD64_ABI |
334 | #define OFFSETOF__MachState__m_Ptrs 0x40 |
335 | #define OFFSETOF__MachState___pRetAddr 0x70 |
336 | #define OFFSETOF__LazyMachState__m_CaptureRip 0xA8 |
337 | #define OFFSETOF__LazyMachState__m_CaptureRsp 0xB0 |
338 | #else |
339 | #define OFFSETOF__MachState__m_Ptrs 0x50 |
340 | #define OFFSETOF__MachState___pRetAddr 0x90 |
341 | #define OFFSETOF__LazyMachState__m_CaptureRip 0x98 |
342 | #define OFFSETOF__LazyMachState__m_CaptureRsp 0xA0 |
343 | #endif |
344 | ASMCONSTANTS_C_ASSERT(OFFSETOF__MachState__m_Ptrs |
345 | == offsetof(MachState, m_Ptrs)); |
346 | ASMCONSTANTS_C_ASSERT(OFFSETOF__MachState___pRetAddr |
347 | == offsetof(MachState, _pRetAddr)); |
348 | ASMCONSTANTS_C_ASSERT(OFFSETOF__LazyMachState__m_CaptureRip |
349 | == offsetof(LazyMachState, m_CaptureRip)); |
350 | ASMCONSTANTS_C_ASSERT(OFFSETOF__LazyMachState__m_CaptureRsp |
351 | == offsetof(LazyMachState, m_CaptureRsp)); |
352 | |
353 | #define OFFSETOF__MethodDesc__m_wFlags DBG_FRE(0x2E, 0x06) |
354 | ASMCONSTANTS_C_ASSERT(OFFSETOF__MethodDesc__m_wFlags == offsetof(MethodDesc, m_wFlags)); |
355 | |
356 | #define OFFSETOF__VASigCookie__pNDirectILStub 0x8 |
357 | ASMCONSTANTS_C_ASSERT(OFFSETOF__VASigCookie__pNDirectILStub |
358 | == offsetof(VASigCookie, pNDirectILStub)); |
359 | |
360 | #define SIZEOF__CONTEXT (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*16 + 8 + /*XMM_SAVE_AREA32*/(2*2 + 1*2 + 2 + 4 + 2*2 + 4 + 2*2 + 4*2 + 16*8 + 16*16 + 1*96) + 26*16 + 8 + 8*5) |
361 | ASMCONSTANTS_C_ASSERT(SIZEOF__CONTEXT |
362 | == sizeof(CONTEXT)); |
363 | |
364 | #define OFFSETOF__CONTEXT__Rax (8*6 + 4*2 + 2*6 + 4 + 8*6) |
365 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Rax |
366 | == offsetof(CONTEXT, Rax)); |
367 | |
368 | #define OFFSETOF__CONTEXT__Rcx (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8) |
369 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Rcx |
370 | == offsetof(CONTEXT, Rcx)); |
371 | |
372 | #define OFFSETOF__CONTEXT__Rdx (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*2) |
373 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Rdx |
374 | == offsetof(CONTEXT, Rdx)); |
375 | |
376 | #define OFFSETOF__CONTEXT__Rbx (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*3) |
377 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Rbx |
378 | == offsetof(CONTEXT, Rbx)); |
379 | |
380 | #define OFFSETOF__CONTEXT__Rsp (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*4) |
381 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Rsp |
382 | == offsetof(CONTEXT, Rsp)); |
383 | |
384 | #define OFFSETOF__CONTEXT__Rbp (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*5) |
385 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Rbp |
386 | == offsetof(CONTEXT, Rbp)); |
387 | |
388 | #define OFFSETOF__CONTEXT__Rsi (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*6) |
389 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Rsi |
390 | == offsetof(CONTEXT, Rsi)); |
391 | |
392 | #define OFFSETOF__CONTEXT__Rdi (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*7) |
393 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Rdi |
394 | == offsetof(CONTEXT, Rdi)); |
395 | |
396 | #define OFFSETOF__CONTEXT__R8 (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*8) |
397 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__R8 |
398 | == offsetof(CONTEXT, R8)); |
399 | |
400 | #define OFFSETOF__CONTEXT__R9 (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*9) |
401 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__R9 |
402 | == offsetof(CONTEXT, R9)); |
403 | |
404 | #define OFFSETOF__CONTEXT__R10 (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*10) |
405 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__R10 |
406 | == offsetof(CONTEXT, R10)); |
407 | |
408 | #define OFFSETOF__CONTEXT__R11 (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*11) |
409 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__R11 |
410 | == offsetof(CONTEXT, R11)); |
411 | |
412 | #define OFFSETOF__CONTEXT__R12 (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*12) |
413 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__R12 |
414 | == offsetof(CONTEXT, R12)); |
415 | |
416 | #define OFFSETOF__CONTEXT__R13 (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*13) |
417 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__R13 |
418 | == offsetof(CONTEXT, R13)); |
419 | |
420 | #define OFFSETOF__CONTEXT__R14 (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*14) |
421 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__R14 |
422 | == offsetof(CONTEXT, R14)); |
423 | |
424 | #define OFFSETOF__CONTEXT__R15 (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*15) |
425 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__R15 |
426 | == offsetof(CONTEXT, R15)); |
427 | |
428 | #define OFFSETOF__CONTEXT__Rip (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*16) |
429 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Rip |
430 | == offsetof(CONTEXT, Rip)); |
431 | |
432 | #define OFFSETOF__CONTEXT__Xmm0 (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*16 + 8 + 2*16 + 8*16) |
433 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Xmm0 |
434 | == offsetof(CONTEXT, Xmm0)); |
435 | |
436 | #define OFFSETOF__CONTEXT__Xmm1 (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*16 + 8 + 2*16 + 8*16 + 16) |
437 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Xmm1 |
438 | == offsetof(CONTEXT, Xmm1)); |
439 | |
440 | #define OFFSETOF__CONTEXT__Xmm2 (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*16 + 8 + 2*16 + 8*16 + 16*2) |
441 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Xmm2 |
442 | == offsetof(CONTEXT, Xmm2)); |
443 | |
444 | #define OFFSETOF__CONTEXT__Xmm3 (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*16 + 8 + 2*16 + 8*16 + 16*3) |
445 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Xmm3 |
446 | == offsetof(CONTEXT, Xmm3)); |
447 | |
448 | #define OFFSETOF__CONTEXT__Xmm4 (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*16 + 8 + 2*16 + 8*16 + 16*4) |
449 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Xmm4 |
450 | == offsetof(CONTEXT, Xmm4)); |
451 | |
452 | #define OFFSETOF__CONTEXT__Xmm5 (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*16 + 8 + 2*16 + 8*16 + 16*5) |
453 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Xmm5 |
454 | == offsetof(CONTEXT, Xmm5)); |
455 | |
456 | #define OFFSETOF__CONTEXT__Xmm6 (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*16 + 8 + 2*16 + 8*16 + 16*6) |
457 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Xmm6 |
458 | == offsetof(CONTEXT, Xmm6)); |
459 | |
460 | #define OFFSETOF__CONTEXT__Xmm7 (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*16 + 8 + 2*16 + 8*16 + 16*7) |
461 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Xmm7 |
462 | == offsetof(CONTEXT, Xmm7)); |
463 | |
464 | #define OFFSETOF__CONTEXT__Xmm8 (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*16 + 8 + 2*16 + 8*16 + 16*8) |
465 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Xmm8 |
466 | == offsetof(CONTEXT, Xmm8)); |
467 | |
468 | #define OFFSETOF__CONTEXT__Xmm9 (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*16 + 8 + 2*16 + 8*16 + 16*9) |
469 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Xmm9 |
470 | == offsetof(CONTEXT, Xmm9)); |
471 | |
472 | #define OFFSETOF__CONTEXT__Xmm10 (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*16 + 8 + 2*16 + 8*16 + 16*10) |
473 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Xmm10 |
474 | == offsetof(CONTEXT, Xmm10)); |
475 | |
476 | #define OFFSETOF__CONTEXT__Xmm11 (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*16 + 8 + 2*16 + 8*16 + 16*11) |
477 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Xmm11 |
478 | == offsetof(CONTEXT, Xmm11)); |
479 | |
480 | #define OFFSETOF__CONTEXT__Xmm12 (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*16 + 8 + 2*16 + 8*16 + 16*12) |
481 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Xmm12 |
482 | == offsetof(CONTEXT, Xmm12)); |
483 | |
484 | #define OFFSETOF__CONTEXT__Xmm13 (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*16 + 8 + 2*16 + 8*16 + 16*13) |
485 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Xmm13 |
486 | == offsetof(CONTEXT, Xmm13)); |
487 | |
488 | #define OFFSETOF__CONTEXT__Xmm14 (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*16 + 8 + 2*16 + 8*16 + 16*14) |
489 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Xmm14 |
490 | == offsetof(CONTEXT, Xmm14)); |
491 | |
492 | #define OFFSETOF__CONTEXT__Xmm15 (8*6 + 4*2 + 2*6 + 4 + 8*6 + 8*16 + 8 + 2*16 + 8*16 + 16*15) |
493 | ASMCONSTANTS_C_ASSERT(OFFSETOF__CONTEXT__Xmm15 |
494 | == offsetof(CONTEXT, Xmm15)); |
495 | |
496 | #define SIZEOF__FaultingExceptionFrame (0x20 + SIZEOF__CONTEXT) |
497 | ASMCONSTANTS_C_ASSERT(SIZEOF__FaultingExceptionFrame |
498 | == sizeof(FaultingExceptionFrame)); |
499 | |
500 | #define OFFSETOF__FaultingExceptionFrame__m_fFilterExecuted 0x10 |
501 | ASMCONSTANTS_C_ASSERT(OFFSETOF__FaultingExceptionFrame__m_fFilterExecuted |
502 | == offsetof(FaultingExceptionFrame, m_fFilterExecuted)); |
503 | |
504 | #define OFFSETOF__PtrArray__m_NumComponents 0x8 |
505 | ASMCONSTANTS_C_ASSERT(OFFSETOF__PtrArray__m_NumComponents |
506 | == offsetof(PtrArray, m_NumComponents)); |
507 | |
508 | #define OFFSETOF__PtrArray__m_Array 0x10 |
509 | ASMCONSTANTS_C_ASSERT(OFFSETOF__PtrArray__m_Array |
510 | == offsetof(PtrArray, m_Array)); |
511 | |
512 | |
513 | #define MethodDescClassification__mdcClassification 0x7 |
514 | ASMCONSTANTS_C_ASSERT(MethodDescClassification__mdcClassification == mdcClassification); |
515 | |
516 | #define MethodDescClassification__mcInstantiated 0x5 |
517 | ASMCONSTANTS_C_ASSERT(MethodDescClassification__mcInstantiated == mcInstantiated); |
518 | |
519 | #ifndef FEATURE_PAL |
520 | #define OFFSET__TEB__ThreadLocalStoragePointer 0x58 |
521 | ASMCONSTANTS_C_ASSERT(OFFSET__TEB__ThreadLocalStoragePointer == offsetof(TEB, ThreadLocalStoragePointer)); |
522 | #endif |
523 | |
524 | // If you change these constants, you need to update code in |
525 | // RedirectHandledJITCase.asm and ExcepAMD64.cpp. |
526 | #define REDIRECTSTUB_ESTABLISHER_OFFSET_RBP 0 |
527 | #define REDIRECTSTUB_RBP_OFFSET_CONTEXT 0x20 |
528 | |
529 | #define THROWSTUB_ESTABLISHER_OFFSET_FaultingExceptionFrame 0x30 |
530 | |
531 | #define UMTHUNKSTUB_HOST_NOTIFY_FLAG_RBPOFFSET (0x40) // xmm save size |
532 | |
533 | #define Thread__ObjectRefFlush ?ObjectRefFlush@Thread@@SAXPEAV1@@Z |
534 | |
535 | |
536 | #define DELEGATE_FIELD_OFFSET__METHOD_AUX 0x20 |
537 | ASMCONSTANTS_RUNTIME_ASSERT(DELEGATE_FIELD_OFFSET__METHOD_AUX == Object::GetOffsetOfFirstField() + |
538 | MscorlibBinder::GetFieldOffset(FIELD__DELEGATE__METHOD_PTR_AUX)); |
539 | |
540 | |
541 | #define ASM_LARGE_OBJECT_SIZE 85000 |
542 | ASMCONSTANTS_C_ASSERT(ASM_LARGE_OBJECT_SIZE == LARGE_OBJECT_SIZE); |
543 | |
544 | #define OFFSETOF__ArrayBase__m_NumComponents 8 |
545 | ASMCONSTANTS_C_ASSERT(OFFSETOF__ArrayBase__m_NumComponents |
546 | == offsetof(ArrayBase, m_NumComponents)); |
547 | |
548 | #define STRING_BASE_SIZE 0x16 |
549 | ASMCONSTANTS_RUNTIME_ASSERT(STRING_BASE_SIZE == StringObject::GetBaseSize()); |
550 | |
551 | #define OFFSETOF__StringObject__m_StringLength 0x8 |
552 | ASMCONSTANTS_C_ASSERT(OFFSETOF__StringObject__m_StringLength |
553 | == offsetof(StringObject, m_StringLength)); |
554 | |
555 | #define OFFSETOF__ArrayTypeDesc__m_Arg 0x10 |
556 | ASMCONSTANTS_C_ASSERT(OFFSETOF__ArrayTypeDesc__m_Arg |
557 | == offsetof(ArrayTypeDesc, m_Arg)); |
558 | |
559 | #define CallDescrData__pSrc 0x00 |
560 | #define CallDescrData__numStackSlots 0x08 |
561 | #ifdef UNIX_AMD64_ABI |
562 | #define CallDescrData__pArgumentRegisters 0x10 |
563 | #define CallDescrData__pFloatArgumentRegisters 0x18 |
564 | #define CallDescrData__fpReturnSize 0x20 |
565 | #define CallDescrData__pTarget 0x28 |
566 | #define CallDescrData__returnValue 0x30 |
567 | #else |
568 | #define CallDescrData__dwRegTypeMap 0x10 |
569 | #define CallDescrData__fpReturnSize 0x18 |
570 | #define CallDescrData__pTarget 0x20 |
571 | #define CallDescrData__returnValue 0x28 |
572 | #endif |
573 | |
574 | ASMCONSTANTS_C_ASSERT(CallDescrData__pSrc == offsetof(CallDescrData, pSrc)) |
575 | ASMCONSTANTS_C_ASSERT(CallDescrData__numStackSlots == offsetof(CallDescrData, numStackSlots)) |
576 | #ifdef UNIX_AMD64_ABI |
577 | ASMCONSTANTS_C_ASSERT(CallDescrData__pArgumentRegisters == offsetof(CallDescrData, pArgumentRegisters)) |
578 | ASMCONSTANTS_C_ASSERT(CallDescrData__pFloatArgumentRegisters == offsetof(CallDescrData, pFloatArgumentRegisters)) |
579 | #else |
580 | ASMCONSTANTS_C_ASSERT(CallDescrData__dwRegTypeMap == offsetof(CallDescrData, dwRegTypeMap)) |
581 | #endif |
582 | ASMCONSTANTS_C_ASSERT(CallDescrData__fpReturnSize == offsetof(CallDescrData, fpReturnSize)) |
583 | ASMCONSTANTS_C_ASSERT(CallDescrData__pTarget == offsetof(CallDescrData, pTarget)) |
584 | ASMCONSTANTS_C_ASSERT(CallDescrData__returnValue == offsetof(CallDescrData, returnValue)) |
585 | |
586 | #ifdef UNIX_AMD64_ABI |
587 | #define OFFSETOF__TransitionBlock__m_argumentRegisters 0x00 |
588 | ASMCONSTANTS_C_ASSERT(OFFSETOF__TransitionBlock__m_argumentRegisters == offsetof(TransitionBlock, m_argumentRegisters)) |
589 | #endif // UNIX_AMD64_ABI |
590 | |
591 | #undef ASMCONSTANTS_RUNTIME_ASSERT |
592 | #undef ASMCONSTANTS_C_ASSERT |
593 | #ifndef UNIX_AMD64_ABI |
594 | #undef DBG_FRE |
595 | #endif // UNIX_AMD64_ABI |
596 | |
597 | |
598 | //#define USE_COMPILE_TIME_CONSTANT_FINDER // Uncomment this line to use the constant finder |
599 | #if defined(__cplusplus) && defined(USE_COMPILE_TIME_CONSTANT_FINDER) |
600 | // This class causes the compiler to emit an error with the constant we're interested in |
601 | // in the error message. This is useful if a size or offset changes. To use, comment out |
602 | // the compile-time assert that is firing, enable the constant finder, add the appropriate |
603 | // constant to find to BogusFunction(), and build. |
604 | // |
605 | // Here's a sample compiler error: |
606 | // d:\dd\clr\src\ndp\clr\src\vm\i386\asmconstants.h(326) : error C2248: 'FindCompileTimeConstant<N>::FindCompileTimeConstant' : cannot access private member declared in class 'FindCompileTimeConstant<N>' |
607 | // with |
608 | // [ |
609 | // N=1520 |
610 | // ] |
611 | // d:\dd\clr\src\ndp\clr\src\vm\i386\asmconstants.h(321) : see declaration of 'FindCompileTimeConstant<N>::FindCompileTimeConstant' |
612 | // with |
613 | // [ |
614 | // N=1520 |
615 | // ] |
616 | template<size_t N> |
617 | class FindCompileTimeConstant |
618 | { |
619 | private: |
620 | FindCompileTimeConstant(); |
621 | }; |
622 | |
623 | void BogusFunction() |
624 | { |
625 | // Sample usage to generate the error |
626 | FindCompileTimeConstant<offsetof(Thread, m_pDomain)> bogus_variable; |
627 | FindCompileTimeConstant<offsetof(Thread, m_ExceptionState)> bogus_variable2; |
628 | } |
629 | #endif // defined(__cplusplus) && defined(USE_COMPILE_TIME_CONSTANT_FINDER) |
630 | |