2010-05-01 Zoltan Varga <vargaz@gmail.com>
authorZoltan Varga <vargaz@gmail.com>
Sat, 1 May 2010 17:24:17 +0000 (17:24 -0000)
committerZoltan Varga <vargaz@gmail.com>
Sat, 1 May 2010 17:24:17 +0000 (17:24 -0000)
* 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.

svn path=/trunk/mono/; revision=156572

14 files changed:
mono/mini/ChangeLog
mono/mini/aot-compiler.c
mono/mini/exceptions-amd64.c
mono/mini/exceptions-arm.c
mono/mini/exceptions-ppc.c
mono/mini/exceptions-x86.c
mono/mini/mini-amd64.h
mono/mini/mini-exceptions.c
mono/mini/mini-trampolines.c
mono/mini/mini.h
mono/mini/tramp-amd64.c
mono/mini/tramp-arm.c
mono/mini/tramp-ppc.c
mono/mini/tramp-x86.c

index cc1d89039d110f3620f52c6bd08231395f3b7f2f..269446d70ada5623f917b38b934fd8cf8f96d430 100755 (executable)
@@ -1,3 +1,11 @@
+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.
index bc8ba55d505b71e536fe2e6ee88cb68a4ec7bbbd..2306c2b1477e159683969a19712e49af61788e94 100644 (file)
@@ -3691,8 +3691,7 @@ emit_plt (MonoAotCompile *acfg)
 }
 
 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];
@@ -3700,6 +3699,17 @@ emit_trampoline (MonoAotCompile *acfg, const char *name, guint8 *code,
        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 */
 
@@ -3767,10 +3777,7 @@ emit_trampolines (MonoAotCompile *acfg)
        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)
@@ -3781,6 +3788,8 @@ emit_trampolines (MonoAotCompile *acfg)
        /* 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.
                 *
@@ -3789,60 +3798,49 @@ emit_trampolines (MonoAotCompile *acfg)
                 * 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);
                }
 
                {
@@ -3853,7 +3851,7 @@ emit_trampolines (MonoAotCompile *acfg)
                        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;
                        }
                }
index 7ab4d62976dfa514b8a3756e945be6b1127a62c1..b6a551cb0ea072bece52c8a05785b769697691f8 100644 (file)
@@ -152,15 +152,15 @@ void win32_seh_set_handler(int type, MonoW32ExceptionHandler handler)
  * 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);
@@ -197,7 +197,8 @@ mono_arch_get_restore_context_full (guint32 *code_size, MonoJumpInfo **ji, gbool
 
        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;
 }
@@ -210,14 +211,14 @@ mono_arch_get_restore_context_full (guint32 *code_size, MonoJumpInfo **ji, gbool
  * @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);
 
@@ -278,7 +279,8 @@ mono_arch_get_call_filter_full (guint32 *code_size, MonoJumpInfo **ji, gboolean
 
        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;
 }
@@ -349,18 +351,17 @@ mono_amd64_throw_exception (guint64 dummy1, guint64 dummy2, guint64 dummy3, guin
 }
 
 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);
@@ -402,7 +403,7 @@ get_throw_trampoline (gboolean rethrow, guint32 *code_size, MonoJumpInfo **ji, g
 #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);
@@ -414,10 +415,11 @@ get_throw_trampoline (gboolean rethrow, guint32 *code_size, MonoJumpInfo **ji, g
 
        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;
 }
 
@@ -430,15 +432,15 @@ get_throw_trampoline (gboolean rethrow, guint32 *code_size, MonoJumpInfo **ji, g
  *
  */
 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);
 }
 
 /**
@@ -452,25 +454,24 @@ mono_arch_get_rethrow_exception_full (guint32 *code_size, MonoJumpInfo **ji, gbo
  * 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);
@@ -498,7 +499,7 @@ mono_arch_get_throw_corlib_exception_full (guint32 *code_size, MonoJumpInfo **ji
        /* 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);
@@ -510,7 +511,8 @@ mono_arch_get_throw_corlib_exception_full (guint32 *code_size, MonoJumpInfo **ji
 
        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;
 }
@@ -939,13 +941,13 @@ mono_amd64_get_original_ip (void)
 }
 
 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);
 
@@ -967,7 +969,7 @@ mono_arch_get_throw_pending_exception_full (guint32 *code_size, MonoJumpInfo **j
 
        /* 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);
@@ -987,7 +989,7 @@ mono_arch_get_throw_pending_exception_full (guint32 *code_size, MonoJumpInfo **j
 
        /* 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);
@@ -1008,7 +1010,7 @@ mono_arch_get_throw_pending_exception_full (guint32 *code_size, MonoJumpInfo **j
 
        /* 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 ();
@@ -1022,7 +1024,7 @@ mono_arch_get_throw_pending_exception_full (guint32 *code_size, MonoJumpInfo **j
 
        /* 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);
@@ -1042,7 +1044,8 @@ mono_arch_get_throw_pending_exception_full (guint32 *code_size, MonoJumpInfo **j
 
        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;
 }
@@ -1083,14 +1086,11 @@ mono_arch_notify_pending_exc (void)
 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);
        }
 }
 
index bc17e5509d0fd9c0ccf6ba842ec52d6631ac47b7..1436fe1740fce95c05219f4a13a0b518809e66b2 100644 (file)
@@ -110,13 +110,13 @@ typedef struct my_ucontext {
  * 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);
 
@@ -148,7 +148,8 @@ mono_arch_get_restore_context_full (guint32 *code_size, MonoJumpInfo **ji, gbool
 
        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;
 }
@@ -161,13 +162,13 @@ mono_arch_get_restore_context_full (guint32 *code_size, MonoJumpInfo **ji, gbool
  * @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);
@@ -193,7 +194,8 @@ mono_arch_get_call_filter_full (guint32 *code_size, MonoJumpInfo **ji, gboolean
 
        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;
 }
@@ -245,12 +247,12 @@ mono_arm_throw_exception_by_token (guint32 type_token, unsigned long eip, unsign
  *
  */
 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);
 
