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
25 $Id: md.c 7249 2007-01-29 19:32:52Z twisti $
36 #if defined(ENABLE_THREADS)
37 # include "threads/native/threads.h"
40 #include "vm/signallocal.h"
42 #include "vm/jit/asmpart.h"
43 #include "vm/jit/stacktrace.h"
46 /* md_signal_handler_sigsegv ***************************************************
48 NullPointerException signal handler for hardware null pointer
51 *******************************************************************************/
53 void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
61 _uc = (ucontext_t *) _p;
62 _mc = &_uc->uc_mcontext;
64 sp = (u1 *) _mc->mc_rsp;
65 xpc = (u1 *) _mc->mc_rip;
66 ra = xpc; /* return address is equal to xpc */
69 /* check for StackOverflowException */
71 threads_check_stackoverflow(sp);
75 (ptrint) stacktrace_hardware_nullpointerexception(NULL, sp, ra, xpc);
77 _mc->mc_r10 = (ptrint) xpc; /* REG_ITMP2_XPC */
78 _mc->mc_rip = (ptrint) asm_handle_exception;
82 /* md_signal_handler_sigfpe ****************************************************
84 ArithmeticException signal handler for hardware divide by zero
87 *******************************************************************************/
89 void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
97 _uc = (ucontext_t *) _p;
98 _mc = &_uc->uc_mcontext;
100 sp = (u1 *) _mc->mc_rsp;
101 xpc = (u1 *) _mc->mc_rip;
102 ra = xpc; /* return address is equal to xpc */
105 (ptrint) stacktrace_hardware_arithmeticexception(NULL, sp, ra, xpc);
107 _mc->mc_r10 = (ptrint) xpc; /* REG_ITMP2_XPC */
108 _mc->mc_rip = (ptrint) asm_handle_exception;
112 /* md_signal_handler_sigusr2 ***************************************************
114 Signal handler for profiling sampling.
116 *******************************************************************************/
118 #if defined(ENABLE_THREADS)
119 void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
128 _uc = (ucontext_t *) _p;
129 _mc = &_uc->uc_mcontext;
131 pc = (u1 *) _mc->mc_rip;
138 #if defined(ENABLE_THREADS)
139 void thread_restartcriticalsection(ucontext_t *_uc)
145 _mc = &_uc->uc_mcontext;
147 pc = (u1 *) _mc->mc_rip;
149 critical = critical_find_restart_point(pc);
151 if (critical != NULL)
152 _mc->mc_rip = (ptrint) critical;
158 * These are local overrides for various environment variables in Emacs.
159 * Please do not remove this and leave it at the end of the file, where
160 * Emacs will automagically detect them.
161 * ---------------------------------------------------------------------
164 * indent-tabs-mode: t
168 * vim:noexpandtab:sw=4:ts=4: