From b454553d7531a5519181d85bbe82319bb97c4eaf Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Tue, 23 Feb 2021 00:35:49 +0100 Subject: [PATCH 1/2] Fix ArgIterator::GetNextOffset for macOS arm64 The ArgIterator::GetNextOffset method was not aligning offsets it returns for reference types and some others. That was causing coreclr test failures with GCStress mode 3. This change fixes it by properly aligning the returned offsets. --- src/coreclr/vm/callingconvention.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/coreclr/vm/callingconvention.h b/src/coreclr/vm/callingconvention.h index 8a1e934d3d78d..bf03ea85d1fa6 100644 --- a/src/coreclr/vm/callingconvention.h +++ b/src/coreclr/vm/callingconvention.h @@ -1437,7 +1437,8 @@ int ArgIteratorTemplate::GetNextOffset() break; } const bool isValueType = (argType == ELEMENT_TYPE_VALUETYPE); - const int cbArg = StackElemSize(argSize, isValueType, thValueType.IsFloatHfa()); + const bool isFloatHfa = thValueType.IsFloatHfa(); + const int cbArg = StackElemSize(argSize, isValueType, isFloatHfa); if (cFPRegs>0 && !this->IsVarArg()) { if (cFPRegs + m_idxFPReg <= 8) @@ -1495,6 +1496,24 @@ int ArgIteratorTemplate::GetNextOffset() } } +#ifdef OSX_ARM64_ABI + int alignment; + if (!isValueType) + { + _ASSERTE((cbArg & (cbArg - 1)) == 0); + alignment = cbArg; + } + else if (isFloatHfa) + { + alignment = 4; + } + else + { + alignment = 8; + } + m_ofsStack = (int)ALIGN_UP(m_ofsStack, alignment); +#endif // OSX_ARM64_ABI + int argOfs = TransitionBlock::GetOffsetOfArgs() + m_ofsStack; m_ofsStack += cbArg; return argOfs; From 185ef3a20c8ad92ab5152f1eb1391acb92a37e0c Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Tue, 23 Feb 2021 10:23:49 +0100 Subject: [PATCH 2/2] Fix indentation --- src/coreclr/vm/callingconvention.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/vm/callingconvention.h b/src/coreclr/vm/callingconvention.h index bf03ea85d1fa6..deab21ca97efe 100644 --- a/src/coreclr/vm/callingconvention.h +++ b/src/coreclr/vm/callingconvention.h @@ -1500,7 +1500,7 @@ int ArgIteratorTemplate::GetNextOffset() int alignment; if (!isValueType) { - _ASSERTE((cbArg & (cbArg - 1)) == 0); + _ASSERTE((cbArg & (cbArg - 1)) == 0); alignment = cbArg; } else if (isFloatHfa)