2008-08-29 Geoff Norton <gnorton@novell.com>
[mono.git] / mono / mini / iltests.il.in
index 836b3098f2b38ace8a0188da06e06c525566879a..44359946250f2ac56a25469502fbd4ff1cdb6ede 100644 (file)
@@ -563,16 +563,33 @@ COND:   ldloc.0
 #endif
 
        .method public static int32 test_5_jmp () cil managed {
-               jmp int32 Tests::jmp2 ()
-               ldc.i4.0
+               ldc.i4.1
+               ldc.i4.2
+               call int32 Tests::jmp2 (int32, int32)
                ret
        }
 
-       .method public static int32 jmp2 () cil managed {
-               ldc.i4.5
+       .method public static int32 jmp2 (int32, int32) cil managed {
+               ldarg.0
+               ldc.i4.1
+               add
+               starg.s 0
+               ldarg.1
+               ldc.i4.1
+               add
+               starg.s 1
+               jmp int32 Tests::jmp3 (int32, int32)
+               ldc.i4.0
                ret
        }               
 
+       .method public static int32 jmp3 (int32 i, int32 j) cil managed {
+               ldarg.0
+               ldarg.1
+               add
+               ret
+       }
+
        .method static public int32 test_11_switch_with_nonempty_stack () il managed {
                .maxstack 16
 
@@ -709,6 +726,95 @@ COND:   ldloc.0
                ret
        }
 
+       .method public static int32 test_1234_conv_ovf_i8_un () cil managed {
+               .maxstack 16
+
+               ldc.i4 1234
+               conv.ovf.i8.un
+               conv.i4
+               ret
+       }
+
+       .method public static int32 test_0_lconv_ovf_i () cil managed {
+               .maxstack 16
+
+               ldc.i4 1234
+               conv.i8
+               conv.ovf.i
+               conv.i4
+               ldc.i4 1234
+               beq L1
+               ldc.i4.1
+               ret
+       L1:
+               ldc.i4.0
+               ret
+       }
+
+       .method public static int32 test_0_lconv_ovf_u () cil managed {
+               .maxstack 16
+
+               ldc.i4 1234
+               conv.i8
+               conv.ovf.u
+               conv.i4
+               ldc.i4 1234
+               beq L1
+               ldc.i4.1
+               ret
+       L1:
+               ldc.i4.0
+               ret
+       }
+
+       .method public static int32 test_0_lconv_ovf_i_un () cil managed {
+               .maxstack 16
+
+               ldc.i4 1234
+               conv.i8
+               conv.ovf.i.un
+               conv.i4
+               ldc.i4 1234
+               beq L1
+               ldc.i4.1
+               ret
+       L1:
+               ldc.i4.0
+               ret
+       }
+
+       .method public static int32 test_0_lconv_ovf_u_un () cil managed {
+               .maxstack 16
+
+               ldc.i4 1234
+               conv.i8
+               conv.ovf.u.un
+               conv.i4
+               ldc.i4 1234
+               beq L1
+               ldc.i4.1
+               ret
+       L1:
+               ldc.i4.0
+               ret
+       }
+
+       .method public static int32 test_0_lconv_to_ovf_u8_un () cil managed {
+               .maxstack 16
+
+               ldc.i4 1234
+               conv.i8
+               conv.ovf.u8.un
+               conv.i4
+               ldc.i4 1234
+               beq L1
+               ldc.i4.1
+               ret
+       L1:
+               ldc.i4.0
+               ret
+       }
+
        .method public static int32 test_2_lconv_to_ovf_i4_un () cil managed {
                .maxstack 16
                .locals init (int32 res)
@@ -796,6 +902,21 @@ COND:   ldloc.0
                ret
        }
 
+       .method public static int32 test_0_fconv_to_i () cil managed {
+               .maxstack 16
+
+               ldc.r8 2147483648.0
+               conv.i
+               ldc.i8 2147483648
+               conv.i
+               beq L1
+               ldc.i4.1
+               ret
+       L1:
+               ldc.i4.0
+               ret
+       }
+
        .method public static int32 test_0_get_type_from_handle_on_bblock_boundary () cil managed 
        {
                .maxstack 16
@@ -1014,6 +1135,25 @@ COND:   ldloc.0
                ret
        }
 
+       .method public static int32 test_0_newobj_vtype_primitive () {
+               .maxstack 6
+               .locals init (
+                       native int V_0
+               )
+
+               ldc.i4.s 10
+               newobj instance void native int::'.ctor'(int32)
+               stloc.0
+               ldloc.0
+               ldc.i4.s 10
+               beq OK
+               ldc.i4.s 1
+               ret
+       OK:
+               ldc.i4.s 0
+               ret
+       }
+
        .method public static int32 test_1_filters () {
                .maxstack 16
                .locals init (
@@ -1509,4 +1649,271 @@ HAS_VALUE:      ldc.i4.1
                ret
        }
 
+       //Bug 372410
+       .method static public int32 test_0_ldelema_type_check () cil managed {
+               .maxstack 16
+               .locals init (object[] V_0,
+                                         object[,] V_1)
+
+               ldc.i4.1
+               newarr object
+               stloc.0
+
+               .try {
+                       ldloc.0
+                       ldc.i4.0
+                       ldelema object
+                       leave L1
+               } catch [mscorlib]System.ArrayTypeMismatchException {
+                       leave ERROR1
+               }
+
+       L1:
+               ldc.i4.1
+               newarr string
+               stloc.0
+
+               .try {
+                       ldloc.0
+                       ldc.i4.0
+                       ldelema object
+                       leave ERROR2
+               } catch [mscorlib]System.ArrayTypeMismatchException {
+                       leave L2
+               }
+
+       L2:
+                       ldc.i4.1
+               newarr string
+               stloc.0
+
+               .try {
+                       ldloc.0
+                       ldc.i4.0
+                       readonly. ldelema object
+                       leave L3
+               } catch [mscorlib]System.ArrayTypeMismatchException {
+                       leave ERROR3
+               }
+
+       L3:
+               ldc.i4.0
+               ret
+
+
+       ERROR1:
+               ldc.i4.1
+               ret
+
+       ERROR2:
+               ldc.i4.2
+               ret
+
+       ERROR3:
+               ldc.i4.3
+               ret
+       }
+
+
+       //Bug 372410
+       .method static public int32 test_0_array_address_type_check () cil managed {
+               .maxstack 16
+               .locals init (object[] V_0,
+                                         object[,] V_1)
+
+               ldc.i4.1 
+           ldc.i4.1 
+           newobj instance void object[,]::.ctor(int32, int32)
+               stloc.1
+
+               .try {
+                       ldloc.1
+                       ldc.i4.0
+                       ldc.i4.0
+                       call instance object&  object[,]::Address(int32, int32)
+                       leave L4
+               } catch [mscorlib]System.ArrayTypeMismatchException {
+                       leave ERROR4
+               }
+
+       L4:
+               ldc.i4.1 
+           ldc.i4.1 
+           newobj instance void string[,]::.ctor(int32, int32)
+               stloc.1
+
+               .try {
+                       ldloc.1
+                       ldc.i4.0
+                       ldc.i4.0
+                       call instance object&  object[,]::Address(int32, int32)
+                       leave ERROR5
+               } catch [mscorlib]System.ArrayTypeMismatchException {
+                       leave L5
+               }
+
+       L5:
+               ldc.i4.1 
+           ldc.i4.1 
+           newobj instance void string[,]::.ctor(int32, int32)
+               stloc.1
+
+               .try {
+                       ldloc.1
+                       ldc.i4.0
+                       ldc.i4.0
+                       readonly. call instance object&  object[,]::Address(int32, int32)
+                       leave L6
+               } catch [mscorlib]System.ArrayTypeMismatchException {
+                       leave ERROR6
+               }
+
+       L6:
+               ldc.i4.0
+               ret
+       ERROR4:
+               ldc.i4.4
+               ret
+
+       ERROR5:
+               ldc.i4.5
+               ret
+
+       ERROR6:
+               ldc.i4.6
+               ret
+       }
+
+       .field public  static unsigned int64 'ull'
+
+       .field public  static int32 'shift2'
+
+       .method public static int32 test_0_long_shift_regalloc () cil managed
+       {
+               .locals (unsigned int32 'cilsimp.28', unsigned int64 'cilsimp.27', int32 'cilsimp.26')
+
+               .maxstack 4
+
+               ldc.i8  81985529234382576
+               stsfld  unsigned int64 Tests::ull
+           ldc.i4      60
+               stsfld  int32 Tests::shift2
+
+               ldsfld  unsigned int64 Tests::ull
+               stloc   'cilsimp.27'
+               ldsfld  int32 Tests::shift2
+               stloc   'cilsimp.28'
+               ldloc   'cilsimp.27'
+               ldloc   'cilsimp.28'
+               shr.un
+               ldloc   'cilsimp.27'
+               ldc.i4  64
+               ldloc   'cilsimp.28'
+               sub
+               shl
+               or
+               ldc.i8  1311768467750121216
+               ceq
+               ldc.i4.1
+               xor
+               conv.u4
+               ret
+       }
+
+       // Test calling ldfld directly on a vtype instead of a vtype address
+       .method public static int32 test_5_call_ldfld_vtype () cil managed
+       {
+               .maxstack 16
+               .locals init (
+                       valuetype Tests/TailCallStruct arg
+               )
+               ldloca 0
+               ldc.i4.2
+               stfld int32 Tests/TailCallStruct::a
+               ldloca 0
+               ldc.i4.4
+               stfld int32 Tests/TailCallStruct::b
+               ldloc.0
+               call valuetype Tests/TailCallStruct Tests::tail2 (valuetype Tests/TailCallStruct)
+               ldfld int32 Tests/TailCallStruct::a
+               ret
+       }
+
+       .method public static int32 throw_ret () cil managed
+       {
+               ldstr "FOO"
+               newobj instance void class [mscorlib]System.OverflowException::.ctor(string)
+               throw
+               ldc.i4.4
+               ret
+       }
+
+       .method public static int32 throw2_ret () cil managed
+       {
+               // Disable inlining
+               ldc.i4.5
+               localloc
+               pop
+
+               call int32 Tests::throw_ret ()
+               ret
+       }
+
+       // Test inlining a method which contains just a throw
+       .method public static int32 test_0_inline_throw () cil managed
+       {
+               .maxstack 16
+               .locals init (
+                               int32 v_0
+               )
+
+               .try {
+                       call int32 Tests::throw2_ret ()
+                       stloc.0
+                       leave L0
+               } catch [mscorlib]System.OverflowException {
+                       pop
+                       leave L1
+               }
+
+               L0:
+                       ldc.i4.1
+                       ret
+               L1:
+                       ldc.i4.0
+                       ret                     
+       }
+
+    .method public static int32 test_0_stelem_any_null_opt () cil managed
+    {
+               .maxstack 16
+               .locals init (
+                               object[]        V_0,
+                               int32   V_1)
+
+               ldc.i4.s 10
+               newarr [mscorlib]System.Object
+               stloc.0
+
+               ldc.i4.0
+               stloc.1
+               br L0
+
+       L1:
+               ldloc.0
+               ldloc.1
+               ldnull
+               stelem.any [mscorlib]System.Object
+               ldloc.1
+               ldc.i4.1
+               add
+               stloc.1
+       L0:
+               ldloc.1
+               ldc.i4.s 10
+               blt L1
+
+               ldc.i4.0
+               ret
+       }
 }