X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmini%2Ftramp-arm.c;h=2872b1c13329feaaa1dc433d66be3f3a6883c1a3;hb=580ccb1ffb8e5c2e3fa0555e342d916764f42930;hp=747163b176dc74678a91987d3b1046224ec8fd61;hpb=cfeadc51e89f1af952323bb2779066d6813a54ec;p=mono.git diff --git a/mono/mini/tramp-arm.c b/mono/mini/tramp-arm.c index 747163b176d..2872b1c1332 100644 --- a/mono/mini/tramp-arm.c +++ b/mono/mini/tramp-arm.c @@ -1,5 +1,6 @@ -/* - * tramp-arm.c: JIT trampoline code for ARM +/** + * \file + * JIT trampoline code for ARM * * Authors: * Paolo Molaro (lupus@ximian.com) @@ -84,6 +85,13 @@ mono_arch_patch_plt_entry (guint8 *code, gpointer *got, mgreg_t *regs, guint8 *a *(guint8**)jump_entry = addr; } +gpointer +mono_arm_handler_block_trampoline_helper (gpointer *ptr) +{ + MonoJitTlsData *jit_tls = mono_tls_get_jit_tls (); + return jit_tls->handler_block_return_address; +} + #ifndef DISABLE_JIT #define arm_is_imm12(v) ((int)(v) > -4096 && (int)(v) < 4096) @@ -680,13 +688,6 @@ mono_arch_create_general_rgctx_lazy_fetch_trampoline (MonoTrampInfo **info, gboo return buf; } -static gpointer -handler_block_trampoline_helper (gpointer *ptr) -{ - 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) { @@ -696,8 +697,6 @@ mono_arch_create_handler_block_trampoline (MonoTrampInfo **info, gboolean aot) MonoJumpInfo *ji = NULL; GSList *unwind_ops = NULL; - g_assert (!aot); - code = buf = mono_global_codeman_reserve (tramp_size); unwind_ops = mono_arch_get_cie_program (); @@ -712,19 +711,30 @@ mono_arch_create_handler_block_trampoline (MonoTrampInfo **info, gboolean aot) * We are in a method frame after the call emitted by OP_CALL_HANDLER. */ /* Obtain jit_tls->handler_block_return_address */ - ARM_LDR_IMM (code, ARMREG_R0, ARMREG_PC, 0); - ARM_B (code, 0); - *(gpointer*)code = handler_block_trampoline_helper; - code += 4; + if (aot) { + code = mono_arm_emit_aotconst (&ji, code, buf, ARMREG_R0, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_arm_handler_block_trampoline_helper"); + ARM_B (code, 0); + } else { + ARM_LDR_IMM (code, ARMREG_R0, ARMREG_PC, 0); + ARM_B (code, 0); + *(gpointer*)code = mono_arm_handler_block_trampoline_helper; + code += 4; + } /* Set it as the return address so the trampoline will return to it */ ARM_MOV_REG_REG (code, ARMREG_LR, ARMREG_R0); /* Call the trampoline */ - ARM_LDR_IMM (code, ARMREG_R0, ARMREG_PC, 0); - code = emit_bx (code, ARMREG_R0); - *(gpointer*)code = tramp; - code += 4; + if (aot) { + char *name = g_strdup_printf ("trampoline_func_%d", MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD); + code = mono_arm_emit_aotconst (&ji, code, buf, ARMREG_R0, MONO_PATCH_INFO_JIT_ICALL_ADDR, name); + code = emit_bx (code, ARMREG_R0); + } else { + ARM_LDR_IMM (code, ARMREG_R0, ARMREG_PC, 0); + code = emit_bx (code, ARMREG_R0); + *(gpointer*)code = tramp; + code += 4; + } mono_arch_flush_icache (buf, code - buf); mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_HELPER, NULL);