1 /* src/vm/jit/sparc64/solaris/md-os.c - machine dependent SPARC Solaris 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
32 /* work around name clash */
37 #include "vm/jit/sparc64/codegen.h"
38 #include "vm/jit/sparc64/md-abi.h"
40 #include "vm/signallocal.hpp"
42 #include "vm/jit/asmpart.h"
43 #include "vm/jit/stacktrace.hpp"
44 #include "vm/jit/trap.h"
47 ptrint md_get_reg_from_context(mcontext_t *_mc, u4 rindex)
53 /* return 0 for REG_ZERO */
61 /* register is in global or out range, available in context */
62 val = _mc->gregs[rindex + 3];
68 /* register is local or in, need to fetch from regsave area on stack */
70 window = (s8 *) (_mc->gregs[REG_O6] + BIAS);
71 val = window[rindex - 16];
79 /* md_signal_handler_sigsegv ***************************************************
81 NullPointerException signal handler for hardware null pointer
84 *******************************************************************************/
86 void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
103 _uc = (ucontext_t *) _p;
104 _mc = &_uc->uc_mcontext;
106 pv = (u1 *) md_get_reg_from_context(_mc, REG_PV_CALLEE);
107 sp = (u1 *) _mc->gregs[REG_O6];
108 ra = (u1 *) md_get_reg_from_context(_mc, REG_RA_CALLEE);
109 xpc = (u1 *) _mc->gregs[REG_PC];
112 /* get exception-throwing instruction */
114 mcode = *((u4 *) xpc);
116 d = M_OP3_GET_RD(mcode);
117 s1 = M_OP3_GET_RS(mcode);
118 disp = M_OP3_GET_IMM(mcode);
120 /* flush register windows? */
122 val = md_get_reg_from_context(_mc, d);
124 /* check for special-load */
126 if (s1 == REG_ZERO) {
127 /* we use the exception type as load displacement */
132 /* This is a normal NPE: addr must be NULL and the NPE-type
135 addr = md_get_reg_from_context(_mc, s1);
139 /* Handle the trap. */
141 p = trap_handle(type, val, pv, sp, ra, xpc, _p);
145 _mc->gregs[REG_G2] = (uintptr_t) p; /* REG_ITMP2_XPTR */
146 _mc->gregs[REG_G3] = (uintptr_t) xpc; /* REG_ITMP3_XPC */
147 _mc->gregs[REG_PC] = (uintptr_t) asm_handle_exception;
148 _mc->gregs[REG_nPC] = (uintptr_t) asm_handle_exception + 4;
152 /* md_icacheflush **************************************************************
154 Calls the system's function to flush the instruction cache.
156 *******************************************************************************/
158 void md_icacheflush(u1 *addr, s4 nbytes)
164 /* zero the least significant 3 bits to align on a 64-bit boundary */
165 addr = (u1 *) (((ptrint) addr) & -8l);
181 * These are local overrides for various environment variables in Emacs.
182 * Please do not remove this and leave it at the end of the file, where
183 * Emacs will automagically detect them.
184 * ---------------------------------------------------------------------
187 * indent-tabs-mode: t