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.
6 // This header defines field offsets and constants used by assembly code
7 // Be sure to rebuild clr/src/vm/ceemain.cpp after changing this file, to
8 // ensure that the constants match the expected C/C++ values
11 // #error this file should only be used on an ARM platform
14 #include "../../inc/switches.h"
16 //-----------------------------------------------------------------------------
18 #ifndef ASMCONSTANTS_C_ASSERT
19 #define ASMCONSTANTS_C_ASSERT(cond)
22 #ifndef ASMCONSTANTS_RUNTIME_ASSERT
23 #define ASMCONSTANTS_RUNTIME_ASSERT(cond)
26 // Some contants are different in _DEBUG builds. This macro factors out ifdefs from below.
28 #define DBG_FRE(dbg,fre) dbg
30 #define DBG_FRE(dbg,fre) fre
33 #define DynamicHelperFrameFlags_Default 0
34 #define DynamicHelperFrameFlags_ObjectArg 1
35 #define DynamicHelperFrameFlags_ObjectArg2 2
37 #define Thread__m_fPreemptiveGCDisabled 0x0C
38 #define Thread__m_pFrame 0x10
40 #ifndef CROSSGEN_COMPILE
41 ASMCONSTANTS_C_ASSERT(Thread__m_fPreemptiveGCDisabled == offsetof(Thread, m_fPreemptiveGCDisabled));
42 ASMCONSTANTS_C_ASSERT(Thread__m_pFrame == offsetof(Thread, m_pFrame));
43 #endif // CROSSGEN_COMPILE
45 #define Thread_m_pFrame Thread__m_pFrame
46 #define Thread_m_fPreemptiveGCDisabled Thread__m_fPreemptiveGCDisabled
48 #define METHODDESC_REGISTER x12
50 #define SIZEOF__ArgumentRegisters 0x40
51 ASMCONSTANTS_C_ASSERT(SIZEOF__ArgumentRegisters == sizeof(ArgumentRegisters))
53 // There are 8 128-bit registers in FloatArgumentRegisters
54 #define SIZEOF__FloatArgumentRegisters 0x80
55 ASMCONSTANTS_C_ASSERT(SIZEOF__FloatArgumentRegisters == sizeof(FloatArgumentRegisters))
57 #define ASM_ENREGISTERED_RETURNTYPE_MAXSIZE 0x40
58 ASMCONSTANTS_C_ASSERT(ASM_ENREGISTERED_RETURNTYPE_MAXSIZE == ENREGISTERED_RETURNTYPE_MAXSIZE)
60 #define CallDescrData__pSrc 0x00
61 #define CallDescrData__numStackSlots 0x08
62 #define CallDescrData__pArgumentRegisters 0x10
63 #define CallDescrData__pFloatArgumentRegisters 0x18
64 #define CallDescrData__fpReturnSize 0x20
65 #define CallDescrData__pTarget 0x28
66 #define CallDescrData__pRetBuffArg 0x30
67 #define CallDescrData__returnValue 0x40
69 ASMCONSTANTS_C_ASSERT(CallDescrData__pSrc == offsetof(CallDescrData, pSrc))
70 ASMCONSTANTS_C_ASSERT(CallDescrData__numStackSlots == offsetof(CallDescrData, numStackSlots))
71 ASMCONSTANTS_C_ASSERT(CallDescrData__pArgumentRegisters == offsetof(CallDescrData, pArgumentRegisters))
72 ASMCONSTANTS_C_ASSERT(CallDescrData__pFloatArgumentRegisters == offsetof(CallDescrData, pFloatArgumentRegisters))
73 ASMCONSTANTS_C_ASSERT(CallDescrData__fpReturnSize == offsetof(CallDescrData, fpReturnSize))
74 ASMCONSTANTS_C_ASSERT(CallDescrData__pTarget == offsetof(CallDescrData, pTarget))
75 ASMCONSTANTS_C_ASSERT(CallDescrData__pRetBuffArg == offsetof(CallDescrData, pRetBuffArg))
76 ASMCONSTANTS_C_ASSERT(CallDescrData__returnValue == offsetof(CallDescrData, returnValue))
78 #define CORINFO_NullReferenceException_ASM 0
79 ASMCONSTANTS_C_ASSERT( CORINFO_NullReferenceException_ASM
80 == CORINFO_NullReferenceException);
83 #define CORINFO_IndexOutOfRangeException_ASM 3
84 ASMCONSTANTS_C_ASSERT( CORINFO_IndexOutOfRangeException_ASM
85 == CORINFO_IndexOutOfRangeException);
88 // Offset of the array containing the address of captured registers in MachState
89 #define MachState__captureX19_X29 0x0
90 ASMCONSTANTS_C_ASSERT(MachState__captureX19_X29 == offsetof(MachState, captureX19_X29))
92 // Offset of the array containing the address of preserved registers in MachState
93 #define MachState__ptrX19_X29 0x58
94 ASMCONSTANTS_C_ASSERT(MachState__ptrX19_X29 == offsetof(MachState, ptrX19_X29))
96 #define MachState__isValid 0xc0
97 ASMCONSTANTS_C_ASSERT(MachState__isValid == offsetof(MachState, _isValid))
99 #define LazyMachState_captureX19_X29 MachState__captureX19_X29
100 ASMCONSTANTS_C_ASSERT(LazyMachState_captureX19_X29 == offsetof(LazyMachState, captureX19_X29))
102 #define LazyMachState_captureSp (MachState__isValid+8) // padding for alignment
103 ASMCONSTANTS_C_ASSERT(LazyMachState_captureSp == offsetof(LazyMachState, captureSp))
105 #define LazyMachState_captureIp (LazyMachState_captureSp+8)
106 ASMCONSTANTS_C_ASSERT(LazyMachState_captureIp == offsetof(LazyMachState, captureIp))
108 #define VASigCookie__pNDirectILStub 0x8
109 ASMCONSTANTS_C_ASSERT(VASigCookie__pNDirectILStub == offsetof(VASigCookie, pNDirectILStub))
111 #define DelegateObject___methodPtr 0x18
112 ASMCONSTANTS_C_ASSERT(DelegateObject___methodPtr == offsetof(DelegateObject, _methodPtr));
114 #define DelegateObject___target 0x08
115 ASMCONSTANTS_C_ASSERT(DelegateObject___target == offsetof(DelegateObject, _target));
117 #define SIZEOF__GSCookie 0x8
118 ASMCONSTANTS_C_ASSERT(SIZEOF__GSCookie == sizeof(GSCookie));
120 #define SIZEOF__Frame 0x10
121 ASMCONSTANTS_C_ASSERT(SIZEOF__Frame == sizeof(Frame));
123 #define SIZEOF__CONTEXT 0x390
124 ASMCONSTANTS_C_ASSERT(SIZEOF__CONTEXT == sizeof(T_CONTEXT));
127 //=========================================
128 #define MethodTable__m_dwFlags 0x0
129 ASMCONSTANTS_C_ASSERT(MethodTable__m_dwFlags == offsetof(MethodTable, m_dwFlags));
131 #define MethodTable__m_BaseSize 0x04
132 ASMCONSTANTS_C_ASSERT(MethodTable__m_BaseSize == offsetof(MethodTable, m_BaseSize));
134 #define MethodTable__m_ElementType DBG_FRE(0x38, 0x30)
135 ASMCONSTANTS_C_ASSERT(MethodTable__m_ElementType == offsetof(MethodTable, m_pMultipurposeSlot1));
137 #define ArrayBase__m_NumComponents 0x8
138 ASMCONSTANTS_C_ASSERT(ArrayBase__m_NumComponents == offsetof(ArrayBase, m_NumComponents));
140 #define PtrArray__m_Array 0x10
141 ASMCONSTANTS_C_ASSERT(PtrArray__m_Array == offsetof(PtrArray, m_Array));
143 #define TypeHandle_CanCast 0x1 // TypeHandle::CanCast
145 //=========================================
149 #ifdef FEATURE_COMINTEROP
151 #define SIZEOF__ComMethodFrame 0x70
152 ASMCONSTANTS_C_ASSERT(SIZEOF__ComMethodFrame == sizeof(ComMethodFrame));
154 #define UnmanagedToManagedFrame__m_pvDatum 0x10
155 ASMCONSTANTS_C_ASSERT(UnmanagedToManagedFrame__m_pvDatum == offsetof(UnmanagedToManagedFrame, m_pvDatum));
157 #endif // FEATURE_COMINTEROP
160 #define UMEntryThunk__m_pUMThunkMarshInfo 0x18
161 ASMCONSTANTS_C_ASSERT(UMEntryThunk__m_pUMThunkMarshInfo == offsetof(UMEntryThunk, m_pUMThunkMarshInfo))
163 #define UMThunkMarshInfo__m_pILStub 0x00
164 ASMCONSTANTS_C_ASSERT(UMThunkMarshInfo__m_pILStub == offsetof(UMThunkMarshInfo, m_pILStub))
166 #define UMThunkMarshInfo__m_cbActualArgSize 0x08
167 ASMCONSTANTS_C_ASSERT(UMThunkMarshInfo__m_cbActualArgSize == offsetof(UMThunkMarshInfo, m_cbActualArgSize))
169 #define REDIRECTSTUB_SP_OFFSET_CONTEXT 0
171 #define CONTEXT_Pc 0x108
172 ASMCONSTANTS_C_ASSERT(CONTEXT_Pc == offsetof(T_CONTEXT,Pc))
174 #define SIZEOF__FaultingExceptionFrame (SIZEOF__Frame + 0x10 + SIZEOF__CONTEXT)
175 #define FaultingExceptionFrame__m_fFilterExecuted SIZEOF__Frame
176 ASMCONSTANTS_C_ASSERT(SIZEOF__FaultingExceptionFrame == sizeof(FaultingExceptionFrame));
177 ASMCONSTANTS_C_ASSERT(FaultingExceptionFrame__m_fFilterExecuted == offsetof(FaultingExceptionFrame, m_fFilterExecuted));
179 #define MethodDesc_ALIGNMENT_SHIFT 3
180 ASMCONSTANTS_C_ASSERT(MethodDesc_ALIGNMENT_SHIFT == MethodDesc::ALIGNMENT_SHIFT);
182 #define SIZEOF__FixupPrecode 24
183 #define Offset_FixupPrecodeChunkIndex 15
184 #define Offset_FixupPrecodeMethodDescChunkIndex 14
185 #define FixupPrecode_ALIGNMENT_SHIFT_1 3
186 #define FixupPrecode_ALIGNMENT_SHIFT_2 4
188 ASMCONSTANTS_C_ASSERT(SIZEOF__FixupPrecode == sizeof(FixupPrecode));
189 ASMCONSTANTS_C_ASSERT(Offset_FixupPrecodeChunkIndex == offsetof(FixupPrecode, m_PrecodeChunkIndex));
190 ASMCONSTANTS_C_ASSERT(Offset_FixupPrecodeMethodDescChunkIndex == offsetof(FixupPrecode, m_MethodDescChunkIndex));
191 ASMCONSTANTS_C_ASSERT((1<<FixupPrecode_ALIGNMENT_SHIFT_1) + (1<<FixupPrecode_ALIGNMENT_SHIFT_2) == sizeof(FixupPrecode));
193 #define SIZEOF__RelativeFixupPrecode 32
194 #define Offset_RelativeFixupPrecodeChunkIndex 17
195 #define Offset_RelativeFixupPrecodeMethodDescChunkIndex 16
196 #define RelativeFixupPrecode_ALIGNMENT_SHIFT 4
198 ASMCONSTANTS_C_ASSERT(SIZEOF__RelativeFixupPrecode == sizeof(RelativeFixupPrecode));
199 ASMCONSTANTS_C_ASSERT(Offset_RelativeFixupPrecodeChunkIndex == offsetof(RelativeFixupPrecode, m_PrecodeChunkIndex));
200 ASMCONSTANTS_C_ASSERT(Offset_RelativeFixupPrecodeMethodDescChunkIndex == offsetof(RelativeFixupPrecode, m_MethodDescChunkIndex));
201 ASMCONSTANTS_C_ASSERT((1<<(RelativeFixupPrecode_ALIGNMENT_SHIFT+1)) == sizeof(RelativeFixupPrecode));
203 #ifndef CROSSGEN_COMPILE
204 #define ResolveCacheElem__target 0x10
205 #define ResolveCacheElem__pNext 0x18
206 ASMCONSTANTS_C_ASSERT(ResolveCacheElem__target == offsetof(ResolveCacheElem, target));
207 ASMCONSTANTS_C_ASSERT(ResolveCacheElem__pNext == offsetof(ResolveCacheElem, pNext));
208 #endif // CROSSGEN_COMPILE
210 #define DomainLocalModule__m_pDataBlob 0x30
211 #define DomainLocalModule__m_pGCStatics 0x20
212 ASMCONSTANTS_C_ASSERT(DomainLocalModule__m_pDataBlob == offsetof(DomainLocalModule, m_pDataBlob));
213 ASMCONSTANTS_C_ASSERT(DomainLocalModule__m_pGCStatics == offsetof(DomainLocalModule, m_pGCStatics));
216 // For JIT_PInvokeBegin and JIT_PInvokeEnd helpers
217 #define Frame__m_Next 0x08
218 ASMCONSTANTS_C_ASSERT(Frame__m_Next == offsetof(Frame, m_Next))
220 #define InlinedCallFrame__m_Datum 0x10
221 ASMCONSTANTS_C_ASSERT(InlinedCallFrame__m_Datum == offsetof(InlinedCallFrame, m_Datum))
223 #define InlinedCallFrame__m_pCallSiteSP 0x20
224 ASMCONSTANTS_C_ASSERT(InlinedCallFrame__m_pCallSiteSP == offsetof(InlinedCallFrame, m_pCallSiteSP))
226 #define InlinedCallFrame__m_pCallerReturnAddress 0x28
227 ASMCONSTANTS_C_ASSERT(InlinedCallFrame__m_pCallerReturnAddress == offsetof(InlinedCallFrame, m_pCallerReturnAddress))
229 #define InlinedCallFrame__m_pCalleeSavedFP 0x30
230 ASMCONSTANTS_C_ASSERT(InlinedCallFrame__m_pCalleeSavedFP == offsetof(InlinedCallFrame, m_pCalleeSavedFP))
232 #define InlinedCallFrame__m_pThread 0x38
233 ASMCONSTANTS_C_ASSERT(InlinedCallFrame__m_pThread == offsetof(InlinedCallFrame, m_pThread))
236 #undef ASMCONSTANTS_RUNTIME_ASSERT
237 #undef ASMCONSTANTS_C_ASSERT