NaCl runtime fixes
[mono.git] / mono / mini / objects.cs
index e9963c873e06947de764b4a93380dbfebc7ebd53..a16871b226c11a4b0c8f148328e4a6dafffd529f 100644 (file)
@@ -114,7 +114,7 @@ struct Gamma {
 
 class Tests {
 
-       static int Main (string[] args) {
+       public static int Main (string[] args) {
                return TestDriver.RunTests (typeof (Tests), args);
        }
        
@@ -1078,7 +1078,8 @@ class Tests {
        }
        public static int test_0_cond_branch_side_effects () {
                counter = 5;
-               if (WriteStuff());
+               if (WriteStuff()) {
+               }
                if (counter == 10)
                        return 0;
                return 1;
@@ -1352,6 +1353,19 @@ ncells ) {
                        return 1;
        }
 
+       struct AStruct2 {
+               public int i;
+               public int j;
+       }
+
+       static float pass_vtype_return_float (AStruct2 s) {
+               return s.i + s.j == 6 ? 1.0f : -1.0f;
+       }
+
+       public static int test_0_vtype_arg_soft_float () {
+               return pass_vtype_return_float (new AStruct2 () { i = 2, j = 4 }) > 0.0 ? 0 : 1;
+       }
+
        static int range_check_strlen (int i, string s) {
                if (i < 0 || i > s.Length)
                        return 1;
@@ -1379,7 +1393,7 @@ ncells ) {
 
        //repro for #506915
        struct Bug506915 { public int val; }
-       static int test_2_ldobj_stobj_optimization ()
+       static int test_2_ldobj_stobj_optization ()
        {
                int i = 99;
                var a = new Bug506915 ();
@@ -1393,6 +1407,8 @@ ncells ) {
                return array [1].val;
        }
 
+       /* mcs can't compile this (#646744) */
+#if FALSE
        static void InitMe (out Gamma noMercyWithTheStack) {
                noMercyWithTheStack = new Gamma ();
        }
@@ -1419,8 +1435,6 @@ ncells ) {
         * This only happens because the call in middle forces the temp for "(float)obj"
         * to be spilled.
        */
-       // This overflows the PS3 stack
-       [Category ("!PS3")]
        public static int test_0_float_load_and_store_with_big_offset ()
        {
                object obj = 1.0f;
@@ -1435,6 +1449,7 @@ ncells ) {
                        return 1;
                return 0;
        }
+#endif
 
        struct VTypePhi {
                public int i;
@@ -1486,5 +1501,99 @@ ncells ) {
                return 0;
        }
 
+       public static bool flag;
+
+       class B {
+
+               internal static B[] d;
+
+               static B () {
+                       flag = true;
+               }
+       }
+
+       [MethodImplAttribute (MethodImplOptions.NoInlining)]
+       static int regress_679467_inner () {
+               if (flag == true)
+                       return 1;
+               var o = B.d;
+               var o2 = B.d;
+               return 0;
+       }
+
+       /*
+        * FIXME: This fails with AOT #703317.
+        */
+       /*
+       static int test_0_multiple_cctor_calls_regress_679467 () {
+               flag = false;
+               return regress_679467_inner ();
+       }
+       */
+
+       static int test_0_char_ctor () {
+               string s = new String (new char[] { 'A', 'B' }, 0, 1);
+               return 0;
+       }
+
+       static object mInstance = null;
+
+       [MethodImpl(MethodImplOptions.Synchronized)]
+       public static object getInstance() {
+               if (mInstance == null)
+                       mInstance = new object();
+               return mInstance;
+       }
+
+       static int test_0_synchronized () {
+               getInstance ();
+               return 0;
+       }
+
+       struct BStruct {
+               public Type t;
+       }
+
+       class Del<T> {
+               public static BStruct foo () {
+                       return new BStruct () { t = typeof (T) };
+               }
+       }
+
+       delegate BStruct ADelegate ();
+
+       static int test_0_regress_10601 () {
+               var act = (ADelegate)(Del<string>.foo);
+               BStruct b = act ();
+               if (b.t != typeof (string))
+                       return 1;
+               return 0;
+       }
+
+       static int test_0_regress_11058 () {
+               int foo = -252674008;
+               int foo2 = (int)(foo ^ 0xF0F0F0F0); // = 28888
+               var arr = new byte[foo2].Length;
+               return 0;
+       }
+
+       public static void do_throw () {
+               throw new Exception ();
+       }
+
+       [MethodImplAttribute (MethodImplOptions.NoInlining)]
+       static void empty () {
+       }
+
+       // #11297
+       public static int test_0_llvm_inline_throw () {
+               try {
+                       empty ();
+               } catch (Exception ex) {
+                       do_throw ();
+               }
+
+               return 0;
+       }
 }