Skip to content

Commit c213c5b

Browse files
authored
[release/6.0] Restore FP pairs when unwinding in ARM64 (#69359)
* Add regression test * Restore FP pairs when unwinding in ARM64 * Disable windows arm64 version of the test
1 parent 0dc7e3b commit c213c5b

File tree

4 files changed

+98
-5
lines changed

4 files changed

+98
-5
lines changed

src/coreclr/unwinder/arm64/unwinder_arm64.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ Return Value:
10381038
ContextRecord,
10391039
8 * (NextCode & 0x3f),
10401040
8 + ((CurCode & 1) << 2) + (NextCode >> 6),
1041-
2 + AccumulatedSaveNexts,
1041+
2 + 2 * AccumulatedSaveNexts,
10421042
UnwindParams);
10431043
AccumulatedSaveNexts = 0;
10441044
}
@@ -1054,7 +1054,7 @@ Return Value:
10541054
ContextRecord,
10551055
-8 * ((NextCode & 0x3f) + 1),
10561056
8 + ((CurCode & 1) << 2) + (NextCode >> 6),
1057-
2 + AccumulatedSaveNexts,
1057+
2 + 2 * AccumulatedSaveNexts,
10581058
UnwindParams);
10591059
AccumulatedSaveNexts = 0;
10601060
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
using System;
2+
using System.Runtime.CompilerServices;
3+
4+
class Program
5+
{
6+
static int Main()
7+
{
8+
double a0 = 1.0;
9+
double a1 = 2.0;
10+
double a2 = 3.0;
11+
double a3 = 4.0;
12+
double a4 = 5.0;
13+
double a5 = 6.0;
14+
double a6 = 7.0;
15+
double a7 = 8.0;
16+
double a8 = 9.0;
17+
double a9 = 10.0;
18+
19+
for (int i = 1; i < 10; i++)
20+
{
21+
a0 *= 1.0;
22+
a1 *= 2.0;
23+
a2 *= 3.0;
24+
a3 *= 4.0;
25+
a4 *= 5.0;
26+
a5 *= 6.0;
27+
a6 *= 7.0;
28+
a7 *= 8.0;
29+
a8 *= 9.0;
30+
a9 *= 10.0;
31+
}
32+
33+
EHMethod();
34+
35+
bool isExpectedValue =
36+
a0 == 1.0
37+
&& a1 == Math.Pow(2, 10)
38+
&& a2 == Math.Pow(3, 10)
39+
&& a3 == Math.Pow(4, 10)
40+
&& a4 == Math.Pow(5, 10)
41+
&& a5 == Math.Pow(6, 10)
42+
&& a6 == Math.Pow(7, 10)
43+
&& a7 == Math.Pow(8, 10)
44+
&& a8 == Math.Pow(9, 10)
45+
&& a9 == Math.Pow(10, 10);
46+
47+
return isExpectedValue ? 100 : 1;
48+
}
49+
50+
[MethodImpl(MethodImplOptions.NoInlining)]
51+
static void EHMethod()
52+
{
53+
try
54+
{
55+
FloatManipulationMethod();
56+
}
57+
catch (Exception) { }
58+
}
59+
60+
[MethodImpl(MethodImplOptions.NoInlining)]
61+
static void FloatManipulationMethod()
62+
{
63+
// Enough locals to try to get the JIT to touch at least some of the non-volatile
64+
// registers (some spilling might happen, but hopefully the lack of EH prioritizes
65+
// registers).
66+
double a0 = 1, a1 = 2, a2 = 3, a3 = 4, a4 = 5, a5 = 6, a6 = 7, a7 = 8;
67+
double a8 = 1, a9 = 2, a10 = 3, a11 = 4, a12 = 5, a13 = 6, a14 = 7, a15 = 8;
68+
double a16 = 1, a17 = 2, a18 = 3, a19 = 4, a20 = 5, a21 = 6, a22 = 7, a23 = 8;
69+
double a24 = 1, a25 = 2, a26 = 3, a27 = 4, a28 = 5, a29 = 6, a30 = 7, a31 = 8;
70+
71+
// Some busy math to prevent easy optimizations and folding.
72+
for (int i = 0; i < 5; i++)
73+
{
74+
a0 -= 1; a1 -= 2; a2 -= 3; a3 -= 4; a4 -= 5; a5 -= 6; a6 -= 7; a7 -= 8;
75+
a8 -= 9; a9 -= 10; a10 -= 11; a11 -= 12; a12 -= 13; a13 -= 14; a14 -= 15; a15 -= 16;
76+
a16 -= 17; a17 -= 18; a18 -= 19; a19 -= 20; a20 -= 21; a21 -= 22; a22 -= 23; a23 -= 24;
77+
a24 -= 25; a25 -= 26; a26 -= 27; a27 -= 28; a28 -= 29; a29 -= 30; a30 -= 31; a31 -= 32;
78+
}
79+
80+
throw new Exception();
81+
}
82+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<Compile Include="UnwindFpBleedTest.cs" />
7+
</ItemGroup>
8+
</Project>

src/tests/issues.targets

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,9 @@
597597
<ExcludeList Include="$(XunitTestBinBase)/JIT/jit64/opt/rngchk/RngchkStress3/*">
598598
<Issue>Needs Triage</Issue>
599599
</ExcludeList>
600+
<ExcludeList Include="$(XunitTestBinBase)/Exceptions/UnwindFpBleedTest/UnwindFpBleedTest/*">
601+
<Issue>Windows's unwinder in ARM64v8 queue doesn't contain FP unwind fix</Issue>
602+
</ExcludeList>
600603
</ItemGroup>
601604

602605
<!-- The following are x64 Unix failures on CoreCLR. -->
@@ -1138,9 +1141,9 @@
11381141
<ExcludeList Include="$(XunitTestBinBase)/Interop/COM/Reflection/Reflection/**">
11391142
<Issue>https://github.com/dotnet/runtime/issues/34371</Issue>
11401143
</ExcludeList>
1141-
<ExcludeList Include="$(XunitTestBinBase)/Interop/COM/ComWrappers/**">
1142-
<Issue>Not supported on Mono</Issue>
1143-
</ExcludeList>
1144+
<ExcludeList Include="$(XunitTestBinBase)/Interop/COM/ComWrappers/**">
1145+
<Issue>Not supported on Mono</Issue>
1146+
</ExcludeList>
11441147
<ExcludeList Include="$(XunitTestBinBase)/Interop/ICastable/Castable/**">
11451148
<Issue>needs triage</Issue>
11461149
</ExcludeList>

0 commit comments

Comments
 (0)