This repository was archived by the owner on Jan 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 12 files changed +29
-2
lines changed Expand file tree Collapse file tree 12 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -2459,4 +2459,16 @@ typedef DPTR(PTR_PCODE) PTR_PTR_PCODE;
2459
2459
// @dbgtodo : Separating asserts and target consistency checks is tracked by DevDiv Bugs 31674
2460
2460
#define TARGET_CONSISTENCY_CHECK (expr,msg ) _ASSERTE_MSG(expr,msg)
2461
2461
2462
+ // For cross compilation, controlling type layout is important
2463
+ // We add a simple macro here which defines DAC_ALIGNAS to the C++11 alignas operator
2464
+ // This helps force the alignment of the next member
2465
+ // For most cross compilation cases the layout of types simply works
2466
+ // There are a few cases (where this macro is helpful) which are not consistent accross platforms:
2467
+ // - Base class whose size is padded to its align size. On Linux the gcc/clang
2468
+ // layouts will reuse this padding in the derived class for the first member
2469
+ // - Class with an vtable pointer and an alignment greater than the pointer size.
2470
+ // The Windows compilers will align the first member to the alignment size of the
2471
+ // class. Linux will align the first member to its natural alignment
2472
+ #define DAC_ALIGNAS (a ) alignas (a)
2473
+
2462
2474
#endif // #ifndef __daccess_h__
Original file line number Diff line number Diff line change @@ -808,6 +808,7 @@ template <COUNT_T MEMSIZE>
808
808
class InlineSString : public SString
809
809
{
810
810
private:
811
+ DAC_ALIGNAS (SString)
811
812
BYTE m_inline[SBUFFER_PADDED_SIZE(MEMSIZE)];
812
813
813
814
public:
@@ -990,6 +991,7 @@ template <COUNT_T MEMSIZE>
990
991
class ScratchBuffer : public SString ::AbstractScratchBuffer
991
992
{
992
993
private:
994
+ DAC_ALIGNAS (::SString::AbstractScratchBuffer)
993
995
BYTE m_inline[MEMSIZE];
994
996
995
997
public:
Original file line number Diff line number Diff line change @@ -1105,6 +1105,7 @@ class StgGuidPool : public StgPool
1105
1105
1106
1106
1107
1107
private:
1108
+ DAC_ALIGNAS (StgPool) // Align first member to alignment of base class
1108
1109
CGuidPoolHash m_Hash; // Hash table for lookups.
1109
1110
int m_bHash; // true to keep hash table.
1110
1111
}; // class StgGuidPool
@@ -1257,6 +1258,7 @@ class StgBlobPool : public StgPool
1257
1258
__checkReturn
1258
1259
HRESULT RehashBlobs ();
1259
1260
1261
+ DAC_ALIGNAS (StgPool) // Align first member to alignment of base class
1260
1262
CBlobPoolHash m_Hash; // Hash table for lookups.
1261
1263
}; // class StgBlobPool
1262
1264
Original file line number Diff line number Diff line change @@ -2648,6 +2648,7 @@ template <class MemMgr>
2648
2648
class CHashTableAndData : public CHashTable
2649
2649
{
2650
2650
public:
2651
+ DAC_ALIGNAS (CHashTable)
2651
2652
ULONG m_iFree; // Index into m_pcEntries[] of next available slot
2652
2653
ULONG m_iEntries; // size of m_pcEntries[]
2653
2654
Original file line number Diff line number Diff line change @@ -1987,8 +1987,7 @@ class RegMeta :
1987
1987
#endif // FEATURE_METADATA_INTERNAL_APIS
1988
1988
1989
1989
UTSemReadWrite *m_pSemReadWrite;
1990
- bool m_fOwnSem;
1991
-
1990
+ unsigned m_fOwnSem : 1 ;
1992
1991
unsigned m_bRemap : 1 ; // If true, there is a token mapper.
1993
1992
unsigned m_bSaveOptimized : 1 ; // If true, save optimization has been done.
1994
1993
unsigned m_hasOptimizedRefToDef : 1 ; // true if we have performed ref to def optimization
Original file line number Diff line number Diff line change @@ -190,6 +190,7 @@ class CLiteWeightStgdbRW : public CLiteWeightStgdb<CMiniMdRW>
190
190
const void **ppv, // [OUT] put pointer to MD stream here.
191
191
ULONG *pcb); // [OUT] put size of the stream here.
192
192
193
+ DAC_ALIGNAS (CLiteWeightStgdb<CMiniMdRW>) // Align the first member to the alignment of the base class
193
194
UINT32 m_cbSaveSize; // Size of the saved streams.
194
195
int m_bSaveCompressed; // If true, save as compressed stream (#-, not #~)
195
196
VOID* m_pImage; // Set in OpenForRead, NULL for anything but PE files
Original file line number Diff line number Diff line change @@ -2120,6 +2120,7 @@ template <class Impl> class CMiniMdTemplate : public CMiniMdBase
2120
2120
2121
2121
FORCEINLINE void MarkUnsafeToDelete () { m_isSafeToDelete = false ; }
2122
2122
2123
+ DAC_ALIGNAS (CMiniMdBase)
2123
2124
bool m_isSafeToDelete; // This starts out true, but gets set to FALSE if we detect
2124
2125
// a MiniMd API call that might have given out an internal pointer.
2125
2126
#endif
Original file line number Diff line number Diff line change @@ -77,6 +77,7 @@ class CMiniMd final: public CMiniMdTemplate<CMiniMd>
77
77
#endif // FEATURE_PREJIT
78
78
79
79
protected:
80
+ DAC_ALIGNAS (CMiniMdTemplate<CMiniMd>) // Align the first member to the alignment of the base class
80
81
// Table info.
81
82
MetaData::TableRO m_Tables[TBL_COUNT];
82
83
#ifdef FEATURE_PREJIT
Original file line number Diff line number Diff line change @@ -672,6 +672,7 @@ class CMiniMdRW : public CMiniMdTemplate<CMiniMdRW>
672
672
return HashToken (tkObject);
673
673
}
674
674
675
+ DAC_ALIGNAS (CMiniMdTemplate<CMiniMdRW>) // Align the first member to the alignment of the base class
675
676
CMemberRefHash *m_pMemberRefHash;
676
677
677
678
// Hash table for Methods and Fields
Original file line number Diff line number Diff line change @@ -154,6 +154,7 @@ class RecordPool : public StgPool
154
154
void **pContext); // Stored context here.
155
155
156
156
private:
157
+ DAC_ALIGNAS (StgPool) // Align first member to alignment of base class
157
158
UINT32 m_cbRec; // How large is each record?
158
159
159
160
}; // class RecordPool
You can’t perform that action at this time.
0 commit comments