Skip to content

Commit

Permalink
Fix ArgIterator::GetNextOffset for macOS arm64 (#48632)
Browse files Browse the repository at this point in the history
* 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.

* Fix indentation
  • Loading branch information
janvorli authored Feb 23, 2021
1 parent c9fe433 commit d5ab93c
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/coreclr/vm/callingconvention.h
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,8 @@ int ArgIteratorTemplate<ARGITERATOR_BASE>::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)
Expand Down Expand Up @@ -1495,6 +1496,24 @@ int ArgIteratorTemplate<ARGITERATOR_BASE>::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;
Expand Down

0 comments on commit d5ab93c

Please sign in to comment.