@@ -262,7 +264,7 @@ mono_arch_get_throw_exception_generic (int size, int by_token, gboolean rethrow,
        /* 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 */
@@ -276,14 +278,14 @@ mono_arch_get_throw_exception_generic (int size, int by_token, gboolean rethrow,
        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);
@@ -292,7 +294,8 @@ mono_arch_get_throw_exception_generic (int size, int by_token, gboolean rethrow,
        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;
 }
@@ -306,9 +309,9 @@ mono_arch_get_throw_exception_generic (int size, int by_token, gboolean rethrow,
  *
  */
 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);
 }
 
 /**
@@ -324,9 +327,9 @@ mono_arch_get_rethrow_exception_full (guint32 *code_size, MonoJumpInfo **ji, gbo
  *
  */
 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);
 }
 
 /**
@@ -341,9 +344,9 @@ mono_arch_get_throw_exception_full (guint32 *code_size, MonoJumpInfo **ji, gbool
  * 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);
 }      
 
 /* 
index ef7fc5c479c3784b3f287f237a117e109e0ff1f2..f5a1dbad3a64d67f15cd74744fd9f1ab38e039ad 100644 (file)
@@ -196,13 +196,14 @@ mono_ppc_create_pre_code_ftnptr (guint8 *code)
  * 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);
@@ -218,7 +219,8 @@ mono_arch_get_restore_context_full (guint32 *code_size, MonoJumpInfo **ji, gbool
        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;
 }
@@ -252,13 +254,13 @@ emit_save_saved_regs (guint8 *code, int pos)
  * @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);
@@ -305,7 +307,8 @@ mono_arch_get_call_filter_full (guint32 *code_size, MonoJumpInfo **ji, gboolean
        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;
 }
@@ -351,12 +354,12 @@ mono_ppc_throw_exception (MonoObject *exc, unsigned long eip, unsigned long esp,
  *
  */
 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)
