-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
test17398.cs
85 lines (68 loc) · 1.65 KB
/
test17398.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.CompilerServices;
using Xunit;
// Repro case for https://github.com/dotnet/coreclr/pull/17398
public class X
{
static int v;
string s;
public override string ToString() => s;
[MethodImpl(MethodImplOptions.NoInlining)]
X(int x)
{
s = "String" + x;
}
[MethodImpl(MethodImplOptions.NoInlining)]
static void F() { }
public static void T0(object o, int x)
{
GC.Collect(2);
throw new Exception(o.ToString());
}
[MethodImpl(MethodImplOptions.NoInlining)]
public static void Test()
{
object x1 = new X(1);
object x2 = new X(2);
if (v == 1)
{
// Generate enough pressure here to
// kill ESI so in linear flow it is dead
// at the call to T0
int w = v;
int x = v;
int y = v;
int z = v;
// Unbounded loop here forces fully interruptible GC
for (int i = 0; i < v; i++)
{
w++;
}
T0(x2, w + x + y + z);
}
// Encourage x1 to be in callee save (ESI)
F();
if (v == 2)
{
T0(x1, 0);
}
}
[Fact]
public static int TestEntryPoint()
{
v = 1;
int r = 0;
try
{
Test();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
r = 100;
}
return r;
}
}