1 /* src/vm/jit/x86_64/freebsd/md-os.c - machine dependent x86_64 FreeBSD functions
3 Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
34 #if defined(ENABLE_THREADS)
35 # include "threads/native/threads.h"
38 #include "vm/signallocal.h"
40 #include "vm/jit/asmpart.h"
41 #include "vm/jit/stacktrace.h"
44 /* md_signal_handler_sigsegv ***************************************************
46 NullPointerException signal handler for hardware null pointer
49 *******************************************************************************/
51 void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
59 _uc = (ucontext_t *) _p;
60 _mc = &_uc->uc_mcontext;
62 sp = (u1 *) _mc->mc_rsp;
63 xpc = (u1 *) _mc->mc_rip;
64 ra = xpc; /* return address is equal to xpc */
67 /* check for StackOverflowException */
69 threads_check_stackoverflow(sp);
73 (ptrint) stacktrace_hardware_nullpointerexception(NULL, sp, ra, xpc);
75 _mc->mc_r10 = (ptrint) xpc; /* REG_ITMP2_XPC */
76 _mc->mc_rip = (ptrint) asm_handle_exception;
80 /* md_signal_handler_sigfpe ****************************************************
82 ArithmeticException signal handler for hardware divide by zero
85 *******************************************************************************/
87 void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
95 _uc = (ucontext_t *) _p;
96 _mc = &_uc->uc_mcontext;
98 sp = (u1 *) _mc->mc_rsp;
99 xpc = (u1 *) _mc->mc_rip;
100 ra = xpc; /* return address is equal to xpc */
103 (ptrint) stacktrace_hardware_arithmeticexception(NULL, sp, ra, xpc);
105 _mc->mc_r10 = (ptrint) xpc; /* REG_ITMP2_XPC */
106 _mc->mc_rip = (ptrint) asm_handle_exception;
110 /* md_signal_handler_sigusr2 ***************************************************
112 Signal handler for profiling sampling.
114 *******************************************************************************/
116 #if defined(ENABLE_THREADS)
117 void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
126 _uc = (ucontext_t *) _p;
127 _mc = &_uc->uc_mcontext;
129 pc = (u1 *) _mc->mc_rip;
136 #if defined(ENABLE_THREADS)
137 void thread_restartcriticalsection(ucontext_t *_uc)
143 _mc = &_uc->uc_mcontext;
145 pc = (u1 *) _mc->mc_rip;
147 critical = critical_find_restart_point(pc);
149 if (critical != NULL)
150 _mc->mc_rip = (ptrint) critical;
156 * These are local overrides for various environment variables in Emacs.
157 * Please do not remove this and leave it at the end of the file, where
158 * Emacs will automagically detect them.
159 * ---------------------------------------------------------------------
162 * indent-tabs-mode: t
166 * vim:noexpandtab:sw=4:ts=4: