2005-12-11 Zoltan Varga <vargaz@gmail.com>
[mono.git] / mono / mini / iltests.il
index 777c38423b8b8311c93a15bb81c4de7ef6b196c0..fd93802fc62b1737c94fd050319698388b4e4c15 100644 (file)
@@ -4,12 +4,13 @@
 
 .class public auto ansi sealed beforefieldinit Tests {
 
-       .method static public int32 Main() il managed {
+       .method static public int32 Main(string[] args) il managed {
                .entrypoint
                
                ldtoken Tests
                call       class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
-               call       int32 [TestDriver]TestDriver::RunTests(class [mscorlib]System.Type)
+               ldarg.0
+               call       int32 [TestDriver]TestDriver::RunTests(class [mscorlib]System.Type, string[])
                ret
        }
 
                
                ret
        }
+
+       .method static public int32 test_0_localloc () cil managed {
+               .locals init (native int, native int, native int, native int, int32)
+
+               ldc.i4 6
+               localloc
+               conv.i
+               stloc.0
+
+               ldc.i4 6
+               localloc
+               conv.i
+               stloc.1
+
+               ldc.i4 6
+               localloc
+               conv.i
+               stloc.2
+
+               // Variable length
+               ldc.i4 128
+               stloc.s 4
+               ldloc.s 4
+               localloc
+               conv.i
+               stloc.3
+
+               // Check zero initialized
+               ldloc.0
+               ldind.i4
+               ldc.i4.0
+               beq OK1
+               ldc.i4.1
+               br FAIL
+
+OK1:
+               ldloc.3
+               ldind.i4
+               ldc.i4.0
+               beq OK2
+               ldc.i4.2
+               br FAIL
+
+OK2:
+               ldloc.3
+               ldc.i4.s 124
+               add
+               ldind.i4
+               ldc.i4.0
+               beq OK3
+               ldc.i4.3
+               br FAIL
+
+OK3:
+               ldloc.1
+               ldc.i4 999999
+               stind.i4
+               ldloc.1
+               ldind.i4
+               ldc.i4 999999
+               beq OK4
+               ldc.i4.4
+               br FAIL
+
+OK4:
+               ldloc.0
+               ldc.i4 999999
+               stind.i4
+               ldloc.0
+               ldind.i4
+               ldc.i4 999999
+               beq OK5
+               ldc.i4.5
+               br FAIL
+
+OK5:
+               // Try allocations bigger than one page
+               ldc.i4 8196
+               localloc
+               conv.i
+               stloc.3
+               ldloc.3
+               ldc.i4 8192
+               add
+               ldc.i4 99
+               stind.i4
+               ldloc.3
+               ldc.i4 8192
+               add
+               ldind.i4
+               ldc.i4 99
+               beq PASS
+               ldc.i4.6
+               br FAIL
+
+FAIL:
+               ret
+
+PASS:  ldc.i4.0
+               ret
+       }
+
+    .method private static void do_localloc () cil managed {
+        .maxstack 3
+        .locals init (
+                unsigned int8*  V_0)
+        IL_0000:  ldc.i4.1
+        IL_0001:  ldc.i4 131072
+        IL_0006:  mul
+        IL_0007:  localloc
+        IL_0009:  stloc.0
+        IL_000a:  ret
+    }
+
+       // Check that localloc can't be inlined
+       .method static public int32 test_0_localloc_inline () cil managed {
+               .maxstack 16
+               .locals init (
+                       int32 i
+               )
+
+               ldc.i4.0
+        stloc.0
+        br COND
+
+START:  call void class Tests::do_localloc()
+        ldloc.0
+        ldc.i4.1
+        add
+        stloc.0
+COND:   ldloc.0
+        ldc.i4 1000
+        blt START
+
+               ldc.i4.0
+               ret
+       }       
        
        .method static public int32 test_3_copy_used_bug () il managed {
 
                extends [mscorlib]System.ValueType {
                .field public int32 a
                .field public int32 b
+               .field public int32 b1
+               .field public int32 b2
+               .field public int32 b3
+               .field public int32 b4
+               .field public int32 b5
+               .field public int32 b6
+               .field public int32 b7
+               .field public int32 b8
        }
 
        .method static valuetype Tests/TailCallStruct tail1 (valuetype Tests/TailCallStruct arg) {
        }
 
        .method static valuetype Tests/TailCallStruct tail2 (valuetype Tests/TailCallStruct arg) {
+               ldarg.0
+               call valuetype Tests/TailCallStruct Tests::tail1 (valuetype Tests/TailCallStruct)
+
                ldarg.0
                tail.
                call valuetype Tests/TailCallStruct Tests::tail1 (valuetype Tests/TailCallStruct)
                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 
        {
-               .entrypoint
                .maxstack 16
        
                ldc.i4.1
                ldtoken [mscorlib]System.Object
        AFTER:
                call class [mscorlib]'System.Type' class [mscorlib]'System.Type'::'GetTypeFromHandle'(valuetype [mscorlib]'System.RuntimeTypeHandle')
-               callvirt string class [mscorlib]System.Type::get_FullName ()
+               callvirt instance string class [mscorlib]System.Type::get_FullName ()
                ldstr "System.String"
-               callvirt bool class [mscorlib]System.Object::Equals(object)
+               callvirt instance bool class [mscorlib]System.Object::Equals(object)
                ldc.i4.0
                ceq
                ret 
                ldc.i4.1
                ret
        }
+       
+       .method public static int32 test_1_bug60056  () {
+               .locals init (int32 m5)
+                       
+               ldc.i4.m1
+               stloc.0
+               
+               ldc.i4.1
+               conv.u8
+               
+               ldloc.0
+               conv.i8
+               mul
+               
+               ldc.i4.m1
+               conv.i8
+               ceq
+               ret
+       }
+       
+       .method public static int32 test_1_conv_u8_cfold  () {
+               ldc.i4.m1
+               conv.u8
+               
+               ldc.i8 0x00000000ffffffff
+               
+               ceq
+               ret
+       }
+       
+       .method public static int32 test_1_array_type_mismatch_ldelema  () {
+               .locals init (int32 r)
+               
+                       ldc.i4.1
+                       newarr string
+                       ldc.i4.0 
+                       ldelema string
+                       pop
+               
+               .try {
+                       ldc.i4.1
+                       newarr string
+                       ldc.i4.0 
+                       ldelema object
+                       pop
+                       
+                       leave end
+               } catch [mscorlib]System.ArrayTypeMismatchException {
+                       pop
+                       ldc.i4.1
+                       stloc.0
+                       leave end
+               }
+       end:
+               ldloc.0
+               ret
+       }
+
+       .method public static int32 test_1_conv_ovf_i8_with_i4 () {
+                       ldc.i4.m1 
+                       conv.ovf.i8
+                       conv.ovf.i4
+                       neg
+                       ret
+       }
+
+       // bug #72148
+    .method public static int32 test_0_initlocals_float_ptr () {
+       .maxstack 3
+       .locals init (
+               float32[]       V_0,
+               float32& pinned V_1,
+               unsigned int32  V_2)
+                       ldc.i4.s 0x0f
+                       newarr [mscorlib]System.Single
+                       stloc.0 
+                       ldloc.0 
+                       ldc.i4.0 
+                       ldc.r4 1.13
+                       stelem.r4 
+                       ldloc.0 
+                       ldc.i4.0 
+                       ldelema [mscorlib]System.Single
+                       stloc.1 
+                       ldloc.1 
+                       conv.i 
+                       ldind.u4 
+                       stloc.2 
+                       ldc.i4.0
+                       ret
+       }
+
+       .method public static int32 test_7_conv_ovf_u8_un () {
+       .maxstack  2
+        .locals    init (unsigned int64)
+
+        ldc.i4.7
+        conv.ovf.u8.un
+        stloc.0
+               ldloc.0
+               conv.i4
+        ret
+       }
+
+       .method public static int32 test_1_bug_74591 () {
+               .maxstack 16
+               .locals init (int32)
+
+               ldc.i4.m1
+               stloc.0
+               ldloc.0
+               conv.ovf.i8
+               ldc.i4.m1
+               conv.ovf.i8
+               mul.ovf
+               conv.i4
+               ret
+       }
+
+       .class public auto ansi Integer
+               extends [mscorlib]System.Object {
+
+               .field public bool n
+
+           .method private hidebysig  specialname  rtspecialname 
+           instance default void .ctor (unsigned int64 i, bool n)  cil managed 
+           {
+                       .maxstack 8
+                       ldarg.0
+                       call instance void class [mscorlib]System.Object::.ctor()
+                       ldarg.0
+                       ldarg.2
+                       stfld bool Tests/Integer::n
+                       ret
+               }
+       }
+
+       .method public static int32 test_1_bug_74726 () {
+               .maxstack 16
+
+               ldc.i4.2
+               conv.ovf.u8
+               ldc.i4.1
+               conv.ovf.u8
+               mul.ovf.un
+               ldc.i4.1
+               newobj instance void class Tests/Integer::.ctor(unsigned int64, bool)
+               ldfld bool Tests/Integer::n
+               ldc.i4.1
+               ceq
+               ret
+       }
+
+       .class nested private auto ansi sealed xxx
+       extends [mscorlib]System.ValueType
+   {
+     .field  public   object a
+
+     .method public hidebysig  specialname  rtspecialname 
+            instance default void .ctor ()  cil managed 
+     {
+                .maxstack 8
+                ret 
+     }
+   } // end of class xxx
+
+       .method public static int32 test_0_newobj_vtype () {
+               .maxstack 6
+               .locals init (
+                       valuetype Tests/xxx V_0
+               )
+
+               newobj instance void valuetype Tests/xxx::.ctor ()
+               stloc.0
+               ldloca.s 0
+               ldfld object Tests/xxx::a
+               brfalse OK
+               ldc.i4.s 1
+               ret
+       OK:
+               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
+       }
 }