diff options
-rw-r--r-- | src/inc/corjit.h | 6 | ||||
-rw-r--r-- | src/vm/jitinterface.cpp | 29 | ||||
-rw-r--r-- | src/zap/zapinfo.cpp | 15 |
3 files changed, 36 insertions, 14 deletions
diff --git a/src/inc/corjit.h b/src/inc/corjit.h index bef6b63bb4..a470d5bff8 100644 --- a/src/inc/corjit.h +++ b/src/inc/corjit.h @@ -300,8 +300,14 @@ enum CorJitAllocMemFlag { 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) diff --git a/src/vm/jitinterface.cpp b/src/vm/jitinterface.cpp index 6ac959bb32..b911d39678 100644 --- a/src/vm/jitinterface.cpp +++ b/src/vm/jitinterface.cpp @@ -11623,19 +11623,25 @@ void CEEJitInfo::allocMem ( 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 @@ -11670,8 +11676,7 @@ void CEEJitInfo::allocMem ( if (roDataSize > 0) { - current = (BYTE *)ALIGN_UP(current, (roDataSize >= 8) ? 8 : sizeof(void *)); - + current = (BYTE *)ALIGN_UP(current, roDataAlignment); *roDataBlock = current; current += roDataSize; } diff --git a/src/zap/zapinfo.cpp b/src/zap/zapinfo.cpp index b21a3809fb..d5bdbabb8c 100644 --- a/src/zap/zapinfo.cpp +++ b/src/zap/zapinfo.cpp @@ -1768,8 +1768,19 @@ void ZapInfo::allocMem( 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(); } |