2009-12-04 Zoltan Varga <vargaz@gmail.com>
[mono.git] / mono / mini / exceptions-s390.c
index 06b5984b425928a8f6c9a5da5fee6ced3b04ea00..2e41bb787e4c6f3456e75e066aa1fb46c0b243ca 100644 (file)
@@ -33,6 +33,8 @@
 #define S390_THROWSTACK_ACCREGS                S390_THROWSTACK_FLTREGS+(16*sizeof(gdouble))
 #define S390_THROWSTACK_SIZE           (S390_THROWSTACK_ACCREGS+(16*sizeof(gulong)))
 
+#define SZ_THROW       384
+
 /*========================= End of Defines =========================*/
 
 /*------------------------------------------------------------------*/
@@ -105,7 +107,7 @@ mono_arch_has_unwind_info (gconstpointer addr)
 gpointer
 mono_arch_get_call_filter (void)
 {
-       static guint8 start [512];
+       static guint8 *start;
        static int inited = 0;
        guint8 *code;
        int alloc_size, pos, i;
@@ -115,7 +117,7 @@ mono_arch_get_call_filter (void)
 
        inited = 1;
        /* call_filter (MonoContext *ctx, unsigned long eip, gpointer exc) */
-       code = start;
+       code = start = mono_global_codeman_reserve (512);
 
        s390_stm (code, s390_r6, s390_r14, STK_BASE, S390_REG_SAVE_OFFSET);
        s390_lr  (code, s390_r14, STK_BASE);
@@ -195,7 +197,7 @@ mono_arch_get_call_filter (void)
        s390_lm   (code, s390_r6, s390_r14, STK_BASE, S390_REG_SAVE_OFFSET);
        s390_br   (code, s390_r14);
 
-       g_assert ((code - start) < sizeof(start));
+       g_assert ((code - start) < SZ_THROW); 
        return start;
 }
 
@@ -348,12 +350,13 @@ get_throw_exception_generic (guint8 *start, int size,
 gpointer 
 mono_arch_get_throw_exception (void)
 {
-       static guint8 start [384];
+       static guint8 *start;
        static int inited = 0;
 
        if (inited)
                return start;
-       get_throw_exception_generic (start, sizeof (start), FALSE, FALSE);
+       start = mono_global_codeman_reserve (SZ_THROW);
+       get_throw_exception_generic (start, SZ_THROW, FALSE, FALSE);
        inited = 1;
        return start;
 }
@@ -374,12 +377,13 @@ mono_arch_get_throw_exception (void)
 gpointer 
 mono_arch_get_rethrow_exception (void)
 {
-       static guint8 start [384];
+       static guint8 *start;
        static int inited = 0;
 
        if (inited)
                return start;
-       get_throw_exception_generic (start, sizeof (start), FALSE, TRUE);
+       start = mono_global_codeman_reserve (SZ_THROW);
+       get_throw_exception_generic (start, SZ_THROW, FALSE, TRUE);
        inited = 1;
        return start;
 }
@@ -400,12 +404,13 @@ mono_arch_get_rethrow_exception (void)
 gpointer 
 mono_arch_get_throw_exception_by_name (void)
 {
-       static guint8 start [384];
+       static guint8 *start;
        static int inited = 0;
 
        if (inited)
                return start;
-       get_throw_exception_generic (start, sizeof (start), TRUE, FALSE);
+       start = mono_global_codeman_reserve (SZ_THROW);
+       get_throw_exception_generic (start, SZ_THROW, TRUE, FALSE);
        inited = 1;
        return start;
 }      
@@ -431,8 +436,7 @@ mono_arch_get_throw_exception_by_name (void)
 MonoJitInfo *
 mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, 
                         MonoJitInfo *res, MonoJitInfo *prev_ji, MonoContext *ctx, 
-                        MonoContext *new_ctx, char **trace, MonoLMF **lmf, 
-                        int *native_offset, gboolean *managed)
+                        MonoContext *new_ctx, MonoLMF **lmf, gboolean *managed)
 {
        MonoJitInfo *ji;
        gpointer ip = MONO_CONTEXT_GET_IP (ctx);
@@ -443,20 +447,13 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
            ((guint8 *) ip <= ((guint8 *) prev_ji->code_start) + prev_ji->code_size)))
                ji = prev_ji;
        else
