#define scontext_t struct sigcontext
-#include "threads/thread.h"
+#include "threads/thread.hpp"
-#include "vm/exceptions.h"
+#include "vm/os.hpp"
#include "vm/signallocal.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
+#include "vm/vm.hpp"
#include "vm/jit/asmpart.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/executionstate.h"
+#include "vm/jit/trap.h"
/* md_signal_handler_sigsegv ***************************************************
mcode = *((s4 *) xpc);
- /* this is a NullPointerException */
+ /* This is a NullPointerException. */
addr = *((s4 *) _sc + OFFSET(scontext_t, arm_r0)/4 + ((mcode >> 16) & 0x0f));
- type = EXCEPTION_HARDWARE_NULLPOINTER;
+ type = addr;
val = 0;
- if (addr != 0)
- vm_abort("md_signal_handler_sigsegv: faulting address is not NULL: addr=%p", addr);
+ /* Handle the trap. */
- /* Handle the type. */
-
- p = signal_handle(type, val, pv, sp, ra, xpc, _p);
+ p = trap_handle(type, val, pv, sp, ra, xpc, _p);
/* set registers */
- _sc->arm_r10 = (intptr_t) p;
- _sc->arm_fp = (intptr_t) xpc;
- _sc->arm_pc = (intptr_t) asm_handle_exception;
+ _sc->arm_r10 = (uintptr_t) p;
+ _sc->arm_fp = (uintptr_t) xpc;
+ _sc->arm_pc = (uintptr_t) asm_handle_exception;
}
type = (mcode >> 8) & 0x0fff;
val = *((s4 *) _sc + OFFSET(scontext_t, arm_r0)/4 + (mcode & 0x0f));
- /* 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 if we have an exception, continue execution
otherwise (this is needed for patchers to work) */
if (p != NULL) {
- _sc->arm_r10 = (intptr_t) p;
- _sc->arm_fp = (intptr_t) xpc;
- _sc->arm_pc = (intptr_t) asm_handle_exception;
+ _sc->arm_r10 = (uintptr_t) p;
+ _sc->arm_fp = (uintptr_t) xpc;
+ _sc->arm_pc = (uintptr_t) asm_handle_exception;
}
}
#endif
-/* md_critical_section_restart *************************************************
+/**
+ * Read the given context into an executionstate.
+ *
+ * @param es execution state
+ * @param context machine context
+ */
+void md_executionstate_read(executionstate_t *es, void *context)
+{
+ vm_abort("md_executionstate_read: IMPLEMENT ME!");
- Search the critical sections tree for a matching section and set
- the PC to the restart point, if necessary.
+#if 0
+ ucontext_t *_uc;
+ mcontext_t *_mc;
+ int i;
-*******************************************************************************/
+ _uc = (ucontext_t *) context;
+ _mc = &_uc->uc_mcontext;
-#if defined(ENABLE_THREADS)
-void md_critical_section_restart(ucontext_t *_uc)
+ /* read special registers */
+ es->pc = (u1 *) _mc->sc_pc;
+ es->sp = (u1 *) _mc->sc_regs[REG_SP];
+ es->pv = (u1 *) _mc->sc_regs[REG_PV];
+ es->ra = (u1 *) _mc->sc_regs[REG_RA];
+
+ /* read integer registers */
+ for (i = 0; i < INT_REG_CNT; i++)
+ es->intregs[i] = _mc->sc_regs[i];
+
+ /* read float registers */
+ /* Do not use the assignment operator '=', as the type of
+ * the _mc->sc_fpregs[i] can cause invalid conversions. */
+
+ assert(sizeof(_mc->sc_fpregs) == sizeof(es->fltregs));
+ os_memcpy(&es->fltregs, &_mc->sc_fpregs, sizeof(_mc->sc_fpregs));
+#endif
+}
+
+
+/**
+ * Write the given executionstate back to the context.
+ *
+ * @param es execution state
+ * @param context machine context
+ */
+void md_executionstate_write(executionstate_t *es, void *context)
{
- scontext_t *_sc;
- u1 *pc;
- u1 *npc;
+ vm_abort("md_executionstate_write: IMPLEMENT ME!");
- _sc = &_uc->uc_mcontext;
+#if 0
+ ucontext_t *_uc;
+ mcontext_t *_mc;
+ int i;
- pc = (u1 *) _sc->arm_pc;
+ _uc = (ucontext_t *) context;
+ _mc = &_uc->uc_mcontext;
- npc = critical_find_restart_point(pc);
+ /* write integer registers */
+ for (i = 0; i < INT_REG_CNT; i++)
+ _mc->sc_regs[i] = es->intregs[i];
- if (npc != NULL)
- _sc->arm_pc = (ptrint) npc;
-}
+ /* write float registers */
+ /* Do not use the assignment operator '=', as the type of
+ * the _mc->sc_fpregs[i] can cause invalid conversions. */
+
+ assert(sizeof(_mc->sc_fpregs) == sizeof(es->fltregs));
+ os_memcpy(&_mc->sc_fpregs, &es->fltregs, sizeof(_mc->sc_fpregs));
+
+ /* write special registers */
+ _mc->sc_pc = (ptrint) es->pc;
+ _mc->sc_regs[REG_SP] = (ptrint) es->sp;
+ _mc->sc_regs[REG_PV] = (ptrint) es->pv;
+ _mc->sc_regs[REG_RA] = (ptrint) es->ra;
#endif
+}
/*