-/* md_signal_handler_sigsegv ***************************************************
-
- NullPointerException signal handler for hardware null pointer
- check.
-
-*******************************************************************************/
-
-void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
-{
- ucontext_t *_uc;
- mcontext_t *_mc;
- u1 *sp;
- u1 *ra;
- u1 *xpc;
-
- _uc = (ucontext_t *) _p;
- _mc = &_uc->uc_mcontext;
-
- /* ATTENTION: Don't use CACAO's internal REG_* defines as they are
- different to the ones in <ucontext.h>. */
-
- sp = (u1 *) _mc->gregs[REG_RSP];
- xpc = (u1 *) _mc->gregs[REG_RIP];
- ra = xpc; /* return address is equal to xpc */
-
-#if 0
- /* check for StackOverflowException */
-
- threads_check_stackoverflow(sp);
-#endif
-
- _mc->gregs[REG_RAX] =
- (ptrint) stacktrace_hardware_nullpointerexception(NULL, sp, ra, xpc);
-
- _mc->gregs[REG_R10] = (ptrint) xpc; /* REG_ITMP2_XPC */
- _mc->gregs[REG_RIP] = (ptrint) asm_handle_exception;
-}
-
-
-/* md_signal_handler_sigfpe ****************************************************
-
- ArithmeticException signal handler for hardware divide by zero
- check.
-
-*******************************************************************************/
-
-void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
-{
- ucontext_t *_uc;
- mcontext_t *_mc;
- u1 *sp;
- u1 *ra;
- u1 *xpc;
-
- _uc = (ucontext_t *) _p;
- _mc = &_uc->uc_mcontext;
-
- /* ATTENTION: Don't use CACAO's internal REG_* defines as they are
- different to the ones in <ucontext.h>. */
-
- sp = (u1 *) _mc->gregs[REG_RSP];
- xpc = (u1 *) _mc->gregs[REG_RIP];
- ra = xpc; /* return address is equal to xpc */
-
- _mc->gregs[REG_RAX] =
- (ptrint) stacktrace_hardware_arithmeticexception(NULL, sp, ra, xpc);
-
- _mc->gregs[REG_R10] = (ptrint) xpc; /* REG_ITMP2_XPC */
- _mc->gregs[REG_RIP] = (ptrint) asm_handle_exception;
-}
-
-
-/* md_signal_handler_sigusr2 ***************************************************
-
- Signal handler for profiling sampling.
-
-*******************************************************************************/
-
-#if defined(ENABLE_THREADS)
-void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
-{
- threadobject *t;
- ucontext_t *_uc;
- mcontext_t *_mc;
- u1 *pc;
-
- t = THREADOBJECT;
-
- _uc = (ucontext_t *) _p;
- _mc = &_uc->uc_mcontext;
-
- /* ATTENTION: Don't use CACAO's internal REG_* defines as they are
- different to the ones in <ucontext.h>. */
-
- pc = (u1 *) _mc->gregs[REG_RIP];
-
- t->pc = pc;
-}
-#endif
-
-
-#if defined(ENABLE_THREADS)
-void thread_restartcriticalsection(ucontext_t *_uc)
-{
- mcontext_t *_mc;
- void *pc;
-
- _mc = &_uc->uc_mcontext;
-
- pc = critical_find_restart_point((void *) _mc->gregs[REG_RIP]);
-
- if (pc != NULL)
- _mc->gregs[REG_RIP] = (ptrint) pc;
-}
-#endif
-
-
-/* md_codegen_patch_branch *****************************************************
-
- Back-patches a branch instruction.
-
-*******************************************************************************/
-
-void md_codegen_patch_branch(codegendata *cd, s4 branchmpc, s4 targetmpc)
-{
- s4 *mcodeptr;
- s4 disp; /* branch displacement */
-
- /* calculate the patch position */
-
- mcodeptr = (s4 *) (cd->mcodebase + branchmpc);
-
- /* Calculate the branch displacement. */
-
- disp = targetmpc - branchmpc;
-
- /* I don't think we have to check for branch-displacement
- overflow. +/-2GB should be enough. */
-
- /* patch the branch instruction before the mcodeptr */
-
- mcodeptr[-1] = disp;
-}
-
-