Skip to content

Commit

Permalink
Add support in crossgen2 for 32-byte alignment (#32602)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalStrehovsky authored Feb 26, 2020
1 parent 707b9c8 commit 7855aa3
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -2489,6 +2491,7 @@ private void MethodCompileComplete(CORINFO_METHOD_STRUCT_* methHnd)

private byte[] _code;
private byte[] _coldCode;
private int _codeAlignment;

private byte[] _roData;

Expand All @@ -2508,11 +2511,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;
}
Expand Down

0 comments on commit 7855aa3

Please sign in to comment.