1 /* src/vm/jit/i386/solaris/md-os.c - machine dependent i386 Solaris functions
3 Copyright (C) 2008, 2009
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
34 #define SKIP_REG_DEFS 1
36 #include "vm/jit/i386/codegen.h"
37 #include "vm/jit/i386/md.h"
39 #include "threads/thread.hpp"
41 #include "vm/signallocal.hpp"
43 #include "vm/jit/executionstate.h"
44 #include "vm/jit/trap.hpp"
48 * Signal handler for hardware exceptions.
50 void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
52 ucontext_t *_uc = (ucontext_t *) _p;
53 mcontext_t *_mc = &_uc->uc_mcontext;
55 void* xpc = (void*) _mc->gregs[EIP];
58 trap_handle(TRAP_SIGSEGV, xpc, _p);
63 * Signal handler for hardware divide by zero (ArithmeticException)
66 void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
68 ucontext_t *_uc = (ucontext_t *) _p;
69 mcontext_t *_mc = &_uc->uc_mcontext;
71 void* xpc = (void*) _mc->gregs[EIP];
74 trap_handle(TRAP_SIGFPE, xpc, _p);
79 * Signal handler for hardware patcher traps (ud2).
81 void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
83 ucontext_t *_uc = (ucontext_t *) _p;
84 mcontext_t *_mc = &_uc->uc_mcontext;
86 void* xpc = (void*) _mc->gregs[EIP];
89 trap_handle(TRAP_SIGILL, xpc, _p);
93 /* md_signal_handler_sigusr2 ***************************************************
95 Signal handler for profiling sampling.
97 *******************************************************************************/
99 #if defined(ENABLE_THREADS)
100 void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
109 _uc = (ucontext_t *) _p;
110 _mc = &_uc->uc_mcontext;
112 pc = (u1 *) _mc->gregs[EIP];
119 /* md_executionstate_read ******************************************************
121 Read the given context into an executionstate for Replacement.
123 *******************************************************************************/
125 void md_executionstate_read(executionstate_t *es, void *context)
131 _uc = (ucontext_t *) context;
132 _mc = &_uc->uc_mcontext;
134 /* read special registers */
135 es->pc = (u1 *) _mc->gregs[EIP];
136 es->sp = (u1 *) _mc->gregs[UESP];
137 es->pv = NULL; /* pv must be looked up via AVL tree */
139 /* read integer registers */
140 for (i = 0; i < INT_REG_CNT; i++)
141 es->intregs[i] = _mc->gregs[EAX - i];
143 /* read float registers */
144 for (i = 0; i < FLT_REG_CNT; i++)
145 es->fltregs[i] = 0xdeadbeefdeadbeefULL;
149 /* md_executionstate_write *****************************************************
151 Write the given executionstate back to the context for Replacement.
153 *******************************************************************************/
155 void md_executionstate_write(executionstate_t *es, void *context)
161 _uc = (ucontext_t *) context;
162 _mc = &_uc->uc_mcontext;
164 /* write integer registers */
165 for (i = 0; i < INT_REG_CNT; i++)
166 _mc->gregs[EAX - i] = es->intregs[i];
168 /* write special registers */
169 _mc->gregs[EIP] = (ptrint) es->pc;
170 _mc->gregs[UESP] = (ptrint) es->sp;
175 * These are local overrides for various environment variables in Emacs.
176 * Please do not remove this and leave it at the end of the file, where
177 * Emacs will automagically detect them.
178 * ---------------------------------------------------------------------
181 * indent-tabs-mode: t