From 5b0a875a3dd764fd7d1d1169b1dcc872019b2457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Thu, 20 Feb 2020 16:07:28 +0100 Subject: [PATCH] Add support in crossgen2 for 32-byte alignment --- .../tools/Common/JitInterface/CorInfoImpl.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs index 4903aec134730..441f5bbce7d1b 100644 --- a/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs @@ -229,6 +229,8 @@ private void PublishCode() _compilation.NodeFactory.Target.MinimumFunctionAlignment : _compilation.NodeFactory.Target.OptimumFunctionAlignment; + alignment = Math.Max(alignment, _codeAlignment); + var objectData = new ObjectNode.ObjectData(_code, relocs, alignment, @@ -2516,6 +2518,7 @@ private void MethodCompileComplete(CORINFO_METHOD_STRUCT_* methHnd) private byte[] _code; private byte[] _coldCode; + private int _codeAlignment; private byte[] _roData; @@ -2535,11 +2538,25 @@ private void allocMem(uint hotCodeSize, uint coldCodeSize, uint roDataSize, uint if (coldCodeSize != 0) coldCodeBlock = (void*)GetPin(_coldCode = new byte[coldCodeSize]); + _codeAlignment = -1; + if ((flag & CorJitAllocMemFlag.CORJIT_ALLOCMEM_FLG_32BYTE_ALIGN) != 0) + { + _codeAlignment = 32; + } + else if ((flag & CorJitAllocMemFlag.CORJIT_ALLOCMEM_FLG_16BYTE_ALIGN) != 0) + { + _codeAlignment = 16; + } + if (roDataSize != 0) { int alignment = 8; - if ((flag & CorJitAllocMemFlag.CORJIT_ALLOCMEM_FLG_RODATA_16BYTE_ALIGN) != 0) + if ((flag & CorJitAllocMemFlag.CORJIT_ALLOCMEM_FLG_RODATA_32BYTE_ALIGN) != 0) + { + alignment = 32; + } + else if ((flag & CorJitAllocMemFlag.CORJIT_ALLOCMEM_FLG_RODATA_16BYTE_ALIGN) != 0) { alignment = 16; }