Merge pull request #1266 from esdrubal/datetimenewformat
[mono.git] / mono / mini / mini-trampolines.c
index 80f5dc3bdee113eb059a19f41e64d74f4c52af69..f65dab8c1e77f6220613e59111a84dd927597b90 100644 (file)
  */
 guint8* mono_trampoline_code [MONO_TRAMPOLINE_NUM];
 
-static GHashTable *class_init_hash_addr = NULL;
-static GHashTable *rgctx_lazy_fetch_trampoline_hash = NULL;
-static GHashTable *rgctx_lazy_fetch_trampoline_hash_addr = NULL;
+static GHashTable *class_init_hash_addr;
+static GHashTable *rgctx_lazy_fetch_trampoline_hash;
+static GHashTable *rgctx_lazy_fetch_trampoline_hash_addr;
 static guint32 trampoline_calls, jit_trampolines, unbox_trampolines, static_rgctx_trampolines;
 
-#define mono_trampolines_lock() EnterCriticalSection (&trampolines_mutex)
-#define mono_trampolines_unlock() LeaveCriticalSection (&trampolines_mutex)
-static CRITICAL_SECTION trampolines_mutex;
+#define mono_trampolines_lock() mono_mutex_lock (&trampolines_mutex)
+#define mono_trampolines_unlock() mono_mutex_unlock (&trampolines_mutex)
+static mono_mutex_t trampolines_mutex;
 
 #ifdef MONO_ARCH_GSHARED_SUPPORTED
 
@@ -58,19 +58,24 @@ rgctx_tramp_info_hash (gconstpointer data)
        return GPOINTER_TO_UINT (info->m) ^ GPOINTER_TO_UINT (info->addr);
 }
 
-/*
+/**
  * mono_create_static_rgctx_trampoline:
+ * @m: the mono method to create a trampoline for
+ * @addr: the address to jump to (where the compiled code for M lives)
  *
- *   Return a static rgctx trampoline for M which branches to ADDR which should
+ * Creates a static rgctx trampoline for M which branches to ADDR which should
  * point to the compiled code of M.
  *
- *   Static rgctx trampolines are used when a shared generic method which doesn't
+ * Static rgctx trampolines are used when a shared generic method which doesn't
  * have a this argument is called indirectly, ie. from code which can't pass in
  * the rgctx argument. The trampoline sets the rgctx argument and jumps to the
  * methods code. These trampolines are similar to the unbox trampolines, they
  * perform the same task as the static rgctx wrappers, but they are smaller/faster,
  * and can be made to work with full AOT.
+ *
  * On PPC addr should be an ftnptr and the return value is an ftnptr too.
+ *
+ * Returns the generated static rgctx trampoline.
  */
 gpointer
 mono_create_static_rgctx_trampoline (MonoMethod *m, gpointer addr)
@@ -133,8 +138,6 @@ mono_create_static_rgctx_trampoline (MonoMethod *m, gpointer addr)
 }
 #endif
 
-#ifdef MONO_ARCH_HAVE_IMT
-
 /*
  * Either IMPL_METHOD or AOT_ADDR will be set on return.
  */
@@ -238,7 +241,6 @@ __attribute__ ((noinline))
                }
        }
 }
-#endif
 
 /*
  * This is a super-ugly hack to fix bug #616463.
@@ -274,12 +276,19 @@ mini_jit_info_is_gsharedvt (MonoJitInfo *ji)
                return FALSE;
 }
 
-/*
+/**
  * mini_add_method_trampoline:
+ * @orig_method: the method the caller originally called i.e. an iface method, or NULL.
+ * @m: 
+ * @compiled_method:
+ * @add_static_rgctx_tramp: adds a static rgctx trampoline
+ * @add_unbox_tramp: adds an unboxing trampoline
+ *
+ * Add static rgctx/gsharedvt_in/unbox trampolines to
+ * M/COMPILED_METHOD if needed.
  *
- *   Add static rgctx/gsharedvt_in/unbox trampolines to M/COMPILED_METHOD if needed. Return the trampoline address, or
- * COMPILED_METHOD if no trampoline is needed.
- * ORIG_METHOD is the method the caller originally called i.e. an iface method, or NULL.
+ * Returns the trampoline address, or COMPILED_METHOD if no trampoline
+ * is needed.
  */
 gpointer
 mini_add_method_trampoline (MonoMethod *orig_method, MonoMethod *m, gpointer compiled_method, gboolean add_static_rgctx_tramp, gboolean add_unbox_tramp)
