-/*
- * tramp-x86.c: JIT trampoline code for x86
+/**
+ * \file
+ * JIT trampoline code for x86
*
* Authors:
* Dietmar Maurer (dietmar@ximian.com)
#include <mono/metadata/metadata-internals.h>
#include <mono/metadata/marshal.h>
#include <mono/metadata/tabledefs.h>
-#include <mono/metadata/mono-debug.h>
-#include <mono/metadata/mono-debug-debugger.h>
#include <mono/metadata/profiler-private.h>
#include <mono/metadata/gc-internals.h>
#include <mono/arch/x86/x86-codegen.h>
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);
}
gpointer
-mono_arch_get_static_rgctx_trampoline (MonoMethod *m, MonoMethodRuntimeGenericContext *mrgctx, gpointer addr)
+mono_arch_get_static_rgctx_trampoline (gpointer arg, gpointer addr)
{
guint8 *code, *start;
int buf_len;
unwind_ops = mono_arch_get_cie_program ();
- x86_mov_reg_imm (code, MONO_ARCH_RGCTX_REG, mrgctx);
+ x86_mov_reg_imm (code, MONO_ARCH_RGCTX_REG, arg);
x86_jump_code (code, 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);
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);
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;
}
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);
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);
x86_call_code (code, (guint8*)func);
}
-static gpointer
-handler_block_trampoline_helper (void)
-{
- MonoJitTlsData *jit_tls = mono_native_tls_get_value (mono_jit_tls_id);
- 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.
- */
-
- if (mono_get_jit_tls_offset () != -1) {
- code = mono_x86_emit_tls_get (code, X86_EAX, mono_get_jit_tls_offset ());
- x86_mov_reg_membase (code, X86_EAX, X86_EAX, MONO_STRUCT_OFFSET (MonoJitTlsData, handler_block_return_address), 4);
- } else {
- /*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)
{
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);
return buf;
}
+gpointer
+mono_arch_get_enter_icall_trampoline (MonoTrampInfo **info)
+{
+ g_assert_not_reached ();
+ return NULL;
+}
+