Merge pull request #439 from mono-soc-2012/garyb/iconfix
[mono.git] / mono / mini / gc-test.cs
index 3da42741b0aed6c6018602b51b939ad8b2dd3135..2ec1c0ab3ff0f314df1f949757c04c5032bfde37 100644 (file)
@@ -1,6 +1,8 @@
 using System;
 using System.Reflection;
 using System.Runtime.CompilerServices;
+using System.Collections;
+using System.Threading;
 
 /*
  * Regression tests for the GC support in the JIT
@@ -551,4 +553,34 @@ class Tests {
                liveness_12_inner (1, 2, 3, 4, 5, 6, new object ());
                return 0;
        }
+
+       public static void liveness_13_inner (ref ArrayList arr) {
+               // The value of arr will be stored in a spill slot
+               arr.Add (alloc_obj_and_gc ());
+       }
+
+       // Liveness for byref arguments in spill slots
+       public static int test_0_liveness_13 () {
+               var arr = new ArrayList ();
+               liveness_13_inner (ref arr);
+               return 0;
+       }
+
+       static ThreadLocal<object> tls;
+
+       [MethodImplAttribute (MethodImplOptions.NoInlining)]
+       static void alloc_tls_obj () {
+               tls = new ThreadLocal<object> ();
+               tls.Value = new object ();
+       }
+
+       public static int test_0_thread_local () {
+               alloc_tls_obj ();
+               GC.Collect ();
+               Type t = tls.Value.GetType ();
+               if (t == typeof (object))
+                       return 0;
+               else
+                       return 1;
+       }
 }
\ No newline at end of file