Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Commit

Permalink
Fixing a bug with handling HFA of floats for arm64. When passing HFAs…
Browse files Browse the repository at this point in the history
…, if the struct fits in the SIMD registers, given that the S and D registers overlap and how the UniversalTransitionThunk and CallDescrWorker copy D values, we treat the HFA struct as an HFA of doubles instead of floats (And we double the size of the struct during this processing).

The issue however is when there aren't enough SIMD registers to fit the HFA struct, and we're forced to pass it on the stack. In that case, we shouldn't double the size of the struct and treat the floats as doubles.

Also fixing the test to exclude invalid scenarios from arm64 (the scenario is invalid because the return buffer pointer is passed using a special x8 register, and not using the x0-7 registers like the rest of the arguments)

[tfs-changeset: 1701853]
  • Loading branch information
Fadi Hanna committed May 24, 2018
1 parent f563c36 commit 498c952
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -935,9 +935,14 @@ public unsafe int GetNextOffset()
#if _TARGET_ARM64_
// NOT DESKTOP BEHAVIOR: The S and D registers overlap, and the UniversalTransitionThunk copies D registers to the transition blocks. We'll need
// to work with the D registers here as well.
bool processingFloatsAsDoublesFromTransitionBlock = false;
if (argType == CorElementType.ELEMENT_TYPE_VALUETYPE && _argTypeHandle.IsHFA() && _argTypeHandle.GetHFAType() == CorElementType.ELEMENT_TYPE_R4)
{
argSize *= 2;
if ((argSize / sizeof(float)) + _idxFPReg <= 8)
{
argSize *= 2;
processingFloatsAsDoublesFromTransitionBlock = true;
}
}
#endif

Expand Down Expand Up @@ -1239,8 +1244,10 @@ public unsafe int GetNextOffset()
if (_argTypeHandle.IsHFA())
{
CorElementType type = _argTypeHandle.GetHFAType();
// DESKTOP BEHAVIOR cFPRegs = (type == CorElementType.ELEMENT_TYPE_R4) ? (argSize / sizeof(float)) : (argSize / sizeof(double));
cFPRegs = argSize / sizeof(double);
if (processingFloatsAsDoublesFromTransitionBlock)
cFPRegs = argSize / sizeof(double);
else
cFPRegs = (type == CorElementType.ELEMENT_TYPE_R4) ? (argSize / sizeof(float)) : (argSize / sizeof(double));
}
else
{
Expand Down

0 comments on commit 498c952

Please sign in to comment.