@@ -381,9 +384,9 @@ mono_arch_get_throw_exception_generic (int size, guint32 *code_size, MonoJumpInf
                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);
@@ -418,8 +421,8 @@ mono_arch_get_throw_exception_generic (int size, guint32 *code_size, MonoJumpInf
                // 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);
@@ -436,7 +439,8 @@ mono_arch_get_throw_exception_generic (int size, guint32 *code_size, MonoJumpInf
        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;
 }
@@ -450,13 +454,13 @@ mono_arch_get_throw_exception_generic (int size, guint32 *code_size, MonoJumpInf
  *
  */
 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);
 }
 
 /**
@@ -472,13 +476,13 @@ mono_arch_get_rethrow_exception_full (guint32 *code_size, MonoJumpInfo **ji, gbo
  *
  */
 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);
 }
 
 /**
@@ -490,13 +494,13 @@ mono_arch_get_throw_exception_full (guint32 *code_size, MonoJumpInfo **ji, gbool
  * 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);
 }
 
 /*
index e64f84139d887e27f8bc1a53a07a42bc47ff7252..76ac83da368da5dc720e29beba55a7c1e0450951 100644 (file)
@@ -261,15 +261,15 @@ void win32_seh_set_handler(int type, MonoW32ExceptionHandler handler)
  * 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 */
@@ -299,7 +299,8 @@ mono_arch_get_restore_context_full (guint32 *code_size, MonoJumpInfo **ji, gbool
        /* 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;
 }
@@ -312,12 +313,12 @@ mono_arch_get_restore_context_full (guint32 *code_size, MonoJumpInfo **ji, gbool
  * @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);
@@ -365,7 +366,8 @@ mono_arch_get_call_filter_full (guint32 *code_size, MonoJumpInfo **ji, gboolean
        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;
@@ -457,14 +459,12 @@ mono_x86_throw_corlib_exception (mgreg_t *regs, guint32 ex_token_index,
  * 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);
 
@@ -549,8 +549,8 @@ get_throw_exception (const char *name, gboolean rethrow, gboolean llvm, gboolean
                // 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);
@@ -559,11 +559,11 @@ get_throw_exception (const char *name, gboolean rethrow, gboolean llvm, gboolean
 
        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;
 }
 
@@ -580,15 +580,15 @@ get_throw_exception (const char *name, gboolean rethrow, gboolean llvm, gboolean
  *
  */
 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);
 }
 
 /**
@@ -602,9 +602,9 @@ mono_arch_get_rethrow_exception_full (guint32 *code_size, MonoJumpInfo **ji, gbo
  * 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
@@ -616,11 +616,11 @@ mono_arch_exceptions_init (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);
 }
index 5a510259791df70d0a78eb429fb161436e7b2763..44cb2f81b3e69023261a60191cebee75d867ea4a 100644 (file)
@@ -340,6 +340,7 @@ typedef struct {
 #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
index 5aa521164e4b0609cd017da49d821ab2b37a6f54..6a1884072f197f224db856ff747f6cb035560374 100644 (file)
@@ -69,19 +69,16 @@ void
 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 ();
@@ -169,10 +166,6 @@ gpointer
 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)
@@ -183,7 +176,7 @@ mono_get_throw_corlib_exception (void)
        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
index 94a4f480ce3fb378f5d143c75cce637ea6577bb3..fc8e43e3de682317a80b1e40469b310595629497 100644 (file)
@@ -1071,6 +1071,23 @@ mono_get_trampoline_func (MonoTrampolineType tramp_type)
        }
 }
 
+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)
 {
@@ -1079,27 +1096,27 @@ 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
 
@@ -1181,7 +1198,11 @@ mono_create_generic_class_init_trampoline (void)
                        /* 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 ();
@@ -1353,7 +1374,11 @@ mono_create_rgctx_lazy_fetch_trampoline (guint32 offset)
        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 ();
@@ -1391,7 +1416,11 @@ mono_create_monitor_enter_trampoline (void)
        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
@@ -1417,7 +1446,11 @@ mono_create_monitor_exit_trampoline (void)
        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
index e2ec3050f1a74fd3bb9a3c42c0d396f3ac2fa03c..7bcc4085971c63651a3a8c29fc0068547203cd03 100644 (file)
@@ -1702,16 +1702,16 @@ gpointer  mono_arch_get_throw_exception_by_name (void) MONO_INTERNAL;
 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;
@@ -1781,13 +1781,12 @@ mono_arch_find_jit_info_ext (MonoDomain *domain, MonoJitTlsData *jit_tls,
                                                         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;
index 45c91722563448398a92013593eca7a00ab7e1a8..9e2a1acbdcfe947249cd7c2e77147961f71aaf1a 100644 (file)
@@ -281,32 +281,14 @@ mono_arch_nullify_plt_entry (guint8 *code, mgreg_t *regs)
 }
 
 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;
@@ -315,8 +297,6 @@ mono_arch_create_trampoline_code_full (MonoTrampolineType tramp_type, guint32 *c
 
        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);
 
@@ -472,7 +452,7 @@ mono_arch_create_trampoline_code_full (MonoTrampolineType tramp_type, guint32 *c
        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);
@@ -509,7 +489,7 @@ mono_arch_create_trampoline_code_full (MonoTrampolineType tramp_type, guint32 *c
 
        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);
@@ -524,7 +504,7 @@ mono_arch_create_trampoline_code_full (MonoTrampolineType tramp_type, guint32 *c
         */
        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);
