1 /* src/vm/jit/powerpc/darwin/md-os.c - machine dependent PowerPC Darwin functions
3 Copyright (C) 1996-2005, 2006 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 Contact: cacao@cacaojvm.org
27 Authors: Christian Thalinger
31 $Id: md-os.c 6123 2006-12-05 21:10:54Z twisti $
44 #include "vm/jit/powerpc/darwin/md-abi.h"
46 #include "vm/exceptions.h"
47 #include "vm/global.h"
48 #include "vm/signallocal.h"
49 #include "vm/stringlocal.h"
50 #include "vm/jit/asmpart.h"
51 #include "vm/jit/stacktrace.h"
54 /* md_signal_handler_sigsegv ***************************************************
56 NullPointerException signal handler for hardware null pointer
59 *******************************************************************************/
61 void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
65 ppc_thread_state_t *_ss;
78 _uc = (ucontext_t *) _p;
79 _mc = _uc->uc_mcontext;
82 /* check for NullPointerException */
86 instr = *((u4 *) _ss->srr0);
87 reg = (instr >> 16) & 31;
88 disp = (instr & 0xffff);
93 ra = (u1 *) _ss->lr; /* this is correct for leafs */
94 xpc = (u1 *) _ss->srr0;
96 /* create stackframeinfo */
98 stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
100 if (reg == REG_ZERO) {
102 case EXCEPTION_LOAD_DISP_ARITHMETIC:
103 vm_abort("ArithmeticException");
105 case EXCEPTION_LOAD_DISP_ARRAYINDEXOUTOFBOUNDS:
106 log_println("ArrayIndexOutOfBoundsException");
107 o = new_arrayindexoutofboundsexception(0);
109 case EXCEPTION_LOAD_DISP_CLASSCAST:
110 vm_abort("ClassCastException");
113 vm_abort("unknown exception %d", disp);
116 else if (addr == 0) {
117 o = exceptions_new_nullpointerexception();
120 codegen_get_pv_from_pc(xpc);
122 /* this should not happen */
127 /* remove stackframeinfo */
129 stacktrace_remove_stackframeinfo(&sfi);
131 _ss->r11 = (ptrint) o;
132 _ss->r12 = (ptrint) xpc;
133 _ss->srr0 = (ptrint) asm_handle_exception;
137 /* md_signal_handler_sigusr2 ***************************************************
139 Signal handler for profiling sampling.
141 *******************************************************************************/
143 void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
148 ppc_thread_state_t *_ss;
153 _uc = (ucontext_t *) _p;
154 _mc = _uc->uc_mcontext;
157 pc = (u1 *) _ss->srr0;
163 #if defined(ENABLE_THREADS)
164 void thread_restartcriticalsection(ucontext_t *_uc)
167 ppc_thread_state_t *_ss;
170 _mc = _uc->uc_mcontext;
173 critical = critical_find_restart_point((void *) _ss->srr0);
176 _ss->srr0 = (ptrint) critical;
182 * These are local overrides for various environment variables in Emacs.
183 * Please do not remove this and leave it at the end of the file, where
184 * Emacs will automagically detect them.
185 * ---------------------------------------------------------------------
188 * indent-tabs-mode: t