+2010-05-01 Zoltan Varga <vargaz@gmail.com>
+
+ * mini-trampolines.c aot-compiler.c tramp-<ARCH>.c exceptions-<ARCH>.c:
+ Reorganize the full aot trampoline creation functions, instead of taking a bunch
+ of out arguments, they will now take a MonoTrampInfo** out argument. Simplify
+ some code in aot-compiler.c because of this. Remove the non-full aot trampoline
+ creation functions on architectures which have the full-aot ones.
+
2010-05-01 Zoltan Varga <vargaz@gmail.com>
* mini-ppc.c (mono_arch_decompose_long_opts): Fix LNEG.
}
static G_GNUC_UNUSED void
-emit_trampoline (MonoAotCompile *acfg, const char *name, guint8 *code,
- guint32 code_size, int got_offset, MonoJumpInfo *ji, GSList *unwind_ops)
+emit_trampoline (MonoAotCompile *acfg, int got_offset, MonoTrampInfo *info)
{
char start_symbol [256];
char symbol [256];
MonoJumpInfo *patch_info;
guint8 *buf, *p;
GPtrArray *patches;
+ char *name;
+ guint8 *code;
+ guint32 code_size;
+ MonoJumpInfo *ji;
+ GSList *unwind_ops;
+
+ name = info->name;
+ code = info->code;
+ code_size = info->code_size;
+ ji = info->ji;
+ unwind_ops = info->unwind_ops;
/* Emit code */
MonoAotTrampoline ntype;
#ifdef MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES
int tramp_type;
- guint32 code_size;
- MonoJumpInfo *ji;
guint8 *code;
- GSList *unwind_ops;
#endif
if (!acfg->aot_opts.full_aot)
/* Currently, we emit most trampolines into the mscorlib AOT image. */
if (strcmp (acfg->image->assembly->aname.name, "mscorlib") == 0) {
#ifdef MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES
+ MonoTrampInfo *info;
+
/*
* Emit the generic trampolines.
*
* method.
*/
for (tramp_type = 0; tramp_type < MONO_TRAMPOLINE_NUM; ++tramp_type) {
- code = mono_arch_create_trampoline_code_full (tramp_type, &code_size, &ji, &unwind_ops, TRUE);
-
- /* Emit trampoline code */
-
- sprintf (symbol, "generic_trampoline_%d", tramp_type);
-
- emit_trampoline (acfg, symbol, code, code_size, acfg->got_offset, ji, unwind_ops);
+ mono_arch_create_generic_trampoline_full (tramp_type, &info, TRUE);
+ emit_trampoline (acfg, acfg->got_offset, info);
}
- code = mono_arch_get_nullified_class_init_trampoline (&code_size);
- emit_trampoline (acfg, "nullified_class_init_trampoline", code, code_size, acfg->got_offset, NULL, NULL);
-#if (defined(TARGET_AMD64) || defined(TARGET_X86)) && defined(MONO_ARCH_MONITOR_OBJECT_REG)
- code = mono_arch_create_monitor_enter_trampoline_full (&code_size, &ji, TRUE);
- emit_trampoline (acfg, "monitor_enter_trampoline", code, code_size, acfg->got_offset, ji, NULL);
- code = mono_arch_create_monitor_exit_trampoline_full (&code_size, &ji, TRUE);
- emit_trampoline (acfg, "monitor_exit_trampoline", code, code_size, acfg->got_offset, ji, NULL);
+ mono_arch_get_nullified_class_init_trampoline (&info);
+ emit_trampoline (acfg, acfg->got_offset, info);
+#if defined(MONO_ARCH_MONITOR_OBJECT_REG)
+ mono_arch_create_monitor_enter_trampoline_full (&info, TRUE);
+ emit_trampoline (acfg, acfg->got_offset, info);
+ mono_arch_create_monitor_exit_trampoline_full (&info, TRUE);
+ emit_trampoline (acfg, acfg->got_offset, info);
#endif
- code = mono_arch_create_generic_class_init_trampoline_full (&code_size, &ji, TRUE);
- emit_trampoline (acfg, "generic_class_init_trampoline", code, code_size, acfg->got_offset, ji, NULL);
+ mono_arch_create_generic_class_init_trampoline_full (&info, TRUE);
+ emit_trampoline (acfg, acfg->got_offset, info);
/* Emit the exception related code pieces */
- code = mono_arch_get_restore_context_full (&code_size, &ji, TRUE);
- emit_trampoline (acfg, "restore_context", code, code_size, acfg->got_offset, ji, NULL);
- code = mono_arch_get_call_filter_full (&code_size, &ji, TRUE);
- emit_trampoline (acfg, "call_filter", code, code_size, acfg->got_offset, ji, NULL);
- code = mono_arch_get_throw_exception_full (&code_size, &ji, TRUE);
- emit_trampoline (acfg, "throw_exception", code, code_size, acfg->got_offset, ji, NULL);
- code = mono_arch_get_rethrow_exception_full (&code_size, &ji, TRUE);
- emit_trampoline (acfg, "rethrow_exception", code, code_size, acfg->got_offset, ji, NULL);
-#ifdef MONO_ARCH_HAVE_THROW_EXCEPTION_BY_NAME
- code = mono_arch_get_throw_exception_by_name_full (&code_size, &ji, TRUE);
- emit_trampoline (acfg, "throw_exception_by_name", code, code_size, acfg->got_offset, ji, NULL);
-#endif
- code = mono_arch_get_throw_corlib_exception_full (&code_size, &ji, TRUE);
- emit_trampoline (acfg, "throw_corlib_exception", code, code_size, acfg->got_offset, ji, NULL);
+ code = mono_arch_get_restore_context_full (&info, TRUE);
+ emit_trampoline (acfg, acfg->got_offset, info);
+ code = mono_arch_get_call_filter_full (&info, TRUE);
+ emit_trampoline (acfg, acfg->got_offset, info);
+ code = mono_arch_get_throw_exception_full (&info, TRUE);
+ emit_trampoline (acfg, acfg->got_offset, info);
+ code = mono_arch_get_rethrow_exception_full (&info, TRUE);
+ emit_trampoline (acfg, acfg->got_offset, info);
+ code = mono_arch_get_throw_corlib_exception_full (&info, TRUE);
+ emit_trampoline (acfg, acfg->got_offset, info);
#if defined(TARGET_AMD64)
- code = mono_arch_get_throw_pending_exception_full (&code_size, &ji, TRUE);
- emit_trampoline (acfg, "throw_pending_exception", code, code_size, acfg->got_offset, ji, NULL);
+ code = mono_arch_get_throw_pending_exception_full (&info, TRUE);
+ emit_trampoline (acfg, acfg->got_offset, info);
#endif
for (i = 0; i < 128; ++i) {
int offset;
offset = MONO_RGCTX_SLOT_MAKE_RGCTX (i);
- code = mono_arch_create_rgctx_lazy_fetch_trampoline_full (offset, &code_size, &ji, TRUE);
- sprintf (symbol, "rgctx_fetch_trampoline_%u", offset);
- emit_trampoline (acfg, symbol, code, code_size, acfg->got_offset, ji, NULL);
+ code = mono_arch_create_rgctx_lazy_fetch_trampoline_full (offset, &info, TRUE);
+ emit_trampoline (acfg, acfg->got_offset, info);
offset = MONO_RGCTX_SLOT_MAKE_MRGCTX (i);
- code = mono_arch_create_rgctx_lazy_fetch_trampoline_full (offset, &code_size, &ji, TRUE);
- sprintf (symbol, "rgctx_fetch_trampoline_%u", offset);
- emit_trampoline (acfg, symbol, code, code_size, acfg->got_offset, ji, NULL);
+ code = mono_arch_create_rgctx_lazy_fetch_trampoline_full (offset, &info, TRUE);
+ emit_trampoline (acfg, acfg->got_offset, info);
}
{
while (l) {
MonoTrampInfo *info = l->data;
- emit_trampoline (acfg, info->name, info->code, info->code_size, acfg->got_offset, NULL, NULL);
+ emit_trampoline (acfg, acfg->got_offset, info);
l = l->next;
}
}
* Returns a pointer to a method which restores a previously saved sigcontext.
*/
gpointer
-mono_arch_get_restore_context_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_get_restore_context_full (MonoTrampInfo **info, gboolean aot)
{
guint8 *start = NULL;
guint8 *code;
+ MonoJumpInfo *ji = NULL;
+ GSList *unwind_ops = NULL;
/* restore_contect (MonoContext *ctx) */
- *ji = NULL;
-
start = code = mono_global_codeman_reserve (256);
amd64_mov_reg_reg (code, AMD64_R11, AMD64_ARG_REG1, 8);
mono_arch_flush_icache (start, code - start);
- *code_size = code - start;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("restore_context"), start, code - start, ji, unwind_ops);
return start;
}
* @exc object in this case).
*/
gpointer
-mono_arch_get_call_filter_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_get_call_filter_full (MonoTrampInfo **info, gboolean aot)
{
guint8 *start;
int i;
guint8 *code;
guint32 pos;
-
- *ji = NULL;
+ MonoJumpInfo *ji = NULL;
+ GSList *unwind_ops = NULL;
start = code = mono_global_codeman_reserve (128);
mono_arch_flush_icache (start, code - start);
- *code_size = code - start;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("call_filter"), start, code - start, ji, unwind_ops);
return start;
}
}
static gpointer
-get_throw_trampoline (gboolean rethrow, guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+get_throw_trampoline (MonoTrampInfo **info, gboolean rethrow, gboolean aot)
{
guint8* start;
guint8 *code;
- GSList *unwind_ops;
+ MonoJumpInfo *ji = NULL;
+ GSList *unwind_ops = NULL;
start = code = mono_global_codeman_reserve (64);
code = start;
- *ji = NULL;
-
unwind_ops = mono_arch_get_cie_program ();
amd64_mov_reg_reg (code, AMD64_R11, AMD64_RSP, 8);
#endif
if (aot) {
- *ji = mono_patch_info_list_prepend (*ji, code - start, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_amd64_throw_exception");
+ ji = mono_patch_info_list_prepend (ji, code - start, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_amd64_throw_exception");
amd64_mov_reg_membase (code, AMD64_R11, AMD64_RIP, 0, 8);
} else {
amd64_mov_reg_imm (code, AMD64_R11, mono_amd64_throw_exception);
g_assert ((code - start) < 64);
- *code_size = code - start;
-
mono_save_trampoline_xdebug_info ("throw_exception_trampoline", start, code - start, unwind_ops);
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf (rethrow ? "rethrow_exception" : "throw_exception"), start, code - start, ji, unwind_ops);
+
return start;
}
*
*/
gpointer
-mono_arch_get_throw_exception_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_get_throw_exception_full (MonoTrampInfo **info, gboolean aot)
{
- return get_throw_trampoline (FALSE, code_size, ji, aot);
+ return get_throw_trampoline (info, FALSE, aot);
}
gpointer
-mono_arch_get_rethrow_exception_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_get_rethrow_exception_full (MonoTrampInfo **info, gboolean aot)
{
- return get_throw_trampoline (TRUE, code_size, ji, aot);
+ return get_throw_trampoline (info, TRUE, aot);
}
/**
* needs no relocations in the caller.
*/
gpointer
-mono_arch_get_throw_corlib_exception_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_get_throw_corlib_exception_full (MonoTrampInfo **info, gboolean aot)
{
- static guint8* start;
- guint8 *code;
+ guint8 *start, *code;
guint64 throw_ex;
+ MonoJumpInfo *ji = NULL;
+ GSList *unwind_ops = NULL;
start = code = mono_global_codeman_reserve (64);
- *ji = NULL;
-
/* Push throw_ip */
amd64_push_reg (code, AMD64_ARG_REG2);
/* Call exception_from_token */
amd64_mov_reg_reg (code, AMD64_ARG_REG2, AMD64_ARG_REG1, 8);
if (aot) {
- *ji = mono_patch_info_list_prepend (*ji, code - start, MONO_PATCH_INFO_IMAGE, mono_defaults.exception_class->image);
+ ji = mono_patch_info_list_prepend (ji, code - start, MONO_PATCH_INFO_IMAGE, mono_defaults.exception_class->image);
amd64_mov_reg_membase (code, AMD64_ARG_REG1, AMD64_RIP, 0, 8);
- *ji = mono_patch_info_list_prepend (*ji, code - start, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_exception_from_token");
+ ji = mono_patch_info_list_prepend (ji, code - start, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_exception_from_token");
amd64_mov_reg_membase (code, AMD64_R11, AMD64_RIP, 0, 8);
} else {
amd64_mov_reg_imm (code, AMD64_ARG_REG1, mono_defaults.exception_class->image);
/* Call throw_exception */
amd64_mov_reg_reg (code, AMD64_ARG_REG1, AMD64_RAX, 8);
if (aot) {
- *ji = mono_patch_info_list_prepend (*ji, code - start, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_throw_exception");
+ ji = mono_patch_info_list_prepend (ji, code - start, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_throw_exception");
amd64_mov_reg_membase (code, AMD64_R11, AMD64_RIP, 0, 8);
} else {
amd64_mov_reg_imm (code, AMD64_R11, throw_ex);
mono_arch_flush_icache (start, code - start);
- *code_size = code - start;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("throw_corlib_exception"), start, code - start, ji, unwind_ops);
return start;
}
}
gpointer
-mono_arch_get_throw_pending_exception_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_get_throw_pending_exception_full (MonoTrampInfo **info, gboolean aot)
{
guint8 *code, *start;
guint8 *br[1];
gpointer throw_trampoline;
-
- *ji = NULL;
+ MonoJumpInfo *ji = NULL;
+ GSList *unwind_ops = NULL;
start = code = mono_global_codeman_reserve (128);
/* Obtain the pending exception */
if (aot) {
- *ji = mono_patch_info_list_prepend (*ji, code - start, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_thread_get_and_clear_pending_exception");
+ ji = mono_patch_info_list_prepend (ji, code - start, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_thread_get_and_clear_pending_exception");
amd64_mov_reg_membase (code, AMD64_R11, AMD64_RIP, 0, 8);
} else {
amd64_mov_reg_imm (code, AMD64_R11, mono_thread_get_and_clear_pending_exception);
/* Obtain the original ip and clear the flag in previous_lmf */
if (aot) {
- *ji = mono_patch_info_list_prepend (*ji, code - start, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_amd64_get_original_ip");
+ ji = mono_patch_info_list_prepend (ji, code - start, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_amd64_get_original_ip");
amd64_mov_reg_membase (code, AMD64_R11, AMD64_RIP, 0, 8);
} else {
amd64_mov_reg_imm (code, AMD64_R11, mono_amd64_get_original_ip);
/* Call the throw trampoline */
if (aot) {
- *ji = mono_patch_info_list_prepend (*ji, code - start, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_amd64_throw_exception");
+ ji = mono_patch_info_list_prepend (ji, code - start, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_amd64_throw_exception");
amd64_mov_reg_membase (code, AMD64_R11, AMD64_RIP, 0, 8);
} else {
throw_trampoline = mono_get_throw_exception ();
/* Obtain the original ip and clear the flag in previous_lmf */
if (aot) {
- *ji = mono_patch_info_list_prepend (*ji, code - start, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_amd64_get_original_ip");
+ ji = mono_patch_info_list_prepend (ji, code - start, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_amd64_get_original_ip");
amd64_mov_reg_membase (code, AMD64_R11, AMD64_RIP, 0, 8);
} else {
amd64_mov_reg_imm (code, AMD64_R11, mono_amd64_get_original_ip);
g_assert ((code - start) < 128);
- *code_size = code - start;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("throw_pending_exception"), start, code - start, ji, unwind_ops);
return start;
}
void
mono_arch_exceptions_init (void)
{
- guint32 code_size;
- MonoJumpInfo *ji;
-
if (mono_aot_only) {
throw_pending_exception = mono_aot_get_named_code ("throw_pending_exception");
} else {
/* Call this to avoid initialization races */
- throw_pending_exception = mono_arch_get_throw_pending_exception_full (&code_size, &ji, FALSE);
+ throw_pending_exception = mono_arch_get_throw_pending_exception_full (NULL, FALSE);
}
}
* The first argument in r0 is the pointer to the context.
*/
gpointer
-mono_arch_get_restore_context_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_get_restore_context_full (MonoTrampInfo **info, gboolean aot)
{
guint8 *code;
guint8 *start;
int ctx_reg;
-
- *ji = NULL;
+ MonoJumpInfo *ji = NULL;
+ GSList *unwind_ops = NULL;
start = code = mono_global_codeman_reserve (128);
mono_arch_flush_icache (start, code - start);
- *code_size = code - start;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("restore_context"), start, code - start, ji, unwind_ops);
return start;
}
* @exc object in this case).
*/
gpointer
-mono_arch_get_call_filter_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_get_call_filter_full (MonoTrampInfo **info, gboolean aot)
{
guint8 *code;
guint8* start;
int ctx_reg;
-
- *ji = NULL;
+ MonoJumpInfo *ji = NULL;
+ GSList *unwind_ops = NULL;
/* call_filter (MonoContext *ctx, unsigned long eip, gpointer exc) */
start = code = mono_global_codeman_reserve (320);
mono_arch_flush_icache (start, code - start);
- *code_size = code - start;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("call_filter"), start, code - start, ji, unwind_ops);
return start;
}
*
*/
static gpointer
-mono_arch_get_throw_exception_generic (int size, int by_token, gboolean rethrow, guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_get_throw_exception_generic (int size, gboolean corlib, gboolean rethrow, MonoTrampInfo **info, gboolean aot)
{
guint8 *start;
guint8 *code;
-
- *ji = NULL;
+ MonoJumpInfo *ji = NULL;
+ GSList *unwind_ops = NULL;
code = start = mono_global_codeman_reserve (size);
/* caller sp */
ARM_ADD_REG_IMM8 (code, ARMREG_R2, ARMREG_SP, 10 * 4); /* 10 saved regs */
/* exc is already in place in r0 */
- if (by_token) {
+ if (corlib) {
/* The caller ip is already in R1 */
} else {
ARM_MOV_REG_REG (code, ARMREG_R1, ARMREG_LR); /* caller ip */
ARM_ORR_REG_IMM8 (code, ARMREG_R1, ARMREG_R1, rethrow);
if (aot) {
- *ji = mono_patch_info_list_prepend (*ji, code - start, MONO_PATCH_INFO_JIT_ICALL_ADDR, by_token ? "mono_arm_throw_exception_by_token" : "mono_arm_throw_exception");
+ ji = mono_patch_info_list_prepend (ji, code - start, MONO_PATCH_INFO_JIT_ICALL_ADDR, corlib ? "mono_arm_throw_exception_by_token" : "mono_arm_throw_exception");
ARM_LDR_IMM (code, ARMREG_IP, ARMREG_PC, 0);
ARM_B (code, 0);
*(gpointer*)(gpointer)code = NULL;
code += 4;
ARM_LDR_REG_REG (code, ARMREG_IP, ARMREG_PC, ARMREG_IP);
} else {
- code = mono_arm_emit_load_imm (code, ARMREG_IP, GPOINTER_TO_UINT (by_token ? (gpointer)mono_arm_throw_exception_by_token : (gpointer)mono_arm_throw_exception));
+ code = mono_arm_emit_load_imm (code, ARMREG_IP, GPOINTER_TO_UINT (corlib ? (gpointer)mono_arm_throw_exception_by_token : (gpointer)mono_arm_throw_exception));
}
ARM_MOV_REG_REG (code, ARMREG_LR, ARMREG_PC);
ARM_MOV_REG_REG (code, ARMREG_PC, ARMREG_IP);
g_assert ((code - start) < size);
mono_arch_flush_icache (start, code - start);
- *code_size = code - start;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf (corlib ? "throw_corlib_exception" : (rethrow ? "rethrow_exception" : "throw_exception")), start, code - start, ji, unwind_ops);
return start;
}
*
*/
gpointer
-mono_arch_get_rethrow_exception_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_get_rethrow_exception_full (MonoTrampInfo **info, gboolean aot)
{
- return mono_arch_get_throw_exception_generic (132, FALSE, TRUE, code_size, ji, aot);
+ return mono_arch_get_throw_exception_generic (132, FALSE, TRUE, info, aot);
}
/**
*
*/
gpointer
-mono_arch_get_throw_exception_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_get_throw_exception_full (MonoTrampInfo **info, gboolean aot)
{
- return mono_arch_get_throw_exception_generic (132, FALSE, FALSE, code_size, ji, aot);
+ return mono_arch_get_throw_exception_generic (132, FALSE, FALSE, info, aot);
}
/**
* On ARM, the ip is passed instead of an offset.
*/
gpointer
-mono_arch_get_throw_corlib_exception_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_get_throw_corlib_exception_full (MonoTrampInfo **info, gboolean aot)
{
- return mono_arch_get_throw_exception_generic (168, TRUE, FALSE, code_size, ji, aot);
+ return mono_arch_get_throw_exception_generic (168, TRUE, FALSE, info, aot);
}
/*
* The first argument in r3 is the pointer to the context.
*/
gpointer
-mono_arch_get_restore_context_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_get_restore_context_full (MonoTrampInfo **info, gboolean aot)
{
guint8 *start, *code;
int size = MONO_PPC_32_64_CASE (128, 172) + PPC_FTNPTR_SIZE;
+ MonoJumpInfo *ji = NULL;
+ GSList *unwind_ops = NULL;
code = start = mono_global_codeman_reserve (size);
- *ji = NULL;
if (!aot)
code = mono_ppc_create_pre_code_ftnptr (code);
restore_regs_from_context (ppc_r3, ppc_r4, ppc_r5);
g_assert ((code - start) <= size);
mono_arch_flush_icache (start, code - start);
- *code_size = code - start;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("restore_context"), start, code - start, ji, unwind_ops);
return start;
}
* @exc object in this case).
*/
gpointer
-mono_arch_get_call_filter_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_get_call_filter_full (MonoTrampInfo **info, gboolean aot)
{
guint8 *start, *code;
int alloc_size, pos, i;
int size = MONO_PPC_32_64_CASE (320, 500) + PPC_FTNPTR_SIZE;
-
- *ji = NULL;
+ MonoJumpInfo *ji = NULL;
+ GSList *unwind_ops = NULL;
/* call_filter (MonoContext *ctx, unsigned long eip, gpointer exc) */
code = start = mono_global_codeman_reserve (size);
g_assert ((code - start) < size);
mono_arch_flush_icache (start, code - start);
- *code_size = code - start;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("call_filter"), start, code - start, ji, unwind_ops);
return start;
}
*
*/
static gpointer
-mono_arch_get_throw_exception_generic (int size, guint32 *code_size, MonoJumpInfo **ji, int corlib, gboolean rethrow, gboolean aot)
+mono_arch_get_throw_exception_generic (int size, MonoTrampInfo **info, int corlib, gboolean rethrow, gboolean aot)
{
guint8 *start, *code;
int alloc_size, pos;
-
- *ji = NULL;
+ MonoJumpInfo *ji = NULL;
+ GSList *unwind_ops = NULL;
code = start = mono_global_codeman_reserve (size);
if (!aot)
ppc_mr (code, ppc_r4, ppc_r3);
if (aot) {
- code = mono_arch_emit_load_aotconst (start, code, ji, MONO_PATCH_INFO_IMAGE, mono_defaults.corlib);
+ code = mono_arch_emit_load_aotconst (start, code, &ji, MONO_PATCH_INFO_IMAGE, mono_defaults.corlib);
ppc_mr (code, ppc_r3, ppc_r11);
- code = mono_arch_emit_load_aotconst (start, code, ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_exception_from_token");
+ code = mono_arch_emit_load_aotconst (start, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_exception_from_token");
#ifdef PPC_USES_FUNCTION_DESCRIPTOR
ppc_ldptr (code, ppc_r2, sizeof (gpointer), ppc_r11);
ppc_ldptr (code, ppc_r11, 0, ppc_r11);
// This can be called from runtime code, which can't guarantee that
// r30 contains the got address.
// So emit the got address loading code too
- code = mono_arch_emit_load_got_addr (start, code, NULL, ji);
- code = mono_arch_emit_load_aotconst (start, code, ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_ppc_throw_exception");
+ code = mono_arch_emit_load_got_addr (start, code, NULL, &ji);
+ code = mono_arch_emit_load_aotconst (start, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_ppc_throw_exception");
#ifdef PPC_USES_FUNCTION_DESCRIPTOR
ppc_ldptr (code, ppc_r2, sizeof (gpointer), ppc_r11);
ppc_ldptr (code, ppc_r11, 0, ppc_r11);
g_assert ((code - start) <= size);
mono_arch_flush_icache (start, code - start);
- *code_size = code - start;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf (corlib ? "throw_corlib_exception" : (rethrow ? "rethrow_exception" : "throw_exception")), start, code - start, ji, unwind_ops);
return start;
}
*
*/
gpointer
-mono_arch_get_rethrow_exception_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_get_rethrow_exception_full (MonoTrampInfo **info, gboolean aot)
{
int size = MONO_PPC_32_64_CASE (132, 224) + PPC_FTNPTR_SIZE;
if (aot)
size += 64;
- return mono_arch_get_throw_exception_generic (size, code_size, ji, FALSE, TRUE, aot);
+ return mono_arch_get_throw_exception_generic (size, info, FALSE, TRUE, aot);
}
/**
*
*/
gpointer
-mono_arch_get_throw_exception_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_get_throw_exception_full (MonoTrampInfo **info, gboolean aot)
{
int size = MONO_PPC_32_64_CASE (132, 224) + PPC_FTNPTR_SIZE;
if (aot)
size += 64;
- return mono_arch_get_throw_exception_generic (size, code_size, ji, FALSE, FALSE, aot);
+ return mono_arch_get_throw_exception_generic (size, info, FALSE, FALSE, aot);
}
/**
* On PPC, we pass the ip instead of the offset
*/
gpointer
-mono_arch_get_throw_corlib_exception_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_get_throw_corlib_exception_full (MonoTrampInfo **info, gboolean aot)
{
int size = MONO_PPC_32_64_CASE (168, 304) + PPC_FTNPTR_SIZE;
if (aot)
size += 64;
- return mono_arch_get_throw_exception_generic (size, code_size, ji, TRUE, FALSE, aot);
+ return mono_arch_get_throw_exception_generic (size, info, TRUE, FALSE, aot);
}
/*
* Returns a pointer to a method which restores a previously saved sigcontext.
*/
gpointer
-mono_arch_get_restore_context_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_get_restore_context_full (MonoTrampInfo **info, gboolean aot)
{
guint8 *start = NULL;
guint8 *code;
+ MonoJumpInfo *ji = NULL;
+ GSList *unwind_ops = NULL;
/* restore_contect (MonoContext *ctx) */
- *ji = NULL;
-
start = code = mono_global_codeman_reserve (128);
/* load ctx */
/* jump to the saved IP */
x86_ret (code);
- *code_size = code - start;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("restore_context"), start, code - start, ji, unwind_ops);
return start;
}
* @exc object in this case).
*/
gpointer
-mono_arch_get_call_filter_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_get_call_filter_full (MonoTrampInfo **info, gboolean aot)
{
guint8* start;
guint8 *code;
-
- *ji = NULL;
+ MonoJumpInfo *ji = NULL;
+ GSList *unwind_ops = NULL;
/* call_filter (MonoContext *ctx, unsigned long eip) */
start = code = mono_global_codeman_reserve (64);
x86_leave (code);
x86_ret (code);
- *code_size = code - start;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("call_filter"), start, code - start, ji, unwind_ops);
g_assert ((code - start) < 64);
return start;
* which doesn't push the arguments.
*/
static guint8*
-get_throw_exception (const char *name, gboolean rethrow, gboolean llvm, gboolean corlib, guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+get_throw_exception (const char *name, gboolean rethrow, gboolean llvm, gboolean corlib, MonoTrampInfo **info, gboolean aot)
{
guint8 *start, *code;
- GSList *unwind_ops = NULL;
int i, stack_size, stack_offset, arg_offsets [5], regs_offset;
-
- if (ji)
- *ji = NULL;
+ MonoJumpInfo *ji = NULL;
+ GSList *unwind_ops = NULL;
start = code = mono_global_codeman_reserve (128);
// This can be called from runtime code, which can't guarantee that
// ebx contains the got address.
// So emit the got address loading code too
- code = mono_arch_emit_load_got_addr (start, code, NULL, ji);
- code = mono_arch_emit_load_aotconst (start, code, ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, corlib ? "mono_x86_throw_corlib_exception" : "mono_x86_throw_exception");
+ code = mono_arch_emit_load_got_addr (start, code, NULL, &ji);
+ code = mono_arch_emit_load_aotconst (start, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, corlib ? "mono_x86_throw_corlib_exception" : "mono_x86_throw_exception");
x86_call_reg (code, X86_EAX);
} else {
x86_call_code (code, corlib ? (gpointer)mono_x86_throw_corlib_exception : (gpointer)mono_x86_throw_exception);
g_assert ((code - start) < 128);
- if (code_size)
- *code_size = code - start;
-
mono_save_trampoline_xdebug_info (corlib ? "llvm_throw_corlib_exception_trampoline" : "llvm_throw_exception_trampoline", start, code - start, unwind_ops);
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf (corlib ? "throw_corlib_exception" : (rethrow ? "rethrow_exception" : "throw_exception")), start, code - start, ji, unwind_ops);
+
return start;
}
*
*/
gpointer
-mono_arch_get_throw_exception_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_get_throw_exception_full (MonoTrampInfo **info, gboolean aot)
{
- return get_throw_exception ("throw_exception_trampoline", FALSE, FALSE, FALSE, code_size, ji, aot);
+ return get_throw_exception ("throw_exception_trampoline", FALSE, FALSE, FALSE, info, aot);
}
gpointer
-mono_arch_get_rethrow_exception_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_get_rethrow_exception_full (MonoTrampInfo **info, gboolean aot)
{
- return get_throw_exception ("rethow_exception_trampoline", TRUE, FALSE, FALSE, code_size, ji, aot);
+ return get_throw_exception ("rethow_exception_trampoline", TRUE, FALSE, FALSE, info, aot);
}
/**
* needs no relocations in the caller.
*/
gpointer
-mono_arch_get_throw_corlib_exception_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_get_throw_corlib_exception_full (MonoTrampInfo **info, gboolean aot)
{
- return get_throw_exception ("throw_corlib_exception_trampoline", FALSE, FALSE, TRUE, code_size, ji, aot);
+ return get_throw_exception ("throw_corlib_exception_trampoline", FALSE, FALSE, TRUE, info, aot);
}
void
return;
/* LLVM needs different throw trampolines */
- tramp = get_throw_exception ("llvm_throw_exception_trampoline", FALSE, TRUE, FALSE, NULL, NULL, FALSE);
+ tramp = get_throw_exception ("llvm_throw_exception_trampoline", FALSE, TRUE, FALSE, NULL, FALSE);
mono_register_jit_icall (tramp, "mono_arch_llvm_throw_exception", NULL, TRUE);
- tramp = get_throw_exception ("llvm_throw_corlib_exception_trampoline", FALSE, TRUE, TRUE, NULL, NULL, FALSE);
+ tramp = get_throw_exception ("llvm_throw_corlib_exception_trampoline", FALSE, TRUE, TRUE, NULL, FALSE);
mono_register_jit_icall (tramp, "mono_arch_llvm_throw_corlib_exception", NULL, TRUE);
}
#define MONO_ARCH_HAVE_ATOMIC_EXCHANGE 1
#define MONO_ARCH_HAVE_ATOMIC_CAS 1
#define MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES 1
+#define MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES_2 1
#define MONO_ARCH_HAVE_IMT 1
#define MONO_ARCH_HAVE_TLS_GET 1
#define MONO_ARCH_IMT_REG AMD64_R11
mono_exceptions_init (void)
{
#ifdef MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES
- guint32 code_size;
- MonoJumpInfo *ji;
-
if (mono_aot_only) {
restore_context_func = mono_aot_get_named_code ("restore_context");
call_filter_func = mono_aot_get_named_code ("call_filter");
throw_exception_func = mono_aot_get_named_code ("throw_exception");
rethrow_exception_func = mono_aot_get_named_code ("rethrow_exception");
} else {
- restore_context_func = mono_arch_get_restore_context_full (&code_size, &ji, FALSE);
- call_filter_func = mono_arch_get_call_filter_full (&code_size, &ji, FALSE);
- throw_exception_func = mono_arch_get_throw_exception_full (&code_size, &ji, FALSE);
- rethrow_exception_func = mono_arch_get_rethrow_exception_full (&code_size, &ji, FALSE);
+ restore_context_func = mono_arch_get_restore_context_full (NULL, FALSE);
+ call_filter_func = mono_arch_get_call_filter_full (NULL, FALSE);
+ throw_exception_func = mono_arch_get_throw_exception_full (NULL, FALSE);
+ rethrow_exception_func = mono_arch_get_rethrow_exception_full (NULL, FALSE);
}
#else
restore_context_func = mono_arch_get_restore_context ();
mono_get_throw_corlib_exception (void)
{
gpointer code = NULL;
-#ifdef MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES
- guint32 code_size;
- MonoJumpInfo *ji;
-#endif
/* This depends on corlib classes so cannot be inited in mono_exceptions_init () */
if (throw_corlib_exception_func)
if (mono_aot_only)
code = mono_aot_get_named_code ("throw_corlib_exception");
else
- code = mono_arch_get_throw_corlib_exception_full (&code_size, &ji, FALSE);
+ code = mono_arch_get_throw_corlib_exception_full (NULL, FALSE);
#else
code = mono_arch_get_throw_corlib_exception ();
#endif
}
}
+static guchar*
+create_trampoline_code (MonoTrampolineType tramp_type)
+{
+#ifdef MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES
+ MonoTrampInfo *info;
+ guchar *code;
+
+ code = mono_arch_create_generic_trampoline_full (tramp_type, &info, FALSE);
+ mono_save_trampoline_xdebug_info (info->name, info->code, info->code_size, info->unwind_ops);
+ mono_tramp_info_free (info);
+
+ return code;
+#else
+ return mono_arch_create_trampoline_code (tramp_type);
+#endif
+}
+
void
mono_trampolines_init (void)
{
if (mono_aot_only)
return;
- mono_trampoline_code [MONO_TRAMPOLINE_JIT] = mono_arch_create_trampoline_code (MONO_TRAMPOLINE_JIT);
- mono_trampoline_code [MONO_TRAMPOLINE_JUMP] = mono_arch_create_trampoline_code (MONO_TRAMPOLINE_JUMP);
- mono_trampoline_code [MONO_TRAMPOLINE_CLASS_INIT] = mono_arch_create_trampoline_code (MONO_TRAMPOLINE_CLASS_INIT);
- mono_trampoline_code [MONO_TRAMPOLINE_GENERIC_CLASS_INIT] = mono_arch_create_trampoline_code (MONO_TRAMPOLINE_GENERIC_CLASS_INIT);
- mono_trampoline_code [MONO_TRAMPOLINE_RGCTX_LAZY_FETCH] = mono_arch_create_trampoline_code (MONO_TRAMPOLINE_RGCTX_LAZY_FETCH);
+ mono_trampoline_code [MONO_TRAMPOLINE_JIT] = create_trampoline_code (MONO_TRAMPOLINE_JIT);
+ mono_trampoline_code [MONO_TRAMPOLINE_JUMP] = create_trampoline_code (MONO_TRAMPOLINE_JUMP);
+ mono_trampoline_code [MONO_TRAMPOLINE_CLASS_INIT] = create_trampoline_code (MONO_TRAMPOLINE_CLASS_INIT);
+ mono_trampoline_code [MONO_TRAMPOLINE_GENERIC_CLASS_INIT] = create_trampoline_code (MONO_TRAMPOLINE_GENERIC_CLASS_INIT);
+ mono_trampoline_code [MONO_TRAMPOLINE_RGCTX_LAZY_FETCH] = create_trampoline_code (MONO_TRAMPOLINE_RGCTX_LAZY_FETCH);
#ifdef MONO_ARCH_AOT_SUPPORTED
- mono_trampoline_code [MONO_TRAMPOLINE_AOT] = mono_arch_create_trampoline_code (MONO_TRAMPOLINE_AOT);
- mono_trampoline_code [MONO_TRAMPOLINE_AOT_PLT] = mono_arch_create_trampoline_code (MONO_TRAMPOLINE_AOT_PLT);
+ mono_trampoline_code [MONO_TRAMPOLINE_AOT] = create_trampoline_code (MONO_TRAMPOLINE_AOT);
+ mono_trampoline_code [MONO_TRAMPOLINE_AOT_PLT] = create_trampoline_code (MONO_TRAMPOLINE_AOT_PLT);
#endif
#ifdef MONO_ARCH_HAVE_CREATE_DELEGATE_TRAMPOLINE
- mono_trampoline_code [MONO_TRAMPOLINE_DELEGATE] = mono_arch_create_trampoline_code (MONO_TRAMPOLINE_DELEGATE);
+ mono_trampoline_code [MONO_TRAMPOLINE_DELEGATE] = create_trampoline_code (MONO_TRAMPOLINE_DELEGATE);
#endif
- mono_trampoline_code [MONO_TRAMPOLINE_RESTORE_STACK_PROT] = mono_arch_create_trampoline_code (MONO_TRAMPOLINE_RESTORE_STACK_PROT);
- mono_trampoline_code [MONO_TRAMPOLINE_GENERIC_VIRTUAL_REMOTING] = mono_arch_create_trampoline_code (MONO_TRAMPOLINE_GENERIC_VIRTUAL_REMOTING);
- mono_trampoline_code [MONO_TRAMPOLINE_MONITOR_ENTER] = mono_arch_create_trampoline_code (MONO_TRAMPOLINE_MONITOR_ENTER);
- mono_trampoline_code [MONO_TRAMPOLINE_MONITOR_EXIT] = mono_arch_create_trampoline_code (MONO_TRAMPOLINE_MONITOR_EXIT);
+ mono_trampoline_code [MONO_TRAMPOLINE_RESTORE_STACK_PROT] = create_trampoline_code (MONO_TRAMPOLINE_RESTORE_STACK_PROT);
+ mono_trampoline_code [MONO_TRAMPOLINE_GENERIC_VIRTUAL_REMOTING] = create_trampoline_code (MONO_TRAMPOLINE_GENERIC_VIRTUAL_REMOTING);
+ mono_trampoline_code [MONO_TRAMPOLINE_MONITOR_ENTER] = create_trampoline_code (MONO_TRAMPOLINE_MONITOR_ENTER);
+ mono_trampoline_code [MONO_TRAMPOLINE_MONITOR_EXIT] = create_trampoline_code (MONO_TRAMPOLINE_MONITOR_EXIT);
#ifdef MONO_ARCH_LLVM_SUPPORTED
- mono_trampoline_code [MONO_TRAMPOLINE_LLVM_VCALL] = mono_arch_create_trampoline_code (MONO_TRAMPOLINE_LLVM_VCALL);
+ mono_trampoline_code [MONO_TRAMPOLINE_LLVM_VCALL] = create_trampoline_code (MONO_TRAMPOLINE_LLVM_VCALL);
#endif
#ifdef MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD
- mono_trampoline_code [MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD] = mono_arch_create_trampoline_code (MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD);
+ mono_trampoline_code [MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD] = create_trampoline_code (MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD);
mono_create_handler_block_trampoline ();
#endif
/* get_named_code () might return an ftnptr, but our caller expects a direct pointer */
code = mono_get_addr_from_ftnptr (mono_aot_get_named_code ("generic_class_init_trampoline"));
else
+#ifdef MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES
+ code = mono_arch_create_generic_class_init_trampoline_full (NULL, FALSE);
+#else
code = mono_arch_create_generic_class_init_trampoline ();
+#endif
}
mono_trampolines_unlock ();
if (tramp)
return tramp;
+#ifdef MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES
+ tramp = mono_arch_create_rgctx_lazy_fetch_trampoline_full (offset, NULL, FALSE);
+#else
tramp = mono_arch_create_rgctx_lazy_fetch_trampoline (offset);
+#endif
ptr = mono_create_ftnptr (mono_get_root_domain (), tramp);
mono_trampolines_lock ();
mono_trampolines_lock ();
if (!code)
+#ifdef MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES
+ code = mono_arch_create_monitor_enter_trampoline_full (NULL, FALSE);
+#else
code = mono_arch_create_monitor_enter_trampoline ();
+#endif
mono_trampolines_unlock ();
#else
mono_trampolines_lock ();
if (!code)
+#ifdef MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES
+ code = mono_arch_create_monitor_exit_trampoline_full (NULL, FALSE);
+#else
code = mono_arch_create_monitor_exit_trampoline ();
+#endif
mono_trampolines_unlock ();
#else
gpointer mono_arch_get_throw_corlib_exception (void) MONO_INTERNAL;
void mono_arch_exceptions_init (void) MONO_INTERNAL;
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, GSList **out_unwind_ops, gboolean aot) MONO_INTERNAL;
+guchar* mono_arch_create_generic_trampoline_full (MonoTrampolineType tramp_type, MonoTrampInfo **info, gboolean aot) MONO_INTERNAL;
gpointer mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot) MONO_INTERNAL;
-gpointer mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, guint32 *code_size, MonoJumpInfo **ji, gboolean aot) MONO_INTERNAL;
+gpointer mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, MonoTrampInfo **info, gboolean aot) MONO_INTERNAL;
gpointer mono_arch_create_generic_class_init_trampoline (void) MONO_INTERNAL;
-gpointer mono_arch_get_nullified_class_init_trampoline (guint32 *code_len) MONO_INTERNAL;
+gpointer mono_arch_create_generic_class_init_trampoline_full (MonoTrampInfo **info, gboolean aot) MONO_INTERNAL;
+gpointer mono_arch_get_nullified_class_init_trampoline (MonoTrampInfo **info) MONO_INTERNAL;
gpointer mono_arch_create_monitor_enter_trampoline (void) MONO_INTERNAL;
gpointer mono_arch_create_monitor_exit_trampoline (void) MONO_INTERNAL;
-gpointer mono_arch_create_monitor_enter_trampoline_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot) MONO_INTERNAL;
-gpointer mono_arch_create_monitor_exit_trampoline_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot) MONO_INTERNAL;
-gpointer mono_arch_create_generic_class_init_trampoline_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot) MONO_INTERNAL;
+gpointer mono_arch_create_monitor_enter_trampoline_full (MonoTrampInfo **info, gboolean aot) MONO_INTERNAL;
+gpointer mono_arch_create_monitor_exit_trampoline_full (MonoTrampInfo **info, gboolean aot) MONO_INTERNAL;
GList *mono_arch_get_allocatable_int_vars (MonoCompile *cfg) MONO_INTERNAL;
GList *mono_arch_get_global_int_regs (MonoCompile *cfg) MONO_INTERNAL;
GList *mono_arch_get_global_fp_regs (MonoCompile *cfg) MONO_INTERNAL;
StackFrameInfo *frame_info) MONO_INTERNAL;
gpointer mono_arch_get_call_filter (void) MONO_INTERNAL;
gpointer mono_arch_get_restore_context (void) MONO_INTERNAL;
-gpointer mono_arch_get_call_filter_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot) MONO_INTERNAL;
-gpointer mono_arch_get_restore_context_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot) MONO_INTERNAL;
-gpointer mono_arch_get_throw_exception_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot) MONO_INTERNAL;
-gpointer mono_arch_get_rethrow_exception_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot) MONO_INTERNAL;
-gpointer mono_arch_get_throw_exception_by_name_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot) MONO_INTERNAL;
-gpointer mono_arch_get_throw_corlib_exception_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot) MONO_INTERNAL;
-gpointer mono_arch_get_throw_pending_exception_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot) MONO_INTERNAL;
+gpointer mono_arch_get_call_filter_full (MonoTrampInfo **info, gboolean aot) MONO_INTERNAL;
+gpointer mono_arch_get_restore_context_full (MonoTrampInfo **info, gboolean aot) MONO_INTERNAL;
+gpointer mono_arch_get_throw_exception_full (MonoTrampInfo **info, gboolean aot) MONO_INTERNAL;
+gpointer mono_arch_get_rethrow_exception_full (MonoTrampInfo **info, gboolean aot) MONO_INTERNAL;
+gpointer mono_arch_get_throw_corlib_exception_full (MonoTrampInfo **info, gboolean aot) MONO_INTERNAL;
+gpointer mono_arch_get_throw_pending_exception_full (MonoTrampInfo **info, gboolean aot) MONO_INTERNAL;
gboolean mono_arch_handle_exception (void *sigctx, gpointer obj, gboolean test_only) MONO_INTERNAL;
void mono_arch_handle_altstack_exception (void *sigctx, gpointer fault_addr, gboolean stack_ovf) MONO_INTERNAL;
gboolean mono_handle_soft_stack_ovf (MonoJitTlsData *jit_tls, MonoJitInfo *ji, void *ctx, guint8* fault_addr) MONO_INTERNAL;
}
guchar*
-mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
-{
- MonoJumpInfo *ji;
- guint32 code_size;
- guchar *code;
- GSList *unwind_ops, *l;
-
- code = mono_arch_create_trampoline_code_full (tramp_type, &code_size, &ji, &unwind_ops, FALSE);
-
- mono_save_trampoline_xdebug_info ("<generic_trampoline>", code, code_size, unwind_ops);
-
- for (l = unwind_ops; l; l = l->next)
- g_free (l->data);
- g_slist_free (unwind_ops);
-
- return code;
-}
-
-guchar*
-mono_arch_create_trampoline_code_full (MonoTrampolineType tramp_type, guint32 *code_size, MonoJumpInfo **ji, GSList **out_unwind_ops, gboolean aot)
+mono_arch_create_generic_trampoline_full (MonoTrampolineType tramp_type, MonoTrampInfo **info, gboolean aot)
{
guint8 *buf, *code, *tramp, *br [2], *r11_save_code, *after_r11_save_code;
int i, lmf_offset, offset, res_offset, arg_offset, rax_offset, tramp_offset, saved_regs_offset;
int saved_fpregs_offset, rbp_offset, framesize, orig_rsp_to_rbp_offset, cfa_offset;
gboolean has_caller;
GSList *unwind_ops = NULL;
+ MonoJumpInfo *ji = NULL;
if (tramp_type == MONO_TRAMPOLINE_JUMP)
has_caller = FALSE;
code = buf = mono_global_codeman_reserve (538);
- *ji = NULL;
-
framesize = 538 + sizeof (MonoLMF);
framesize = (framesize + (MONO_ARCH_FRAME_ALIGNMENT - 1)) & ~ (MONO_ARCH_FRAME_ALIGNMENT - 1);
amd64_mov_membase_reg (code, AMD64_RBP, lmf_offset + G_STRUCT_OFFSET (MonoLMF, r15), AMD64_R15, 8);
if (aot) {
- *ji = mono_patch_info_list_prepend (*ji, code - buf, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_get_lmf_addr");
+ ji = mono_patch_info_list_prepend (ji, code - buf, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_get_lmf_addr");
amd64_mov_reg_membase (code, AMD64_R11, AMD64_RIP, 0, 8);
} else {
amd64_mov_reg_imm (code, AMD64_R11, mono_get_lmf_addr);
if (aot) {
char *icall_name = g_strdup_printf ("trampoline_func_%d", tramp_type);
- *ji = mono_patch_info_list_prepend (*ji, code - buf, MONO_PATCH_INFO_JIT_ICALL_ADDR, icall_name);
+ ji = mono_patch_info_list_prepend (ji, code - buf, MONO_PATCH_INFO_JIT_ICALL_ADDR, icall_name);
amd64_mov_reg_membase (code, AMD64_RAX, AMD64_RIP, 0, 8);
} else {
tramp = (guint8*)mono_get_trampoline_func (tramp_type);
*/
amd64_mov_membase_reg (code, AMD64_RBP, res_offset, AMD64_RAX, 8);
if (aot) {
- *ji = mono_patch_info_list_prepend (*ji, code - buf, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_thread_force_interruption_checkpoint");
+ ji = mono_patch_info_list_prepend (ji, code - buf, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_thread_force_interruption_checkpoint");
amd64_mov_reg_membase (code, AMD64_RAX, AMD64_RIP, 0, 8);
} else {
amd64_mov_reg_imm (code, AMD64_RAX, (guint8*)mono_thread_force_interruption_checkpoint);
mono_arch_flush_icache (buf, code - buf);
- *code_size = code - buf;
-
if (tramp_type == MONO_TRAMPOLINE_CLASS_INIT) {
- guint32 code_len;
-
/* Initialize the nullified class init trampoline used in the AOT case */
- nullified_class_init_trampoline = mono_arch_get_nullified_class_init_trampoline (&code_len);
+ nullified_class_init_trampoline = mono_arch_get_nullified_class_init_trampoline (NULL);
}
- *out_unwind_ops = unwind_ops;
-
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("generic_trampoline_%d", tramp_type), buf, code - buf, ji, unwind_ops);
+
return buf;
}
gpointer
-mono_arch_get_nullified_class_init_trampoline (guint32 *code_len)
+mono_arch_get_nullified_class_init_trampoline (MonoTrampInfo **info)
{
guint8 *code, *buf;
mono_arch_flush_icache (buf, code - buf);
- *code_len = code - buf;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("nullified_class_init_trampoline"), buf, code - buf, NULL, NULL);
return buf;
}
}
gpointer
-mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot)
-{
- guint32 code_size;
- MonoJumpInfo *ji;
-
- return mono_arch_create_rgctx_lazy_fetch_trampoline_full (slot, &code_size, &ji, FALSE);
-}
-
-gpointer
-mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, MonoTrampInfo **info, gboolean aot)
{
guint8 *tramp;
guint8 *code, *buf;
int depth, index;
int i;
gboolean mrgctx;
+ MonoJumpInfo *ji = NULL;
GSList *unwind_ops = NULL;
char *name;
- *ji = NULL;
-
mrgctx = MONO_RGCTX_SLOT_IS_MRGCTX (slot);
index = MONO_RGCTX_SLOT_INDEX (slot);
if (mrgctx)
amd64_mov_reg_reg (code, MONO_ARCH_VTABLE_REG, AMD64_ARG_REG1, 8);
if (aot) {
- *ji = mono_patch_info_list_prepend (*ji, code - buf, MONO_PATCH_INFO_JIT_ICALL_ADDR, g_strdup_printf ("specific_trampoline_lazy_fetch_%u", slot));
+ ji = mono_patch_info_list_prepend (ji, code - buf, MONO_PATCH_INFO_JIT_ICALL_ADDR, g_strdup_printf ("specific_trampoline_lazy_fetch_%u", slot));
amd64_mov_reg_membase (code, AMD64_R11, AMD64_RIP, 0, 8);
amd64_jump_reg (code, AMD64_R11);
} else {
g_assert (code - buf <= tramp_size);
- *code_size = code - buf;
-
name = g_strdup_printf ("rgctx_fetch_trampoline_%s_%d", mrgctx ? "mrgctx" : "rgctx", index);
mono_save_trampoline_xdebug_info (name, buf, code - buf, unwind_ops);
g_free (name);
- return buf;
-}
-
-gpointer
-mono_arch_create_generic_class_init_trampoline (void)
-{
- guint32 code_size;
- MonoJumpInfo *ji;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("rgctx_fetch_trampoline_%u", slot), buf, code - buf, ji, unwind_ops);
- return mono_arch_create_generic_class_init_trampoline_full (&code_size, &ji, FALSE);
+ return buf;
}
gpointer
-mono_arch_create_generic_class_init_trampoline_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_create_generic_class_init_trampoline_full (MonoTrampInfo **info, gboolean aot)
{
guint8 *tramp;
guint8 *code, *buf;
static guint8 bitmask;
guint8 *jump;
int tramp_size;
-
- *ji = NULL;
+ GSList *unwind_ops = NULL;
+ MonoJumpInfo *ji = NULL;
tramp_size = 64;
x86_patch (jump, code);
if (aot) {
- *ji = mono_patch_info_list_prepend (*ji, code - buf, MONO_PATCH_INFO_JIT_ICALL_ADDR, "specific_trampoline_generic_class_init");
+ ji = mono_patch_info_list_prepend (ji, code - buf, MONO_PATCH_INFO_JIT_ICALL_ADDR, "specific_trampoline_generic_class_init");
amd64_mov_reg_membase (code, AMD64_R11, AMD64_RIP, 0, 8);
amd64_jump_reg (code, AMD64_R11);
} else {
g_assert (code - buf <= tramp_size);
- *code_size = code - buf;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("generic_class_init_trampoline"), buf, code - buf, ji, unwind_ops);
return buf;
}
#ifdef MONO_ARCH_MONITOR_OBJECT_REG
gpointer
-mono_arch_create_monitor_enter_trampoline (void)
-{
- guint32 code_size;
- MonoJumpInfo *ji;
-
- return mono_arch_create_monitor_enter_trampoline_full (&code_size, &ji, FALSE);
-}
-
-gpointer
-mono_arch_create_monitor_enter_trampoline_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_create_monitor_enter_trampoline_full (MonoTrampInfo **info, gboolean aot)
{
-
guint8 *tramp;
guint8 *code, *buf;
guint8 *jump_obj_null, *jump_sync_null, *jump_cmpxchg_failed, *jump_other_owner, *jump_tid;
int tramp_size;
int owner_offset, nest_offset, dummy;
-
- *ji = NULL;
+ MonoJumpInfo *ji = NULL;
+ GSList *unwind_ops = NULL;
g_assert (MONO_ARCH_MONITOR_OBJECT_REG == AMD64_RDI);
#endif
if (aot) {
- *ji = mono_patch_info_list_prepend (*ji, code - buf, MONO_PATCH_INFO_JIT_ICALL_ADDR, "specific_trampoline_monitor_enter");
+ ji = mono_patch_info_list_prepend (ji, code - buf, MONO_PATCH_INFO_JIT_ICALL_ADDR, "specific_trampoline_monitor_enter");
amd64_mov_reg_membase (code, AMD64_R11, AMD64_RIP, 0, 8);
amd64_jump_reg (code, AMD64_R11);
} else {
mono_arch_flush_icache (code, code - buf);
g_assert (code - buf <= tramp_size);
- *code_size = code - buf;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("monitor_enter_trampoline"), buf, code - buf, ji, unwind_ops);
return buf;
}
gpointer
-mono_arch_create_monitor_exit_trampoline (void)
-{
- guint32 code_size;
- MonoJumpInfo *ji;
-
- return mono_arch_create_monitor_exit_trampoline_full (&code_size, &ji, FALSE);
-}
-
-gpointer
-mono_arch_create_monitor_exit_trampoline_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_create_monitor_exit_trampoline_full (MonoTrampInfo **info, gboolean aot)
{
guint8 *tramp;
guint8 *code, *buf;
guint8 *jump_next;
int tramp_size;
int owner_offset, nest_offset, entry_count_offset;
-
- *ji = NULL;
+ MonoJumpInfo *ji = NULL;
+ GSList *unwind_ops = NULL;
g_assert (MONO_ARCH_MONITOR_OBJECT_REG == AMD64_RDI);
#endif
if (aot) {
- *ji = mono_patch_info_list_prepend (*ji, code - buf, MONO_PATCH_INFO_JIT_ICALL_ADDR, "specific_trampoline_monitor_exit");
+ ji = mono_patch_info_list_prepend (ji, code - buf, MONO_PATCH_INFO_JIT_ICALL_ADDR, "specific_trampoline_monitor_exit");
amd64_mov_reg_membase (code, AMD64_R11, AMD64_RIP, 0, 8);
amd64_jump_reg (code, AMD64_R11);
} else {
mono_arch_flush_icache (code, code - buf);
g_assert (code - buf <= tramp_size);
- *code_size = code - buf;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("monitor_exit_trampoline"), buf, code - buf, ji, unwind_ops);
return buf;
}
#define JUMP_TRAMPOLINE_SIZE 64
#define GEN_TRAMP_SIZE 196
-
-/*
- * Stack frame description when the generic trampoline is called.
- * caller frame
- * ------------------- old sp
- * MonoLMF
- * ------------------- sp
- */
-guchar*
-mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
-{
- MonoJumpInfo *ji;
- guint32 code_size;
- guchar *code;
- GSList *unwind_ops, *l;
-
- code = mono_arch_create_trampoline_code_full (tramp_type, &code_size, &ji, &unwind_ops, FALSE);
-
- mono_save_trampoline_xdebug_info ("<generic_trampoline>", code, code_size, unwind_ops);
-
- for (l = unwind_ops; l; l = l->next)
- g_free (l->data);
- g_slist_free (unwind_ops);
-
- return code;
-}
guchar*
-mono_arch_create_trampoline_code_full (MonoTrampolineType tramp_type, guint32 *code_size, MonoJumpInfo **ji, GSList **out_unwind_ops, gboolean aot)
+mono_arch_create_generic_trampoline_full (MonoTrampolineType tramp_type, MonoTrampInfo **info, gboolean aot)
{
guint8 *buf, *code = NULL;
guint8 *load_get_lmf_addr, *load_trampoline;
gpointer *constants;
- GSList *unwind_ops = NULL;
int cfa_offset;
-
- *ji = NULL;
+ GSList *unwind_ops = NULL;
+ MonoJumpInfo *ji = NULL;
/* Now we'll create in 'buf' the ARM trampoline code. This
is the trampoline code common to all methods */
* This is a synthetized call to mono_get_lmf_addr ()
*/
if (aot) {
- *ji = mono_patch_info_list_prepend (*ji, code - buf, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_get_lmf_addr");
+ ji = mono_patch_info_list_prepend (ji, code - buf, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_get_lmf_addr");
ARM_LDR_IMM (code, ARMREG_R0, ARMREG_PC, 0);
ARM_B (code, 0);
*(gpointer*)code = NULL;
if (aot) {
char *icall_name = g_strdup_printf ("trampoline_func_%d", tramp_type);
- *ji = mono_patch_info_list_prepend (*ji, code - buf, MONO_PATCH_INFO_JIT_ICALL_ADDR, icall_name);
+ ji = mono_patch_info_list_prepend (ji, code - buf, MONO_PATCH_INFO_JIT_ICALL_ADDR, icall_name);
ARM_LDR_IMM (code, ARMREG_IP, ARMREG_PC, 0);
ARM_B (code, 0);
*(gpointer*)code = NULL;
* Have to call the _force_ variant, since there could be a protected wrapper on the top of the stack.
*/
if (aot) {
- *ji = mono_patch_info_list_prepend (*ji, code - buf, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_thread_force_interruption_checkpoint");
+ ji = mono_patch_info_list_prepend (ji, code - buf, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_thread_force_interruption_checkpoint");
ARM_LDR_IMM (code, ARMREG_IP, ARMREG_PC, 0);
ARM_B (code, 0);
*(gpointer*)code = NULL;
/* Sanity check */
g_assert ((code - buf) <= GEN_TRAMP_SIZE);
- *code_size = code - buf;
-
- if (tramp_type == MONO_TRAMPOLINE_CLASS_INIT) {
- guint32 code_len;
-
+ if (tramp_type == MONO_TRAMPOLINE_CLASS_INIT)
/* Initialize the nullified class init trampoline used in the AOT case */
- nullified_class_init_trampoline = mono_arch_get_nullified_class_init_trampoline (&code_len);
- }
+ nullified_class_init_trampoline = mono_arch_get_nullified_class_init_trampoline (NULL);
- *out_unwind_ops = unwind_ops;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("generic_trampoline_%d", tramp_type), buf, code - buf, ji, unwind_ops);
return buf;
}
gpointer
-mono_arch_get_nullified_class_init_trampoline (guint32 *code_len)
+mono_arch_get_nullified_class_init_trampoline (MonoTrampInfo **info)
{
guint8 *buf, *code;
mono_arch_flush_icache (buf, code - buf);
- *code_len = code - buf;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("nullified_class_init_trampoline"), buf, code - buf, NULL, NULL);
return buf;
}
}
gpointer
-mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot)
-{
- guint32 code_size;
- MonoJumpInfo *ji;
-
- return mono_arch_create_rgctx_lazy_fetch_trampoline_full (slot, &code_size, &ji, FALSE);
-}
-
-gpointer
-mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, MonoTrampInfo **info, gboolean aot)
{
guint8 *tramp;
guint8 *code, *buf;
int depth, index;
int i, njumps;
gboolean mrgctx;
-
- *ji = NULL;
+ MonoJumpInfo *ji = NULL;
+ GSList *unwind_ops = NULL;
mrgctx = MONO_RGCTX_SLOT_IS_MRGCTX (slot);
index = MONO_RGCTX_SLOT_INDEX (slot);
/* The vtable/mrgctx is still in R0 */
if (aot) {
- *ji = mono_patch_info_list_prepend (*ji, code - buf, MONO_PATCH_INFO_JIT_ICALL_ADDR, g_strdup_printf ("specific_trampoline_lazy_fetch_%u", slot));
+ ji = mono_patch_info_list_prepend (ji, code - buf, MONO_PATCH_INFO_JIT_ICALL_ADDR, g_strdup_printf ("specific_trampoline_lazy_fetch_%u", slot));
ARM_LDR_IMM (code, ARMREG_R1, ARMREG_PC, 0);
ARM_B (code, 0);
*(gpointer*)code = NULL;
g_assert (code - buf <= tramp_size);
- *code_size = code - buf;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("rgctx_fetch_trampoline_%u", slot), buf, code - buf, ji, unwind_ops);
return buf;
}
#define arm_is_imm8(v) ((v) > -256 && (v) < 256)
gpointer
-mono_arch_create_generic_class_init_trampoline (void)
-{
- guint32 code_size;
- MonoJumpInfo *ji;
-
- return mono_arch_create_generic_class_init_trampoline_full (&code_size, &ji, FALSE);
-}
-
-gpointer
-mono_arch_create_generic_class_init_trampoline_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_create_generic_class_init_trampoline_full (MonoTrampInfo **info, gboolean aot)
{
guint8 *tramp;
guint8 *code, *buf;
int tramp_size;
guint32 code_len, imm8;
gint rot_amount;
-
- *ji = NULL;
+ GSList *unwind_ops = NULL;
+ MonoJumpInfo *ji = NULL;
tramp_size = 64;
arm_patch (jump, code);
if (aot) {
- *ji = mono_patch_info_list_prepend (*ji, code - buf, MONO_PATCH_INFO_JIT_ICALL_ADDR, "specific_trampoline_generic_class_init");
+ ji = mono_patch_info_list_prepend (ji, code - buf, MONO_PATCH_INFO_JIT_ICALL_ADDR, "specific_trampoline_generic_class_init");
ARM_LDR_IMM (code, ARMREG_R1, ARMREG_PC, 0);
ARM_B (code, 0);
*(gpointer*)code = NULL;
g_assert (code - buf <= tramp_size);
- *code_size = code - buf;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("generic_class_init_trampoline"), buf, code - buf, ji, unwind_ops);
return buf;
}
#else
guchar*
-mono_arch_create_trampoline_code_full (MonoTrampolineType tramp_type, guint32 *code_size, MonoJumpInfo **ji, GSList **out_unwind_ops, gboolean aot)
-{
- g_assert_not_reached ();
- return NULL;
-}
-
-guchar*
-mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
-{
- g_assert_not_reached ();
- return NULL;
-}
-
-gpointer
-mono_arch_get_nullified_class_init_trampoline (guint32 *code_len)
+mono_arch_create_generic_trampoline_full (MonoTrampolineType tramp_type, MonoTrampInfo **info, gboolean aot)
{
g_assert_not_reached ();
return NULL;
}
gpointer
-mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot)
-{
- g_assert_not_reached ();
- return NULL;
-}
-
-gpointer
-mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
-{
- g_assert_not_reached ();
- return NULL;
-}
-
-gpointer
-mono_arch_create_generic_class_init_trampoline (void)
+mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, MonoTrampInfo **info, gboolean aot)
{
g_assert_not_reached ();
return NULL;
}
gpointer
-mono_arch_create_generic_class_init_trampoline_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_create_generic_class_init_trampoline_full (MonoTrampInfo **info, gboolean aot)
{
g_assert_not_reached ();
return NULL;
#define PPC_TOC_REG -1
#endif
-guchar*
-mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
-{
- MonoJumpInfo *ji;
- guint32 code_size;
- guchar *code;
- GSList *unwind_ops, *l;
-
- code = mono_arch_create_trampoline_code_full (tramp_type, &code_size, &ji, &unwind_ops, FALSE);
-
- //mono_save_trampoline_xdebug_info ("<generic_trampoline>", code, code_size, unwind_ops);
-
- for (l = unwind_ops; l; l = l->next)
- g_free (l->data);
- g_slist_free (unwind_ops);
-
- return code;
-}
-
/*
* Stack frame description when the generic trampoline is called.
* caller frame
* -------------------
*/
guchar*
-mono_arch_create_trampoline_code_full (MonoTrampolineType tramp_type, guint32 *code_size, MonoJumpInfo **ji, GSList **out_unwind_ops, gboolean aot)
+mono_arch_create_generic_trampoline_full (MonoTrampolineType tramp_type, MonoTrampInfo **info, gboolean aot)
{
+
guint8 *buf, *code = NULL;
int i, offset;
gconstpointer tramp_handler;
int size = MONO_PPC_32_64_CASE (600, 800);
+ GSList *unwind_ops = NULL;
+ MonoJumpInfo *ji = NULL;
/* Now we'll create in 'buf' the PowerPC trampoline code. This
is the trampoline code common to all methods */
code = buf = mono_global_codeman_reserve (size);
- *ji = NULL;
- *out_unwind_ops = NULL;
-
- ppc_str_update (buf, ppc_r1, -STACK, ppc_r1);
+ ppc_str_update (code, ppc_r1, -STACK, ppc_r1);
/* start building the MonoLMF on the stack */
offset = STACK - sizeof (double) * MONO_SAVED_FREGS;
for (i = 14; i < 32; i++) {
- ppc_stfd (buf, i, offset, ppc_r1);
+ ppc_stfd (code, i, offset, ppc_r1);
offset += sizeof (double);
}
/*
* now the integer registers.
*/
offset = STACK - sizeof (MonoLMF) + G_STRUCT_OFFSET (MonoLMF, iregs);
- ppc_str_multiple (buf, ppc_r13, offset, ppc_r1);
+ ppc_str_multiple (code, ppc_r13, offset, ppc_r1);
/* Now save the rest of the registers below the MonoLMF struct, first 14
* fp regs and then the 31 gregs.
*/
offset = STACK - sizeof (MonoLMF) - (14 * sizeof (double));
for (i = 0; i < 14; i++) {
- ppc_stfd (buf, i, offset, ppc_r1);
+ ppc_stfd (code, i, offset, ppc_r1);
offset += sizeof (double);
}
#define GREGS_OFFSET (STACK - sizeof (MonoLMF) - (14 * sizeof (double)) - (31 * sizeof (mgreg_t)))
offset = GREGS_OFFSET;
for (i = 0; i < 31; i++) {
- ppc_str (buf, i, offset, ppc_r1);
+ ppc_str (code, i, offset, ppc_r1);
offset += sizeof (mgreg_t);
}
* in the parent frame (we do it here to reduce the size of the
* method-specific trampoline)
*/
- ppc_mflr (buf, ppc_r0);
- ppc_str (buf, ppc_r0, STACK + PPC_RET_ADDR_OFFSET, ppc_r1);
+ ppc_mflr (code, ppc_r0);
+ ppc_str (code, ppc_r0, STACK + PPC_RET_ADDR_OFFSET, ppc_r1);
/* ok, now we can continue with the MonoLMF setup, mostly untouched
* from emit_prolog in mini-ppc.c
*/
if (aot) {
- buf = mono_arch_emit_load_aotconst (code, buf, ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_get_lmf_addr");
+ code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_get_lmf_addr");
#ifdef PPC_USES_FUNCTION_DESCRIPTOR
- ppc_ldptr (buf, ppc_r2, sizeof (gpointer), ppc_r11);
- ppc_ldptr (buf, ppc_r11, 0, ppc_r11);
+ ppc_ldptr (code, ppc_r2, sizeof (gpointer), ppc_r11);
+ ppc_ldptr (code, ppc_r11, 0, ppc_r11);
#endif
- ppc_mtlr (buf, ppc_r11);
- ppc_blrl (buf);
+ ppc_mtlr (code, ppc_r11);
+ ppc_blrl (code);
} else {
- ppc_load_func (buf, ppc_r0, mono_get_lmf_addr);
- ppc_mtlr (buf, ppc_r0);
- ppc_blrl (buf);
+ ppc_load_func (code, ppc_r0, mono_get_lmf_addr);
+ ppc_mtlr (code, ppc_r0);
+ ppc_blrl (code);
}
/* we build the MonoLMF structure on the stack - see mini-ppc.h
* The pointer to the struct is put in ppc_r11.
*/
- ppc_addi (buf, ppc_r11, ppc_sp, STACK - sizeof (MonoLMF));
- ppc_stptr (buf, ppc_r3, G_STRUCT_OFFSET(MonoLMF, lmf_addr), ppc_r11);
+ ppc_addi (code, ppc_r11, ppc_sp, STACK - sizeof (MonoLMF));
+ ppc_stptr (code, ppc_r3, G_STRUCT_OFFSET(MonoLMF, lmf_addr), ppc_r11);
/* new_lmf->previous_lmf = *lmf_addr */
- ppc_ldptr (buf, ppc_r0, G_STRUCT_OFFSET(MonoLMF, previous_lmf), ppc_r3);
- ppc_stptr (buf, ppc_r0, G_STRUCT_OFFSET(MonoLMF, previous_lmf), ppc_r11);
+ ppc_ldptr (code, ppc_r0, G_STRUCT_OFFSET(MonoLMF, previous_lmf), ppc_r3);
+ ppc_stptr (code, ppc_r0, G_STRUCT_OFFSET(MonoLMF, previous_lmf), ppc_r11);
/* *(lmf_addr) = r11 */
- ppc_stptr (buf, ppc_r11, G_STRUCT_OFFSET(MonoLMF, previous_lmf), ppc_r3);
+ ppc_stptr (code, ppc_r11, G_STRUCT_OFFSET(MonoLMF, previous_lmf), ppc_r3);
/* save method info (it's stored on the stack, so get it first). */
if ((tramp_type == MONO_TRAMPOLINE_JIT) || (tramp_type == MONO_TRAMPOLINE_JUMP)) {
- ppc_ldr (buf, ppc_r0, GREGS_OFFSET, ppc_r1);
- ppc_stptr (buf, ppc_r0, G_STRUCT_OFFSET(MonoLMF, method), ppc_r11);
+ ppc_ldr (code, ppc_r0, GREGS_OFFSET, ppc_r1);
+ ppc_stptr (code, ppc_r0, G_STRUCT_OFFSET(MonoLMF, method), ppc_r11);
} else {
- ppc_load (buf, ppc_r0, 0);
- ppc_stptr (buf, ppc_r0, G_STRUCT_OFFSET(MonoLMF, method), ppc_r11);
+ ppc_load (code, ppc_r0, 0);
+ ppc_stptr (code, ppc_r0, G_STRUCT_OFFSET(MonoLMF, method), ppc_r11);
}
/* store the frame pointer of the calling method */
- ppc_addi (buf, ppc_r0, ppc_sp, STACK);
- ppc_stptr (buf, ppc_r0, G_STRUCT_OFFSET(MonoLMF, ebp), ppc_r11);
+ ppc_addi (code, ppc_r0, ppc_sp, STACK);
+ ppc_stptr (code, ppc_r0, G_STRUCT_OFFSET(MonoLMF, ebp), ppc_r11);
/* save the IP (caller ip) */
if (tramp_type == MONO_TRAMPOLINE_JUMP) {
- ppc_li (buf, ppc_r0, 0);
+ ppc_li (code, ppc_r0, 0);
} else {
- ppc_ldr (buf, ppc_r0, STACK + PPC_RET_ADDR_OFFSET, ppc_r1);
+ ppc_ldr (code, ppc_r0, STACK + PPC_RET_ADDR_OFFSET, ppc_r1);
}
- ppc_stptr (buf, ppc_r0, G_STRUCT_OFFSET(MonoLMF, eip), ppc_r11);
+ ppc_stptr (code, ppc_r0, G_STRUCT_OFFSET(MonoLMF, eip), ppc_r11);
/*
* Now we're ready to call trampoline (mgreg_t *regs, guint8 *code, gpointer value, guint8 *tramp)
* Note that the last argument is unused.
*/
/* Arg 1: a pointer to the registers */
- ppc_addi (buf, ppc_r3, ppc_r1, GREGS_OFFSET);
+ ppc_addi (code, ppc_r3, ppc_r1, GREGS_OFFSET);
/* Arg 2: code (next address to the instruction that called us) */
if (tramp_type == MONO_TRAMPOLINE_JUMP)
- ppc_li (buf, ppc_r4, 0);
+ ppc_li (code, ppc_r4, 0);
else
- ppc_ldr (buf, ppc_r4, STACK + PPC_RET_ADDR_OFFSET, ppc_r1);
+ ppc_ldr (code, ppc_r4, STACK + PPC_RET_ADDR_OFFSET, ppc_r1);
/* Arg 3: trampoline argument */
if (tramp_type == MONO_TRAMPOLINE_GENERIC_CLASS_INIT)
- ppc_ldr (buf, ppc_r5, GREGS_OFFSET + MONO_ARCH_VTABLE_REG * sizeof (mgreg_t), ppc_r1);
+ ppc_ldr (code, ppc_r5, GREGS_OFFSET + MONO_ARCH_VTABLE_REG * sizeof (mgreg_t), ppc_r1);
else
- ppc_ldr (buf, ppc_r5, GREGS_OFFSET, ppc_r1);
+ ppc_ldr (code, ppc_r5, GREGS_OFFSET, ppc_r1);
if (aot) {
- buf = mono_arch_emit_load_aotconst (code, buf, ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, g_strdup_printf ("trampoline_func_%d", tramp_type));
+ code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, g_strdup_printf ("trampoline_func_%d", tramp_type));
#ifdef PPC_USES_FUNCTION_DESCRIPTOR
- ppc_ldptr (buf, ppc_r2, sizeof (gpointer), ppc_r11);
- ppc_ldptr (buf, ppc_r11, 0, ppc_r11);
+ ppc_ldptr (code, ppc_r2, sizeof (gpointer), ppc_r11);
+ ppc_ldptr (code, ppc_r11, 0, ppc_r11);
#endif
- ppc_mtlr (buf, ppc_r11);
- ppc_blrl (buf);
+ ppc_mtlr (code, ppc_r11);
+ ppc_blrl (code);
} else {
tramp_handler = mono_get_trampoline_func (tramp_type);
- ppc_load_func (buf, ppc_r0, tramp_handler);
- ppc_mtlr (buf, ppc_r0);
- ppc_blrl (buf);
+ ppc_load_func (code, ppc_r0, tramp_handler);
+ ppc_mtlr (code, ppc_r0);
+ ppc_blrl (code);
}
/* OK, code address is now on r3. Move it to the counter reg
*/
if (!MONO_TRAMPOLINE_TYPE_MUST_RETURN (tramp_type)) {
#ifdef PPC_USES_FUNCTION_DESCRIPTOR
- ppc_ldptr (buf, ppc_r2, sizeof (gpointer), ppc_r3);
- ppc_ldptr (buf, ppc_r3, 0, ppc_r3);
+ ppc_ldptr (code, ppc_r2, sizeof (gpointer), ppc_r3);
+ ppc_ldptr (code, ppc_r3, 0, ppc_r3);
#endif
- ppc_mtctr (buf, ppc_r3);
+ ppc_mtctr (code, ppc_r3);
}
/*
* the same state as before we executed.
* The pointer to MonoLMF is in ppc_r11.
*/
- ppc_addi (buf, ppc_r11, ppc_r1, STACK - sizeof (MonoLMF));
+ ppc_addi (code, ppc_r11, ppc_r1, STACK - sizeof (MonoLMF));
/* r5 = previous_lmf */
- ppc_ldptr (buf, ppc_r5, G_STRUCT_OFFSET(MonoLMF, previous_lmf), ppc_r11);
+ ppc_ldptr (code, ppc_r5, G_STRUCT_OFFSET(MonoLMF, previous_lmf), ppc_r11);
/* r6 = lmf_addr */
- ppc_ldptr (buf, ppc_r6, G_STRUCT_OFFSET(MonoLMF, lmf_addr), ppc_r11);
+ ppc_ldptr (code, ppc_r6, G_STRUCT_OFFSET(MonoLMF, lmf_addr), ppc_r11);
/* *(lmf_addr) = previous_lmf */
- ppc_stptr (buf, ppc_r5, G_STRUCT_OFFSET(MonoLMF, previous_lmf), ppc_r6);
+ ppc_stptr (code, ppc_r5, G_STRUCT_OFFSET(MonoLMF, previous_lmf), ppc_r6);
/* restore iregs */
- ppc_ldr_multiple (buf, ppc_r13, G_STRUCT_OFFSET(MonoLMF, iregs), ppc_r11);
+ ppc_ldr_multiple (code, ppc_r13, G_STRUCT_OFFSET(MonoLMF, iregs), ppc_r11);
/* restore fregs */
for (i = 14; i < 32; i++)
- ppc_lfd (buf, i, G_STRUCT_OFFSET(MonoLMF, fregs) + ((i-14) * sizeof (gdouble)), ppc_r11);
+ ppc_lfd (code, i, G_STRUCT_OFFSET(MonoLMF, fregs) + ((i-14) * sizeof (gdouble)), ppc_r11);
/* restore the volatile registers, we skip r1, of course */
offset = STACK - sizeof (MonoLMF) - (14 * sizeof (double));
for (i = 0; i < 14; i++) {
- ppc_lfd (buf, i, offset, ppc_r1);
+ ppc_lfd (code, i, offset, ppc_r1);
offset += sizeof (double);
}
offset = STACK - sizeof (MonoLMF) - (14 * sizeof (double)) - (31 * sizeof (mgreg_t));
- ppc_ldr (buf, ppc_r0, offset, ppc_r1);
+ ppc_ldr (code, ppc_r0, offset, ppc_r1);
offset += 2 * sizeof (mgreg_t);
for (i = 2; i < 13; i++) {
if (i != PPC_TOC_REG && (i != 3 || tramp_type != MONO_TRAMPOLINE_RGCTX_LAZY_FETCH))
- ppc_ldr (buf, i, offset, ppc_r1);
+ ppc_ldr (code, i, offset, ppc_r1);
offset += sizeof (mgreg_t);
}
* return, we just jump to the compiled code.
*/
/* Restore stack pointer and LR and jump to the code */
- ppc_ldr (buf, ppc_r1, 0, ppc_r1);
- ppc_ldr (buf, ppc_r11, PPC_RET_ADDR_OFFSET, ppc_r1);
- ppc_mtlr (buf, ppc_r11);
+ ppc_ldr (code, ppc_r1, 0, ppc_r1);
+ ppc_ldr (code, ppc_r11, PPC_RET_ADDR_OFFSET, ppc_r1);
+ ppc_mtlr (code, ppc_r11);
if (MONO_TRAMPOLINE_TYPE_MUST_RETURN (tramp_type))
- ppc_blr (buf);
+ ppc_blr (code);
else
- ppc_bcctr (buf, 20, 0);
+ ppc_bcctr (code, 20, 0);
/* Flush instruction cache, since we've generated code */
- mono_arch_flush_icache (code, buf - code);
+ mono_arch_flush_icache (buf, code - buf);
- *code_size = buf - code;
-
/* Sanity check */
- g_assert ((buf - code) <= size);
+ g_assert ((code - buf) <= size);
if (tramp_type == MONO_TRAMPOLINE_CLASS_INIT) {
- guint32 code_len;
-
/* Initialize the nullified class init trampoline */
- nullified_class_init_trampoline = mono_ppc_create_ftnptr (mono_arch_get_nullified_class_init_trampoline (&code_len));
+ nullified_class_init_trampoline = mono_ppc_create_ftnptr (mono_arch_get_nullified_class_init_trampoline (NULL));
}
- return code;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("generic_trampoline_%d", tramp_type), buf, code - buf, ji, unwind_ops);
+
+ return buf;
}
#define TRAMPOLINE_SIZE (MONO_PPC_32_64_CASE (24, (5+5+1+1)*4))
mono_domain_unlock (domain);
if (short_branch) {
- ppc_load_sequence (buf, ppc_r0, (mgreg_t)(gsize) arg1);
- ppc_emit32 (buf, short_branch);
+ ppc_load_sequence (code, ppc_r0, (mgreg_t)(gsize) arg1);
+ ppc_emit32 (code, short_branch);
} else {
/* Prepare the jump to the generic trampoline code.*/
- ppc_load_ptr (buf, ppc_r0, tramp);
- ppc_mtctr (buf, ppc_r0);
+ ppc_load_ptr (code, ppc_r0, tramp);
+ ppc_mtctr (code, ppc_r0);
/* And finally put 'arg1' in r0 and fly! */
- ppc_load_ptr (buf, ppc_r0, arg1);
- ppc_bcctr (buf, 20, 0);
+ ppc_load_ptr (code, ppc_r0, arg1);
+ ppc_bcctr (code, 20, 0);
}
/* Flush instruction cache, since we've generated code */
- mono_arch_flush_icache (code, buf - code);
+ mono_arch_flush_icache (buf, code - buf);
+
+ g_assert ((code - buf) <= TRAMPOLINE_SIZE);
- g_assert ((buf - code) <= TRAMPOLINE_SIZE);
if (code_len)
- *code_len = buf - code;
+ *code_len = code - buf;
- return code;
+ return buf;
}
static guint8*
}
gpointer
-mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot)
-{
- guint32 code_size;
- MonoJumpInfo *ji;
-
- return mono_arch_create_rgctx_lazy_fetch_trampoline_full (slot, &code_size, &ji, FALSE);
-}
-
-gpointer
-mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, MonoTrampInfo **info, gboolean aot)
{
#ifdef MONO_ARCH_VTABLE_REG
guint8 *tramp;
int depth, index;
int i;
gboolean mrgctx;
-
- *ji = NULL;
+ MonoJumpInfo *ji = NULL;
+ GSList *unwind_ops = NULL;
mrgctx = MONO_RGCTX_SLOT_IS_MRGCTX (slot);
index = MONO_RGCTX_SLOT_INDEX (slot);
ppc_mr (code, MONO_ARCH_VTABLE_REG, ppc_r3);
if (aot) {
- code = mono_arch_emit_load_aotconst (buf, code, ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, g_strdup_printf ("specific_trampoline_lazy_fetch_%u", slot));
+ code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, g_strdup_printf ("specific_trampoline_lazy_fetch_%u", slot));
/* Branch to the trampoline */
#ifdef PPC_USES_FUNCTION_DESCRIPTOR
ppc_ldptr (code, ppc_r11, 0, ppc_r11);
g_assert (code - buf <= tramp_size);
- *code_size = code - buf;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("rgctx_fetch_trampoline_%u", slot), buf, code - buf, ji, unwind_ops);
return buf;
#else
}
gpointer
-mono_arch_create_generic_class_init_trampoline (void)
-{
- guint32 code_size;
- MonoJumpInfo *ji;
-
- return mono_arch_create_generic_class_init_trampoline_full (&code_size, &ji, FALSE);
-}
-
-gpointer
-mono_arch_create_generic_class_init_trampoline_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_create_generic_class_init_trampoline_full (MonoTrampInfo **info, gboolean aot)
{
guint8 *tramp;
guint8 *code, *buf;
static guint8 bitmask;
guint8 *jump;
int tramp_size;
+ GSList *unwind_ops = NULL;
+ MonoJumpInfo *ji = NULL;
tramp_size = MONO_PPC_32_64_CASE (32, 44);
if (aot)
code = buf = mono_global_codeman_reserve (tramp_size);
- *ji = NULL;
-
if (byte_offset < 0)
mono_marshal_find_bitfield_offset (MonoVTable, initialized, &byte_offset, &bitmask);
ppc_patch (jump, code);
if (aot) {
- code = mono_arch_emit_load_aotconst (buf, code, ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "specific_trampoline_generic_class_init");
+ code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "specific_trampoline_generic_class_init");
/* Branch to the trampoline */
#ifdef PPC_USES_FUNCTION_DESCRIPTOR
ppc_ldptr (code, ppc_r11, 0, ppc_r11);
mono_arch_flush_icache (buf, code - buf);
- *code_size = code - buf;
-
g_assert (code - buf <= tramp_size);
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("generic_class_init_trampoline"), buf, code - buf, ji, unwind_ops);
+
return buf;
}
gpointer
-mono_arch_get_nullified_class_init_trampoline (guint32 *code_len)
+mono_arch_get_nullified_class_init_trampoline (MonoTrampInfo **info)
{
guint8 *code, *buf;
guint32 tramp_size = 64;
mono_arch_flush_icache (buf, code - buf);
- *code_len = code - buf;
-
g_assert (code - buf <= tramp_size);
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("nullified_class_init_trampoline"), buf, code - buf, NULL, NULL);
+
return buf;
}
}
guchar*
-mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
-{
- MonoJumpInfo *ji;
- guint32 code_size;
- guchar *code;
- GSList *unwind_ops, *l;
-
- code = mono_arch_create_trampoline_code_full (tramp_type, &code_size, &ji, &unwind_ops, FALSE);
-
- mono_save_trampoline_xdebug_info ("<generic_trampoline>", code, code_size, unwind_ops);
-
- for (l = unwind_ops; l; l = l->next)
- g_free (l->data);
- g_slist_free (unwind_ops);
-
- return code;
-}
-
-guchar*
-mono_arch_create_trampoline_code_full (MonoTrampolineType tramp_type, guint32 *code_size, MonoJumpInfo **ji, GSList **out_unwind_ops, gboolean aot)
+mono_arch_create_generic_trampoline_full (MonoTrampolineType tramp_type, MonoTrampInfo **info, gboolean aot)
{
guint8 *buf, *code, *tramp;
int pushed_args, pushed_args_caller_saved;
GSList *unwind_ops = NULL;
+ MonoJumpInfo *ji = NULL;
code = buf = mono_global_codeman_reserve (256);
- *ji = NULL;
-
/* Note that there is a single argument to the trampoline
* and it is stored at: esp + pushed_args * sizeof (gpointer)
* the ret address is at: esp + (pushed_args + 1) * sizeof (gpointer)
/* get the address of lmf for the current thread */
if (aot) {
- code = mono_arch_emit_load_aotconst (buf, code, ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_get_lmf_addr");
+ code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_get_lmf_addr");
x86_call_reg (code, X86_EAX);
} else {
x86_call_code (code, mono_get_lmf_addr);
if (aot) {
char *icall_name = g_strdup_printf ("trampoline_func_%d", tramp_type);
- code = mono_arch_emit_load_aotconst (buf, code, ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, icall_name);
+ code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, icall_name);
x86_call_reg (code, X86_EAX);
} else {
tramp = (guint8*)mono_get_trampoline_func (tramp_type);
x86_alu_reg_imm (code, X86_SUB, X86_ESP, 3 * 4);
x86_push_reg (code, X86_EAX);
if (aot) {
- code = mono_arch_emit_load_aotconst (buf, code, ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_thread_force_interruption_checkpoint");
+ code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_thread_force_interruption_checkpoint");
x86_call_reg (code, X86_EAX);
} else {
x86_call_code (code, (guint8*)mono_thread_force_interruption_checkpoint);
g_assert ((code - buf) <= 256);
- *code_size = code - buf;
-
if (tramp_type == MONO_TRAMPOLINE_CLASS_INIT) {
/* Initialize the nullified class init trampoline used in the AOT case */
nullified_class_init_trampoline = code = mono_global_codeman_reserve (16);
x86_ret (code);
}
- *out_unwind_ops = unwind_ops;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("generic_trampoline_%d", tramp_type), buf, code - buf, ji, unwind_ops);
return buf;
}
gpointer
-mono_arch_get_nullified_class_init_trampoline (guint32 *code_len)
+mono_arch_get_nullified_class_init_trampoline (MonoTrampInfo **info)
{
guint8 *code, *buf;
mono_arch_flush_icache (buf, code - buf);
- *code_len = code - buf;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("nullified_class_init_trampoline"), buf, code - buf, NULL, NULL);
return buf;
}
}
gpointer
-mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot)
-{
- guint32 code_size;
- MonoJumpInfo *ji;
-
- return mono_arch_create_rgctx_lazy_fetch_trampoline_full (slot, &code_size, &ji, FALSE);
-}
-
-gpointer
-mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, MonoTrampInfo **info, gboolean aot)
{
guint8 *tramp;
guint8 *code, *buf;
int depth, index;
int i;
gboolean mrgctx;
-
- *ji = NULL;
+ MonoJumpInfo *ji = NULL;
+ GSList *unwind_ops = NULL;
mrgctx = MONO_RGCTX_SLOT_IS_MRGCTX (slot);
index = MONO_RGCTX_SLOT_INDEX (slot);
x86_mov_reg_membase (code, MONO_ARCH_VTABLE_REG, X86_ESP, 4, 4);
if (aot) {
- code = mono_arch_emit_load_aotconst (buf, code, ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, g_strdup_printf ("specific_trampoline_lazy_fetch_%u", slot));
+ code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, g_strdup_printf ("specific_trampoline_lazy_fetch_%u", slot));
x86_jump_reg (code, X86_EAX);
} else {
tramp = mono_arch_create_specific_trampoline (GUINT_TO_POINTER (slot), MONO_TRAMPOLINE_RGCTX_LAZY_FETCH, mono_get_root_domain (), NULL);
g_assert (code - buf <= tramp_size);
- *code_size = code - buf;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("rgctx_fetch_trampoline_%u", slot), buf, code - buf, ji, unwind_ops);
return buf;
}
gpointer
-mono_arch_create_generic_class_init_trampoline (void)
-{
- guint32 code_size;
- MonoJumpInfo *ji;
-
- return mono_arch_create_generic_class_init_trampoline_full (&code_size, &ji, FALSE);
-}
-
-gpointer
-mono_arch_create_generic_class_init_trampoline_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_create_generic_class_init_trampoline_full (MonoTrampInfo **info, gboolean aot)
{
guint8 *tramp;
guint8 *code, *buf;
static guint8 bitmask;
guint8 *jump;
int tramp_size;
+ GSList *unwind_ops = NULL;
+ MonoJumpInfo *ji = NULL;
tramp_size = 64;
code = buf = mono_global_codeman_reserve (tramp_size);
- *ji = NULL;
-
if (byte_offset < 0)
mono_marshal_find_bitfield_offset (MonoVTable, initialized, &byte_offset, &bitmask);
x86_push_reg (code, MONO_ARCH_VTABLE_REG);
if (aot) {
- code = mono_arch_emit_load_aotconst (buf, code, ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "generic_trampoline_generic_class_init");
+ code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "generic_trampoline_generic_class_init");
x86_jump_reg (code, X86_EAX);
} else {
tramp = mono_get_trampoline_code (MONO_TRAMPOLINE_GENERIC_CLASS_INIT);
g_assert (code - buf <= tramp_size);
- *code_size = code - buf;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("generic_class_init_trampoline"), buf, code - buf, ji, unwind_ops);
return buf;
}
*
*/
gpointer
-mono_arch_create_monitor_enter_trampoline (void)
-{
- guint32 code_size;
- MonoJumpInfo *ji;
-
- return mono_arch_create_monitor_enter_trampoline_full (&code_size, &ji, FALSE);
-}
-
-gpointer
-mono_arch_create_monitor_enter_trampoline_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_create_monitor_enter_trampoline_full (MonoTrampInfo **info, gboolean aot)
{
guint8 *tramp = mono_get_trampoline_code (MONO_TRAMPOLINE_MONITOR_ENTER);
guint8 *code, *buf;
guint8 *jump_obj_null, *jump_sync_null, *jump_other_owner, *jump_cmpxchg_failed, *jump_tid;
int tramp_size;
int owner_offset, nest_offset, dummy;
-
- *ji = NULL;
+ MonoJumpInfo *ji = NULL;
+ GSList *unwind_ops = NULL;
g_assert (MONO_ARCH_MONITOR_OBJECT_REG == X86_EAX);
/* We are calling the generic trampoline directly, the argument is pushed
* on the stack just like a specific trampoline.
*/
- code = mono_arch_emit_load_aotconst (buf, code, ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "generic_trampoline_monitor_enter");
+ code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "generic_trampoline_monitor_enter");
x86_jump_reg (code, X86_EAX);
} else {
x86_jump_code (code, tramp);
/* push obj and jump to the actual trampoline */
x86_push_reg (code, X86_EAX);
if (aot) {
- code = mono_arch_emit_load_aotconst (buf, code, ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "generic_trampoline_monitor_enter");
+ code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "generic_trampoline_monitor_enter");
x86_jump_reg (code, X86_EAX);
} else {
x86_jump_code (code, tramp);
mono_arch_flush_icache (buf, code - buf);
g_assert (code - buf <= tramp_size);
- *code_size = code - buf;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("monitor_enter_trampoline"), buf, code - buf, ji, unwind_ops);
return buf;
}
gpointer
-mono_arch_create_monitor_exit_trampoline (void)
-{
- guint32 code_size;
- MonoJumpInfo *ji;
-
- return mono_arch_create_monitor_exit_trampoline_full (&code_size, &ji, FALSE);
-}
-
-gpointer
-mono_arch_create_monitor_exit_trampoline_full (guint32 *code_size, MonoJumpInfo **ji, gboolean aot)
+mono_arch_create_monitor_exit_trampoline_full (MonoTrampInfo **info, gboolean aot)
{
guint8 *tramp = mono_get_trampoline_code (MONO_TRAMPOLINE_MONITOR_EXIT);
guint8 *code, *buf;
guint8 *jump_next;
int tramp_size;
int owner_offset, nest_offset, entry_count_offset;
-
- *ji = NULL;
+ MonoJumpInfo *ji = NULL;
+ GSList *unwind_ops = NULL;
g_assert (MONO_ARCH_MONITOR_OBJECT_REG == X86_EAX);
/* push obj and jump to the actual trampoline */
x86_push_reg (code, X86_EAX);
if (aot) {
- code = mono_arch_emit_load_aotconst (buf, code, ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "generic_trampoline_monitor_exit");
+ code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "generic_trampoline_monitor_exit");
x86_jump_reg (code, X86_EAX);
} else {
x86_jump_code (code, tramp);
mono_arch_flush_icache (buf, code - buf);
g_assert (code - buf <= tramp_size);
- *code_size = code - buf;
+ if (info)
+ *info = mono_tramp_info_create (g_strdup_printf ("monitor_exit_trampoline"), buf, code - buf, ji, unwind_ops);
return buf;
}