2005-08-21 Zoltan Varga <vargaz@freemail.hu>
+ * mini.h mini-trampolines.c: Pass the trampoline argument to
+ mono_arch_patch_delegate_trampoline.
+
+ * mini-ia64.h mini-ia64.c tramp-ia64.c: Add support for delegate trampolines.
+
* mini-trampolines.c: Fix build.
* mini-amd64.h: Add delegate trampolines.
call = (MonoCallInst*)ins;
/* Indirect call */
- ia64_mov (code, GP_SCRATCH_REG, ins->sreg1);
- ia64_ld8_inc_imm (code, GP_SCRATCH_REG2, GP_SCRATCH_REG, 8);
+ /*
+ * mono_arch_patch_delegate_trampoline will patch this, this is why R8 is
+ * used.
+ */
+ ia64_mov (code, IA64_R8, ins->sreg1);
+ ia64_ld8_inc_imm (code, GP_SCRATCH_REG2, IA64_R8, 8);
ia64_mov_to_br (code, IA64_B6, GP_SCRATCH_REG2);
- ia64_ld8 (code, IA64_GP, GP_SCRATCH_REG);
+ ia64_ld8 (code, IA64_GP, IA64_R8);
ia64_br_call_reg (code, IA64_B0, IA64_B6);
code = emit_move_return_value (cfg, ins, code);
#define MONO_ARCH_HAVE_PIC_AOT 1
#define MONO_ARCH_HAVE_CREATE_TRAMPOLINE_FROM_TOKEN 1
#define MONO_ARCH_HAVE_CREATE_SPECIFIC_TRAMPOLINE 1
+#define MONO_ARCH_HAVE_CREATE_DELEGATE_TRAMPOLINE 1
#define MONO_ARCH_HAVE_SAVE_UNWIND_INFO 1
#define MONO_ARCH_HAVE_CREATE_VARS 1
mono_delegate_trampoline (gssize *regs, guint8 *code, MonoMethod *m, guint8* tramp)
{
gpointer addr;
- gpointer *vtable_slot;
addr = mono_compile_method (m);
g_assert (addr);
- mono_arch_patch_delegate_trampoline (code, regs, addr);
+ mono_arch_patch_delegate_trampoline (code, tramp, regs, addr);
return addr;
}
gpointer mono_arch_get_unbox_trampoline (MonoMethod *m, gpointer addr);
void mono_arch_patch_callsite (guint8 *code, guint8 *addr);
void mono_arch_nullify_class_init_trampoline(guint8 *code, gssize *regs);
-void mono_arch_patch_delegate_trampoline (guint8 *code, gssize *regs, guint8 *addr);
+void mono_arch_patch_delegate_trampoline (guint8 *code, guint8 *tramp, gssize *regs, guint8 *addr);
gpointer mono_arch_create_specific_trampoline (gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, guint32 *code_len);
/* Exception handling */
}
void
-mono_arch_patch_delegate_trampoline (guint8 *code, gssize *regs, guint8 *addr)
+mono_arch_patch_delegate_trampoline (guint8 *code, guint8 *tramp, gssize *regs, guint8 *addr)
{
guint8 rex = 0;
guint32 reg;
mono_arch_flush_icache (callsite_begin, code - callsite_begin);
}
+void
+mono_arch_patch_delegate_trampoline (guint8 *code, guint8 *tramp, gssize *regs, guint8 *addr)
+{
+ /*
+ * This is called by the code generated by OP_CALL_REG:
+ * ld8 r30=[r8],8
+ * nop.i 0x0;;
+ * mov.sptk b6=r30
+ * ld8 r1=[r8]
+ * br.call.sptk.few b0=b6
+ */
+
+ /* We patch the function descriptor instead of delegate->method_ptr */
+ //g_assert (((gpointer*)(regs [8] - 8))[0] == tramp);
+ ((gpointer*)(regs [8] - 8))[0] = mono_get_addr_from_ftnptr (addr);
+ ((gpointer*)(regs [8] - 8))[1] = NULL;
+}
+
guchar*
mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
{
tramp = (guint8*)mono_class_init_trampoline;
else if (tramp_type == MONO_TRAMPOLINE_AOT)
tramp = (guint8*)mono_aot_trampoline;
+ else if (tramp_type == MONO_TRAMPOLINE_DELEGATE)
+ tramp = (guint8*)mono_delegate_trampoline;
else
tramp = (guint8*)mono_magic_trampoline;