1 /* src/vm/jit/mips/irix/md-os.c - machine dependent MIPS IRIX 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
35 #include "vm/jit/mips/codegen.h"
36 #include "vm/jit/mips/md-abi.h"
40 #include "vm/global.h"
41 #include "vm/signallocal.h"
42 #include "vm/stringlocal.h"
44 #include "vm/jit/asmpart.h"
45 #include "vm/jit/codegen-common.h"
46 #include "vm/jit/stacktrace.h"
49 /* md_init *********************************************************************
51 Do some machine dependent initialization.
53 *******************************************************************************/
57 /* The Boehm GC initialization blocks the SIGSEGV signal. So we do a */
58 /* dummy allocation here to ensure that the GC is initialized. */
60 #if defined(ENABLE_GC_BOEHM)
65 /* Turn off flush-to-zero */
69 n.fc_word = get_fpc_csr();
70 n.fc_struct.flush = 0;
71 set_fpc_csr(n.fc_word);
76 /* md_signal_handler_sigsegv ***************************************************
78 Signal handler for hardware-exceptions.
80 *******************************************************************************/
82 void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
99 _uc = (struct ucontext *) _p;
100 _mc = &_uc->uc_mcontext;
102 pv = (u1 *) _mc->gregs[REG_PV];
103 sp = (u1 *) _mc->gregs[REG_SP];
104 ra = (u1 *) _mc->gregs[REG_RA]; /* this is correct for leafs */
105 xpc = (u1 *) _mc->gregs[CTX_EPC];
107 /* get exception-throwing instruction */
109 mcode = *((u4 *) xpc);
111 d = M_ITYPE_GET_RT(mcode);
112 s1 = M_ITYPE_GET_RS(mcode);
113 disp = M_ITYPE_GET_IMM(mcode);
115 /* check for special-load */
117 if (s1 == REG_ZERO) {
118 /* we use the exception type as load displacement */
124 /* This is a normal NPE: addr must be NULL and the NPE-type
127 addr = _mc->gregs[s1];
132 /* Handle the type. */
134 p = signal_handle(type, val, pv, sp, ra, xpc, _p);
136 /* set registers (only if exception object ready) */
139 _mc->gregs[REG_ITMP1_XPTR] = (intptr_t) p;
140 _mc->gregs[REG_ITMP2_XPC] = (intptr_t) xpc;
141 _mc->gregs[CTX_EPC] = (intptr_t) asm_handle_exception;
147 * These are local overrides for various environment variables in Emacs.
148 * Please do not remove this and leave it at the end of the file, where
149 * Emacs will automagically detect them.
150 * ---------------------------------------------------------------------
153 * indent-tabs-mode: t