Thu Nov 23 20:01:12 CET 2006 Paolo Molaro <lupus@ximian.com>
[mono.git] / mono / mini / iltests.il
index d591a31d51be0a8d926ce3671d482cd6b839b82e..4bfd9f9f227cd548600733eb3cdcc4574b755e21 100644 (file)
@@ -510,6 +510,64 @@ COND:   ldloc.0
                ret
        }
 
+       .method static public int32 tail3 (int32 i, int32 j) il managed {
+               ldarg.0
+               ldarg.1
+               add
+               ret
+       }
+
+       .method static public int32 tail4 (int32 i, int32 j) il managed {
+               .maxstack 16
+               .locals init (
+                       int32 k)
+
+               // Test arg0 allocated to a register
+               ldarg.0
+               ldarg.0
+               ldarg.0
+               ldarg.0
+               add
+               add
+               add
+               starg 0
+
+               // Test switched up argument variables as the actual arguments
+               ldarg.1
+               ldarg.0
+               tail.
+               call int32 Tests::tail3 (int32, int32)
+               ret
+       }
+
+       .method static public int32 test_24_tail_calls2 () il managed {
+               .maxstack 16
+               .locals init (
+                       int32 i,
+                       int32 j)
+
+               ldc.i4.4
+               stloc.0
+               ldc.i4.8
+               stloc.1
+
+               ldloc.0 
+               ldloc.1
+               call int32 Tests::tail4 (int32, int32)
+               ret
+       }
+
+       .method public static int32 test_5_jmp () cil managed {
+               jmp int32 Tests::jmp2 ()
+               ldc.i4.0
+               ret
+       }
+
+       .method public static int32 jmp2 () cil managed {
+               ldc.i4.5
+               ret
+       }               
+
        .method static public int32 test_11_switch_with_nonempty_stack () il managed {
                .maxstack 16
 
@@ -554,6 +612,15 @@ COND:   ldloc.0
                ret
        }               
 
+       .method public static int32 test_1234_conv_u4 () il managed {
+               .maxstack 16
+
+               ldc.i4 1234
+               conv.u4
+               conv.i4
+               ret
+       }
+
        .method public static int32 test_0_get_type_from_handle_on_bblock_boundary () cil managed 
        {
                .maxstack 16
@@ -707,12 +774,12 @@ COND:   ldloc.0
                ret
        }
 
