* mini-trampolines.c (mono_get_trampoline_func): New helper function.
* tramp-<ARCH>.c: Use the new helper function.
svn path=/trunk/mono/; revision=90934
+2007-12-07 Zoltan Varga <vargaz@gmail.com>
+
+ * mini-trampolines.c (mono_get_trampoline_func): New helper function.
+
+ * tramp-<ARCH>.c: Use the new helper function.
+
2007-12-07 Mark Probst <mark.probst@gmail.com>
* inssel.brg: Added a pattern for the OP_TRAMPCALL_VTABLE
#endif
+/*
+ * mono_get_trampoline_func:
+ *
+ * Return the C function which needs to be called by the generic trampoline of type
+ * TRAMP_TYPE.
+ */
+gconstpointer
+mono_get_trampoline_func (MonoTrampolineType tramp_type)
+{
+ switch (tramp_type) {
+ case MONO_TRAMPOLINE_GENERIC:
+ case MONO_TRAMPOLINE_JUMP:
+ return mono_magic_trampoline;
+ case MONO_TRAMPOLINE_CLASS_INIT:
+ return mono_class_init_trampoline;
+ case MONO_TRAMPOLINE_GENERIC_CLASS_INIT:
+ return mono_generic_class_init_trampoline;
+#ifdef MONO_ARCH_AOT_SUPPORTED
+ case MONO_TRAMPOLINE_AOT:
+ return mono_aot_trampoline;
+ case MONO_TRAMPOLINE_AOT_PLT:
+ return mono_aot_plt_trampoline;
+#endif
+#ifdef MONO_ARCH_HAVE_CREATE_DELEGATE_TRAMPOLINE
+ case MONO_TRAMPOLINE_DELEGATE:
+ return mono_delegate_trampoline;
+#endif
+ default:
+ g_assert_not_reached ();
+ return NULL;
+ }
+}
+
guint8* tramp) MONO_INTERNAL;
void mono_class_init_trampoline (gssize *regs, guint8 *code, MonoVTable *vtable, guint8 *tramp) MONO_INTERNAL;
void mono_generic_class_init_trampoline (gssize *regs, guint8 *code, gpointer dummy, guint8 *tramp) MONO_INTERNAL;
+gconstpointer mono_get_trampoline_func (MonoTrampolineType tramp_type);
gpointer mini_get_vtable_trampoline (void) MONO_INTERNAL;
gpointer mono_debugger_create_notification_function (void) MONO_INTERNAL;
else
amd64_mov_reg_membase (code, AMD64_ARG_REG4, AMD64_RBP, tramp_offset, 8);
- if (tramp_type == MONO_TRAMPOLINE_CLASS_INIT)
- tramp = (guint8*)mono_class_init_trampoline;
- else if (tramp_type == MONO_TRAMPOLINE_GENERIC_CLASS_INIT)
- tramp = (guint8*)mono_generic_class_init_trampoline;
- else if (tramp_type == MONO_TRAMPOLINE_AOT)
- tramp = (guint8*)mono_aot_trampoline;
- else if (tramp_type == MONO_TRAMPOLINE_AOT_PLT)
- tramp = (guint8*)mono_aot_plt_trampoline;
- else if (tramp_type == MONO_TRAMPOLINE_DELEGATE)
- tramp = (guint8*)mono_delegate_trampoline;
- else
- tramp = (guint8*)mono_magic_trampoline;
-
+ tramp = mono_get_trampoline_func (tramp_type);
amd64_mov_reg_imm (code, AMD64_RAX, tramp);
amd64_call_reg (code, AMD64_RAX);
constants = (gpointer*)buf;
constants [0] = mono_get_lmf_addr;
- if (tramp_type == MONO_TRAMPOLINE_CLASS_INIT)
- constants [1] = mono_class_init_trampoline;
- else if (tramp_type == MONO_TRAMPOLINE_AOT)
- constants [1] = mono_aot_trampoline;
- else if (tramp_type == MONO_TRAMPOLINE_AOT_PLT)
- constants [1] = mono_aot_plt_trampoline;
- else if (tramp_type == MONO_TRAMPOLINE_DELEGATE)
- constants [1] = mono_delegate_trampoline;
- else
- constants [1] = mono_magic_trampoline;
+ constants [1] = mono_get_trampoline_func (tramp_type);
/* backpatch by emitting the missing instructions skipped above */
ARM_LDR_IMM (load_get_lmf_addr, ARMREG_R0, ARMREG_PC, (buf - load_get_lmf_addr - 8));
ia64_codegen_init (code, buf);
- /* FIXME: Save/restore lmf */
-
/* Stacked Registers */
in0 = 32;
local0 = in0 + 8;
/* FIXME: */
ia64_mov (code, o3, 0);
- if (tramp_type == MONO_TRAMPOLINE_CLASS_INIT)
- 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;
+ tramp = mono_get_trampoline_func (tramp_type);
/* Call the trampoline using an indirect call */
ia64_movl (code, l0, tramp);
}
}
- if (tramp_type == MONO_TRAMPOLINE_CLASS_INIT)
- tramp_addr = &mono_class_init_trampoline;
- else if (tramp_type == MONO_TRAMPOLINE_AOT)
- tramp_addr = mono_aot_trampoline;
- else
- tramp_addr = &mono_magic_trampoline;
+ tramp_addr = mono_get_trampoline_func (tramp_type);
sparc_ldi_imm (code, sparc_sp, MONO_SPARC_STACK_BIAS + 200, sparc_o2);
/* pass address of register table as third argument */
sparc_add_imm (code, FALSE, sparc_sp, regs_offset, sparc_o0);
guchar*
mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
{
- guint8 *buf, *code;
+ guint8 *buf, *code, *tramp;
int pushed_args;
code = buf = mono_global_codeman_reserve (256);
x86_breakpoint (buf);*/
#endif
- if (tramp_type == MONO_TRAMPOLINE_CLASS_INIT)
- x86_call_code (buf, mono_class_init_trampoline);
- else if (tramp_type == MONO_TRAMPOLINE_GENERIC_CLASS_INIT)
- x86_call_code (buf, mono_generic_class_init_trampoline);
- else if (tramp_type == MONO_TRAMPOLINE_AOT)
- x86_call_code (buf, mono_aot_trampoline);
- else if (tramp_type == MONO_TRAMPOLINE_AOT_PLT)
- x86_call_code (buf, mono_aot_plt_trampoline);
- else if (tramp_type == MONO_TRAMPOLINE_DELEGATE)
- x86_call_code (buf, mono_delegate_trampoline);
- else
- x86_call_code (buf, mono_magic_trampoline);
+ tramp = mono_get_trampoline_func (tramp_type);
+ x86_call_code (tramp);
x86_alu_reg_imm (buf, X86_ADD, X86_ESP, 4*4);