CACAO
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
source
cacao
src
vm
jit
mips
irix
md-os.cpp
Go to the documentation of this file.
1
/* src/vm/jit/mips/irix/md-os.cpp - machine dependent MIPS IRIX functions
2
3
Copyright (C) 1996-2013
4
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5
6
This file is part of CACAO.
7
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.
12
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.
17
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
21
02110-1301, USA.
22
23
*/
24
25
26
#include "config.h"
27
28
#include <cassert>
29
#include <signal.h>
30
#include <stdint.h>
31
#include <sys/fpu.h>
32
33
#include "
vm/types.hpp
"
34
35
#include "
vm/jit/mips/codegen.hpp
"
36
#include "
vm/jit/mips/md-abi.hpp
"
37
38
#include "
mm/gc.hpp
"
39
40
#include "
vm/global.hpp
"
41
#include "
vm/signallocal.hpp
"
42
43
#include "
vm/jit/asmpart.hpp
"
44
#include "
vm/jit/codegen-common.hpp
"
45
46
47
/* md_init *********************************************************************
48
49
Do some machine dependent initialization.
50
51
*******************************************************************************/
52
53
void
md_init
(
void
)
54
{
55
/* The Boehm GC initialization blocks the SIGSEGV signal. So we do a */
56
/* dummy allocation here to ensure that the GC is initialized. */
57
58
#if defined(ENABLE_GC_BOEHM)
59
(
void
)
GCNEW
(
u1
);
60
#endif
61
62
63
/* Turn off flush-to-zero */
64
65
{
66
union
fpc_csr n;
67
n.fc_word = get_fpc_csr();
68
n.fc_struct.flush = 0;
69
set_fpc_csr(n.fc_word);
70
}
71
}
72
73
74
/* md_signal_handler_sigsegv ***************************************************
75
76
Signal handler for hardware-exceptions.
77
78
*******************************************************************************/
79
80
void
md_signal_handler_sigsegv
(
int
sig, siginfo_t *siginfo,
void
*_p)
81
{
82
ucontext_t
*_uc;
83
mcontext_t
*_mc;
84
u1
*
pv
;
85
u1
*
sp
;
86
u1
*
ra
;
87
u1
*
xpc
;
88
u4
mcode;
89
int
d;
90
int
s1
;
91
int16_t disp;
92
intptr_t val;
93
intptr_t addr;
94
int
type;
95
void
*p;
96
97
_uc = (
struct
ucontext
*) _p;
98
_mc = &_uc->
uc_mcontext
;
99
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];
104
105
/* get exception-throwing instruction */
106
107
mcode = *((
u4
*) xpc);
108
109
d =
M_ITYPE_GET_RT
(mcode);
110
s1 =
M_ITYPE_GET_RS
(mcode);
111
disp =
M_ITYPE_GET_IMM
(mcode);
112
113
/* check for special-load */
114
115
if
(s1 ==
REG_ZERO
) {
116
/* we use the exception type as load displacement */
117
118
type = disp;
119
val = _mc->gregs[d];
120
}
121
else
{
122
/* This is a normal NPE: addr must be NULL and the NPE-type
123
define is 0. */
124
125
addr = _mc->gregs[
s1
];
126
type = (int) addr;
127
val = 0;
128
}
129
130
/* Handle the type. */
131
132
p = signal_handle(type, val, pv, sp, ra, xpc, _p);
133
134
/* set registers (only if exception object ready) */
135
136
if
(p != NULL) {
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
;
140
}
141
}
142
143
144
/*
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
* ---------------------------------------------------------------------
149
* Local variables:
150
* mode: c++
151
* indent-tabs-mode: t
152
* c-basic-offset: 4
153
* tab-width: 4
154
* End:
155
*/
REG_SP
#define REG_SP
Definition:
md-abi.hpp:55
M_ITYPE_GET_IMM
#define M_ITYPE_GET_IMM(x)
Definition:
codegen.hpp:106
pv
#define pv
Definition:
md-asm.hpp:65
REG_PV
#define REG_PV
Definition:
md-abi.hpp:42
ra
#define ra
Definition:
md-asm.hpp:62
md_signal_handler_sigsegv
void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
NullPointerException signal handler for hardware null pointer check.
Definition:
md-os.cpp:50
codegen-common.hpp
void
typedef void(JNICALL *jvmtiEventSingleStep)(jvmtiEnv *jvmti_env
ucontext::uc_mcontext
struct sigcontext uc_mcontext
Definition:
md-os.cpp:42
REG_ITMP1_XPTR
#define REG_ITMP1_XPTR
Definition:
md-abi.hpp:50
u1
uint8_t u1
Definition:
types.hpp:40
types.hpp
REG_ITMP2_XPC
#define REG_ITMP2_XPC
Definition:
md-abi.hpp:51
ucontext
Definition:
md-os.cpp:38
md-abi.hpp
xpc
#define xpc
Definition:
md-asm.hpp:51
signallocal.hpp
asmpart.hpp
REG_RA
#define REG_RA
Definition:
md-abi.hpp:41
asm_handle_exception
void asm_handle_exception(void)
GCNEW
#define GCNEW(type)
Definition:
memory.hpp:117
gc.hpp
u4
uint32_t u4
Definition:
types.hpp:46
mcontext_t
CONTEXT mcontext_t
Definition:
ucontext.h:27
sp
#define sp
Definition:
md-asm.hpp:81
M_ITYPE_GET_RT
#define M_ITYPE_GET_RT(x)
Definition:
codegen.hpp:105
codegen.hpp
global.hpp
s1
int8_t s1
Definition:
types.hpp:39
REG_ZERO
#define REG_ZERO
Definition:
md-abi.hpp:56
md_init
void md_init(void)
Definition:
md.cpp:48
M_ITYPE_GET_RS
#define M_ITYPE_GET_RS(x)
Definition:
codegen.hpp:104
Generated on Fri Aug 4 2017 02:01:50 for CACAO by
1.8.5