Merged with tip.
[cacao.git] / src / vm / jit / alpha / linux / md-os.c
index c080a7bc22a6837b633a89beb10aed9d5030f08a..daad38ff3b8dea6e1c63f92628b2344c99322060 100644 (file)
 #include "threads/thread.h"
 
 #include "vm/builtin.h"
-#include "vm/exceptions.h"
 #include "vm/signallocal.h"
 
 #include "vm/jit/asmpart.h"
+#include "vm/jit/executionstate.h"
 #include "vm/jit/stacktrace.h"
+#include "vm/jit/trap.h"
+
+#include "vmcore/system.h"
 
 
 /* md_signal_handler_sigsegv ***************************************************
@@ -94,7 +97,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 1, because the RA points to the
                           instruction after the call. */
 
@@ -109,14 +112,14 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
                type = (int) 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) {
                        _mc->sc_regs[REG_PV] = (uintptr_t) p;
                        _mc->sc_pc           = (uintptr_t) p;
@@ -137,7 +140,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;
 
@@ -204,18 +207,17 @@ void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
 #endif
 
 
-/* md_replace_executionstate_read **********************************************
+/* md_executionstate_read ******************************************************
 
-   Read the given context into an executionstate for Replacement.
+   Read the given context into an executionstate.
 
 *******************************************************************************/
 
-#if defined(ENABLE_REPLACEMENT)
-void md_replace_executionstate_read(executionstate_t *es, void *context)
+void md_executionstate_read(executionstate_t *es, void *context)
 {
        ucontext_t *_uc;
        mcontext_t *_mc;
-       s4          i;
+       int         i;
 
        _uc = (ucontext_t *) context;
        _mc = &_uc->uc_mcontext;
@@ -235,23 +237,21 @@ void md_replace_executionstate_read(executionstate_t *es, void *context)
         * the _mc->sc_fpregs[i] can cause invalid conversions. */
 
        assert(sizeof(_mc->sc_fpregs) == sizeof(es->fltregs));
-       memcpy(&es->fltregs, &_mc->sc_fpregs, sizeof(_mc->sc_fpregs));
+       system_memcpy(&es->fltregs, &_mc->sc_fpregs, sizeof(_mc->sc_fpregs));
 }
-#endif
 
 
-/* md_replace_executionstate_write *********************************************
+/* md_executionstate_write *****************************************************
 
-   Write the given executionstate back to the context for Replacement.
+   Write the given executionstate back to the context.
 
 *******************************************************************************/
 
-#if defined(ENABLE_REPLACEMENT)
-void md_replace_executionstate_write(executionstate_t *es, void *context)
+void md_executionstate_write(executionstate_t *es, void *context)
 {
        ucontext_t *_uc;
        mcontext_t *_mc;
-       s4          i;
+       int         i;
 
        _uc = (ucontext_t *) context;
        _mc = &_uc->uc_mcontext;
@@ -265,7 +265,7 @@ void md_replace_executionstate_write(executionstate_t *es, void *context)
         * the _mc->sc_fpregs[i] can cause invalid conversions. */
 
        assert(sizeof(_mc->sc_fpregs) == sizeof(es->fltregs));
-       memcpy(&_mc->sc_fpregs, &es->fltregs, sizeof(_mc->sc_fpregs));
+       system_memcpy(&_mc->sc_fpregs, &es->fltregs, sizeof(_mc->sc_fpregs));
 
        /* write special registers */
        _mc->sc_pc           = (ptrint) es->pc;
@@ -273,33 +273,6 @@ void md_replace_executionstate_write(executionstate_t *es, void *context)
        _mc->sc_regs[REG_PV] = (ptrint) es->pv;
        _mc->sc_regs[REG_RA] = (ptrint) es->ra;
 }
-#endif
-
-
-/* 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;
-       u1         *pc;
-       u1         *npc;
-
-       _mc = &_uc->uc_mcontext;
-
-       pc = (u1 *) _mc->sc_pc;
-
-       npc = critical_find_restart_point(pc);
-
-       if (npc != NULL)
-               _mc->sc_pc = (ptrint) npc;
-}
-#endif
 
 
 /*