[fix] 修复当struct只包含一个float或double字段时,在arm64上计算桥接函数签名错误的bug

main
walon 2023-05-06 18:57:47 +08:00
parent f63bbc8a52
commit 1f4e754adb
2 changed files with 5 additions and 4 deletions

View File

@ -70,7 +70,7 @@ namespace HybridCLR.Editor.ABI
case ElementType.Module: case ElementType.Module:
case ElementType.Var: case ElementType.Var:
case ElementType.MVar: case ElementType.MVar:
return GetNativeIntTypeInfo(); return GetNativeIntTypeInfo();
case ElementType.TypedByRef: return CreateValueType(type); case ElementType.TypedByRef: return CreateValueType(type);
case ElementType.ValueType: case ElementType.ValueType:
{ {
@ -105,7 +105,7 @@ namespace HybridCLR.Editor.ABI
private static bool IsNotHFAFastCheck(int typeSize) private static bool IsNotHFAFastCheck(int typeSize)
{ {
return typeSize != 8 && typeSize != 12 && typeSize != 16 && typeSize != 24 && typeSize != 32; return typeSize % 4 != 0 || typeSize > 32;
} }
private static bool ComputHFATypeInfo0(TypeSig type, HFATypeInfo typeInfo) private static bool ComputHFATypeInfo0(TypeSig type, HFATypeInfo typeInfo)
@ -169,7 +169,7 @@ namespace HybridCLR.Editor.ABI
return false; return false;
} }
bool ok = ComputHFATypeInfo0(type, typeInfo); bool ok = ComputHFATypeInfo0(type, typeInfo);
if (ok && typeInfo.Count >= 2 && typeInfo.Count <= 4) if (ok && typeInfo.Count >= 1 && typeInfo.Count <= 4)
{ {
int fieldSize = typeInfo.Type.ElementType == ElementType.R4 ? 4 : 8; int fieldSize = typeInfo.Type.ElementType == ElementType.R4 ? 4 : 8;
return typeSize == fieldSize * typeInfo.Count; return typeSize == fieldSize * typeInfo.Count;
@ -293,6 +293,7 @@ namespace HybridCLR.Editor.ABI
bool isFloat = hfaTypeInfo.Type.ElementType == ElementType.R4; bool isFloat = hfaTypeInfo.Type.ElementType == ElementType.R4;
switch (hfaTypeInfo.Count) switch (hfaTypeInfo.Count)
{ {
case 1: return isFloat ? TypeInfo.s_r4 : TypeInfo.s_r8;
case 2: return isFloat ? TypeInfo.s_vf2 : TypeInfo.s_vd2; case 2: return isFloat ? TypeInfo.s_vf2 : TypeInfo.s_vd2;
case 3: return isFloat ? TypeInfo.s_vf3 : TypeInfo.s_vd3; case 3: return isFloat ? TypeInfo.s_vf3 : TypeInfo.s_vd3;
case 4: return isFloat ? TypeInfo.s_vf4 : TypeInfo.s_vd4; case 4: return isFloat ? TypeInfo.s_vf4 : TypeInfo.s_vd4;

View File

@ -10,7 +10,7 @@ namespace HybridCLR.Editor.ABI
{ {
public override bool IsArch32 => false; public override bool IsArch32 => false;
public override bool IsSupportHFA => true; public override bool IsSupportHFA => false;
protected override TypeInfo OptimizeSigType(TypeInfo type, bool returnType) protected override TypeInfo OptimizeSigType(TypeInfo type, bool returnType)
{ {