@@ -394,7 +403,6 @@ common_call_trampoline (mgreg_t *regs, guint8 *code, MonoMethod *m, guint8* tram
        orig_vtable_slot = vtable_slot;
        vtable_slot_to_patch = vtable_slot;
 
-#ifdef MONO_ARCH_HAVE_IMT
        /* IMT call */
        if (vt && (gpointer)vtable_slot < (gpointer)vt) {
                MonoMethod *impl_method = NULL;
@@ -418,6 +426,8 @@ common_call_trampoline (mgreg_t *regs, guint8 *code, MonoMethod *m, guint8* tram
                } else {
                        gboolean lookup_aot;
 
+                       mono_class_interface_offset_with_variance (vt->klass, m->klass, &variance_used);
+
                        if (m->is_inflated && ((MonoMethodInflated*)m)->context.method_inst) {
                                /* Generic virtual method */
                                generic_virtual = m;
@@ -450,7 +460,6 @@ common_call_trampoline (mgreg_t *regs, guint8 *code, MonoMethod *m, guint8* tram
                        m = impl_method;
                }
        }
-#endif
 
        /*
         * The virtual check is needed because is_generic_method_definition (m) could
@@ -470,9 +479,7 @@ common_call_trampoline (mgreg_t *regs, guint8 *code, MonoMethod *m, guint8* tram
                else
                        g_assert (!m->klass->generic_container);
 
-#ifdef MONO_ARCH_HAVE_IMT
                generic_virtual = mono_arch_find_imt_method (regs, code);
-#endif
                if (generic_virtual) {
                        g_assert (generic_virtual->is_inflated);
                        context.method_inst = ((MonoMethodInflated*)generic_virtual)->context.method_inst;
@@ -510,7 +517,6 @@ common_call_trampoline (mgreg_t *regs, guint8 *code, MonoMethod *m, guint8* tram
                        g_assert_not_reached ();
 #endif
                } else {
-#ifdef MONO_ARCH_HAVE_IMT
                        MonoObject *this_argument = mono_arch_get_this_arg_from_call (regs, code);
 
                        vt = this_argument->vtable;
@@ -523,9 +529,6 @@ common_call_trampoline (mgreg_t *regs, guint8 *code, MonoMethod *m, guint8* tram
                                mono_class_setup_supertypes (this_argument->vtable->klass);
                                klass = this_argument->vtable->klass->supertypes [m->klass->idepth - 1];
                        }
-#else
-                       NOT_IMPLEMENTED;
-#endif
                }
 
                g_assert (vtable_slot || klass);
@@ -659,7 +662,7 @@ common_call_trampoline (mgreg_t *regs, guint8 *code, MonoMethod *m, guint8* tram
                                }
                        }
                        if (!no_patch)
-                               mono_aot_patch_plt_entry (plt_entry, NULL, regs, addr);
+                               mono_aot_patch_plt_entry (code, plt_entry, NULL, regs, addr);
                } else {
                        if (generic_shared) {
                                if (m->wrapper_type != MONO_WRAPPER_NONE)
@@ -693,7 +696,7 @@ common_call_trampoline (mgreg_t *regs, guint8 *code, MonoMethod *m, guint8* tram
 /**
  * mono_magic_trampoline:
  *
- *   This trampoline handles normal calls from JITted code.
+ * This trampoline handles normal calls from JITted code.
  */
 gpointer
 mono_magic_trampoline (mgreg_t *regs, guint8 *code, gpointer arg, guint8* tramp)
@@ -703,10 +706,10 @@ mono_magic_trampoline (mgreg_t *regs, guint8 *code, gpointer arg, guint8* tramp)
        return common_call_trampoline (regs, code, arg, tramp, NULL, NULL, FALSE);
 }
 
-/*
+/**
  * mono_vcall_trampoline:
  *
- *   This trampoline handles virtual calls.
+ * This trampoline handles virtual calls.
  */
 static gpointer
 mono_vcall_trampoline (mgreg_t *regs, guint8 *code, int slot, guint8 *tramp)
@@ -802,11 +805,9 @@ mono_generic_virtual_remoting_trampoline (mgreg_t *regs, guint8 *code, MonoMetho
        else
                g_assert (!m->klass->generic_container);
 
-#ifdef MONO_ARCH_HAVE_IMT
        imt_method = mono_arch_find_imt_method (regs, code);
        if (imt_method->is_inflated)
                context.method_inst = ((MonoMethodInflated*)imt_method)->context.method_inst;
-#endif
        m = mono_class_inflate_generic_method (declaring, &context);
        m = mono_marshal_get_remoting_invoke_with_check (m);
 
@@ -817,10 +818,10 @@ mono_generic_virtual_remoting_trampoline (mgreg_t *regs, guint8 *code, MonoMetho
 }
 #endif
 
-/*
+/**
  * mono_aot_trampoline:
  *
- *   This trampoline handles calls made from AOT code. We try to bypass the 
+ * This trampoline handles calls made from AOT code. We try to bypass the 
  * normal JIT compilation logic to avoid loading the metadata for the method.
  */
 #ifdef MONO_ARCH_AOT_SUPPORTED
@@ -855,7 +856,7 @@ mono_aot_trampoline (mgreg_t *regs, guint8 *code, guint8 *token_info,
        plt_entry = mono_aot_get_plt_entry (code);
        g_assert (plt_entry);
 
-       mono_aot_patch_plt_entry (plt_entry, NULL, regs, addr);
+       mono_aot_patch_plt_entry (code, plt_entry, NULL, regs, addr);
 
        return addr;
 }
@@ -903,7 +904,7 @@ mono_class_init_trampoline (mgreg_t *regs, guint8 *code, MonoVTable *vtable, gui
 
        if (vtable->initialized) {
                if (plt_entry)
-                       mono_arch_nullify_plt_entry (plt_entry, regs);
+                       mono_aot_patch_plt_entry (code, plt_entry, NULL, regs, mini_get_nullified_class_init_trampoline ());
                else
                        mono_arch_nullify_class_init_trampoline (code, regs);
        }
@@ -967,6 +968,36 @@ mono_monitor_exit_trampoline (mgreg_t *regs, guint8 *code, MonoObject *obj, guin
 
 #ifdef MONO_ARCH_HAVE_CREATE_DELEGATE_TRAMPOLINE
 
+/*
+ * Precompute data to speed up mono_delegate_trampoline ().
+ * METHOD might be NULL.
+ */
+static MonoDelegateTrampInfo*
+create_delegate_trampoline_data (MonoDomain *domain, MonoClass *klass, MonoMethod *method)
+{
+       MonoDelegateTrampInfo *tramp_data;
+       MonoMethod *invoke;
+       MonoError err;
+
+       // Precompute the delegate invoke impl and pass it to the delegate trampoline
+       invoke = mono_get_delegate_invoke (klass);
+       g_assert (invoke);
+
+       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);
+       tramp_data->impl_nothis = mono_arch_get_delegate_invoke_impl (mono_method_signature (invoke), FALSE);
+       tramp_data->method = method;
+       if (method) {
+               mono_error_init (&err);
+               tramp_data->sig = mono_method_signature_checked (method, &err);
+               tramp_data->need_rgctx_tramp = mono_method_needs_static_rgctx_invoke (method, FALSE);
+       }
+
+       return tramp_data;
+}
+
 /**
  * mono_delegate_trampoline:
  *
@@ -974,23 +1005,25 @@ mono_monitor_exit_trampoline (mgreg_t *regs, guint8 *code, MonoObject *obj, guin
  * This is called once the first time a delegate is invoked, so it must be fast.
  */
 gpointer
-mono_delegate_trampoline (mgreg_t *regs, guint8 *code, gpointer *tramp_data, guint8* tramp)
+mono_delegate_trampoline (mgreg_t *regs, guint8 *code, gpointer *arg, guint8* tramp)
 {
        MonoDomain *domain = mono_domain_get ();
        MonoDelegate *delegate;
        MonoJitInfo *ji;
        MonoMethod *m;
        MonoMethod *method = NULL;
-       gboolean multicast, callvirt = FALSE;
+       gboolean multicast, callvirt = FALSE, closed_over_null = FALSE;
        gboolean need_rgctx_tramp = FALSE;
        gboolean need_unbox_tramp = FALSE;
        gboolean enable_caching = TRUE;
-       MonoMethod *invoke = tramp_data [0];
-       guint8 *impl_this = tramp_data [1];
-       guint8 *impl_nothis = tramp_data [2];
+       MonoDelegateTrampInfo *tramp_info = (MonoDelegateTrampInfo*)arg;
+       MonoMethod *invoke = tramp_info->invoke;
+       guint8 *impl_this = tramp_info->impl_this;
+       guint8 *impl_nothis = tramp_info->impl_nothis;
        MonoError err;
        MonoMethodSignature *sig;
        gpointer addr, compiled_method;
+       gboolean is_remote = FALSE;
 
        trampoline_calls ++;
 
@@ -1009,19 +1042,23 @@ mono_delegate_trampoline (mgreg_t *regs, guint8 *code, gpointer *tramp_data, gui
                 */
 #ifndef DISABLE_REMOTING
                if (delegate->target && delegate->target->vtable->klass == mono_defaults.transparent_proxy_class) {
+                       is_remote = TRUE;
 #ifndef DISABLE_COM
                        if (((MonoTransparentProxy *)delegate->target)->remote_class->proxy_class != mono_class_get_com_object_class () &&
                           !mono_class_is_com_object (((MonoTransparentProxy *)delegate->target)->remote_class->proxy_class))
 #endif
                                method = mono_marshal_get_remoting_invoke (method);
-               } else
+               }
 #endif
-               {
-                       mono_error_init (&err);
-                       sig = mono_method_signature_checked (method, &err);
-                       if (!sig)
-                               mono_error_raise_exception (&err);
-                               
+               if (!is_remote) {
+                       sig = tramp_info->sig;
+                       if (!(sig && method == tramp_info->method)) {
+                               mono_error_init (&err);
+                               sig = mono_method_signature_checked (method, &err);
+                               if (!sig)
+                                       mono_error_raise_exception (&err);
+                       }
+
                        if (sig->hasthis && method->klass->valuetype) {
                                if (mono_aot_only)
                                        need_unbox_tramp = TRUE;
@@ -1036,12 +1073,34 @@ mono_delegate_trampoline (mgreg_t *regs, guint8 *code, gpointer *tramp_data, gui
        }
 
        if (method) {
-               mono_error_init (&err);
-               sig = mono_method_signature_checked (method, &err);
-               if (!sig)
-                       mono_error_raise_exception (&err);
+               sig = tramp_info->sig;
+               if (!(sig && method == tramp_info->method)) {
+                       mono_error_init (&err);
+                       sig = mono_method_signature_checked (method, &err);
+                       if (!sig)
+                               mono_error_raise_exception (&err);
+               }
 
                callvirt = !delegate->target && sig->hasthis;
+               if (callvirt)
+                       closed_over_null = tramp_info->invoke_sig->param_count == sig->param_count;
+
+               if (callvirt && !closed_over_null) {
+                       /*
+                        * The delegate needs to make a virtual call to the target method using its
+                        * first argument as the receiver. This is hard to support in full-aot, so
+                        * optimize it in some cases if possible.
+                        * If the target method is not virtual or is in a sealed class,
+                        * the vcall will call it directly.
+                        * If the call doesn't return a valuetype, then the vcall uses the same calling
+                        * convention as a normal call.
+                        */
+                       if (((method->klass->flags & TYPE_ATTRIBUTE_SEALED) || !(method->flags & METHOD_ATTRIBUTE_VIRTUAL)) && !MONO_TYPE_ISSTRUCT (sig->ret)) {
+                               callvirt = FALSE;
+                               enable_caching = FALSE;
+                       }
+               }
+
                if (delegate->target && 
                        method->flags & METHOD_ATTRIBUTE_VIRTUAL && 
                        method->flags & METHOD_ATTRIBUTE_ABSTRACT &&
@@ -1049,13 +1108,15 @@ mono_delegate_trampoline (mgreg_t *regs, guint8 *code, gpointer *tramp_data, gui
                        method = mono_object_get_virtual_method (delegate->target, method);
                        enable_caching = FALSE;
                }
-       }
 
-       if (method && method->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED)
-               method = mono_marshal_get_synchronized_wrapper (method);
+               if (method->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED)
+                       method = mono_marshal_get_synchronized_wrapper (method);
 
-       if (method && mono_method_needs_static_rgctx_invoke (method, FALSE))
-               need_rgctx_tramp = TRUE;
+               if (method == tramp_info->method)
+                       need_rgctx_tramp = tramp_info->need_rgctx_tramp;
+               else if (mono_method_needs_static_rgctx_invoke (method, FALSE))
+                       need_rgctx_tramp = TRUE;
+       }
 
        /* 
         * If the called address is a trampoline, replace it with the compiled method so
@@ -1077,6 +1138,9 @@ mono_delegate_trampoline (mgreg_t *regs, guint8 *code, gpointer *tramp_data, gui
                        delegate->method_ptr = mono_create_static_rgctx_trampoline (method, delegate->method_ptr);
        }
 
+       /* Necessary for !code condition to fallback to slow path */
+       code = NULL;
+
        multicast = ((MonoMulticastDelegate*)delegate)->prev != NULL;
        if (!multicast && !callvirt) {
                if (method && (method->flags & METHOD_ATTRIBUTE_STATIC) && mono_method_signature (method)->param_count == mono_method_signature (invoke)->param_count + 1)
@@ -1084,18 +1148,20 @@ mono_delegate_trampoline (mgreg_t *regs, guint8 *code, gpointer *tramp_data, gui
                        code = impl_this;
                else
                        code = delegate->target ? impl_this : impl_nothis;
+       }
 
-               if (code) {
-                       delegate->invoke_impl = mono_get_addr_from_ftnptr (code);
-                       return code;
-               }
+       if (!code) {
+               /* The general, unoptimized case */
+               m = mono_marshal_get_delegate_invoke (invoke, delegate);
+               code = mono_compile_method (m);
+               code = mini_add_method_trampoline (NULL, m, code, mono_method_needs_static_rgctx_invoke (m, FALSE), FALSE);
        }
 
-       /* The general, unoptimized case */
-       m = mono_marshal_get_delegate_invoke (invoke, delegate);
-       code = mono_compile_method (m);
-       code = mini_add_method_trampoline (NULL, m, code, mono_method_needs_static_rgctx_invoke (m, FALSE), FALSE);
        delegate->invoke_impl = mono_get_addr_from_ftnptr (code);
+       if (enable_caching && !callvirt && tramp_info->method) {
+               tramp_info->method_ptr = delegate->method_ptr;
+               tramp_info->invoke_impl = delegate->invoke_impl;
+       }
 
        return code;
 }
@@ -1104,7 +1170,7 @@ mono_delegate_trampoline (mgreg_t *regs, guint8 *code, gpointer *tramp_data, gui
 
 #ifdef MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD
 static gpointer
-mono_handler_block_guard_trampoline (mgreg_t *regs, guint8 *code, gpointer *tramp_data, guint8* tramp)
+mono_handler_block_guard_trampoline (mgreg_t *regs, guint8 *code, gpointer *tramp_info, guint8* tramp)
 {
        MonoContext ctx;
        MonoException *exc;
@@ -1139,16 +1205,16 @@ mono_create_handler_block_trampoline (void)
                return code;
        }
 
-
-       if (mono_aot_only) {
-               g_assert (0);
-               return code;
-       }
+       g_assert (!mono_aot_only);
 
        mono_trampolines_lock ();
 
        if (!code) {
-               gpointer tmp = mono_arch_create_handler_block_trampoline ();
+               MonoTrampInfo *info;
+               gpointer tmp;
+
+               tmp = mono_arch_create_handler_block_trampoline (&info, FALSE);
+               mono_tramp_info_register (info);
                mono_memory_barrier ();
                code = tmp;
        }
@@ -1224,7 +1290,7 @@ create_trampoline_code (MonoTrampolineType tramp_type)
 void
 mono_trampolines_init (void)
 {
-       InitializeCriticalSection (&trampolines_mutex);
+       mono_mutex_init_recursive (&trampolines_mutex);
 
        if (mono_aot_only)
                return;
@@ -1269,7 +1335,7 @@ mono_trampolines_cleanup (void)
        if (rgctx_lazy_fetch_trampoline_hash_addr)
                g_hash_table_destroy (rgctx_lazy_fetch_trampoline_hash_addr);
 
-       DeleteCriticalSection (&trampolines_mutex);
+       mono_mutex_destroy (&trampolines_mutex);
 }
 
 guint8 *
@@ -1454,40 +1520,65 @@ mono_create_jit_trampoline_from_token (MonoImage *image, guint32 token)
        return tramp;
 }      
 
-gpointer
-mono_create_delegate_trampoline (MonoDomain *domain, MonoClass *klass)
+
+/*
+ * mono_create_delegate_trampoline_info:
+ *
+ *   Create a delegate trampoline for the KLASS+METHOD pair.
+ */
+MonoDelegateTrampInfo*
+mono_create_delegate_trampoline_info (MonoDomain *domain, MonoClass *klass, MonoMethod *method)
 {
 #ifdef MONO_ARCH_HAVE_CREATE_DELEGATE_TRAMPOLINE
-       gpointer ptr;
+       MonoDelegateTrampInfo *tramp_info;
+       MonoClassMethodPair pair, *dpair;
        guint32 code_size = 0;
-       gpointer *tramp_data;
-       MonoMethod *invoke;
 
+       pair.klass = klass;
+       pair.method = method;
        mono_domain_lock (domain);
-       ptr = g_hash_table_lookup (domain_jit_info (domain)->delegate_trampoline_hash, klass);
+       tramp_info = g_hash_table_lookup (domain_jit_info (domain)->delegate_trampoline_hash, &pair);
        mono_domain_unlock (domain);
-       if (ptr)
-               return ptr;
+       if (tramp_info)
+               return tramp_info;
 
-       // Precompute the delegate invoke impl and pass it to the delegate trampoline
-       invoke = mono_get_delegate_invoke (klass);
-       g_assert (invoke);
-
-       tramp_data = mono_domain_alloc (domain, sizeof (gpointer) * 3);
-       tramp_data [0] = invoke;
-       tramp_data [1] = mono_arch_get_delegate_invoke_impl (mono_method_signature (invoke), TRUE);
-       tramp_data [2] = mono_arch_get_delegate_invoke_impl (mono_method_signature (invoke), FALSE);
+       tramp_info = create_delegate_trampoline_data (domain, klass, method);
 
-       ptr = mono_create_specific_trampoline (tramp_data, MONO_TRAMPOLINE_DELEGATE, domain, &code_size);
+       tramp_info->invoke_impl = mono_create_specific_trampoline (tramp_info, MONO_TRAMPOLINE_DELEGATE, domain, &code_size);
        g_assert (code_size);
 
+       dpair = mono_domain_alloc0 (domain, sizeof (MonoClassMethodPair));
+       memcpy (dpair, &pair, sizeof (MonoClassMethodPair));
+
        /* store trampoline address */
        mono_domain_lock (domain);
-       g_hash_table_insert (domain_jit_info (domain)->delegate_trampoline_hash,
-                                                         klass, ptr);
+       g_hash_table_insert (domain_jit_info (domain)->delegate_trampoline_hash, dpair, tramp_info);
        mono_domain_unlock (domain);
 
-       return ptr;
+       return tramp_info;
+#else
+       return NULL;
+#endif
+}
+
+gpointer
+mono_create_delegate_trampoline (MonoDomain *domain, MonoClass *klass)
+{
+#ifdef MONO_ARCH_HAVE_CREATE_DELEGATE_TRAMPOLINE
+       return mono_create_delegate_trampoline_info (domain, klass, NULL)->invoke_impl;
+#else
+       return NULL;
+#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