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"
43 #include "vm/jit/asmpart.h"
44 #include "vm/jit/codegen-common.hpp"
47 /* md_init *********************************************************************
49 Do some machine dependent initialization.
51 *******************************************************************************/
55 /* The Boehm GC initialization blocks the SIGSEGV signal. So we do a */
56 /* dummy allocation here to ensure that the GC is initialized. */
58 #if defined(ENABLE_GC_BOEHM)
63 /* Turn off flush-to-zero */
67 n.fc_word = get_fpc_csr();
68 n.fc_struct.flush = 0;
69 set_fpc_csr(n.fc_word);
74 /* md_signal_handler_sigsegv ***************************************************
76 Signal handler for hardware-exceptions.
78 *******************************************************************************/
80 void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
97 _uc = (struct ucontext *) _p;
98 _mc = &_uc->uc_mcontext;
100 pv = (u1 *) _mc->gregs[REG_PV];
101 sp = (u1 *) _mc->gregs[REG_SP];
102 ra = (u1 *) _mc->gregs[REG_RA]; /* this is correct for leafs */
103 xpc = (u1 *) _mc->gregs[CTX_EPC];
105 /* get exception-throwing instruction */
107 mcode = *((u4 *) xpc);
109 d = M_ITYPE_GET_RT(mcode);
110 s1 = M_ITYPE_GET_RS(mcode);
111 disp = M_ITYPE_GET_IMM(mcode);
113 /* check for special-load */
115 if (s1 == REG_ZERO) {
116 /* we use the exception type as load displacement */
122 /* This is a normal NPE: addr must be NULL and the NPE-type
125 addr = _mc->gregs[s1];
130 /* Handle the type. */
132 p = signal_handle(type, val, pv, sp, ra, xpc, _p);
134 /* set registers (only if exception object ready) */
137 _mc->gregs[REG_ITMP1_XPTR] = (intptr_t) p;
138 _mc->gregs[REG_ITMP2_XPC] = (intptr_t) xpc;
139 _mc->gregs[CTX_EPC] = (intptr_t) asm_handle_exception;
145 * These are local overrides for various environment variables in Emacs.
146 * Please do not remove this and leave it at the end of the file, where
147 * Emacs will automagically detect them.
148 * ---------------------------------------------------------------------
151 * indent-tabs-mode: t