more c*****y windows issues.
[mono.git] / mono / mini / inssel.brg
index ef89d1b4a4424d76d46a3c14e7457a9ebc37e278..d711d893c412e5bab874d1fe0d425f5fbb078d50 100644 (file)
@@ -1637,13 +1637,22 @@ mini_emit_virtual_call (MonoCompile *cfg, void *st, MonoInst *tree, int novirtop
        MonoMethod *method = ((MonoCallInst*)tree)->method;
        int vtable_reg, slot_reg, this_reg;
        MBState *state = st;
+       gboolean enable_for_aot = TRUE;
 
        this_reg = state->left->reg1;
        mono_arch_emit_this_vret_args (cfg, (MonoCallInst*)tree, this_reg, state->left->tree->type, novirtop == OP_VCALL? state->right->reg1: -1);
 
-       if (!(method->flags & METHOD_ATTRIBUTE_VIRTUAL) || 
-           ((method->flags & METHOD_ATTRIBUTE_FINAL) && 
-            method->wrapper_type != MONO_WRAPPER_REMOTING_INVOKE_WITH_CHECK)) {
+#ifdef MONO_ARCH_NEED_GOT_VAR
+       /* Can't create a got var at this point */
+       enable_for_aot = cfg->got_var != NULL;
+#else
+       enable_for_aot = TRUE;
+#endif
+
+       if ((!cfg->compile_aot || enable_for_aot) && 
+               (!(method->flags & METHOD_ATTRIBUTE_VIRTUAL) || 
+            ((method->flags & METHOD_ATTRIBUTE_FINAL) && 
+            method->wrapper_type != MONO_WRAPPER_REMOTING_INVOKE_WITH_CHECK))) {
                /* 
                 * the method is not virtual, we just need to ensure this is not null
                 * and then we can call the method directly.
@@ -1661,6 +1670,9 @@ mini_emit_virtual_call (MonoCompile *cfg, void *st, MonoInst *tree, int novirtop
                return;
        }
 
+       /* Initialize method->slot */
+       mono_class_setup_vtable (method->klass);
+
        vtable_reg = mono_regstate_next_int (cfg->rs);
        MONO_EMIT_NEW_LOAD_MEMBASE (cfg, vtable_reg, this_reg, G_STRUCT_OFFSET (MonoObject, vtable));
        if (method->klass->flags & TYPE_ATTRIBUTE_INTERFACE) {