Skip to content
Merged
Changes from 5 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: 19 additions & 0 deletions src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,25 @@ private void CompileMethodInternal(IMethodNode methodCodeNodeNeedingCode, Method
#endif
}

if (codeSize < _code.Length)
{
if (_compilation.TypeSystemContext.Target.Architecture == TargetArchitecture.X64 ||
_compilation.TypeSystemContext.Target.Architecture == TargetArchitecture.X86)
{
// For xarch, the generated code is sometimes smaller than the memory allocated.
// In that case, trim the codeBlock to the actual value.
//
// For armarch, the allocation request of `hotCodeSize` also includes the roData size
// while the `codeSize` returned just contains the size of the native code. As such,
// there is guarantee that for armarch, (codeSize == _code.Length) is always true.
//
// Currently, hot/cold splitting is not done and hence `codeSize` just includes the size of
// hotCode. Once hot/cold splitting is done, need to trim respective `_code` or `_coldCode`
// accordingly.
Debug.Assert(codeSize != 0);
Array.Resize(ref _code, (int)codeSize);
}
}
PublishCode();
PublishROData();
}
Expand Down