[interp] Remove unreachable code (#12411)
[mono-project.git] / mono / tests / sgen-cementing-stress.cs
blobb6c94260d8dc8e96c7ed95de8940faf12c62dae4
1 using System;
3 class PinList
5 class Pinned
7 public Pinned ()
12 Pinned reference;
13 PinList next;
15 PinList (PinList n)
17 next = n;
20 static int list_size = 0;
22 static PinList MakeList (int length)
24 PinList l = null;
25 for (int i = 0; i < length; ++i)
26 l = new PinList (l);
27 return l;
30 static void AssignReferences (PinList l, Pinned[] objs)
32 int i = 0;
33 int n = objs.Length;
34 while (l != null)
36 l.reference = objs [i++ % n];
37 l = l.next;
41 static Pinned Work (PinList list, Pinned[] objs, int i)
43 if (i >= objs.Length)
45 for (int j = 0; j < 10; ++j)
47 MakeList (list_size >> 5);
48 AssignReferences (list, objs);
50 return null;
52 else
54 Pinned obj = new Pinned ();
55 objs [i] = obj;
56 Pinned dummy = Work (list, objs, i + 1);
57 return obj != dummy ? obj : dummy; // to keep obj alive
61 static void Benchmark (PinList list, int n)
63 Pinned[] objs = new Pinned [n];
64 Work (list, objs, 0);
67 public static void Main ()
69 list_size = 1 << 15;
70 TestTimeout timeout = TestTimeout.Start(TimeSpan.FromSeconds(TestTimeout.IsStressTest ? 60 : 5));
72 for (int it1 = 1; it1 <= 10; it1++, list_size <<= 1) {
73 PinList list = MakeList (list_size);
74 Console.WriteLine ("long list constructed {0}", it1);
75 for (int it2 = 0; it2 < 5; it2++) {
76 Benchmark (list, 10 * it1);
77 GC.Collect (1);
79 if (!timeout.HaveTimeLeft)
80 return;