diff --git a/src/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/CallingConventions.cs b/src/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/CallingConventions.cs index 25ee7b1daf5..f40dedb4677 100644 --- a/src/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/CallingConventions.cs +++ b/src/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/CallingConventions.cs @@ -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 @@ -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 {