1 /* src/vm/jit/powerpc64/linux/md-os.c - machine dependent PowerPC64 Linux functions
3 Copyright (C) 1996-2005, 2006, 2007, 2008
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 #include "vm/jit/powerpc64/codegen.h"
35 #include "vm/jit/powerpc64/md.h"
36 #include "vm/jit/powerpc64/linux/md-abi.h"
38 #include "threads/thread.h"
40 #include "vm/builtin.h"
41 #include "vm/exceptions.h"
42 #include "vm/signallocal.h"
44 #include "vm/jit/asmpart.h"
46 #if defined(ENABLE_PROFILING)
47 # include "vm/jit/optimizing/profile.h"
50 #include "vm/jit/stacktrace.h"
53 /* md_signal_handler_sigsegv ***************************************************
55 Signal handler for hardware-exceptions.
57 *******************************************************************************/
59 void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
76 _uc = (ucontext_t *) _p;
77 _mc = &(_uc->uc_mcontext);
79 /* get register values */
81 pv = (u1*) _mc->gp_regs[REG_PV];
82 sp = (u1*) _mc->gp_regs[REG_SP];
83 ra = (u1*) _mc->gp_regs[PT_LNK]; /* correct for leafs */
84 xpc =(u1*) _mc->gp_regs[PT_NIP];
86 /* get the throwing instruction */
90 s1 = M_INSTR_OP2_IMM_A(mcode);
91 disp = M_INSTR_OP2_IMM_I(mcode);
92 d = M_INSTR_OP2_IMM_D(mcode);
94 val = _mc->gp_regs[d];
97 /* we use the exception type as load displacement */
100 if (type == EXCEPTION_HARDWARE_COMPILER) {
101 /* The XPC is the RA minus 1, because the RA points to the
102 instruction after the call. */
109 addr = _mc->gp_regs[s1];
113 /* Handle the type. */
115 p = signal_handle(type, val, pv, sp, ra, xpc, _p);
120 case EXCEPTION_HARDWARE_COMPILER:
122 _mc->gp_regs[REG_PV] = (uintptr_t) p;
123 _mc->gp_regs[PT_NIP] = (uintptr_t) p;
127 /* Get and set the PV from the parent Java method. */
129 pv = md_codegen_get_pv_from_pc(ra);
131 _mc->gp_regs[REG_PV] = (uintptr_t) pv;
133 /* Get the exception object. */
135 p = builtin_retrieve_exception();
141 case EXCEPTION_HARDWARE_PATCHER:
148 _mc->gp_regs[REG_ITMP1_XPTR] = (uintptr_t) p;
149 _mc->gp_regs[REG_ITMP2_XPC] = (uintptr_t) xpc;
150 _mc->gp_regs[PT_NIP] = (uintptr_t) asm_handle_exception;
155 /* md_signal_handler_sigusr2 ***************************************************
157 Signal handler for profiling sampling.
159 *******************************************************************************/
161 #if defined(ENABLE_THREADS)
162 void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
171 _uc = (ucontext_t *) _p;
172 _mc = &(_uc->uc_mcontext);
174 pc = (u1 *) _mc->gp_regs[PT_NIP];
181 /* md_critical_section_restart *************************************************
183 Search the critical sections tree for a matching section and set
184 the PC to the restart point, if necessary.
186 *******************************************************************************/
188 #if defined(ENABLE_THREADS)
189 void md_critical_section_restart(ucontext_t *_uc)
195 _mc = &(_uc->uc_mcontext);
197 pc = (u1 *) _mc->gp_regs[PT_NIP];
199 npc = critical_find_restart_point(pc);
202 _mc->gp_regs[PT_NIP] = (ptrint) npc;
208 * These are local overrides for various environment variables in Emacs.
209 * Please do not remove this and leave it at the end of the file, where
210 * Emacs will automagically detect them.
211 * ---------------------------------------------------------------------
214 * indent-tabs-mode: t