Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / mini / tramp-x86.c
index 55a6d77191e6a34d30958724a11cb3950be2f46a..bced9017f43deb62af57f101446bf70456ae6005 100644 (file)
@@ -54,7 +54,7 @@ mono_arch_get_unbox_trampoline (MonoMethod *m, gpointer addr)
        x86_jump_code (code, addr);
        g_assert ((code - start) < size);
 
-       mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_UNBOX_TRAMPOLINE, m);
+       MONO_PROFILER_RAISE (jit_code_buffer, (start, code - start, MONO_PROFILER_CODE_BUFFER_UNBOX_TRAMPOLINE, m));
 
        mono_tramp_info_register (mono_tramp_info_create (NULL, start, code - start, NULL, unwind_ops), domain);
 
@@ -81,7 +81,7 @@ mono_arch_get_static_rgctx_trampoline (gpointer arg, gpointer addr)
        g_assert ((code - start) <= buf_len);
 
        mono_arch_flush_icache (start, code - start);
-       mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_GENERICS_TRAMPOLINE, NULL);
+       MONO_PROFILER_RAISE (jit_code_buffer, (start, code - start, MONO_PROFILER_CODE_BUFFER_GENERICS_TRAMPOLINE, NULL));
 
        mono_tramp_info_register (mono_tramp_info_create (NULL, start, code - start, NULL, unwind_ops), domain);
 
@@ -414,20 +414,11 @@ mono_arch_create_generic_trampoline (MonoTrampolineType tramp_type, MonoTrampInf
                mono_add_unwind_op_def_cfa_offset (unwind_ops, code, buf, cfa_offset);
                x86_ret (code);
        } else {
-               /* The trampoline argument is at the top of the stack, and it contains the address we need to branch to */
-               if (tramp_type == MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD) {
-                       x86_pop_reg (code, X86_EAX);
-                       cfa_offset -= sizeof (mgreg_t);
-                       mono_add_unwind_op_def_cfa_offset (unwind_ops, code, buf, cfa_offset);
-                       x86_alu_reg_imm (code, X86_ADD, X86_ESP, 0x8);
-                       x86_jump_reg (code, X86_EAX);
-               } else {
-                       x86_ret (code);
-               }
+               x86_ret (code);
        }
 
        g_assert ((code - buf) <= 256);
-       mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_HELPER, NULL);
+       MONO_PROFILER_RAISE (jit_code_buffer, (buf, code - buf, MONO_PROFILER_CODE_BUFFER_HELPER, NULL));
 
        tramp_name = mono_get_generic_trampoline_name (tramp_type);
        *info = mono_tramp_info_create (tramp_name, buf, code - buf, ji, unwind_ops);
@@ -452,7 +443,7 @@ mono_arch_create_specific_trampoline (gpointer arg1, MonoTrampolineType tramp_ty
        g_assert ((buf - code) <= TRAMPOLINE_SIZE);
 
        mono_arch_flush_icache (code, buf - code);
-       mono_profiler_code_buffer_new (code, buf - code, MONO_PROFILER_CODE_BUFFER_SPECIFIC_TRAMPOLINE, mono_get_generic_trampoline_simple_name (tramp_type));
+       MONO_PROFILER_RAISE (jit_code_buffer, (code, buf - code, MONO_PROFILER_CODE_BUFFER_SPECIFIC_TRAMPOLINE, mono_get_generic_trampoline_simple_name (tramp_type)));
 
        if (code_len)
                *code_len = buf - code;
@@ -546,7 +537,7 @@ mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot, MonoTrampInfo **info
        }
 
        mono_arch_flush_icache (buf, code - buf);
-       mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_GENERICS_TRAMPOLINE, NULL);
+       MONO_PROFILER_RAISE (jit_code_buffer, (buf, code - buf, MONO_PROFILER_CODE_BUFFER_GENERICS_TRAMPOLINE, NULL));
 
        g_assert (code - buf <= tramp_size);
 
