Merge pull request #2720 from mono/fix-39325
[mono.git] / mono / mini / exceptions-sparc.c
index 20d2f0facefe90102e81875de578903664e8c138..77510a7f934de0d832dd20fca39c687f19c4d1de 100644 (file)
@@ -21,7 +21,7 @@
 #include <mono/metadata/debug-helpers.h>
 #include <mono/metadata/exception.h>
 #include <mono/metadata/mono-debug.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
 #include <mono/metadata/tokentype.h>
 
 #include "mini.h"
@@ -166,6 +166,7 @@ mono_arch_get_call_filter (MonoTrampInfo **info, gboolean aot)
 static void
 throw_exception (MonoObject *exc, gpointer sp, gpointer ip, gboolean rethrow)
 {
+       MonoError error;
        MonoContext ctx;
        static void (*restore_context) (MonoContext *);
        gpointer *window;
@@ -178,11 +179,14 @@ throw_exception (MonoObject *exc, gpointer sp, gpointer ip, gboolean rethrow)
        ctx.ip = ip;
        ctx.fp = (gpointer*)(MONO_SPARC_WINDOW_ADDR (sp) [sparc_i6 - 16]);
 
-       if (mono_object_isinst (exc, mono_defaults.exception_class)) {
+       if (mono_object_isinst_checked (exc, mono_defaults.exception_class, &error)) {
                MonoException *mono_ex = (MonoException*)exc;
-               if (!rethrow)
+               if (!rethrow) {
                        mono_ex->stack_trace = NULL;
+                       mono_ex->trace_ips = NULL;
+               }
        }
+       mono_error_assert_ok (&error);
        mono_handle_exception (&ctx, exc);
        restore_context (&ctx);
 
@@ -324,7 +328,7 @@ mono_arch_get_throw_corlib_exception (MonoTrampInfo **info, gboolean aot)
        return start;
 }
 
-/* mono_arch_find_jit_info:
+/* mono_arch_unwind_frame:
  *
  * This function is used to gather information from @ctx. It return the 
  * MonoJitInfo of the corresponding function, unwinds one stack frame and
@@ -334,7 +338,7 @@ mono_arch_get_throw_corlib_exception (MonoTrampInfo **info, gboolean aot)
  * start of the function or -1 if that info is not available.
  */
 gboolean
-mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, 
+mono_arch_unwind_frame (MonoDomain *domain, MonoJitTlsData *jit_tls, 
                                                         MonoJitInfo *ji, MonoContext *ctx, 
                                                         MonoContext *new_ctx, MonoLMF **lmf,
                                                         mgreg_t **save_locations,
@@ -348,12 +352,10 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
        *new_ctx = *ctx;
 
        if (ji != NULL) {
-               frame->type = FRAME_TYPE_MANAGED;
-
-               if (*lmf && (MONO_CONTEXT_GET_BP (ctx) >= (gpointer)(*lmf)->ebp)) {
-                       /* remove any unused lmf */
-                       *lmf = (*lmf)->previous_lmf;
-               }
+               if (ji->is_trampoline)
+                       frame->type = FRAME_TYPE_TRAMPOLINE;
+               else
+                       frame->type = FRAME_TYPE_MANAGED;
 
                /* Restore ip and sp from the saved register window */
                window = MONO_SPARC_WINDOW_ADDR (ctx->sp);