-               ji = mono_jit_info_table_find (domain, ip);
-
-       if (trace)
-               *trace = NULL;
-
-       if (native_offset)
-               *native_offset = -1;
+               ji = mini_jit_info_table_find (domain, ip, NULL);
 
        if (managed)
                *managed = FALSE;
 
        if (ji != NULL) {
-               char *source_location, *tmpaddr, *fname;
-               gint32 address, iloffset;
+               gint32 address;
 
                *new_ctx = *ctx;
 
@@ -467,40 +464,16 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
 
                address = (char *)ip - (char *)ji->code_start;
 
-               if (native_offset)
-                       *native_offset = address;
-
                if (managed)
                        if (!ji->method->wrapper_type)
                                *managed = TRUE;
 
-               if (trace) {
-                       source_location = mono_debug_source_location_from_address (ji->method, address, NULL, domain);
-                       iloffset = mono_debug_il_offset_from_address (ji->method, address, domain);
-
-                       if (iloffset < 0)
-                               tmpaddr = g_strdup_printf ("<0x%08x>", address);
-                       else
-                               tmpaddr = g_strdup_printf ("[0x%08x]", iloffset);
-               
-                       fname = mono_method_full_name (ji->method, TRUE);
-
-                       if (source_location)
-                               *trace = g_strdup_printf ("in %s (at %s) %s", tmpaddr, source_location, fname);
-                       else
-                               *trace = g_strdup_printf ("in %s %s", tmpaddr, fname);
-
-                       g_free (fname);
-                       g_free (source_location);
-                       g_free (tmpaddr);
-               }
                sframe = (MonoS390StackFrame *) MONO_CONTEXT_GET_SP (ctx);
                MONO_CONTEXT_SET_BP (new_ctx, sframe->prev);
                sframe = (MonoS390StackFrame *) sframe->prev;
                MONO_CONTEXT_SET_IP (new_ctx, sframe->return_address);
                memcpy (&new_ctx->uc_mcontext.gregs[6], sframe->regs, (8*sizeof(gint32)));
-               *res = *ji;
-               return res;
+               return ji;
        } else if (*lmf) {
                
                *new_ctx = *ctx;
@@ -508,13 +481,9 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
                if (!(*lmf)->method)
                        return (gpointer)-1;
 
-               if (trace)
-                       *trace = g_strdup_printf ("in (unmanaged) %s", mono_method_full_name ((*lmf)->method, TRUE));
-               
-               if ((ji = mono_jit_info_table_find (domain, (gpointer)(*lmf)->eip))) {
-                       *res = *ji;
+               if ((ji = mini_jit_info_table_find (domain, (gpointer)(*lmf)->eip, NULL))) {
                } else {
-                       memset (res, 0, sizeof (MonoJitInfo));
+                       memset (res, 0, MONO_SIZEOF_JIT_INFO);
                        res->method = (*lmf)->method;
                }
 
@@ -525,8 +494,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
                MONO_CONTEXT_SET_IP (new_ctx, (*lmf)->eip);
                *lmf = (*lmf)->previous_lmf;
 
-               return res;
-               
+               return ji ? ji : res;
        }
 
        return NULL;
@@ -627,7 +595,7 @@ mono_arch_is_int_overflow (void *uc, void *info)
                case 0x5d :             /* Divide                   */
                        regNo   = (code[2] & 0xf0 >> 8);        
                        offset  = *((guint16 *) code+2) & 0x0fff;
-                       operand = ctx->uc_mcontext.gregs[regNo] + offset;
+                       operand = (guint32*)(ctx->uc_mcontext.gregs[regNo] + offset);
                        if (*operand == 0)
                                arithExc = FALSE; 
                break;
@@ -642,7 +610,7 @@ mono_arch_is_int_overflow (void *uc, void *info)
                        if (code[1] == 0x97) {  
                                regNo   = (code[2] & 0xf0 >> 8);        
                                offset  = *((guint32 *) code+1) & 0x000fffff;
-                               operand = ctx->uc_mcontext.gregs[regNo] + offset;
+                               operand = (guint32*)(ctx->uc_mcontext.gregs[regNo] + offset);
                                if (*operand == 0)
                                        arithExc = FALSE; 
                        }
@@ -650,7 +618,7 @@ mono_arch_is_int_overflow (void *uc, void *info)
                default:
                        arithExc = TRUE;
        }
-       ctx->uc_mcontext.psw.addr = code;
+       ctx->uc_mcontext.psw.addr = (guint32)code;
        return (arithExc);
 }