Add a Length property and a GetChars () method to StringMirror. Fixes #2301.
[mono.git] / mono / mini / exceptions-mips.c
index e42d0c39108f3123d6da0530add75e40233643d0..da90482edbbf24fa2b03b5f3bb0619cac06da680 100644 (file)
@@ -219,7 +219,7 @@ throw_exception (MonoObject *exc, unsigned long eip, unsigned long esp, gboolean
                if (!rethrow)
                        mono_ex->stack_trace = NULL;
        }
-       mono_handle_exception (&ctx, exc, (void *)eip, FALSE);
+       mono_handle_exception (&ctx, exc);
 #ifdef DEBUG_EXCEPTIONS
        g_print ("throw_exception: restore to pc=%p sp=%p fp=%p ctx=%p\n",
                 (void *) ctx.sc_pc, (void *) ctx.sc_regs[mips_sp],
@@ -396,25 +396,6 @@ mono_arch_get_throw_corlib_exception (MonoTrampInfo **info, gboolean aot)
        mono_arch_get_throw_exception_generic (start, sizeof (start), TRUE, FALSE);
        inited = 1;
        return start;
-}      
-
-static MonoArray *
-glist_to_array (GList *list, MonoClass *eclass) 
-{
-       MonoDomain *domain = mono_domain_get ();
-       MonoArray *res;
-       int len, i;
-
-       if (!list)
-               return NULL;
-
-       len = g_list_length (list);
-       res = mono_array_new (domain, eclass, len);
-
-       for (i = 0; list; list = list->next, i++)
-               mono_array_set (res, gpointer, i, list->data);
-
-       return res;
 }
 
 /*
@@ -432,10 +413,6 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
                                                         mgreg_t **save_locations,
                                                         StackFrameInfo *frame)
 {
-       gpointer ip = MONO_CONTEXT_GET_IP (ctx);
-       gpointer fp = MONO_CONTEXT_GET_BP (ctx);
-       guint32 sp;
-
        memset (frame, 0, sizeof (StackFrameInfo));
        frame->ji = ji;
 
@@ -443,22 +420,46 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
 
        if (ji != NULL) {
                int i;
-               gint32 address;
-               int offset = 0;
+               gpointer ip = MONO_CONTEXT_GET_IP (ctx);
+               mgreg_t regs [MONO_MAX_IREGS + 1];
+               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);
+
+               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,
+                                                  save_locations, MONO_MAX_IREGS, &cfa);
+
+               for (i = 0; i < MONO_MAX_IREGS; ++i)
+                       new_ctx->sc_regs [i] = regs [i];
+               new_ctx->sc_pc = regs [mips_ra];
+               new_ctx->sc_regs [mips_sp] = (mgreg_t)cfa;
+
                if (*lmf && (MONO_CONTEXT_GET_BP (ctx) >= (gpointer)(*lmf)->ebp)) {
                        /* remove any unused lmf */
                        *lmf = (*lmf)->previous_lmf;
                }
 
-               address = (char *)ip - (char *)ji->code_start;
+               /* we substract 8, so that the IP points into the call instruction */
+               MONO_CONTEXT_SET_IP (new_ctx, new_ctx->sc_pc - 8);
 
-               /* My stack frame */
-               fp = MONO_CONTEXT_GET_BP (ctx);
+#if 0
 
-               /* Compute the previous stack frame */
+               address = (char *)ip - (char *)ji->code_start;
+
+               /* Compute the previous stack frame, assuming method
+                * starts with addiu sp, sp, <offset>. */
                sp = (guint32)(fp) - (short)(*(guint32 *)(ji->code_start));
 
                /* Sanity check the frame */
@@ -506,9 +507,10 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
                }
                /* we substract 8, so that the IP points into the call instruction */
                MONO_CONTEXT_SET_IP (new_ctx, new_ctx->sc_regs[mips_ra] - 8);
+#endif
 
                /* Sanity check -- we should have made progress here */
-               g_assert (new_ctx->sc_pc != ctx->sc_pc);
+               g_assert (MONO_CONTEXT_GET_BP (new_ctx) != MONO_CONTEXT_GET_BP (ctx));
                return TRUE;
        } else if (*lmf) {
                if (!(*lmf)->method) {
@@ -578,7 +580,7 @@ mono_arch_ip_from_context (void *sigctx)
  * This is the function called from the signal handler
  */
 gboolean
-mono_arch_handle_exception (void *ctx, gpointer obj, gboolean test_only)
+mono_arch_handle_exception (void *ctx, gpointer obj)
 {
        MonoContext mctx;
        gboolean result;
@@ -587,7 +589,7 @@ mono_arch_handle_exception (void *ctx, gpointer obj, gboolean test_only)
 #ifdef DEBUG_EXCEPTIONS
        g_print ("mono_arch_handle_exception: pc=%p\n", (void *) mctx.sc_pc);
 #endif
-       mono_handle_exception (&mctx, obj, (gpointer)mctx.sc_pc, test_only);
+       mono_handle_exception (&mctx, obj);
        result = TRUE;
 
 #ifdef DEBUG_EXCEPTIONS