Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / mini / gc-test.cs
index 2ec1c0ab3ff0f314df1f949757c04c5032bfde37..91234b6eec8da38a58334dc3a7f04e00c5ea9864 100644 (file)
@@ -7,12 +7,17 @@ using System.Threading;
 /*
  * Regression tests for the GC support in the JIT
  */
-
-class Tests {
-
-       static int Main () {
-               return TestDriver.RunTests (typeof (Tests));
-       }
+#if __MOBILE__
+class GcTests
+#else
+class Tests
+#endif
+{
+#if !__MOBILE__
+       public static int Main (string[] args) {
+               return TestDriver.RunTests (typeof (Tests), args);
+       }
+#endif
 
        public static int test_36_simple () {
                // Overflow the registers
@@ -525,9 +530,16 @@ class Tests {
                return 0;
        }
 
+       class ObjWithShiftOp {
+               public static ObjWithShiftOp operator >> (ObjWithShiftOp bi1, int shiftVal) {
+                       clobber_regs_and_gc ();
+                       return bi1;
+               }
+       }
+
        // Liveness for spill slots holding managed pointers
        public static int test_0_liveness_11 () {
-               Tests[] arr = new Tests [10];
+               ObjWithShiftOp[] arr = new ObjWithShiftOp [10];
                // This uses an ldelema internally
                // FIXME: This doesn't crash if mp-s are not correctly tracked, just writes to
                // an old object.
@@ -536,21 +548,44 @@ class Tests {
                return 0;
        }
 
-       public static Tests operator >> (Tests bi1, int shiftVal) {
-               clobber_regs_and_gc ();
-               return bi1;
-       }
 
        [MethodImplAttribute (MethodImplOptions.NoInlining)]
-       public static void liveness_12_inner (int a, int b, int c, int d, int e, int f, object o) {
+       public static void liveness_12_inner (int a, int b, int c, int d, int e, int f, object o, ref string s) {
                GC.Collect (1);
                o.GetHashCode ();
+               s.GetHashCode ();
+       }
+
+       class FooClass {
+               public string s;
        }
 
        // Liveness for param area
        public static int test_0_liveness_12 () {
+               var f = new FooClass () { s = "A" };
                // The ref argument should be passed on the stack
-               liveness_12_inner (1, 2, 3, 4, 5, 6, new object ());
+               liveness_12_inner (1, 2, 3, 4, 5, 6, new object (), ref f.s);
+               return 0;
+       }
+       
+       interface IFace {
+               int foo ();
+       }
+
+       struct BarStruct : IFace {
+               int i;
+
+               public int foo () {
+                       GC.Collect ();
+                       return i;
+               }
+       }
+               
+       public static int test_0_liveness_unbox_trampoline () {
+               var s = new BarStruct ();
+               
+               IFace iface = s;
+               iface.foo ();
                return 0;
        }
 
@@ -583,4 +618,22 @@ class Tests {
                else
                        return 1;
        }
-}
\ No newline at end of file
+
+       struct LargeBitmap {
+               public object o1, o2, o3;
+               public int i;
+               public object o4, o5, o6, o7, o9, o10, o11, o12, o13, o14, o15, o16, o17, o18, o19, o20, o21, o22, o23, o24, o25, o26, o27, o28, o29, o30, o31, o32;
+       }
+
+       public static int test_12_large_bitmap () {
+               LargeBitmap lb = new LargeBitmap ();
+               lb.o1 = 1;
+               lb.o2 = 2;
+               lb.o3 = 3;
+               lb.o32 = 6;
+
+               GC.Collect (0);
+
+               return (int)lb.o1 + (int)lb.o2 + (int)lb.o3 + (int)lb.o32;
+       }
+}