2005-01-25 Sebastien Pouliot <sebastien@ximian.com>
[mono.git] / mono / mini / iltests.il
index 76df62091a498c73d2a34f2bfadc457b9c977bb2..a703b7fe3882cecead505f3cbc31065ccc50c623 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
        }
 
        }
 
        .method static public int32 test_0_localloc () cil managed {
-               .locals init (native int, native int, native int)
+               .locals init (native int, native int, native int, native int, int32)
 
                ldc.i4 6
                localloc
                conv.i
                stloc.2
 
-               // br OK1
+               // 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 OK1
+               beq OK4
+               ldc.i4.4
                br FAIL
 
-OK1:
+OK4:
                ldloc.0
                ldc.i4 999999
                stind.i4
@@ -266,13 +302,51 @@ OK1:
                ldind.i4
                ldc.i4 999999
                beq PASS
+               ldc.i4.5
+               br FAIL
 
-FAIL:  ldc.i4.1
+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 {
 
@@ -462,7 +536,6 @@ PASS:       ldc.i4.0
 
        .method public static int32 test_0_get_type_from_handle_on_bblock_boundary () cil managed 
        {
-               .entrypoint
                .maxstack 16
        
                ldc.i4.1
@@ -474,9 +547,9 @@ PASS:       ldc.i4.0
                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 
@@ -524,4 +597,40 @@ PASS:      ldc.i4.0
                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
+       }
 }