#include <mono/arch/arm/arm-codegen.h>
#include <mono/arch/arm/arm-vfp-codegen.h>
+#include <mono/metadata/abi-details.h>
#include <mono/metadata/appdomain.h>
#include <mono/metadata/tabledefs.h>
#include <mono/metadata/threads.h>
#include "mini.h"
#include "mini-arm.h"
#include "mono/utils/mono-sigcontext.h"
+#include "mono/utils/mono-compiler.h"
/*
* arch_get_restore_context:
ctx_reg = ARMREG_R0;
if (!mono_arch_is_soft_float ()) {
- ARM_ADD_REG_IMM8 (code, ARMREG_IP, ctx_reg, G_STRUCT_OFFSET (MonoContext, fregs));
+ ARM_ADD_REG_IMM8 (code, ARMREG_IP, ctx_reg, MONO_STRUCT_OFFSET (MonoContext, fregs));
ARM_FLDMD (code, ARM_VFP_D0, 16, ARMREG_IP);
}
/* move pc to PC */
- ARM_LDR_IMM (code, ARMREG_IP, ctx_reg, G_STRUCT_OFFSET (MonoContext, pc));
- ARM_STR_IMM (code, ARMREG_IP, ctx_reg, G_STRUCT_OFFSET (MonoContext, regs) + (ARMREG_PC * sizeof (mgreg_t)));
+ ARM_LDR_IMM (code, ARMREG_IP, ctx_reg, MONO_STRUCT_OFFSET (MonoContext, pc));
+ ARM_STR_IMM (code, ARMREG_IP, ctx_reg, MONO_STRUCT_OFFSET (MonoContext, regs) + (ARMREG_PC * sizeof (mgreg_t)));
/* restore everything */
- ARM_ADD_REG_IMM8 (code, ARMREG_IP, ctx_reg, G_STRUCT_OFFSET(MonoContext, regs));
+ ARM_ADD_REG_IMM8 (code, ARMREG_IP, ctx_reg, MONO_STRUCT_OFFSET(MonoContext, regs));
ARM_LDM (code, ARMREG_IP, 0xffff);
/* never reached */
/* restore all the regs from ctx (in r0), but not sp, the stack pointer */
ctx_reg = ARMREG_R0;
- ARM_LDR_IMM (code, ARMREG_IP, ctx_reg, G_STRUCT_OFFSET (MonoContext, pc));
- ARM_ADD_REG_IMM8 (code, ARMREG_LR, ctx_reg, G_STRUCT_OFFSET(MonoContext, regs) + (MONO_ARM_FIRST_SAVED_REG * sizeof (mgreg_t)));
+ ARM_LDR_IMM (code, ARMREG_IP, ctx_reg, MONO_STRUCT_OFFSET (MonoContext, pc));
+ ARM_ADD_REG_IMM8 (code, ARMREG_LR, ctx_reg, MONO_STRUCT_OFFSET(MonoContext, regs) + (MONO_ARM_FIRST_SAVED_REG * sizeof (mgreg_t)));
ARM_LDM (code, ARMREG_LR, MONO_ARM_REGSAVE_MASK);
/* call handler at eip (r1) and set the first arg with the exception (r2) */
ARM_MOV_REG_REG (code, ARMREG_R0, ARMREG_R2);
mono_arm_throw_exception (MonoObject *exc, mgreg_t pc, mgreg_t sp, mgreg_t *int_regs, gdouble *fp_regs)
{
MonoContext ctx;
- gboolean rethrow = pc & 1;
+ gboolean rethrow = sp & 1;
- pc &= ~1; /* clear the optional rethrow bit */
+ sp &= ~1; /* clear the optional rethrow bit */
+ pc &= ~1; /* clear the thumb bit */
/* adjust eip so that it point into the call instruction */
pc -= 4;
if (mono_object_isinst (exc, mono_defaults.exception_class)) {
MonoException *mono_ex = (MonoException*)exc;
- if (!rethrow)
+ if (!rethrow) {
mono_ex->stack_trace = NULL;
+ mono_ex->trace_ips = NULL;
+ }
}
mono_handle_exception (&ctx, exc);
mono_restore_context (&ctx);
/* call throw_exception (exc, ip, sp, int_regs, fp_regs) */
/* caller sp */
ARM_ADD_REG_IMM8 (code, ARMREG_R2, ARMREG_SP, cfa_offset);
+ /* we encode rethrow in sp */
+ if (rethrow) {
+ g_assert (!resume_unwind);
+ g_assert (!corlib);
+ ARM_ORR_REG_IMM8 (code, ARMREG_R2, ARMREG_R2, rethrow);
+ }
/* exc is already in place in r0 */
if (corlib) {
/* The caller ip is already in R1 */
}
/* int regs */
ARM_ADD_REG_IMM8 (code, ARMREG_R3, ARMREG_SP, (cfa_offset - (MONO_ARM_NUM_SAVED_REGS * sizeof (mgreg_t))));
- /* we encode rethrow in the ip */
- ARM_ORR_REG_IMM8 (code, ARMREG_R1, ARMREG_R1, rethrow);
/* fp regs */
ARM_ADD_REG_IMM8 (code, ARMREG_LR, ARMREG_SP, 8);
ARM_STR_IMM (code, ARMREG_LR, ARMREG_SP, 0);
mono_unwind_frame (unwind_info, unwind_info_len, ji->code_start,
(guint8*)ji->code_start + ji->code_size,
- ip, regs, MONO_MAX_IREGS + 8,
+ ip, NULL, regs, MONO_MAX_IREGS + 8,
save_locations, MONO_MAX_IREGS, &cfa);
for (i = 0; i < 16; ++i)
new_ctx->fregs [8 + i] = regs [MONO_MAX_IREGS + i];
#endif
- if (*lmf && (MONO_CONTEXT_GET_SP (ctx) >= (gpointer)(*lmf)->sp)) {
- /* remove any unused lmf */
- *lmf = (gpointer)(((gsize)(*lmf)->previous_lmf) & ~3);
- }
-
/* Clear thumb bit */
new_ctx->pc &= ~1;
return FALSE;
}
-#if MONO_ARCH_HAVE_SIGCTX_TO_MONOCTX
-void
-mono_arch_sigctx_to_monoctx (void *sigctx, MonoContext *mctx)
-{
- mono_sigctx_to_monoctx (sigctx, mctx);
-}
-
-void
-mono_arch_monoctx_to_sigctx (MonoContext *mctx, void *ctx)
-{
- mono_monoctx_to_sigctx (mctx, ctx);
-}
-#endif /* MONO_ARCH_HAVE_SIGCTX_TO_MONOCTX */
-
/*
* handle_exception:
*
* This works around a gcc 4.5 bug:
* https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/721531
*/
-#if defined(__GNUC__)
-__attribute__((noinline))
-#endif
-static gpointer
+static MONO_NEVER_INLINE gpointer
get_handle_signal_exception_addr (void)
{
return handle_signal_exception;
guint64 sp = UCONTEXT_REG_SP (sigctx);
/* Pass the ctx parameter in TLS */
- mono_arch_sigctx_to_monoctx (sigctx, &jit_tls->ex_ctx);
+ mono_sigctx_to_monoctx (sigctx, &jit_tls->ex_ctx);
/* The others in registers */
UCONTEXT_REG_R0 (sigctx) = (gsize)obj;
MonoContext mctx;
gboolean result;
- mono_arch_sigctx_to_monoctx (ctx, &mctx);
+ mono_sigctx_to_monoctx (ctx, &mctx);
result = mono_handle_exception (&mctx, obj);
/* restore the context so that returning from the signal handler will invoke
* the catch clause
*/
- mono_arch_monoctx_to_sigctx (&mctx, ctx);
+ mono_monoctx_to_sigctx (&mctx, ctx);
return result;
#endif
}
/* Allocate a stack frame */
sp -= 16;
MONO_CONTEXT_SET_SP (ctx, sp);
- MONO_CONTEXT_SET_IP (ctx, async_cb);
- // FIXME: thumb/arm
+ mono_arch_setup_resume_sighandler_ctx (ctx, async_cb);
}
/*