llilc jit needs this to support LLVM floating-point constant pools.
{
CORJIT_ALLOCMEM_DEFAULT_CODE_ALIGN = 0x00000000, // The code will be use the normal alignment
CORJIT_ALLOCMEM_FLG_16BYTE_ALIGN = 0x00000001, // The code will be 16-byte aligned
+ CORJIT_ALLOCMEM_FLG_RODATA_16BYTE_ALIGN = 0x00000002, // The read-only data will be 16-byte aligned
};
+inline CorJitAllocMemFlag operator |(CorJitAllocMemFlag a, CorJitAllocMemFlag b)
+{
+ return static_cast<CorJitAllocMemFlag>(static_cast<int>(a) | static_cast<int>(b));
+}
+
enum CorJitFuncKind
{
CORJIT_FUNC_ROOT, // The main/root function (always id==0)
S_SIZE_T totalSize = S_SIZE_T(codeSize);
+ size_t roDataAlignment = sizeof(void*);
+ if ((flag & CORJIT_ALLOCMEM_FLG_RODATA_16BYTE_ALIGN)!= 0)
+ {
+ roDataAlignment = 16;
+ }
+ else if (roDataSize >= 8)
+ {
+ roDataAlignment = 8;
+ }
if (roDataSize > 0)
{
- totalSize.AlignUp(sizeof(void *));
- totalSize += roDataSize;
-
-#ifndef _WIN64
- if (roDataSize >= 8)
- {
- // allocates an extra 4 bytes so that we can
- // double align the roData section.
- totalSize += 4;
+ size_t codeAlignment = ((flag & CORJIT_ALLOCMEM_FLG_16BYTE_ALIGN)!= 0)
+ ? 16 : sizeof(void*);
+ totalSize.AlignUp(codeAlignment);
+ if (roDataAlignment > codeAlignment) {
+ // Add padding to align read-only data.
+ totalSize += (roDataAlignment - codeAlignment);
}
-#endif
+ totalSize += roDataSize;
}
#ifdef WIN64EXCEPTIONS
if (roDataSize > 0)
{
- current = (BYTE *)ALIGN_UP(current, (roDataSize >= 8) ? 8 : sizeof(void *));
-
+ current = (BYTE *)ALIGN_UP(current, roDataAlignment);
*roDataBlock = current;
current += roDataSize;
}
if (roDataSize > 0)
{
- m_pROData = ZapBlobWithRelocs::NewAlignedBlob(m_pImage, NULL, roDataSize,
- optForSize || (roDataSize < 8) ? sizeof(TADDR) : 8);
+ if (flag & CORJIT_ALLOCMEM_FLG_RODATA_16BYTE_ALIGN)
+ {
+ align = 16;
+ }
+ else if (optForSize || (roDataSize < 8))
+ {
+ align = sizeof(TADDR);
+ }
+ else
+ {
+ align = 8;
+ }
+ m_pROData = ZapBlobWithRelocs::NewAlignedBlob(m_pImage, NULL, roDataSize, align);
*roDataBlock = m_pROData->GetData();
}