2008-08-22 Zoltan Varga <vargaz@gmail.com>
+ * tramp-<ARCH>.c (mono_arch_get_rgctx_lazy_fetch_offset): Removed, no longer
+ needed.
+
+ * mini-trampolines.c (mono_rgctx_lazy_fetch_trampoline): Get the additional
+ trampoline argument from MONO_ARCH_VTABLE_REG.
+
+ * tramp-x86.c (mono_arch_create_rgctx_lazy_fetch_trampoline): Change the
+ order of the arguments to the C trampoline: pass 'slot' as the trampoline
+ argument, and pass the vtable in VTABLE_REG.
+
* tramp-amd64.c (mono_arch_create_rgctx_lazy_fetch_trampoline): Change the
order of the arguments to the C trampoline: pass 'slot' as the trampoline
argument, and pass the vtable in VTABLE_REG.
static gpointer
mono_rgctx_lazy_fetch_trampoline (gssize *regs, guint8 *code, gpointer data, guint8 *tramp)
{
+#ifdef MONO_ARCH_VTABLE_REG
static gboolean inited = FALSE;
static int num_lookups = 0;
-
-#ifdef __x86_64__
guint32 slot = GPOINTER_TO_UINT (data);
gpointer arg = (gpointer)(gssize)regs [MONO_ARCH_VTABLE_REG];
-#else
- guint32 slot = mono_arch_get_rgctx_lazy_fetch_offset ((gpointer*)regs);
- gpointer arg = data;
-#endif
guint32 index = MONO_RGCTX_SLOT_INDEX (slot);
gboolean mrgctx = MONO_RGCTX_SLOT_IS_MRGCTX (slot);
return mono_method_fill_runtime_generic_context (arg, index);
else
return mono_class_fill_runtime_generic_context (arg, index);
+#else
+ g_assert_not_reached ();
+#endif
}
#ifdef MONO_ARCH_HAVE_CREATE_DELEGATE_TRAMPOLINE
guchar* mono_arch_create_trampoline_code (MonoTrampolineType tramp_type) MONO_INTERNAL;
guchar* mono_arch_create_trampoline_code_full (MonoTrampolineType tramp_type, guint32 *code_size, MonoJumpInfo **ji, gboolean aot) MONO_INTERNAL;
gpointer mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot) MONO_INTERNAL;
-guint32 mono_arch_get_rgctx_lazy_fetch_offset (gpointer *regs) MONO_INTERNAL;
gpointer mono_arch_get_nullified_class_init_trampoline (guint32 *code_len) MONO_INTERNAL;
GList *mono_arch_get_allocatable_int_vars (MonoCompile *cfg) MONO_INTERNAL;
GList *mono_arch_get_global_int_regs (MonoCompile *cfg) MONO_INTERNAL;
g_assert_not_reached ();
return NULL;
}
-
-guint32
-mono_arch_get_rgctx_lazy_fetch_offset (gpointer *regs)
-{
- /* FIXME: implement! */
- g_assert_not_reached ();
- return 0;
-}
return code;
}
-guint32
-mono_arch_get_rgctx_lazy_fetch_offset (gpointer *regs)
-{
- return (guint32)(gulong)(regs [MONO_AMD64_ARG_REG2]);
-}
-
void
mono_arch_invalidate_method (MonoJitInfo *ji, void *func, gpointer func_arg)
{
g_assert_not_reached ();
return NULL;
}
-
-guint32
-mono_arch_get_rgctx_lazy_fetch_offset (gpointer *regs)
-{
- /* FIXME: implement! */
- g_assert_not_reached ();
- return 0;
-}
g_assert_not_reached ();
return NULL;
}
-
-guint32
-mono_arch_get_rgctx_lazy_fetch_offset (gpointer *regs)
-{
- /* FIXME: implement! */
- g_assert_not_reached ();
- return 0;
-}
g_assert_not_reached ();
return NULL;
}
-
-guint32
-mono_arch_get_rgctx_lazy_fetch_offset (gpointer *regs)
-{
- /* FIXME: implement! */
- g_assert_not_reached ();
- return 0;
-}
g_assert_not_reached ();
return NULL;
}
-
-guint32
-mono_arch_get_rgctx_lazy_fetch_offset (gpointer *regs)
-{
- /* FIXME: implement! */
- g_assert_not_reached ();
- return 0;
-}
g_assert_not_reached ();
return NULL;
}
-
-guint32
-mono_arch_get_rgctx_lazy_fetch_offset (gpointer *regs)
-{
- /* FIXME: implement! */
- g_assert_not_reached ();
- return 0;
-}
g_assert_not_reached ();
return NULL;
}
-
-guint32
-mono_arch_get_rgctx_lazy_fetch_offset (gpointer *regs)
-{
- /* FIXME: implement! */
- g_assert_not_reached ();
- return 0;
-}
g_assert_not_reached ();
return NULL;
}
-
-guint32
-mono_arch_get_rgctx_lazy_fetch_offset (gpointer *regs)
-{
- /* FIXME: implement! */
- g_assert_not_reached ();
- return 0;
-}
g_assert_not_reached ();
return NULL;
}
-
-guint32
-mono_arch_get_rgctx_lazy_fetch_offset (gpointer *regs)
-{
- /* FIXME: implement! */
- g_assert_not_reached ();
- return 0;
-}
gpointer
mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot)
{
- guint8 *tramp = mono_get_trampoline_code (MONO_TRAMPOLINE_RGCTX_LAZY_FETCH);
+ guint8 *tramp;
guint8 *code, *buf;
guint8 **rgctx_null_jumps;
int tramp_size;
int i;
gboolean mrgctx;
- g_assert (tramp);
-
mrgctx = MONO_RGCTX_SLOT_IS_MRGCTX (slot);
index = MONO_RGCTX_SLOT_INDEX (slot);
if (mrgctx)
g_free (rgctx_null_jumps);
- /*
- * our stack looks like this (tos on top):
- *
- * | ret addr |
- * | vtable ptr |
- * | ... |
- *
- * the trampoline code expects it to look like this:
- *
- * | vtable ptr |
- * | ret addr |
- * | ... |
- *
- * whereas our caller expects to still have one argument on
- * the stack when we return, so we transform the stack into
- * this:
- *
- * | vtable ptr |
- * | ret addr |
- * | dummy |
- * | ... |
- *
- * which actually only requires us to push the vtable ptr, and
- * the "old" vtable ptr becomes the dummy.
- */
+ x86_mov_reg_membase (buf, MONO_ARCH_VTABLE_REG, X86_ESP, 4, 4);
- x86_push_membase (buf, X86_ESP, 4);
+ tramp = mono_arch_create_specific_trampoline (GUINT_TO_POINTER (slot), MONO_TRAMPOLINE_RGCTX_LAZY_FETCH, mono_get_root_domain (), NULL);
- x86_mov_reg_imm (buf, X86_EAX, slot);
+ /* jump to the actual trampoline */
x86_jump_code (buf, tramp);
mono_arch_flush_icache (code, buf - code);
return code;
}
-guint32
-mono_arch_get_rgctx_lazy_fetch_offset (gpointer *regs)
-{
- return (guint32)(regs [X86_EAX]);
-}
-
void
mono_arch_invalidate_method (MonoJitInfo *ji, void *func, gpointer func_arg)
{