Merge pull request #901 from Blewzman/FixAggregateExceptionGetBaseException
[mono.git] / mono / mini / exceptions-arm.c
index 8931dd8467e20dd0a7c77486a25ffdfac78112d7..a6e75730df06d21367c1a1e085a79c7dc759898c 100644 (file)
@@ -60,10 +60,10 @@ mono_arch_get_restore_context (MonoTrampInfo **info, gboolean aot)
 
        ctx_reg = ARMREG_R0;
 
-#if defined(ARM_FPU_VFP)
-       ARM_ADD_REG_IMM8 (code, ARMREG_IP, ctx_reg, G_STRUCT_OFFSET (MonoContext, fregs));
-       ARM_FLDMD (code, ARM_VFP_D0, 16, ARMREG_IP);
-#endif
+       if (!mono_arch_is_soft_float ()) {
+               ARM_ADD_REG_IMM8 (code, ARMREG_IP, ctx_reg, G_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));
@@ -135,13 +135,9 @@ mono_arch_get_call_filter (MonoTrampInfo **info, gboolean aot)
 void
 mono_arm_throw_exception (MonoObject *exc, mgreg_t pc, mgreg_t sp, mgreg_t *int_regs, gdouble *fp_regs)
 {
-       static void (*restore_context) (MonoContext *);
        MonoContext ctx;
        gboolean rethrow = pc & 1;
 
-       if (!restore_context)
-               restore_context = mono_get_restore_context ();
-
        pc &= ~1; /* clear the optional rethrow bit */
        /* adjust eip so that it point into the call instruction */
        pc -= 4;
@@ -159,7 +155,7 @@ mono_arm_throw_exception (MonoObject *exc, mgreg_t pc, mgreg_t sp, mgreg_t *int_
                        mono_ex->stack_trace = NULL;
        }
        mono_handle_exception (&ctx, exc);
-       restore_context (&ctx);
+       mono_restore_context (&ctx);
        g_assert_not_reached ();
 }
 
@@ -220,12 +216,12 @@ get_throw_trampoline (int size, gboolean corlib, gboolean rethrow, gboolean llvm
        mono_add_unwind_op_offset (unwind_ops, code, start, ARMREG_LR, - sizeof (mgreg_t));
 
        /* Save fp regs */
-       ARM_SUB_REG_IMM8 (code, ARMREG_SP, ARMREG_SP, sizeof (double) * 16);
-       cfa_offset += sizeof (double) * 16;
-       mono_add_unwind_op_def_cfa_offset (unwind_ops, code, start, cfa_offset);
-#if defined(ARM_FPU_VFP)
-       ARM_FSTMD (code, ARM_VFP_D0, 16, ARMREG_SP);
-#endif
+       if (!mono_arch_is_soft_float ()) {
+               ARM_SUB_REG_IMM8 (code, ARMREG_SP, ARMREG_SP, sizeof (double) * 16);
+               cfa_offset += sizeof (double) * 16;
+               mono_add_unwind_op_def_cfa_offset (unwind_ops, code, start, cfa_offset);
+               ARM_FSTMD (code, ARM_VFP_D0, 16, ARMREG_SP);
+       }
 
        /* Param area */
        ARM_SUB_REG_IMM8 (code, ARMREG_SP, ARMREG_SP, 8);
@@ -371,8 +367,7 @@ mono_arch_exceptions_init (void)
                        MonoTrampInfo *info = l->data;
 
                        mono_register_jit_icall (info->code, g_strdup (info->name), NULL, TRUE);
-                       mono_save_trampoline_xdebug_info (info);
-                       mono_tramp_info_free (info);
+                       mono_tramp_info_register (info);
                }
                g_slist_free (tramps);
        }
@@ -399,30 +394,41 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
 
        if (ji != NULL) {
                int i;
-               gssize regs [MONO_MAX_IREGS + 1];
+               gssize regs [MONO_MAX_IREGS + 1 + 8];
                guint8 *cfa;
                guint32 unwind_info_len;
                guint8 *unwind_info;
 
                frame->type = FRAME_TYPE_MANAGED;
 
-               if (ji->from_aot)
-                       unwind_info = mono_aot_get_unwind_info (ji, &unwind_info_len);
-               else
-                       unwind_info = mono_get_cached_unwind_info (ji->used_regs, &unwind_info_len);
+               unwind_info = mono_jinfo_get_unwind_info (ji, &unwind_info_len);
+
+               /*
+               printf ("%s %p %p\n", ji->d.method->name, ji->code_start, ip);
+               mono_print_unwind_info (unwind_info, unwind_info_len);
+               */
 
                for (i = 0; i < 16; ++i)
                        regs [i] = new_ctx->regs [i];
+#ifdef TARGET_IOS
+               /* On IOS, d8..d15 are callee saved. They are mapped to 8..15 in unwind.c */
+               for (i = 0; i < 8; ++i)
+                       regs [MONO_MAX_IREGS + i] = new_ctx->fregs [8 + i];
+#endif
 
                mono_unwind_frame (unwind_info, unwind_info_len, ji->code_start, 
                                                   (guint8*)ji->code_start + ji->code_size,
-                                                  ip, regs, MONO_MAX_IREGS,
+                                                  ip, regs, MONO_MAX_IREGS + 8,
                                                   save_locations, MONO_MAX_IREGS, &cfa);
 
                for (i = 0; i < 16; ++i)
                        new_ctx->regs [i] = regs [i];
                new_ctx->pc = regs [ARMREG_LR];
                new_ctx->regs [ARMREG_SP] = (gsize)cfa;
+#ifdef TARGET_IOS
+               for (i = 0; i < 8; ++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 */
@@ -517,16 +523,12 @@ handle_signal_exception (gpointer obj)
 {
        MonoJitTlsData *jit_tls = mono_native_tls_get_value (mono_jit_tls_id);
        MonoContext ctx;
-       static void (*restore_context) (MonoContext *);
-
-       if (!restore_context)
-               restore_context = mono_get_restore_context ();
 
        memcpy (&ctx, &jit_tls->ex_ctx, sizeof (MonoContext));
 
        mono_handle_exception (&ctx, obj);
 
-       restore_context (&ctx);
+       mono_restore_context (&ctx);
 }
 
 /*