Fix the handling of fail tramps in the full-aot IMT thunks on x86. Fixes #6112.
authorZoltan Varga <vargaz@gmail.com>
Sun, 15 Jul 2012 12:59:03 +0000 (14:59 +0200)
committerZoltan Varga <vargaz@gmail.com>
Sun, 15 Jul 2012 12:59:24 +0000 (14:59 +0200)
mono/mini/aot-compiler.c
mono/mini/aot-runtime.c
mono/mini/generics.cs

index 7717f8cd86186802976256fabc216ca03e31749b..f176c7c5b0d67b627d1b80fa962682a6572933d0 100644 (file)
@@ -1400,7 +1400,7 @@ arch_emit_imt_thunk (MonoAotCompile *acfg, int offset, int *tramp_size)
 #ifdef __native_client_codegen__
        guint8 *buf_alloc;
 #endif
-       guint8 *labels [3];
+       guint8 *labels [16];
 
 #if defined(__default_codegen__)
        code = buf = g_malloc (256);
@@ -1445,8 +1445,19 @@ arch_emit_imt_thunk (MonoAotCompile *acfg, int offset, int *tramp_size)
        x86_ret (code);
 
        /* No match */
-       /* FIXME: */
        mono_x86_patch (labels [1], code);
+       /* Load fail tramp */
+       x86_mov_reg_membase (code, X86_EAX, X86_EAX, sizeof (gpointer), 4);
+       x86_alu_membase_imm (code, X86_CMP, X86_EAX, 0, 0);
+       labels [3] = code;
+       x86_branch8 (code, X86_CC_Z, FALSE, 0);
+       /* Jump to fail tramp */
+       x86_mov_membase_reg (code, X86_ESP, 4, X86_EAX, 4);
+       x86_pop_reg (code, X86_EAX);
+       x86_ret (code);
+
+       /* Fail */
+       mono_x86_patch (labels [3], code);
        x86_breakpoint (code);
 
 #ifdef __native_client_codegen__
index e046124203d2727ab4276e088db60aa28420f119..213f559bcc90eae469e96866c45983b04b062633 100644 (file)
@@ -1365,7 +1365,7 @@ check_usable (MonoAssembly *assembly, MonoAotFileInfo *info, char **out_msg)
                usable = FALSE;
        }
 
-       if (info->simd_opts & ~mono_arch_cpu_enumerate_simd_versions ()) {
+       if (!mono_aot_only && (info->simd_opts & ~mono_arch_cpu_enumerate_simd_versions ())) {
                msg = g_strdup_printf ("compiled with unsupported SIMD extensions");
                usable = FALSE;
        }
index 842ddf6352d65b38ea7fbe461dc9a53c2eee467c..4c23b39a7c7b2d1d6838e2a88be918d366d464fd 100644 (file)
@@ -921,4 +921,24 @@ class Tests {
                }
                return 0;
        }
+
+       class A { }
+
+    static List<A> sources = new List<A>();
+
+       // #6112
+    public static int test_0_fullaot_imt () {
+        sources.Add(null);
+        sources.Add(null);
+
+        int a = sources.Count;
+        var enumerator = sources.GetEnumerator() as IEnumerator<object>;
+
+        while (enumerator.MoveNext())
+        {
+            object o = enumerator.Current;
+        }
+
+               return 0;
+       }
 }