* Removed all Id tags.
[cacao.git] / src / vm / jit / powerpc64 / linux / md-os.c
index 730435c0294af9d7d26a306573c6dbfe6da7d32e..3e62f609598ae29371a409dc0d70b8dea04934d8 100644 (file)
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: md-os.c 7596 2007-03-28 21:05:53Z 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;
 }
 
 
@@ -133,22 +147,31 @@ void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
 
        tobj->pc = pc;
 }
+#endif
+
 
+/* md_critical_section_restart *************************************************
 
-void thread_restartcriticalsection(ucontext_t *_uc)
+   Search the critical sections tree for a matching section and set
+   the PC to the restart point, if necessary.
+
+*******************************************************************************/
+
+#if defined(ENABLE_THREADS)
+void md_critical_section_restart(ucontext_t *_uc)
 {
        mcontext_t *_mc;
        u1         *pc;
-       void       *critical;
+       u1         *npc;
 
        _mc = &(_uc->uc_mcontext);
 
        pc = (u1 *) _mc->gp_regs[PT_NIP];
 
-       critical = critical_find_restart_point(pc);
+       npc = critical_find_restart_point(pc);
 
-       if (critical != NULL)
-               _mc->gp_regs[PT_NIP] = (ptrint) critical;
+       if (npc != NULL)
+               _mc->gp_regs[PT_NIP] = (ptrint) npc;
 }
 #endif