author | neliasso |
Mon, 15 Aug 2016 16:04:16 +0200 | |
changeset 40649 | 48c8f5272051 |
parent 40093 | f94d179a730b |
child 40898 | 1c147e5e2b71 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
37430
fd743dadef12
8151939: VM_Version_init() print buffer is too small
coleenp
parents:
35201
diff
changeset
|
2 |
* Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3261
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3261
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3261
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
// no precompiled headers |
14631
526804361522
8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
13963
diff
changeset
|
26 |
#include "asm/macroAssembler.hpp" |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
29573
diff
changeset
|
27 |
#include "macroAssembler_sparc.hpp" |
7397 | 28 |
#include "classfile/classLoader.hpp" |
29 |
#include "classfile/systemDictionary.hpp" |
|
30 |
#include "classfile/vmSymbols.hpp" |
|
25715
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
23865
diff
changeset
|
31 |
#include "code/codeCache.hpp" |
7397 | 32 |
#include "code/icBuffer.hpp" |
33 |
#include "code/vtableStubs.hpp" |
|
34 |
#include "interpreter/interpreter.hpp" |
|
35 |
#include "jvm_solaris.h" |
|
36 |
#include "memory/allocation.inline.hpp" |
|
37 |
#include "nativeInst_sparc.hpp" |
|
38 |
#include "os_share_solaris.hpp" |
|
39 |
#include "prims/jniFastGetField.hpp" |
|
40 |
#include "prims/jvm.h" |
|
41 |
#include "prims/jvm_misc.hpp" |
|
42 |
#include "runtime/arguments.hpp" |
|
43 |
#include "runtime/extendedPC.hpp" |
|
44 |
#include "runtime/frame.inline.hpp" |
|
45 |
#include "runtime/interfaceSupport.hpp" |
|
46 |
#include "runtime/java.hpp" |
|
47 |
#include "runtime/javaCalls.hpp" |
|
48 |
#include "runtime/mutexLocker.hpp" |
|
49 |
#include "runtime/osThread.hpp" |
|
50 |
#include "runtime/sharedRuntime.hpp" |
|
51 |
#include "runtime/stubRoutines.hpp" |
|
14583
d70ee55535f4
8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
13963
diff
changeset
|
52 |
#include "runtime/thread.inline.hpp" |
7397 | 53 |
#include "runtime/timer.hpp" |
54 |
#include "utilities/events.hpp" |
|
55 |
#include "utilities/vmError.hpp" |
|
1 | 56 |
|
57 |
# include <signal.h> // needed first to avoid name collision for "std" with SC 5.0 |
|
58 |
||
59 |
// put OS-includes here |
|
60 |
# include <sys/types.h> |
|
61 |
# include <sys/mman.h> |
|
62 |
# include <pthread.h> |
|
63 |
# include <errno.h> |
|
64 |
# include <dlfcn.h> |
|
65 |
# include <stdio.h> |
|
66 |
# include <unistd.h> |
|
67 |
# include <sys/resource.h> |
|
68 |
# include <thread.h> |
|
69 |
# include <sys/stat.h> |
|
70 |
# include <sys/time.h> |
|
71 |
# include <sys/filio.h> |
|
72 |
# include <sys/utsname.h> |
|
73 |
# include <sys/systeminfo.h> |
|
74 |
# include <sys/socket.h> |
|
75 |
# include <sys/lwp.h> |
|
76 |
# include <poll.h> |
|
77 |
# include <sys/lwp.h> |
|
78 |
||
79 |
# define _STRUCTURED_PROC 1 // this gets us the new structured proc interfaces of 5.6 & later |
|
80 |
# include <sys/procfs.h> // see comment in <sys/procfs.h> |
|
81 |
||
82 |
#define MAX_PATH (2 * K) |
|
83 |
||
84 |
// Minimum stack size for the VM. It's easier to document a constant |
|
85 |
// but it's different for x86 and sparc because the page sizes are different. |
|
86 |
#ifdef _LP64 |
|
87 |
size_t os::Solaris::min_stack_allowed = 128*K; |
|
88 |
#else |
|
89 |
size_t os::Solaris::min_stack_allowed = 96*K; |
|
90 |
#endif |
|
91 |
||
92 |
int os::Solaris::max_register_window_saves_before_flushing() { |
|
93 |
// We should detect this at run time. For now, filling |
|
94 |
// in with a constant. |
|
95 |
return 8; |
|
96 |
} |
|
97 |
||
98 |
static void handle_unflushed_register_windows(gwindows_t *win) { |
|
99 |
int restore_count = win->wbcnt; |
|
100 |
int i; |
|
101 |
||
102 |
for(i=0; i<restore_count; i++) { |
|
103 |
address sp = ((address)win->spbuf[i]) + STACK_BIAS; |
|
104 |
address reg_win = (address)&win->wbuf[i]; |
|
105 |
memcpy(sp,reg_win,sizeof(struct rwindow)); |
|
106 |
} |
|
107 |
} |
|
108 |
||
109 |
char* os::non_memory_address_word() { |
|
110 |
// Must never look like an address returned by reserve_memory, |
|
111 |
// even in its subfields (as defined by the CPU immediate fields, |
|
112 |
// if the CPU splits constants across multiple instructions). |
|
113 |
// On SPARC, 0 != %hi(any real address), because there is no |
|
114 |
// allocation in the first 1Kb of the virtual address space. |
|
115 |
return (char*) 0; |
|
116 |
} |
|
117 |
||
118 |
// Validate a ucontext retrieved from walking a uc_link of a ucontext. |
|
119 |
// There are issues with libthread giving out uc_links for different threads |
|
120 |
// on the same uc_link chain and bad or circular links. |
|
121 |
// |
|
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
122 |
bool os::Solaris::valid_ucontext(Thread* thread, const ucontext_t* valid, const ucontext_t* suspect) { |
1 | 123 |
if (valid >= suspect || |
124 |
valid->uc_stack.ss_flags != suspect->uc_stack.ss_flags || |
|
125 |
valid->uc_stack.ss_sp != suspect->uc_stack.ss_sp || |
|
126 |
valid->uc_stack.ss_size != suspect->uc_stack.ss_size) { |
|
127 |
DEBUG_ONLY(tty->print_cr("valid_ucontext: failed test 1");) |
|
128 |
return false; |
|
129 |
} |
|
130 |
||
131 |
if (thread->is_Java_thread()) { |
|
132 |
if (!valid_stack_address(thread, (address)suspect)) { |
|
133 |
DEBUG_ONLY(tty->print_cr("valid_ucontext: uc_link not in thread stack");) |
|
134 |
return false; |
|
135 |
} |
|
136 |
address _sp = (address)((intptr_t)suspect->uc_mcontext.gregs[REG_SP] + STACK_BIAS); |
|
137 |
if (!valid_stack_address(thread, _sp) || |
|
138 |
!frame::is_valid_stack_pointer(((JavaThread*)thread)->base_of_stack_pointer(), (intptr_t*)_sp)) { |
|
139 |
DEBUG_ONLY(tty->print_cr("valid_ucontext: stackpointer not in thread stack");) |
|
140 |
return false; |
|
141 |
} |
|
142 |
} |
|
143 |
return true; |
|
144 |
} |
|
145 |
||
146 |
// We will only follow one level of uc_link since there are libthread |
|
147 |
// issues with ucontext linking and it is better to be safe and just |
|
148 |
// let caller retry later. |
|
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
149 |
const ucontext_t* os::Solaris::get_valid_uc_in_signal_handler(Thread *thread, |
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
150 |
const ucontext_t *uc) { |
1 | 151 |
|
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
152 |
const ucontext_t *retuc = NULL; |
1 | 153 |
|
154 |
// Sometimes the topmost register windows are not properly flushed. |
|
155 |
// i.e., if the kernel would have needed to take a page fault |
|
156 |
if (uc != NULL && uc->uc_mcontext.gwins != NULL) { |
|
157 |
::handle_unflushed_register_windows(uc->uc_mcontext.gwins); |
|
158 |
} |
|
159 |
||
160 |
if (uc != NULL) { |
|
161 |
if (uc->uc_link == NULL) { |
|
162 |
// cannot validate without uc_link so accept current ucontext |
|
163 |
retuc = uc; |
|
164 |
} else if (os::Solaris::valid_ucontext(thread, uc, uc->uc_link)) { |
|
165 |
// first ucontext is valid so try the next one |
|
166 |
uc = uc->uc_link; |
|
167 |
if (uc->uc_link == NULL) { |
|
168 |
// cannot validate without uc_link so accept current ucontext |
|
169 |
retuc = uc; |
|
170 |
} else if (os::Solaris::valid_ucontext(thread, uc, uc->uc_link)) { |
|
171 |
// the ucontext one level down is also valid so return it |
|
172 |
retuc = uc; |
|
173 |
} |
|
174 |
} |
|
175 |
} |
|
176 |
return retuc; |
|
177 |
} |
|
178 |
||
179 |
// Assumes ucontext is valid |
|
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
180 |
ExtendedPC os::Solaris::ucontext_get_ExtendedPC(const ucontext_t *uc) { |
1 | 181 |
address pc = (address)uc->uc_mcontext.gregs[REG_PC]; |
182 |
// set npc to zero to avoid using it for safepoint, good for profiling only |
|
183 |
return ExtendedPC(pc); |
|
184 |
} |
|
185 |
||
29573
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
26821
diff
changeset
|
186 |
void os::Solaris::ucontext_set_pc(ucontext_t* uc, address pc) { |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
26821
diff
changeset
|
187 |
uc->uc_mcontext.gregs [REG_PC] = (greg_t) pc; |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
26821
diff
changeset
|
188 |
uc->uc_mcontext.gregs [REG_nPC] = (greg_t) (pc + 4); |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
26821
diff
changeset
|
189 |
} |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
26821
diff
changeset
|
190 |
|
1 | 191 |
// Assumes ucontext is valid |
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
192 |
intptr_t* os::Solaris::ucontext_get_sp(const ucontext_t *uc) { |
1 | 193 |
return (intptr_t*)((intptr_t)uc->uc_mcontext.gregs[REG_SP] + STACK_BIAS); |
194 |
} |
|
195 |
||
196 |
// Solaris X86 only |
|
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
197 |
intptr_t* os::Solaris::ucontext_get_fp(const ucontext_t *uc) { |
1 | 198 |
ShouldNotReachHere(); |
199 |
return NULL; |
|
200 |
} |
|
201 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
202 |
address os::Solaris::ucontext_get_pc(const ucontext_t *uc) { |
18025 | 203 |
return (address) uc->uc_mcontext.gregs[REG_PC]; |
204 |
} |
|
205 |
||
206 |
||
1 | 207 |
// For Forte Analyzer AsyncGetCallTrace profiling support - thread |
208 |
// is currently interrupted by SIGPROF. |
|
209 |
// |
|
210 |
// ret_fp parameter is only used by Solaris X86. |
|
211 |
// |
|
212 |
// The difference between this and os::fetch_frame_from_context() is that |
|
213 |
// here we try to skip nested signal frames. |
|
35071
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
214 |
// This method is also used for stack overflow signal handling. |
1 | 215 |
ExtendedPC os::Solaris::fetch_frame_from_ucontext(Thread* thread, |
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
216 |
const ucontext_t* uc, intptr_t** ret_sp, intptr_t** ret_fp) { |
1 | 217 |
|
218 |
assert(thread != NULL, "just checking"); |
|
219 |
assert(ret_sp != NULL, "just checking"); |
|
220 |
assert(ret_fp == NULL, "just checking"); |
|
221 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
222 |
const ucontext_t *luc = os::Solaris::get_valid_uc_in_signal_handler(thread, uc); |
1 | 223 |
|
224 |
return os::fetch_frame_from_context(luc, ret_sp, ret_fp); |
|
225 |
} |
|
226 |
||
227 |
||
228 |
// ret_fp parameter is only used by Solaris X86. |
|
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
229 |
ExtendedPC os::fetch_frame_from_context(const void* ucVoid, |
1 | 230 |
intptr_t** ret_sp, intptr_t** ret_fp) { |
231 |
||
232 |
ExtendedPC epc; |
|
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
233 |
const ucontext_t *uc = (const ucontext_t*)ucVoid; |
1 | 234 |
|
235 |
if (uc != NULL) { |
|
236 |
epc = os::Solaris::ucontext_get_ExtendedPC(uc); |
|
237 |
if (ret_sp) *ret_sp = os::Solaris::ucontext_get_sp(uc); |
|
238 |
} else { |
|
239 |
// construct empty ExtendedPC for return value checking |
|
240 |
epc = ExtendedPC(NULL); |
|
241 |
if (ret_sp) *ret_sp = (intptr_t *)NULL; |
|
242 |
} |
|
243 |
||
244 |
return epc; |
|
245 |
} |
|
246 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
247 |
frame os::fetch_frame_from_context(const void* ucVoid) { |
1 | 248 |
intptr_t* sp; |
249 |
intptr_t* fp; |
|
250 |
ExtendedPC epc = fetch_frame_from_context(ucVoid, &sp, &fp); |
|
251 |
return frame(sp, frame::unpatchable, epc.pc()); |
|
252 |
} |
|
253 |
||
35071
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
254 |
frame os::fetch_frame_from_ucontext(Thread* thread, void* ucVoid) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
255 |
intptr_t* sp; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
256 |
ExtendedPC epc = os::Solaris::fetch_frame_from_ucontext(thread, (ucontext_t*)ucVoid, &sp, NULL); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
257 |
return frame(sp, frame::unpatchable, epc.pc()); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
258 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
259 |
|
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
260 |
bool os::Solaris::get_frame_at_stack_banging_point(JavaThread* thread, ucontext_t* uc, frame* fr) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
261 |
address pc = (address) os::Solaris::ucontext_get_pc(uc); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
262 |
if (Interpreter::contains(pc)) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
263 |
*fr = os::fetch_frame_from_ucontext(thread, uc); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
264 |
if (!fr->is_first_java_frame()) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
265 |
assert(fr->safe_for_sender(thread), "Safety check"); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
266 |
*fr = fr->java_sender(); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
267 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
268 |
} else { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
269 |
// more complex code with compiled code |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
270 |
assert(!Interpreter::contains(pc), "Interpreted methods should have been handled above"); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
271 |
CodeBlob* cb = CodeCache::find_blob(pc); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
272 |
if (cb == NULL || !cb->is_nmethod() || cb->is_frame_complete_at(pc)) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
273 |
// Not sure where the pc points to, fallback to default |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
274 |
// stack overflow handling |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
275 |
return false; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
276 |
} else { |
40649
48c8f5272051
8156659: assert(CodeCache::find_blob_unsafe(_pc) == _cb) failed: inconsistent
neliasso
parents:
40093
diff
changeset
|
277 |
// Returned frame will be the caller of the method that faults on the stack bang. |
48c8f5272051
8156659: assert(CodeCache::find_blob_unsafe(_pc) == _cb) failed: inconsistent
neliasso
parents:
40093
diff
changeset
|
278 |
// Register window not yet rotated (happens at SAVE after stack bang), so there is no new |
48c8f5272051
8156659: assert(CodeCache::find_blob_unsafe(_pc) == _cb) failed: inconsistent
neliasso
parents:
40093
diff
changeset
|
279 |
// frame to go with the faulting PC. Using caller SP that is still in SP, and caller PC |
48c8f5272051
8156659: assert(CodeCache::find_blob_unsafe(_pc) == _cb) failed: inconsistent
neliasso
parents:
40093
diff
changeset
|
280 |
// that was written to O7 at call. |
48c8f5272051
8156659: assert(CodeCache::find_blob_unsafe(_pc) == _cb) failed: inconsistent
neliasso
parents:
40093
diff
changeset
|
281 |
intptr_t* sp = os::Solaris::ucontext_get_sp(uc); |
48c8f5272051
8156659: assert(CodeCache::find_blob_unsafe(_pc) == _cb) failed: inconsistent
neliasso
parents:
40093
diff
changeset
|
282 |
address pc = (address)uc->uc_mcontext.gregs[REG_O7]; |
48c8f5272051
8156659: assert(CodeCache::find_blob_unsafe(_pc) == _cb) failed: inconsistent
neliasso
parents:
40093
diff
changeset
|
283 |
*fr = frame(sp, frame::unpatchable, pc); |
48c8f5272051
8156659: assert(CodeCache::find_blob_unsafe(_pc) == _cb) failed: inconsistent
neliasso
parents:
40093
diff
changeset
|
284 |
|
35071
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
285 |
if (!fr->is_java_frame()) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
286 |
assert(fr->safe_for_sender(thread), "Safety check"); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
287 |
*fr = fr->java_sender(); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
288 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
289 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
290 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
291 |
assert(fr->is_java_frame(), "Safety check"); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
292 |
return true; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
293 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
294 |
|
1 | 295 |
frame os::get_sender_for_C_frame(frame* fr) { |
296 |
return frame(fr->sender_sp(), frame::unpatchable, fr->sender_pc()); |
|
297 |
} |
|
298 |
||
11961
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
299 |
// Returns an estimate of the current stack pointer. Result must be guaranteed to |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
300 |
// point into the calling threads stack, and be no lower than the current stack |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
301 |
// pointer. |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
302 |
address os::current_stack_pointer() { |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
303 |
volatile int dummy; |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
304 |
address sp = (address)&dummy + 8; // %%%% need to confirm if this is right |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
305 |
return sp; |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
306 |
} |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
307 |
|
1 | 308 |
frame os::current_frame() { |
309 |
intptr_t* sp = StubRoutines::Sparc::flush_callers_register_windows_func()(); |
|
310 |
frame myframe(sp, frame::unpatchable, |
|
311 |
CAST_FROM_FN_PTR(address, os::current_frame)); |
|
312 |
if (os::is_first_C_frame(&myframe)) { |
|
313 |
// stack is not walkable |
|
26821
ce9f82507dc2
8058345: Refactor native stack printing from vmError.cpp to debug.cpp to make it available in gdb as well
simonis
parents:
26576
diff
changeset
|
314 |
return frame(NULL, NULL, false); |
1 | 315 |
} else { |
316 |
return os::get_sender_for_C_frame(&myframe); |
|
317 |
} |
|
318 |
} |
|
319 |
||
320 |
bool os::is_allocatable(size_t bytes) { |
|
321 |
#ifdef _LP64 |
|
322 |
return true; |
|
323 |
#else |
|
324 |
return (bytes <= (size_t)3835*M); |
|
325 |
#endif |
|
326 |
} |
|
327 |
||
8106 | 328 |
extern "C" JNIEXPORT int |
329 |
JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, |
|
330 |
int abort_if_unrecognized) { |
|
1 | 331 |
ucontext_t* uc = (ucontext_t*) ucVoid; |
332 |
||
34633
2a6c7c7b30a7
8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents:
33732
diff
changeset
|
333 |
Thread* t = Thread::current_or_null_safe(); |
1 | 334 |
|
18943 | 335 |
// Must do this before SignalHandlerMark, if crash protection installed we will longjmp away |
336 |
// (no destructors can be run) |
|
337 |
os::WatcherThreadCrashProtection::check_crash_protection(sig, t); |
|
338 |
||
1 | 339 |
SignalHandlerMark shm(t); |
340 |
||
341 |
if(sig == SIGPIPE || sig == SIGXFSZ) { |
|
342 |
if (os::Solaris::chained_handler(sig, info, ucVoid)) { |
|
343 |
return true; |
|
344 |
} else { |
|
37430
fd743dadef12
8151939: VM_Version_init() print buffer is too small
coleenp
parents:
35201
diff
changeset
|
345 |
// Ignoring SIGPIPE/SIGXFSZ - see bugs 4229104 or 6499219 |
1 | 346 |
return true; |
347 |
} |
|
348 |
} |
|
349 |
||
350 |
JavaThread* thread = NULL; |
|
351 |
VMThread* vmthread = NULL; |
|
352 |
if (os::Solaris::signal_handlers_are_installed) { |
|
353 |
if (t != NULL ){ |
|
354 |
if(t->is_Java_thread()) { |
|
355 |
thread = (JavaThread*)t; |
|
356 |
} |
|
357 |
else if(t->is_VM_thread()){ |
|
358 |
vmthread = (VMThread *)t; |
|
359 |
} |
|
360 |
} |
|
361 |
} |
|
362 |
||
363 |
if (sig == os::Solaris::SIGasync()) { |
|
18025 | 364 |
if (thread || vmthread) { |
365 |
OSThread::SR_handler(t, uc); |
|
1 | 366 |
return true; |
367 |
} else if (os::Solaris::chained_handler(sig, info, ucVoid)) { |
|
368 |
return true; |
|
369 |
} else { |
|
370 |
// If os::Solaris::SIGasync not chained, and this is a non-vm and |
|
371 |
// non-java thread |
|
372 |
return true; |
|
373 |
} |
|
374 |
} |
|
375 |
||
376 |
if (info == NULL || info->si_code <= 0 || info->si_code == SI_NOINFO) { |
|
377 |
// can't decode this kind of signal |
|
378 |
info = NULL; |
|
379 |
} else { |
|
380 |
assert(sig == info->si_signo, "bad siginfo"); |
|
381 |
} |
|
382 |
||
383 |
// decide if this trap can be handled by a stub |
|
384 |
address stub = NULL; |
|
385 |
||
386 |
address pc = NULL; |
|
387 |
address npc = NULL; |
|
388 |
||
389 |
//%note os_trap_1 |
|
390 |
if (info != NULL && uc != NULL && thread != NULL) { |
|
391 |
// factor me: getPCfromContext |
|
392 |
pc = (address) uc->uc_mcontext.gregs[REG_PC]; |
|
393 |
npc = (address) uc->uc_mcontext.gregs[REG_nPC]; |
|
394 |
||
395 |
// SafeFetch() support |
|
18740 | 396 |
if (StubRoutines::is_safefetch_fault(pc)) { |
29573
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
26821
diff
changeset
|
397 |
os::Solaris::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc)); |
18740 | 398 |
return 1; |
1 | 399 |
} |
400 |
||
401 |
// Handle ALL stack overflow variations here |
|
402 |
if (sig == SIGSEGV && info->si_code == SEGV_ACCERR) { |
|
403 |
address addr = (address) info->si_addr; |
|
35201
996db89f378e
8139864: Improve handling of stack protection zones.
goetz
parents:
35077
diff
changeset
|
404 |
if (thread->in_stack_yellow_reserved_zone(addr)) { |
1 | 405 |
// Sometimes the register windows are not properly flushed. |
406 |
if(uc->uc_mcontext.gwins != NULL) { |
|
407 |
::handle_unflushed_register_windows(uc->uc_mcontext.gwins); |
|
408 |
} |
|
409 |
if (thread->thread_state() == _thread_in_Java) { |
|
35071
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
410 |
if (thread->in_stack_reserved_zone(addr)) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
411 |
frame fr; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
412 |
if (os::Solaris::get_frame_at_stack_banging_point(thread, uc, &fr)) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
413 |
assert(fr.is_java_frame(), "Must be a Java frame"); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
414 |
frame activation = SharedRuntime::look_for_reserved_stack_annotated_method(thread, fr); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
415 |
if (activation.sp() != NULL) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
416 |
thread->disable_stack_reserved_zone(); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
417 |
RegisterMap map(thread); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
418 |
int frame_size = activation.frame_size(&map); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
419 |
thread->set_reserved_stack_activation((address)(((address)activation.sp()) - STACK_BIAS)); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
420 |
return true; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
421 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
422 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
423 |
} |
1 | 424 |
// Throw a stack overflow exception. Guard pages will be reenabled |
425 |
// while unwinding the stack. |
|
35201
996db89f378e
8139864: Improve handling of stack protection zones.
goetz
parents:
35077
diff
changeset
|
426 |
thread->disable_stack_yellow_reserved_zone(); |
1 | 427 |
stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::STACK_OVERFLOW); |
428 |
} else { |
|
429 |
// Thread was in the vm or native code. Return and try to finish. |
|
35201
996db89f378e
8139864: Improve handling of stack protection zones.
goetz
parents:
35077
diff
changeset
|
430 |
thread->disable_stack_yellow_reserved_zone(); |
1 | 431 |
return true; |
432 |
} |
|
433 |
} else if (thread->in_stack_red_zone(addr)) { |
|
434 |
// Fatal red zone violation. Disable the guard pages and fall through |
|
435 |
// to handle_unexpected_exception way down below. |
|
436 |
thread->disable_stack_red_zone(); |
|
437 |
tty->print_raw_cr("An irrecoverable stack overflow has occurred."); |
|
438 |
// Sometimes the register windows are not properly flushed. |
|
439 |
if(uc->uc_mcontext.gwins != NULL) { |
|
440 |
::handle_unflushed_register_windows(uc->uc_mcontext.gwins); |
|
441 |
} |
|
442 |
} |
|
443 |
} |
|
444 |
||
445 |
||
446 |
if (thread->thread_state() == _thread_in_vm) { |
|
447 |
if (sig == SIGBUS && info->si_code == BUS_OBJERR && thread->doing_unsafe_access()) { |
|
38209
b2a58604e046
8156088: Reintegrate 8153892: Handle unsafe access error directly in signal handler instead of going through a stub
mikael
parents:
38190
diff
changeset
|
448 |
stub = SharedRuntime::handle_unsafe_access(thread, npc); |
1 | 449 |
} |
450 |
} |
|
451 |
||
452 |
else if (thread->thread_state() == _thread_in_Java) { |
|
453 |
// Java thread running in Java code => find exception handler if any |
|
454 |
// a fault inside compiled code, the interpreter, or a stub |
|
455 |
||
456 |
// Support Safepoint Polling |
|
457 |
if ( sig == SIGSEGV && (address)info->si_addr == os::get_polling_page() ) { |
|
458 |
stub = SharedRuntime::get_poll_stub(pc); |
|
459 |
} |
|
460 |
||
461 |
// Not needed on x86 solaris because verify_oops doesn't generate |
|
462 |
// SEGV/BUS like sparc does. |
|
463 |
if ( (sig == SIGSEGV || sig == SIGBUS) |
|
464 |
&& pc >= MacroAssembler::_verify_oop_implicit_branch[0] |
|
465 |
&& pc < MacroAssembler::_verify_oop_implicit_branch[1] ) { |
|
466 |
stub = MacroAssembler::_verify_oop_implicit_branch[2]; |
|
467 |
warning("fixed up memory fault in +VerifyOops at address " INTPTR_FORMAT, info->si_addr); |
|
468 |
} |
|
469 |
||
470 |
// This is not factored because on x86 solaris the patching for |
|
471 |
// zombies does not generate a SEGV. |
|
472 |
else if (sig == SIGSEGV && nativeInstruction_at(pc)->is_zombie()) { |
|
473 |
// zombie method (ld [%g0],%o7 instruction) |
|
474 |
stub = SharedRuntime::get_handle_wrong_method_stub(); |
|
475 |
||
476 |
// At the stub it needs to look like a call from the caller of this |
|
477 |
// method (not a call from the segv site). |
|
478 |
pc = (address)uc->uc_mcontext.gregs[REG_O7]; |
|
479 |
} |
|
480 |
else if (sig == SIGBUS && info->si_code == BUS_OBJERR) { |
|
481 |
// BugId 4454115: A read from a MappedByteBuffer can fault |
|
482 |
// here if the underlying file has been truncated. |
|
483 |
// Do not crash the VM in such a case. |
|
484 |
CodeBlob* cb = CodeCache::find_blob_unsafe(pc); |
|
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
37431
diff
changeset
|
485 |
CompiledMethod* nm = cb->as_compiled_method_or_null(); |
1 | 486 |
if (nm != NULL && nm->has_unsafe_access()) { |
38209
b2a58604e046
8156088: Reintegrate 8153892: Handle unsafe access error directly in signal handler instead of going through a stub
mikael
parents:
38190
diff
changeset
|
487 |
stub = SharedRuntime::handle_unsafe_access(thread, npc); |
1 | 488 |
} |
489 |
} |
|
490 |
||
491 |
else if (sig == SIGFPE && info->si_code == FPE_INTDIV) { |
|
492 |
// integer divide by zero |
|
493 |
stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO); |
|
494 |
} |
|
495 |
else if (sig == SIGFPE && info->si_code == FPE_FLTDIV) { |
|
496 |
// floating-point divide by zero |
|
497 |
stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO); |
|
498 |
} |
|
499 |
#ifdef COMPILER2 |
|
500 |
else if (sig == SIGILL && nativeInstruction_at(pc)->is_ic_miss_trap()) { |
|
501 |
#ifdef ASSERT |
|
502 |
#ifdef TIERED |
|
503 |
CodeBlob* cb = CodeCache::find_blob_unsafe(pc); |
|
504 |
assert(cb->is_compiled_by_c2(), "Wrong compiler"); |
|
505 |
#endif // TIERED |
|
506 |
#endif // ASSERT |
|
507 |
// Inline cache missed and user trap "Tne G0+ST_RESERVED_FOR_USER_0+2" taken. |
|
508 |
stub = SharedRuntime::get_ic_miss_stub(); |
|
509 |
// At the stub it needs to look like a call from the caller of this |
|
510 |
// method (not a call from the segv site). |
|
511 |
pc = (address)uc->uc_mcontext.gregs[REG_O7]; |
|
512 |
} |
|
513 |
#endif // COMPILER2 |
|
514 |
||
515 |
else if (sig == SIGSEGV && info->si_code > 0 && !MacroAssembler::needs_explicit_null_check((intptr_t)info->si_addr)) { |
|
516 |
// Determination of interpreter/vtable stub/compiled code null exception |
|
517 |
stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL); |
|
518 |
} |
|
519 |
} |
|
520 |
||
521 |
// jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks in |
|
522 |
// and the heap gets shrunk before the field access. |
|
523 |
if ((sig == SIGSEGV) || (sig == SIGBUS)) { |
|
524 |
address addr = JNI_FastGetField::find_slowcase_pc(pc); |
|
525 |
if (addr != (address)-1) { |
|
526 |
stub = addr; |
|
527 |
} |
|
528 |
} |
|
529 |
||
530 |
// Check to see if we caught the safepoint code in the |
|
531 |
// process of write protecting the memory serialization page. |
|
532 |
// It write enables the page immediately after protecting it |
|
533 |
// so just return. |
|
534 |
if ((sig == SIGSEGV) && |
|
535 |
os::is_memory_serialize_page(thread, (address)info->si_addr)) { |
|
536 |
// Block current thread until the memory serialize page permission restored. |
|
537 |
os::block_on_serialize_page_trap(); |
|
538 |
return true; |
|
539 |
} |
|
540 |
} |
|
541 |
||
542 |
if (stub != NULL) { |
|
543 |
// save all thread context in case we need to restore it |
|
544 |
||
545 |
thread->set_saved_exception_pc(pc); |
|
546 |
thread->set_saved_exception_npc(npc); |
|
547 |
||
548 |
// simulate a branch to the stub (a "call" in the safepoint stub case) |
|
549 |
// factor me: setPC |
|
29573
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
26821
diff
changeset
|
550 |
os::Solaris::ucontext_set_pc(uc, stub); |
1 | 551 |
|
552 |
return true; |
|
553 |
} |
|
554 |
||
555 |
// signal-chaining |
|
556 |
if (os::Solaris::chained_handler(sig, info, ucVoid)) { |
|
557 |
return true; |
|
558 |
} |
|
559 |
||
560 |
if (!abort_if_unrecognized) { |
|
561 |
// caller wants another chance, so give it to him |
|
562 |
return false; |
|
563 |
} |
|
564 |
||
565 |
if (!os::Solaris::libjsig_is_loaded) { |
|
566 |
struct sigaction oldAct; |
|
567 |
sigaction(sig, (struct sigaction *)0, &oldAct); |
|
568 |
if (oldAct.sa_sigaction != signalHandler) { |
|
569 |
void* sighand = oldAct.sa_sigaction ? CAST_FROM_FN_PTR(void*, oldAct.sa_sigaction) |
|
570 |
: CAST_FROM_FN_PTR(void*, oldAct.sa_handler); |
|
2131 | 571 |
warning("Unexpected Signal %d occurred under user-defined signal handler " INTPTR_FORMAT, sig, (intptr_t)sighand); |
1 | 572 |
} |
573 |
} |
|
574 |
||
575 |
if (pc == NULL && uc != NULL) { |
|
576 |
pc = (address) uc->uc_mcontext.gregs[REG_PC]; |
|
577 |
} |
|
578 |
||
7108 | 579 |
// Sometimes the register windows are not properly flushed. |
580 |
if(uc->uc_mcontext.gwins != NULL) { |
|
581 |
::handle_unflushed_register_windows(uc->uc_mcontext.gwins); |
|
582 |
} |
|
583 |
||
1 | 584 |
// unmask current signal |
585 |
sigset_t newset; |
|
586 |
sigemptyset(&newset); |
|
587 |
sigaddset(&newset, sig); |
|
588 |
sigprocmask(SIG_UNBLOCK, &newset, NULL); |
|
589 |
||
7719
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7405
diff
changeset
|
590 |
// Determine which sort of error to throw. Out of swap may signal |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7405
diff
changeset
|
591 |
// on the thread stack, which could get a mapping error when touched. |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7405
diff
changeset
|
592 |
address addr = (address) info->si_addr; |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7405
diff
changeset
|
593 |
if (sig == SIGBUS && info->si_code == BUS_OBJERR && info->si_errno == ENOMEM) { |
17087
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
14633
diff
changeset
|
594 |
vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "Out of swap space to map in thread stack."); |
7719
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7405
diff
changeset
|
595 |
} |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7405
diff
changeset
|
596 |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
29573
diff
changeset
|
597 |
VMError::report_and_die(t, sig, pc, info, ucVoid); |
1 | 598 |
|
599 |
ShouldNotReachHere(); |
|
34667 | 600 |
return false; |
1 | 601 |
} |
602 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
603 |
void os::print_context(outputStream *st, const void *context) { |
1 | 604 |
if (context == NULL) return; |
605 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
606 |
const ucontext_t *uc = (const ucontext_t*)context; |
1 | 607 |
st->print_cr("Registers:"); |
608 |
||
7108 | 609 |
st->print_cr(" G1=" INTPTR_FORMAT " G2=" INTPTR_FORMAT |
610 |
" G3=" INTPTR_FORMAT " G4=" INTPTR_FORMAT, |
|
611 |
uc->uc_mcontext.gregs[REG_G1], |
|
612 |
uc->uc_mcontext.gregs[REG_G2], |
|
613 |
uc->uc_mcontext.gregs[REG_G3], |
|
614 |
uc->uc_mcontext.gregs[REG_G4]); |
|
615 |
st->print_cr(" G5=" INTPTR_FORMAT " G6=" INTPTR_FORMAT |
|
616 |
" G7=" INTPTR_FORMAT " Y=" INTPTR_FORMAT, |
|
617 |
uc->uc_mcontext.gregs[REG_G5], |
|
618 |
uc->uc_mcontext.gregs[REG_G6], |
|
619 |
uc->uc_mcontext.gregs[REG_G7], |
|
620 |
uc->uc_mcontext.gregs[REG_Y]); |
|
1 | 621 |
st->print_cr(" O0=" INTPTR_FORMAT " O1=" INTPTR_FORMAT |
622 |
" O2=" INTPTR_FORMAT " O3=" INTPTR_FORMAT, |
|
623 |
uc->uc_mcontext.gregs[REG_O0], |
|
624 |
uc->uc_mcontext.gregs[REG_O1], |
|
625 |
uc->uc_mcontext.gregs[REG_O2], |
|
626 |
uc->uc_mcontext.gregs[REG_O3]); |
|
627 |
st->print_cr(" O4=" INTPTR_FORMAT " O5=" INTPTR_FORMAT |
|
628 |
" O6=" INTPTR_FORMAT " O7=" INTPTR_FORMAT, |
|
629 |
uc->uc_mcontext.gregs[REG_O4], |
|
630 |
uc->uc_mcontext.gregs[REG_O5], |
|
631 |
uc->uc_mcontext.gregs[REG_O6], |
|
632 |
uc->uc_mcontext.gregs[REG_O7]); |
|
633 |
||
7108 | 634 |
|
635 |
intptr_t *sp = (intptr_t *)os::Solaris::ucontext_get_sp(uc); |
|
636 |
st->print_cr(" L0=" INTPTR_FORMAT " L1=" INTPTR_FORMAT |
|
637 |
" L2=" INTPTR_FORMAT " L3=" INTPTR_FORMAT, |
|
638 |
sp[L0->sp_offset_in_saved_window()], |
|
639 |
sp[L1->sp_offset_in_saved_window()], |
|
640 |
sp[L2->sp_offset_in_saved_window()], |
|
641 |
sp[L3->sp_offset_in_saved_window()]); |
|
642 |
st->print_cr(" L4=" INTPTR_FORMAT " L5=" INTPTR_FORMAT |
|
643 |
" L6=" INTPTR_FORMAT " L7=" INTPTR_FORMAT, |
|
644 |
sp[L4->sp_offset_in_saved_window()], |
|
645 |
sp[L5->sp_offset_in_saved_window()], |
|
646 |
sp[L6->sp_offset_in_saved_window()], |
|
647 |
sp[L7->sp_offset_in_saved_window()]); |
|
648 |
st->print_cr(" I0=" INTPTR_FORMAT " I1=" INTPTR_FORMAT |
|
649 |
" I2=" INTPTR_FORMAT " I3=" INTPTR_FORMAT, |
|
650 |
sp[I0->sp_offset_in_saved_window()], |
|
651 |
sp[I1->sp_offset_in_saved_window()], |
|
652 |
sp[I2->sp_offset_in_saved_window()], |
|
653 |
sp[I3->sp_offset_in_saved_window()]); |
|
654 |
st->print_cr(" I4=" INTPTR_FORMAT " I5=" INTPTR_FORMAT |
|
655 |
" I6=" INTPTR_FORMAT " I7=" INTPTR_FORMAT, |
|
656 |
sp[I4->sp_offset_in_saved_window()], |
|
657 |
sp[I5->sp_offset_in_saved_window()], |
|
658 |
sp[I6->sp_offset_in_saved_window()], |
|
659 |
sp[I7->sp_offset_in_saved_window()]); |
|
1 | 660 |
|
661 |
st->print_cr(" PC=" INTPTR_FORMAT " nPC=" INTPTR_FORMAT, |
|
662 |
uc->uc_mcontext.gregs[REG_PC], |
|
663 |
uc->uc_mcontext.gregs[REG_nPC]); |
|
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
664 |
st->cr(); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
665 |
st->cr(); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
666 |
|
1 | 667 |
st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp); |
668 |
print_hex_dump(st, (address)sp, (address)(sp + 32), sizeof(intptr_t)); |
|
669 |
st->cr(); |
|
670 |
||
671 |
// Note: it may be unsafe to inspect memory near pc. For example, pc may |
|
672 |
// point to garbage if entry point in an nmethod is corrupted. Leave |
|
673 |
// this at the end, and hope for the best. |
|
674 |
ExtendedPC epc = os::Solaris::ucontext_get_ExtendedPC(uc); |
|
675 |
address pc = epc.pc(); |
|
676 |
st->print_cr("Instructions: (pc=" PTR_FORMAT ")", pc); |
|
7108 | 677 |
print_hex_dump(st, pc - 32, pc + 32, sizeof(char)); |
678 |
} |
|
679 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
680 |
void os::print_register_info(outputStream *st, const void *context) { |
7108 | 681 |
if (context == NULL) return; |
682 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
683 |
const ucontext_t *uc = (const ucontext_t*)context; |
7108 | 684 |
intptr_t *sp = (intptr_t *)os::Solaris::ucontext_get_sp(uc); |
685 |
||
686 |
st->print_cr("Register to memory mapping:"); |
|
687 |
st->cr(); |
|
688 |
||
689 |
// this is only for the "general purpose" registers |
|
690 |
st->print("G1="); print_location(st, uc->uc_mcontext.gregs[REG_G1]); |
|
691 |
st->print("G2="); print_location(st, uc->uc_mcontext.gregs[REG_G2]); |
|
692 |
st->print("G3="); print_location(st, uc->uc_mcontext.gregs[REG_G3]); |
|
693 |
st->print("G4="); print_location(st, uc->uc_mcontext.gregs[REG_G4]); |
|
694 |
st->print("G5="); print_location(st, uc->uc_mcontext.gregs[REG_G5]); |
|
695 |
st->print("G6="); print_location(st, uc->uc_mcontext.gregs[REG_G6]); |
|
696 |
st->print("G7="); print_location(st, uc->uc_mcontext.gregs[REG_G7]); |
|
697 |
st->cr(); |
|
698 |
||
699 |
st->print("O0="); print_location(st, uc->uc_mcontext.gregs[REG_O0]); |
|
700 |
st->print("O1="); print_location(st, uc->uc_mcontext.gregs[REG_O1]); |
|
701 |
st->print("O2="); print_location(st, uc->uc_mcontext.gregs[REG_O2]); |
|
702 |
st->print("O3="); print_location(st, uc->uc_mcontext.gregs[REG_O3]); |
|
703 |
st->print("O4="); print_location(st, uc->uc_mcontext.gregs[REG_O4]); |
|
704 |
st->print("O5="); print_location(st, uc->uc_mcontext.gregs[REG_O5]); |
|
705 |
st->print("O6="); print_location(st, uc->uc_mcontext.gregs[REG_O6]); |
|
706 |
st->print("O7="); print_location(st, uc->uc_mcontext.gregs[REG_O7]); |
|
707 |
st->cr(); |
|
708 |
||
709 |
st->print("L0="); print_location(st, sp[L0->sp_offset_in_saved_window()]); |
|
710 |
st->print("L1="); print_location(st, sp[L1->sp_offset_in_saved_window()]); |
|
711 |
st->print("L2="); print_location(st, sp[L2->sp_offset_in_saved_window()]); |
|
712 |
st->print("L3="); print_location(st, sp[L3->sp_offset_in_saved_window()]); |
|
713 |
st->print("L4="); print_location(st, sp[L4->sp_offset_in_saved_window()]); |
|
714 |
st->print("L5="); print_location(st, sp[L5->sp_offset_in_saved_window()]); |
|
715 |
st->print("L6="); print_location(st, sp[L6->sp_offset_in_saved_window()]); |
|
716 |
st->print("L7="); print_location(st, sp[L7->sp_offset_in_saved_window()]); |
|
717 |
st->cr(); |
|
718 |
||
719 |
st->print("I0="); print_location(st, sp[I0->sp_offset_in_saved_window()]); |
|
720 |
st->print("I1="); print_location(st, sp[I1->sp_offset_in_saved_window()]); |
|
721 |
st->print("I2="); print_location(st, sp[I2->sp_offset_in_saved_window()]); |
|
722 |
st->print("I3="); print_location(st, sp[I3->sp_offset_in_saved_window()]); |
|
723 |
st->print("I4="); print_location(st, sp[I4->sp_offset_in_saved_window()]); |
|
724 |
st->print("I5="); print_location(st, sp[I5->sp_offset_in_saved_window()]); |
|
725 |
st->print("I6="); print_location(st, sp[I6->sp_offset_in_saved_window()]); |
|
726 |
st->print("I7="); print_location(st, sp[I7->sp_offset_in_saved_window()]); |
|
727 |
st->cr(); |
|
1 | 728 |
} |
729 |
||
730 |
void os::Solaris::init_thread_fpu_state(void) { |
|
731 |
// Nothing needed on Sparc. |
|
732 |
} |
|
733 |
||
734 |
#if !defined(COMPILER2) && !defined(_LP64) |
|
735 |
||
736 |
// These routines are the initial value of atomic_xchg_entry(), |
|
737 |
// atomic_cmpxchg_entry(), atomic_add_entry() and fence_entry() |
|
738 |
// until initialization is complete. |
|
739 |
// TODO - remove when the VM drops support for V8. |
|
740 |
||
741 |
typedef jint xchg_func_t (jint, volatile jint*); |
|
742 |
typedef jint cmpxchg_func_t (jint, volatile jint*, jint); |
|
743 |
typedef jlong cmpxchg_long_func_t(jlong, volatile jlong*, jlong); |
|
744 |
typedef jint add_func_t (jint, volatile jint*); |
|
745 |
||
746 |
jint os::atomic_xchg_bootstrap(jint exchange_value, volatile jint* dest) { |
|
747 |
// try to use the stub: |
|
748 |
xchg_func_t* func = CAST_TO_FN_PTR(xchg_func_t*, StubRoutines::atomic_xchg_entry()); |
|
749 |
||
750 |
if (func != NULL) { |
|
751 |
os::atomic_xchg_func = func; |
|
752 |
return (*func)(exchange_value, dest); |
|
753 |
} |
|
754 |
assert(Threads::number_of_threads() == 0, "for bootstrap only"); |
|
755 |
||
756 |
jint old_value = *dest; |
|
757 |
*dest = exchange_value; |
|
758 |
return old_value; |
|
759 |
} |
|
760 |
||
761 |
jint os::atomic_cmpxchg_bootstrap(jint exchange_value, volatile jint* dest, jint compare_value) { |
|
762 |
// try to use the stub: |
|
763 |
cmpxchg_func_t* func = CAST_TO_FN_PTR(cmpxchg_func_t*, StubRoutines::atomic_cmpxchg_entry()); |
|
764 |
||
765 |
if (func != NULL) { |
|
766 |
os::atomic_cmpxchg_func = func; |
|
767 |
return (*func)(exchange_value, dest, compare_value); |
|
768 |
} |
|
769 |
assert(Threads::number_of_threads() == 0, "for bootstrap only"); |
|
770 |
||
771 |
jint old_value = *dest; |
|
772 |
if (old_value == compare_value) |
|
773 |
*dest = exchange_value; |
|
774 |
return old_value; |
|
775 |
} |
|
776 |
||
777 |
jlong os::atomic_cmpxchg_long_bootstrap(jlong exchange_value, volatile jlong* dest, jlong compare_value) { |
|
778 |
// try to use the stub: |
|
779 |
cmpxchg_long_func_t* func = CAST_TO_FN_PTR(cmpxchg_long_func_t*, StubRoutines::atomic_cmpxchg_long_entry()); |
|
780 |
||
781 |
if (func != NULL) { |
|
782 |
os::atomic_cmpxchg_long_func = func; |
|
783 |
return (*func)(exchange_value, dest, compare_value); |
|
784 |
} |
|
785 |
assert(Threads::number_of_threads() == 0, "for bootstrap only"); |
|
786 |
||
787 |
jlong old_value = *dest; |
|
788 |
if (old_value == compare_value) |
|
789 |
*dest = exchange_value; |
|
790 |
return old_value; |
|
791 |
} |
|
792 |
||
793 |
jint os::atomic_add_bootstrap(jint add_value, volatile jint* dest) { |
|
794 |
// try to use the stub: |
|
795 |
add_func_t* func = CAST_TO_FN_PTR(add_func_t*, StubRoutines::atomic_add_entry()); |
|
796 |
||
797 |
if (func != NULL) { |
|
798 |
os::atomic_add_func = func; |
|
799 |
return (*func)(add_value, dest); |
|
800 |
} |
|
801 |
assert(Threads::number_of_threads() == 0, "for bootstrap only"); |
|
802 |
||
803 |
return (*dest) += add_value; |
|
804 |
} |
|
805 |
||
806 |
xchg_func_t* os::atomic_xchg_func = os::atomic_xchg_bootstrap; |
|
807 |
cmpxchg_func_t* os::atomic_cmpxchg_func = os::atomic_cmpxchg_bootstrap; |
|
808 |
cmpxchg_long_func_t* os::atomic_cmpxchg_long_func = os::atomic_cmpxchg_long_bootstrap; |
|
809 |
add_func_t* os::atomic_add_func = os::atomic_add_bootstrap; |
|
810 |
||
811 |
#endif // !_LP64 && !COMPILER2 |
|
812 |
||
813 |
#if defined(__sparc) && defined(COMPILER2) && defined(_GNU_SOURCE) |
|
814 |
// See file build/solaris/makefiles/$compiler.make |
|
815 |
// For compiler1 the architecture is v8 and frps isn't present in v8 |
|
816 |
extern "C" void _mark_fpu_nosave() { |
|
817 |
__asm__ __volatile__ ("wr %%g0, 0, %%fprs \n\t" : : :); |
|
818 |
} |
|
819 |
#endif //defined(__sparc) && defined(COMPILER2) |
|
11961
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
820 |
|
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
821 |
#ifndef PRODUCT |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
822 |
void os::verify_stack_alignment() { |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
823 |
} |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
824 |
#endif |
26576
a9429d24d429
8050147: StoreLoad barrier interferes with stack usages
shade
parents:
25715
diff
changeset
|
825 |
|
a9429d24d429
8050147: StoreLoad barrier interferes with stack usages
shade
parents:
25715
diff
changeset
|
826 |
int os::extra_bang_size_in_bytes() { |
a9429d24d429
8050147: StoreLoad barrier interferes with stack usages
shade
parents:
25715
diff
changeset
|
827 |
// SPARC does not require an additional stack bang. |
a9429d24d429
8050147: StoreLoad barrier interferes with stack usages
shade
parents:
25715
diff
changeset
|
828 |
return 0; |
a9429d24d429
8050147: StoreLoad barrier interferes with stack usages
shade
parents:
25715
diff
changeset
|
829 |
} |