Merge pull request #1668 from alexanderkyte/bug1856
[mono.git] / mono / mini / exceptions-mips.c
index ea58f176176baf50b9be20ef4ddaca1837c268d7..dfb4a57d3b9a3ff5418b7cb005b8f283ffbbd387 100644 (file)
@@ -77,6 +77,7 @@ mono_arch_get_restore_context (MonoTrampInfo **info, gboolean aot)
 
        g_assert ((code - start) < sizeof(start));
        mono_arch_flush_icache (start, code - start);
+       mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING, NULL);
        return start;
 }
 
@@ -168,6 +169,7 @@ mono_arch_get_call_filter (MonoTrampInfo **info, gboolean aot)
 
        g_assert ((code - start) < sizeof(start));
        mono_arch_flush_icache (start, code - start);
+       mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING, NULL);
        return start;
 }
 
@@ -194,8 +196,10 @@ throw_exception (MonoObject *exc, unsigned long eip, unsigned long esp, gboolean
 
        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);
 #ifdef DEBUG_EXCEPTIONS
@@ -281,6 +285,7 @@ mono_arch_get_throw_exception_generic (guint8 *start, int size, int corlib, gboo
 
        g_assert ((code - start) < size);
        mono_arch_flush_icache (start, code - start);
+       mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING, NULL);
        return start;
 }
 
@@ -348,6 +353,7 @@ mono_arch_get_throw_exception_by_name (void)
        start = code = mono_global_codeman_reserve (size);
        mips_break (code, 0xfd);
        mono_arch_flush_icache (start, code - start);
+       mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING, NULL);
        return start;
 }
 
@@ -406,17 +412,14 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
 
                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);
 
                for (i = 0; i < MONO_MAX_IREGS; ++i)
                        regs [i] = new_ctx->sc_regs [i];
 
                mono_unwind_frame (unwind_info, unwind_info_len, ji->code_start, 
                                                   (guint8*)ji->code_start + ji->code_size,
-                                                  ip, regs, MONO_MAX_IREGS,
+                                                  ip, NULL, regs, MONO_MAX_IREGS,
                                                   save_locations, MONO_MAX_IREGS, &cfa);
 
                for (i = 0; i < MONO_MAX_IREGS; ++i)
@@ -424,11 +427,6 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
                new_ctx->sc_pc = regs [mips_ra];
                new_ctx->sc_regs [mips_sp] = (mgreg_t)cfa;
 
-               if (*lmf && (MONO_CONTEXT_GET_SP (ctx) >= (gpointer)(*lmf)->iregs [mips_sp])) {
-                       /* remove any unused lmf */
-                       *lmf = (gpointer)(((gsize)(*lmf)->previous_lmf) & ~3);
-               }
-
                /* we substract 8, so that the IP points into the call instruction */
                MONO_CONTEXT_SET_IP (new_ctx, new_ctx->sc_pc - 8);
 
@@ -486,22 +484,10 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
        return FALSE;
 }
 
-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 *sigctx)
-{
-       mono_monoctx_to_sigctx (mctx, sigctx);
-}
-
 gpointer
 mono_arch_ip_from_context (void *sigctx)
 {
-       return (gpointer)UCONTEXT_REG_PC (sigctx);
+       return (gpointer)(gsize)UCONTEXT_REG_PC (sigctx);
 }
 
 /*
@@ -542,7 +528,7 @@ mono_arch_handle_exception (void *ctx, gpointer obj)
        guint64 sp = UCONTEXT_GREGS (sigctx) [mips_sp];
 
        /* 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_GREGS (sigctx)[mips_a0] = (gsize)obj;
 
@@ -557,13 +543,13 @@ mono_arch_handle_exception (void *ctx, gpointer 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
 }