2 using System.Reflection;
3 using System.Runtime.CompilerServices;
6 * Regression tests for the GC support in the JIT
12 return TestDriver.RunTests (typeof (Tests));
15 public static int test_36_simple () {
16 // Overflow the registers
26 /* Prevent the variables from being local to a bb */
31 return (int)o1 + (int)o2 + (int)o3 + (int)o4 + (int)o5 + (int)o6 + (int)o7 + (int)o8;
36 public static int test_36_liveness () {
38 object o1, o2, o3, o4, o5, o6, o7, o8;
54 return (int)o1 + (int)o2 + (int)o3 + (int)o4 + (int)o5 + (int)o6 + (int)o7 + (int)o8;
64 public FooStruct (int i1, int i, int i2) {
71 public static int test_4_vtype () {
72 FooStruct s = new FooStruct (1, 2, 3);
76 return (int)s.o1 + (int)s.o2;
80 public object o1, o2, o3, o4, o5, o6, o7, o8, o9, o10;
81 public object o11, o12, o13, o14, o15, o16, o17, o18, o19, o20;
82 public object o21, o22, o23, o24, o25, o26, o27, o28, o29, o30;
83 public object o31, o32;
86 static void set_fields (BigClass b) {
122 // Test marking of objects with > 32 fields
123 public static int test_528_mark_runlength_large () {
124 BigClass b = new BigClass ();
127 * Do the initialization in a separate method so no object refs remain in
135 (int)b.o1 + (int)b.o2 + (int)b.o3 + (int)b.o4 + (int)b.o5 +
136 (int)b.o6 + (int)b.o7 + (int)b.o8 + (int)b.o9 + (int)b.o10 +
137 (int)b.o11 + (int)b.o12 + (int)b.o13 + (int)b.o14 + (int)b.o15 +
138 (int)b.o16 + (int)b.o17 + (int)b.o18 + (int)b.o19 + (int)b.o20 +
139 (int)b.o21 + (int)b.o22 + (int)b.o23 + (int)b.o24 + (int)b.o25 +
140 (int)b.o26 + (int)b.o27 + (int)b.o28 + (int)b.o29 + (int)b.o30 +
141 (int)b.o31 + (int)b.o32;
144 static void cond (bool b) {
146 /* Exhaust all registers so 'o' is stack allocated */
147 int sum = 0, i, j, k, l, m;
148 for (i = 0; i < 100; ++i)
150 for (j = 0; j < 100; ++j)
152 for (k = 0; k < 100; ++k)
154 for (l = 0; l < 100; ++l)
156 for (m = 0; m < 100; ++m)
159 object o = new object ();
162 throw new Exception (o.ToString ());
169 * Tests liveness of object references which are initialized conditionally,
170 * used in an out-of-line bblock, and the initlocals assignment is optimized away.
172 public static int test_0_liveness_out_of_line_bblocks () {
178 * Test liveness and loops.
180 public static int test_0_liveness_2 () {
181 object o = new object ();
182 for (int n = 0; n < 10; ++n) {
183 /* Exhaust all registers so 'o' is stack allocated */
184 int sum = 0, i, j, k, l, m;
185 for (i = 0; i < 100; ++i)
187 for (j = 0; j < 100; ++j)
189 for (k = 0; k < 100; ++k)
191 for (l = 0; l < 100; ++l)
193 for (m = 0; m < 100; ++m)
213 * Test liveness and stack slot sharing
214 * This doesn't work yet, its hard to make the JIT share the stack slots of the
217 public static int test_0_liveness_3 () {
221 /* Exhaust all registers so 'o' is stack allocated */
222 int sum = 0, i, j, k, l, m, n, s;
223 for (i = 0; i < 100; ++i)
225 for (j = 0; j < 100; ++j)
227 for (k = 0; k < 100; ++k)
229 for (l = 0; l < 100; ++l)
231 for (m = 0; m < 100; ++m)
233 for (n = 0; n < 100; ++n)
235 for (s = 0; s < 100; ++s)
239 object o = new object ();
241 /* Make sure o is global */
243 Console.WriteLine ();
251 object o = new object ();
253 /* Make sure o is global */
255 Console.WriteLine ();
260 sum += i + j + k + l + m + n + s;
266 * Test liveness of variables used to handle items on the IL stack.
268 [MethodImplAttribute (MethodImplOptions.NoInlining)]
269 static string call1 () {
273 [MethodImplAttribute (MethodImplOptions.NoInlining)]
274 static string call2 () {
279 public static int test_0_liveness_4 () {
283 /* Exhaust all registers so 'o' is stack allocated */
284 int sum = 0, i, j, k, l, m, n, s;
285 for (i = 0; i < 100; ++i)
287 for (j = 0; j < 100; ++j)
289 for (k = 0; k < 100; ++k)
291 for (l = 0; l < 100; ++l)
293 for (m = 0; m < 100; ++m)
295 for (n = 0; n < 100; ++n)
297 for (s = 0; s < 100; ++s)
300 string o = b ? call1 () : call2 ();
304 sum += i + j + k + l + m + n + s;
311 * Test liveness of volatile variables
313 [MethodImplAttribute (MethodImplOptions.NoInlining)]
314 static void liveness_5_1 (out object o) {
318 public static int test_0_liveness_5 () {
322 /* Exhaust all registers so 'o' is stack allocated */
323 int sum = 0, i, j, k, l, m, n, s;
324 for (i = 0; i < 100; ++i)
326 for (j = 0; j < 100; ++j)
328 for (k = 0; k < 100; ++k)
330 for (l = 0; l < 100; ++l)
332 for (m = 0; m < 100; ++m)
334 for (n = 0; n < 100; ++n)
336 for (s = 0; s < 100; ++s)
341 liveness_5_1 (out o);
343 for (int x = 0; x < 10; ++x) {
350 sum += i + j + k + l + m + n + s;
356 * Test the case when a stack slot becomes dead, then live again due to a backward
360 [MethodImplAttribute (MethodImplOptions.NoInlining)]
361 static object liveness_6_1 () {
362 return new object ();
365 public static int test_0_liveness_6 () {
369 /* Exhaust all registers so 'o' is stack allocated */
370 int sum = 0, i, j, k, l, m, n, s;
371 for (i = 0; i < 100; ++i)
373 for (j = 0; j < 100; ++j)
375 for (k = 0; k < 100; ++k)
377 for (l = 0; l < 100; ++l)
379 for (m = 0; m < 100; ++m)
381 for (n = 0; n < 100; ++n)
383 for (s = 0; s < 100; ++s)
386 for (int x = 0; x < 10; ++x) {
390 object o = liveness_6_1 ();
397 sum += i + j + k + l + m + n + s;