@@ -571,22 +551,19 @@ mono_arch_create_trampoline_code_full (MonoTrampolineType tramp_type, guint32 *c
 
        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;
 
@@ -595,7 +572,8 @@ mono_arch_get_nullified_class_init_trampoline (guint32 *code_len)
 
        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;
 }
@@ -638,16 +616,7 @@ mono_arch_create_specific_trampoline (gpointer arg1, MonoTrampolineType tramp_ty
 }      
 
 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;
@@ -656,11 +625,10 @@ mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, guint32 *code_s
        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)
@@ -726,7 +694,7 @@ mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, guint32 *code_s
        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 {
@@ -740,26 +708,18 @@ mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, guint32 *code_s
 
        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;
@@ -767,8 +727,8 @@ mono_arch_create_generic_class_init_trampoline_full (guint32 *code_size, MonoJum
        static guint8 bitmask;
        guint8 *jump;
        int tramp_size;
-
-       *ji = NULL;
+       GSList *unwind_ops = NULL;
+       MonoJumpInfo *ji = NULL;
 
        tramp_size = 64;
 
@@ -786,7 +746,7 @@ mono_arch_create_generic_class_init_trampoline_full (guint32 *code_size, MonoJum
        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 {
@@ -800,7 +760,8 @@ mono_arch_create_generic_class_init_trampoline_full (guint32 *code_size, MonoJum
 
        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;
 }
@@ -808,25 +769,15 @@ mono_arch_create_generic_class_init_trampoline_full (guint32 *code_size, MonoJum
 #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);
 
@@ -903,7 +854,7 @@ mono_arch_create_monitor_enter_trampoline_full (guint32 *code_size, MonoJumpInfo
 #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 {
@@ -916,22 +867,14 @@ mono_arch_create_monitor_enter_trampoline_full (guint32 *code_size, MonoJumpInfo
        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;
@@ -939,8 +882,8 @@ mono_arch_create_monitor_exit_trampoline_full (guint32 *code_size, MonoJumpInfo
        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);
 
@@ -1016,7 +959,7 @@ mono_arch_create_monitor_exit_trampoline_full (guint32 *code_size, MonoJumpInfo
 #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 {
@@ -1027,7 +970,8 @@ mono_arch_create_monitor_exit_trampoline_full (guint32 *code_size, MonoJumpInfo
        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;
 }
index a4605a9de6093cfd84e8982830ac0d485ae54433..d33ce05aba30af175619922563a548c24e0530ff 100644 (file)
@@ -126,43 +126,16 @@ emit_bx (guint8* code, int reg)
 #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  */
@@ -208,7 +181,7 @@ mono_arch_create_trampoline_code_full (MonoTrampolineType tramp_type, guint32 *c
         * 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;
@@ -272,7 +245,7 @@ mono_arch_create_trampoline_code_full (MonoTrampolineType tramp_type, guint32 *c
 
        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;
@@ -299,7 +272,7 @@ mono_arch_create_trampoline_code_full (MonoTrampolineType tramp_type, guint32 *c
         * 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;
@@ -363,22 +336,18 @@ mono_arch_create_trampoline_code_full (MonoTrampolineType tramp_type, guint32 *c
        /* 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;
 
@@ -388,7 +357,8 @@ mono_arch_get_nullified_class_init_trampoline (guint32 *code_len)
 
        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;
 }
@@ -515,16 +485,7 @@ mono_arch_get_static_rgctx_trampoline (MonoMethod *m, MonoMethodRuntimeGenericCo
 }
 
 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;
@@ -534,8 +495,8 @@ mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, guint32 *code_s
        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);
@@ -611,7 +572,7 @@ mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, guint32 *code_s
        /* 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;
@@ -631,7 +592,8 @@ mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, guint32 *code_s
 
        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;
 }
@@ -639,16 +601,7 @@ mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, guint32 *code_s
 #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;
@@ -658,8 +611,8 @@ mono_arch_create_generic_class_init_trampoline_full (guint32 *code_size, MonoJum
        int tramp_size;
        guint32 code_len, imm8;
        gint rot_amount;
-
-       *ji = NULL;
+       GSList *unwind_ops = NULL;
+       MonoJumpInfo *ji = NULL;
 
        tramp_size = 64;
 
@@ -684,7 +637,7 @@ mono_arch_create_generic_class_init_trampoline_full (guint32 *code_size, MonoJum
        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;
@@ -704,7 +657,8 @@ mono_arch_create_generic_class_init_trampoline_full (guint32 *code_size, MonoJum
 
        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;
 }
@@ -712,21 +666,7 @@ mono_arch_create_generic_class_init_trampoline_full (guint32 *code_size, MonoJum
 #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;
@@ -754,28 +694,14 @@ mono_arch_get_static_rgctx_trampoline (MonoMethod *m, MonoMethodRuntimeGenericCo
 }
 
 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;
index ec8de1d45780e278ae39344a24cdbf4b3bde73d2..9443484a89fa559f02b19a7b7cb1ff4f375f6c86 100644 (file)
@@ -234,25 +234,6 @@ mono_arch_nullify_plt_entry (guint8 *code, mgreg_t *regs)
 #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
@@ -269,47 +250,47 @@ mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
  *  -------------------
  */
 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);
        }
 
@@ -317,86 +298,86 @@ mono_arch_create_trampoline_code_full (MonoTrampolineType tramp_type, guint32 *c
         * 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
@@ -405,10 +386,10 @@ mono_arch_create_trampoline_code_full (MonoTrampolineType tramp_type, guint32 *c
         */
        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);
        }
 
        /*
@@ -417,31 +398,31 @@ mono_arch_create_trampoline_code_full (MonoTrampolineType tramp_type, guint32 *c
         * 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);
        }
 
@@ -449,30 +430,29 @@ mono_arch_create_trampoline_code_full (MonoTrampolineType tramp_type, guint32 *c
         * 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))
@@ -496,26 +476,27 @@ mono_arch_create_specific_trampoline (gpointer arg1, MonoTrampolineType tramp_ty
        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*
@@ -537,16 +518,7 @@ emit_trampoline_jump (guint8 *code, guint8 *tramp)
 }
 
 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;
@@ -556,8 +528,8 @@ mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, guint32 *code_s
        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);
@@ -630,7 +602,7 @@ mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, guint32 *code_s
        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);
@@ -649,7 +621,8 @@ mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, guint32 *code_s
 
        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
@@ -658,16 +631,7 @@ mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, guint32 *code_s
 }
 
 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;
@@ -675,6 +639,8 @@ mono_arch_create_generic_class_init_trampoline_full (guint32 *code_size, MonoJum
        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)
@@ -682,8 +648,6 @@ mono_arch_create_generic_class_init_trampoline_full (guint32 *code_size, MonoJum
 
        code = buf = mono_global_codeman_reserve (tramp_size);
 
-       *ji = NULL;
-
        if (byte_offset < 0)
                mono_marshal_find_bitfield_offset (MonoVTable, initialized, &byte_offset, &bitmask);
 
@@ -697,7 +661,7 @@ mono_arch_create_generic_class_init_trampoline_full (guint32 *code_size, MonoJum
        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);
@@ -714,15 +678,16 @@ mono_arch_create_generic_class_init_trampoline_full (guint32 *code_size, MonoJum
 
        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;
@@ -732,9 +697,10 @@ mono_arch_get_nullified_class_init_trampoline (guint32 *code_len)
 
        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;
 }
index 84604f3bcac9af1848dce4cc32127b8f145158cb..0c1eb121de98e6f5955328b82243a995ba6e1472 100644 (file)
@@ -223,35 +223,15 @@ mono_arch_nullify_plt_entry (guint8 *code, mgreg_t *regs)
 }
 
 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)
@@ -318,7 +298,7 @@ mono_arch_create_trampoline_code_full (MonoTrampolineType tramp_type, guint32 *c
 
        /* 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);
@@ -370,7 +350,7 @@ mono_arch_create_trampoline_code_full (MonoTrampolineType tramp_type, guint32 *c
 
        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);
@@ -387,7 +367,7 @@ mono_arch_create_trampoline_code_full (MonoTrampolineType tramp_type, guint32 *c
        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);
@@ -464,21 +444,20 @@ mono_arch_create_trampoline_code_full (MonoTrampolineType tramp_type, guint32 *c
 
        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;
 
@@ -487,7 +466,8 @@ mono_arch_get_nullified_class_init_trampoline (guint32 *code_len)
 
        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;
 }
@@ -516,16 +496,7 @@ mono_arch_create_specific_trampoline (gpointer arg1, MonoTrampolineType tramp_ty
 }
 
 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;
@@ -534,8 +505,8 @@ mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, guint32 *code_s
        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);
@@ -598,7 +569,7 @@ mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, guint32 *code_s
        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);
@@ -611,22 +582,14 @@ mono_arch_create_rgctx_lazy_fetch_trampoline_full (guint32 slot, guint32 *code_s
 
        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;
@@ -634,13 +597,13 @@ mono_arch_create_generic_class_init_trampoline_full (guint32 *code_size, MonoJum
        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);
 
@@ -656,7 +619,7 @@ mono_arch_create_generic_class_init_trampoline_full (guint32 *code_size, MonoJum
        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);
@@ -669,7 +632,8 @@ mono_arch_create_generic_class_init_trampoline_full (guint32 *code_size, MonoJum
 
        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;
 }
@@ -694,24 +658,15 @@ mono_arch_create_generic_class_init_trampoline_full (guint32 *code_size, MonoJum
  *
  */
 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);
 
@@ -790,7 +745,7 @@ mono_arch_create_monitor_enter_trampoline_full (guint32 *code_size, MonoJumpInfo
                        /* 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);
@@ -799,7 +754,7 @@ mono_arch_create_monitor_enter_trampoline_full (guint32 *code_size, MonoJumpInfo
                /* 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);
@@ -809,22 +764,14 @@ mono_arch_create_monitor_enter_trampoline_full (guint32 *code_size, MonoJumpInfo
        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;
@@ -832,8 +779,8 @@ mono_arch_create_monitor_exit_trampoline_full (guint32 *code_size, MonoJumpInfo
        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);
 
@@ -907,7 +854,7 @@ mono_arch_create_monitor_exit_trampoline_full (guint32 *code_size, MonoJumpInfo
        /* 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);
@@ -916,7 +863,8 @@ mono_arch_create_monitor_exit_trampoline_full (guint32 *code_size, MonoJumpInfo
        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;
 }