* Removed all Id tags.
[cacao.git] / src / vm / jit / powerpc64 / linux / md-os.c
index 89a00576ce103e84e40f89ae828ba1631eb839a9..3e62f609598ae29371a409dc0d70b8dea04934d8 100644 (file)
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: md-os.c 7958 2007-05-23 19:11:10Z twisti $
-
 */
 
 
 #include "config.h"
 
 #include <assert.h>
+#include <stdint.h>
 #include <ucontext.h>
 
 #include "vm/types.h"
 
 void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 {
-       ucontext_t      *_uc;
-       mcontext_t      *_mc;
-       u1              *pv;
-       u1              *sp;
-       u1              *ra;
-       u1              *xpc;
-       u4              mcode;
-       s4              s1;
-       s4              disp;
-       s4              d;
-       s4              type;
-       ptrint          addr;
-       ptrint          val;
-       java_objectheader *e;
+       stackframeinfo  sfi;
+       ucontext_t     *_uc;
+       mcontext_t     *_mc;
+       u1             *pv;
+       u1             *sp;
+       u1             *ra;
+       u1             *xpc;
+       u4              mcode;
+       int             s1;
+       int16_t         disp;
+       int             d;
+       int             type;
+       intptr_t        addr;
+       intptr_t        val;
+       void           *p;
 
        _uc = (ucontext_t *) _p;
        _mc = &(_uc->uc_mcontext);
 
        /* get register values */
+
        pv = (u1*) _mc->gp_regs[REG_PV];
        sp = (u1*) _mc->gp_regs[REG_SP];
        ra = (u1*) _mc->gp_regs[PT_LNK];                     /* correct for leafs */
        xpc =(u1*) _mc->gp_regs[PT_NIP];
 
        /* get the throwing instruction */
+
        mcode = *((u4*)xpc);
 
        s1   = M_INSTR_OP2_IMM_A(mcode);
@@ -94,19 +96,31 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
        val  = _mc->gp_regs[d];
 
-       if (s1 == REG_ZERO)     {
+       if (s1 == REG_ZERO) {
                /* we use the exception type as load displacement */
                type = disp;
-       } else  {
+       }
+       else {
                /* normal NPE */
                addr = _mc->gp_regs[s1];
                type = (s4) addr;
        }
-       e = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val);
 
-       _mc->gp_regs[REG_ITMP1]     = (ptrint) e;
-       _mc->gp_regs[REG_ITMP2_XPC] = (ptrint) xpc;
-       _mc->gp_regs[PT_NIP]        = (ptrint) asm_handle_exception;
+       /* create stackframeinfo */
+
+       stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
+
+       /* Handle the type. */
+
+       p = signal_handle(xpc, type, val);
+
+       /* remove stackframeinfo */
+
+       stacktrace_remove_stackframeinfo(&sfi);
+
+       _mc->gp_regs[REG_ITMP1]     = (intptr_t) p;
+       _mc->gp_regs[REG_ITMP2_XPC] = (intptr_t) xpc;
+       _mc->gp_regs[PT_NIP]        = (intptr_t) asm_handle_exception;
 }