-       .class public auto ansi Integer
+       .class nested public auto ansi Integer
                extends [mscorlib]System.Object {
 
                .field public bool n
 
-           .method private hidebysig  specialname  rtspecialname 
+           .method public hidebysig  specialname  rtspecialname 
            instance default void .ctor (unsigned int64 i, bool n)  cil managed 
            {
                        .maxstack 8
@@ -771,4 +838,290 @@ COND:   ldloc.0
                ldc.i4.s 0
                ret
        }
+
+       .method public static int32 test_1_filters () {
+               .maxstack 16
+               .locals init (
+                       int32 res
+               )
+
+               .try { // 0
+                       .try {
+                               ldstr "OnErrorSub test Exception"
+                               newobj instance void class [mscorlib]System.Exception::.ctor(string)
+                               throw 
+                               leave.s IL_0033
+                       }
+                       filter {
+                               pop
+                               ldc.i4.0
+                               endfilter
+                       } {
+                               pop
+                               // Should not be called
+                               ldc.i4.2
+                               stloc res
+                               leave.s IL_0033
+                       }
+               }
+               filter {
+                       pop
+                       ldc.i4.1
+                       endfilter 
+               } {
+                 pop
+                 ldc.i4.1
+                 stloc res       
+                 leave.s IL_0033
+
+               }
+               IL_0033:
+               ldloc res
+               ret
+       }
+
+       .class nested private auto ansi sealed beforefieldinit TheStruct
+               extends [mscorlib]System.ValueType {
+               .field public int32 a
+               .field public int32 b
+       }
+
+       .method public static int32 test_5_cpobj () {
+               .maxstack 8
+               .locals init (  
+                               valuetype Tests/TheStruct v_0, 
+                               valuetype Tests/TheStruct v_1
+                                        )
+
+               ldloca v_0
+               ldc.i4.2
+               stfld int32 Tests/TheStruct::a
+
+               ldloca v_0
+               ldc.i4.3
+               stfld int32 Tests/TheStruct::b
+
+               ldloca v_1
+               ldloca v_0
+               cpobj Tests/TheStruct
+
+               ldloca v_1
+               ldfld int32 Tests/TheStruct::a
+               ldloca v_1
+               ldfld int32 Tests/TheStruct::b
+               add
+
+               ret
+       }
+
+       .method public static int32 test_5_ldobj_stloc_optimization () {
+               .maxstack 8
+               .locals init (  
+                               valuetype Tests/TheStruct v_0, 
+                               valuetype Tests/TheStruct v_1
+                                        )
+
+               ldloca v_0
+               ldc.i4.2
+               stfld int32 Tests/TheStruct::a
+
+               ldloca v_0
+               ldc.i4.3
+               stfld int32 Tests/TheStruct::b
+
+               ldloca v_0
+               ldobj valuetype Tests/TheStruct
+               stloc.s v_1
+
+               ldloca v_1
+               ldfld int32 Tests/TheStruct::a
+               ldloca v_1
+               ldfld int32 Tests/TheStruct::b
+               add
+
+               ret
+       }
+
+       .method public static int32 test_1_cpobj_reference () {
+               .maxstack 8
+               .locals init (  
+                               object v_0, 
+                               object v_1
+                                        )
+
+               newobj instance void object::.ctor()
+               stloc v_0
+
+               ldloca v_1
+               ldloca v_0
+               cpobj object
+
+               ldloc v_0
+               ldloc v_1
+               ceq
+               ret
+       }
+
+       .method public static int32 test_1_initobj_reference () {
+               .maxstack 8
+               .locals init (  
+                               object v_0
+                                        )
+
+               newobj instance void object::.ctor()
+               stloc v_0
+
+               ldloca v_0
+               initobj object
+
+               ldloc v_0
+               ldnull
+               ceq
+               ret
+       }
+
+       .method public static int32 test_1_ldobj_reference () {
+               .maxstack 8
+               .locals init (  
+                               object v_0
+                                        )
+
+               newobj instance void object::.ctor()
+               stloc v_0
+
+               ldloc v_0
+               ldloca v_0
+               ldobj object
+               ceq
+               ret
+       }
+
+       .method public static int32 test_5_vtype_on_bb_boundary () {
+               .maxstack 8
+               .locals init (  
+                               valuetype Tests/TheStruct v_0, 
+                               valuetype Tests/TheStruct v_1
+                                        )
+
+               ldloca v_0
+               ldc.i4.2
+               stfld int32 Tests/TheStruct::a
+
+               ldloca v_0
+               ldc.i4.3
+               stfld int32 Tests/TheStruct::b
+
+               ldloc v_0
+               br L_0
+       L_0: stloc v_1
+
+               ldloca v_1
+               ldfld int32 Tests/TheStruct::a
+               ldloca v_1
+               ldfld int32 Tests/TheStruct::b
+               add
+               ret
+       }
+
+       .method public static int32 test_3_larray_get_set () {
+               .locals init (
+                       int32[2]        V_0)
+                         
+                       ldc.i4.2 
+                       newobj instance void int32[0...]::.ctor(int32)
+                       stloc.0 
+                       ldloc.0 
+                       ldc.i4.0 
+                       ldc.i4 1
+                       call instance void int32[0...]::Set(int32, int32)
+                   ldloc.0 
+                   ldc.i4.1 
+                       ldc.i4 2
+                       call instance void int32[0...]::Set(int32, int32)
+
+                       ldloc.0
+                       ldc.i4.0
+                       call instance int32 int32[0...]::Get(int32)
+                       ldloc.0
+                       ldc.i4.1
+                       call instance int32 int32[0...]::Get(int32)
+                       add
+                       ret
+       }
+
+       .method public static void regalloc_regress_78314_helper (object o) cil managed
+       {
+               ret
+       }
+
+       .method public static int32 test_1_regalloc_regress_78314 () cil managed
+       {
+    // Code size       68 (0x44)
+    .maxstack  6
+    .locals init (int32 V_0, bool V_1)
+    IL_0000:  ldc.i4.0
+    IL_0001:  stloc.0
+    IL_0002:  br.s       IL_003b
+
+    IL_0004:
+    IL_001e:  ldc.i4.s   10
+    IL_0020:  ldloc.0
+    IL_0021:  shl
+    IL_0022:  ldc.i4.s   10
+    IL_0024:  ldloc.0
+    IL_0025:  shl
+    IL_0026:  ceq
+    IL_0028:  box        [mscorlib]System.Boolean
+    IL_0032:  call       void Tests::regalloc_regress_78314_helper(object)
+    IL_0037:  ldloc.0
+    IL_0038:  ldc.i4.1
+    IL_0039:  add
+    IL_003a:  stloc.0
+    IL_003b:  ldloc.0
+    IL_003c:  ldc.i4.8
+    IL_003f:  blt.s      IL_0004
+
+       ldloc.0
+       ldc.i4.8
+       ceq
+       conv.i4
+       ret     
+  }
+
+       .method public static void try_block_end_remove_if_useless () cil managed {
+           .maxstack  8
+
+           T_START:
+               ldstr   "Start"
+                       pop
+               leave.s COMPLETE
+           T1_END:
+
+           COMPLETE:
+               ret
+
+           F1_START:
+               ldstr   "Finally1"
+                       pop
+               endfinally
+           F1_END:
+
+           .try T_START to T1_END finally handler F1_START to F1_END
+       }
+
+       .method public static int32 test_0_try_block_end_remove_if_useless () cil managed {
+               call void class Tests::try_block_end_remove_if_useless ()
+               ldc.i4.0
+               ret
+       }
+
+   .method private static int32 test_0_regress_78629_switch_next_ins_target ()  cil managed
+    {
+        ldc.i4.0
+        switch (target)
+        target: ldstr "bar"
+               pop
+               ldc.i4.0
+        ret
+    }
 }