#include "mini.h"
/**
- * magic_trampoline:
+ * mono_magic_trampoline:
*
* This trampoline handles calls from JITted code.
*/
addr = mono_compile_method (m);
g_assert (addr);
- //printf ("ENTER: %s\n", mono_method_full_name (m, TRUE));
-
/* the method was jumped to */
if (!code)
- /* FIXME: Optimize the case when the call is from a delegate wrapper */
return addr;
vtable_slot = mono_arch_get_vcall_slot_addr (code, (gpointer*)regs);
g_assert (*vtable_slot);
if (mono_aot_is_got_entry (code, (guint8*)vtable_slot) || mono_domain_owns_vtable_slot (mono_domain_get (), vtable_slot))
- *vtable_slot = addr;
+ *vtable_slot = mono_get_addr_from_ftnptr (addr);
}
else {
/* Patch calling code */
MonoJitInfo *ji =
mono_jit_info_table_find (mono_domain_get (), code);
MonoJitInfo *target_ji =
- mono_jit_info_table_find (mono_domain_get (), addr);
+ mono_jit_info_table_find (mono_domain_get (), mono_get_addr_from_ftnptr (addr));
if (mono_method_same_domain (ji, target_ji))
mono_arch_patch_callsite (code, addr);
}
/*
- * aot_trampoline:
+ * mono_aot_trampoline:
*
* 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.
gpointer *vtable_slot;
gboolean is_got_entry;
- image = *(gpointer*)token_info;
+ image = *(gpointer*)(gpointer)token_info;
token_info += sizeof (gpointer);
- token = *(guint32*)token_info;
+ token = *(guint32*)(gpointer)token_info;
addr = mono_aot_get_method_from_token (mono_domain_get (), image, token);
if (!addr) {
if (!mono_running_on_valgrind ())
mono_arch_nullify_class_init_trampoline (code, regs);
}
+
+#ifdef MONO_ARCH_HAVE_CREATE_DELEGATE_TRAMPOLINE
+
+/**
+ * mono_delegate_trampoline:
+ *
+ * This trampoline handles calls made from the delegate invoke wrapper. It patches
+ * the function address inside the delegate.
+ */
+gpointer
+mono_delegate_trampoline (gssize *regs, guint8 *code, MonoMethod *m, guint8* tramp)
+{
+ gpointer addr;
+
+ addr = mono_compile_method (m);
+ g_assert (addr);
+
+ mono_arch_patch_delegate_trampoline (code, tramp, regs, addr);
+
+ return addr;
+}
+
+#endif