Merge pull request #1369 from DynamicDevices/ajl/appveyor
[mono.git] / mono / mini / mini-trampolines.c
index 95798a2350c19156b310fc8dce0a2c47c49cb196..d8f1e4298e956e681b2b67aeffe75750005c678a 100644 (file)
@@ -13,6 +13,7 @@
 #include <mono/utils/mono-counters.h>
 #include <mono/utils/mono-error-internals.h>
 #include <mono/utils/mono-membar.h>
+#include <mono/utils/mono-compiler.h>
 
 #include "mini.h"
 
@@ -140,18 +141,15 @@ mono_create_static_rgctx_trampoline (MonoMethod *m, gpointer addr)
 
 /*
  * Either IMPL_METHOD or AOT_ADDR will be set on return.
- */
-static gpointer*
-#ifdef __GNUC__
-/*
+ *
+ * MONO_NEVER_INLINE :
  * This works against problems when compiling with gcc 4.6 on arm. The 'then' part of
  * this line gets executed, even when the condition is false:
  *             if (impl && mono_method_needs_static_rgctx_invoke (impl, FALSE))
  *                     *need_rgctx_tramp = TRUE;
  */
-__attribute__ ((noinline))
-#endif
-       mono_convert_imt_slot_to_vtable_slot (gpointer* slot, mgreg_t *regs, guint8 *code, MonoMethod *method, gboolean lookup_aot, MonoMethod **impl_method, gboolean *need_rgctx_tramp, gboolean *variance_used, gpointer *aot_addr)
+static MONO_NEVER_INLINE gpointer*
+mono_convert_imt_slot_to_vtable_slot (gpointer* slot, mgreg_t *regs, guint8 *code, MonoMethod *method, gboolean lookup_aot, MonoMethod **impl_method, gboolean *need_rgctx_tramp, gboolean *variance_used, gpointer *aot_addr)
 {
        MonoObject *this_argument = mono_arch_get_this_arg_from_call (regs, code);
        MonoVTable *vt = this_argument->vtable;
@@ -730,10 +728,6 @@ mono_vcall_trampoline (mgreg_t *regs, guint8 *code, int slot, guint8 *tramp)
         * We use one vtable trampoline per vtable slot index, so we need only the vtable,
         * the other two can be computed from the vtable + the slot index.
         */
-#ifndef MONO_ARCH_THIS_AS_FIRST_ARG
-       /* All architectures should support this */
-       g_assert_not_reached ();
-#endif
 
        /*
         * Obtain the vtable from the 'this' arg.
@@ -983,7 +977,7 @@ create_delegate_trampoline_data (MonoDomain *domain, MonoClass *klass, MonoMetho
        invoke = mono_get_delegate_invoke (klass);
        g_assert (invoke);
 
-       tramp_data = mono_domain_alloc (domain, sizeof (MonoDelegateTrampInfo));
+       tramp_data = mono_domain_alloc0 (domain, sizeof (MonoDelegateTrampInfo));
        tramp_data->invoke = invoke;
        tramp_data->invoke_sig = mono_method_signature (invoke);
        tramp_data->impl_this = mono_arch_get_delegate_invoke_impl (mono_method_signature (invoke), TRUE);
@@ -1571,6 +1565,19 @@ mono_create_delegate_trampoline (MonoDomain *domain, MonoClass *klass)
 #endif
 }
 
+gpointer
+mono_create_delegate_virtual_trampoline (MonoDomain *domain, MonoClass *klass, MonoMethod *method)
+{
+#ifdef MONO_ARCH_HAVE_CREATE_DELEGATE_TRAMPOLINE
+       MonoMethod *invoke = mono_get_delegate_invoke (klass);
+       g_assert (invoke);
+
+       return mono_get_delegate_virtual_invoke_impl (mono_method_signature (invoke), method);
+#else
+       return NULL;
+#endif
+}
+
 gpointer
 mono_create_rgctx_lazy_fetch_trampoline (guint32 offset)
 {