Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support in crossgen2 for 32-byte alignment #32602

Merged
merged 1 commit into from
Feb 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -2516,6 +2518,7 @@ private void MethodCompileComplete(CORINFO_METHOD_STRUCT_* methHnd)

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

private byte[] _roData;

Expand All @@ -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;
}
Expand Down