@@ -589,7 +580,7 @@ mono_arch_create_general_rgctx_lazy_fetch_trampoline (MonoTrampInfo **info, gboo
        x86_jump_reg (code, X86_EAX);
 
        mono_arch_flush_icache (buf, code - buf);
-       mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_GENERICS_TRAMPOLINE, NULL);
+       MONO_PROFILER_RAISE (jit_code_buffer, (buf, code - buf, MONO_PROFILER_CODE_BUFFER_GENERICS_TRAMPOLINE, NULL));
 
        g_assert (code - buf <= tramp_size);
 
@@ -608,65 +599,6 @@ mono_arch_invalidate_method (MonoJitInfo *ji, void *func, gpointer func_arg)
        x86_call_code (code, (guint8*)func);
 }
 
-static gpointer
-handler_block_trampoline_helper (void)
-{
-       MonoJitTlsData *jit_tls = mono_tls_get_jit_tls ();
-       return jit_tls->handler_block_return_address;
-}
-
-gpointer
-mono_arch_create_handler_block_trampoline (MonoTrampInfo **info, gboolean aot)
-{
-       guint8 *tramp = mono_get_trampoline_code (MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD);
-       guint8 *code, *buf;
-       int tramp_size = 64;
-       MonoJumpInfo *ji = NULL;
-       int cfa_offset;
-       GSList *unwind_ops = NULL;
-
-       g_assert (!aot);
-
-       code = buf = mono_global_codeman_reserve (tramp_size);
-
-       unwind_ops = mono_arch_get_cie_program ();
-       cfa_offset = sizeof (mgreg_t);
-       /*
-       This trampoline restore the call chain of the handler block then jumps into the code that deals with it.
-       */
-
-       /*
-        * We are in a method frame after the call emitted by OP_CALL_HANDLER.
-        */
-
-       /*Slow path uses a c helper*/
-       x86_call_code (code, handler_block_trampoline_helper);
-       /* Simulate a call */
-       /*Fix stack alignment*/
-       x86_alu_reg_imm (code, X86_SUB, X86_ESP, 0x4);
-       cfa_offset += sizeof (mgreg_t);
-       mono_add_unwind_op_def_cfa_offset (unwind_ops, code, buf, cfa_offset);
-
-       /* This is the address the trampoline will return to */
-       x86_push_reg (code, X86_EAX);
-       cfa_offset += sizeof (mgreg_t);
-       mono_add_unwind_op_def_cfa_offset (unwind_ops, code, buf, cfa_offset);
-
-       /* Dummy trampoline argument, since we call the generic trampoline directly */
-       x86_push_imm (code, 0);
-       cfa_offset += sizeof (mgreg_t);
-       mono_add_unwind_op_def_cfa_offset (unwind_ops, code, buf, cfa_offset);
-       x86_jump_code (code, tramp);
-
-       mono_arch_flush_icache (buf, code - buf);
-       mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_HELPER, NULL);
-       g_assert (code - buf <= tramp_size);
-
-       *info = mono_tramp_info_create ("handler_block_trampoline", buf, code - buf, ji, unwind_ops);
-
-       return buf;
-}
-
 guint8*
 mono_arch_get_call_target (guint8 *code)
 {
@@ -710,7 +642,7 @@ mono_arch_get_gsharedvt_arg_trampoline (MonoDomain *domain, gpointer arg, gpoint
        g_assert ((code - start) <= buf_len);
 
        mono_arch_flush_icache (start, code - start);
-       mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_GENERICS_TRAMPOLINE, NULL);
+       MONO_PROFILER_RAISE (jit_code_buffer, (start, code - start, MONO_PROFILER_CODE_BUFFER_GENERICS_TRAMPOLINE, NULL));
 
        mono_tramp_info_register (mono_tramp_info_create (NULL, start, code - start, NULL, unwind_ops), domain);