Merged trunk and subtype.
[cacao.git] / src / vm / jit / powerpc / linux / md-os.c
index cdc937f5a8e329af60f7d9b1d1ff3aeb0bd52cec..02c95b6d431b4a802661d665b7172d673b1ae59d 100644 (file)
 #include "vm/jit/powerpc/md.h"
 #include "vm/jit/powerpc/linux/md-abi.h"
 
-#include "threads/thread.h"
+#include "threads/thread.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
+#include "vm/jit/builtin.hpp"
 #include "vm/signallocal.h"
-#include "vm/stringlocal.h"
+#include "vm/os.hpp"
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/executionstate.h"
@@ -49,9 +48,7 @@
 # include "vm/jit/optimizing/profile.h"
 #endif
 
-#include "vm/jit/stacktrace.h"
-
-#include "vmcore/system.h"
+#include "vm/jit/trap.h"
 
 
 /* md_signal_handler_sigsegv ***************************************************
@@ -110,7 +107,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
                type = disp;
 
-               if (type == EXCEPTION_HARDWARE_COMPILER) {
+               if (type == TRAP_COMPILER) {
                        /* The XPC is the RA minus 4, because the RA points to the
                           instruction after the call. */
 
@@ -122,20 +119,17 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
                   define is 0. */
 
                addr = _gregs[s1];
-               type = EXCEPTION_HARDWARE_NULLPOINTER;
-
-               if (addr != 0)
-                       vm_abort("md_signal_handler_sigsegv: faulting address is not NULL: addr=%p", addr);
+               type = addr;
        }
 
-       /* Handle the type. */
+       /* Handle the trap. */
 
-       p = signal_handle(type, val, pv, sp, ra, xpc, _p);
+       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
 
        /* Set registers. */
 
        switch (type) {
-       case EXCEPTION_HARDWARE_COMPILER:
+       case TRAP_COMPILER:
                if (p != NULL) {
                        _gregs[REG_PV] = (uintptr_t) p;
                        _gregs[PT_NIP] = (uintptr_t) p;
@@ -156,7 +150,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
                /* fall-through */
 
-       case EXCEPTION_HARDWARE_PATCHER:
+       case TRAP_PATCHER:
                if (p == NULL)
                        break;
 
@@ -212,20 +206,20 @@ void md_signal_handler_sigtrap(int sig, siginfo_t *siginfo, void *_p)
 
        s1 = M_OP3_GET_A(mcode);
 
-       /* for now we only handle ArrayIndexOutOfBoundsException */
+       /* For now we only handle ArrayIndexOutOfBoundsException. */
 
-       type = EXCEPTION_HARDWARE_ARRAYINDEXOUTOFBOUNDS;
+       type = TRAP_ArrayIndexOutOfBoundsException;
        val  = _gregs[s1];
 
-       /* Handle the type. */
+       /* Handle the trap. */
 
-       p = signal_handle(type, val, pv, sp, ra, xpc, _p);
+       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
 
-       /* set registers */
+       /* Set registers. */
 
-       _gregs[REG_ITMP1_XPTR] = (intptr_t) p;
-       _gregs[REG_ITMP2_XPC]  = (intptr_t) xpc;
-       _gregs[PT_NIP]         = (intptr_t) asm_handle_exception;
+       _gregs[REG_ITMP1_XPTR] = (uintptr_t) p;
+       _gregs[REG_ITMP2_XPC]  = (uintptr_t) xpc;
+       _gregs[PT_NIP]         = (uintptr_t) asm_handle_exception;
 }
 
 
@@ -337,7 +331,7 @@ void md_executionstate_read(executionstate_t *es, void *context)
         * the _mc->fpregs[i] can cause invalid conversions. */
 
        assert(sizeof(_mc->fpregs.fpregs) == sizeof(es->fltregs));
-       system_memcpy(&es->fltregs, &_mc->fpregs.fpregs, sizeof(_mc->fpregs.fpregs));
+       os_memcpy(&es->fltregs, &_mc->fpregs.fpregs, sizeof(_mc->fpregs.fpregs));
 }
 
 
@@ -372,7 +366,7 @@ void md_executionstate_write(executionstate_t *es, void *context)
         * the _mc->fpregs[i] can cause invalid conversions. */
 
        assert(sizeof(_mc->fpregs.fpregs) == sizeof(es->fltregs));
-       system_memcpy(&_mc->fpregs.fpregs, &es->fltregs, sizeof(_mc->fpregs.fpregs));
+       os_memcpy(&_mc->fpregs.fpregs, &es->fltregs, sizeof(_mc->fpregs.fpregs));
 
        /* write special registers */
        _gregs[PT_NIP] = (ptrint) es->pc;
@@ -382,39 +376,6 @@ void md_executionstate_write(executionstate_t *es, void *context)
 }
 
 
-/* md_critical_section_restart *************************************************
-
-   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;
-       unsigned long *_gregs;
-       u1            *pc;
-       u1            *npc;
-
-#if defined(__UCLIBC__)
-       _mc    = &(_uc->uc_mcontext);
-       _gregs = _mc->regs->gpr;
-#else
-       _mc    = _uc->uc_mcontext.uc_regs;
-       _gregs = _mc->gregs;
-#endif
-
-       pc = (u1 *) _gregs[PT_NIP];
-
-       npc = critical_find_restart_point(pc);
-
-       if (npc != NULL)
-               _gregs[PT_NIP] = (ptrint) npc;
-}
-#endif
-
-
 /*
  * These are local overrides for various environment variables in Emacs.
  * Please do not remove this and leave it at the end of the file, where