Mercurial > hg > graal-compiler
annotate src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp @ 21353:876e710523c5
Truffle/Instrumentation: rename "Tool Eval" Instrument kind to "Advanced" Instrument kind
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Tue, 12 May 2015 12:57:47 -0700 |
parents | 6f8d03da5d08 |
children | be896a1983c0 |
rev | line source |
---|---|
0 | 1 /* |
10405 | 2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 // no precompiled headers |
7204
f0c2369fda5a
8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
6842
diff
changeset
|
26 #include "asm/macroAssembler.hpp" |
20816
6f8d03da5d08
[SPARC] Ignore SIGILL instruction when the trap is 0x10 (breakpoint op, used for GRAAL debugging)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
11153
diff
changeset
|
27 #include "macroAssembler_sparc.hpp" |
1972 | 28 #include "classfile/classLoader.hpp" |
29 #include "classfile/systemDictionary.hpp" | |
30 #include "classfile/vmSymbols.hpp" | |
31 #include "code/icBuffer.hpp" | |
32 #include "code/vtableStubs.hpp" | |
33 #include "interpreter/interpreter.hpp" | |
34 #include "jvm_solaris.h" | |
35 #include "memory/allocation.inline.hpp" | |
36 #include "mutex_solaris.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" | |
7180
f34d701e952e
8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
6842
diff
changeset
|
52 #include "runtime/thread.inline.hpp" |
1972 | 53 #include "runtime/timer.hpp" |
54 #include "utilities/events.hpp" | |
55 #include "utilities/vmError.hpp" | |
0 | 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 <pwd.h> | |
77 # include <poll.h> | |
78 # include <sys/lwp.h> | |
79 | |
80 # define _STRUCTURED_PROC 1 // this gets us the new structured proc interfaces of 5.6 & later | |
81 # include <sys/procfs.h> // see comment in <sys/procfs.h> | |
82 | |
83 #define MAX_PATH (2 * K) | |
84 | |
85 // Minimum stack size for the VM. It's easier to document a constant | |
86 // but it's different for x86 and sparc because the page sizes are different. | |
87 #ifdef _LP64 | |
88 size_t os::Solaris::min_stack_allowed = 128*K; | |
89 #else | |
90 size_t os::Solaris::min_stack_allowed = 96*K; | |
91 #endif | |
92 | |
93 int os::Solaris::max_register_window_saves_before_flushing() { | |
94 // We should detect this at run time. For now, filling | |
95 // in with a constant. | |
96 return 8; | |
97 } | |
98 | |
99 static void handle_unflushed_register_windows(gwindows_t *win) { | |
100 int restore_count = win->wbcnt; | |
101 int i; | |
102 | |
103 for(i=0; i<restore_count; i++) { | |
104 address sp = ((address)win->spbuf[i]) + STACK_BIAS; | |
105 address reg_win = (address)&win->wbuf[i]; | |
106 memcpy(sp,reg_win,sizeof(struct rwindow)); | |
107 } | |
108 } | |
109 | |
110 char* os::non_memory_address_word() { | |
111 // Must never look like an address returned by reserve_memory, | |
112 // even in its subfields (as defined by the CPU immediate fields, | |
113 // if the CPU splits constants across multiple instructions). | |
114 // On SPARC, 0 != %hi(any real address), because there is no | |
115 // allocation in the first 1Kb of the virtual address space. | |
116 return (char*) 0; | |
117 } | |
118 | |
119 // Validate a ucontext retrieved from walking a uc_link of a ucontext. | |
120 // There are issues with libthread giving out uc_links for different threads | |
121 // on the same uc_link chain and bad or circular links. | |
122 // | |
123 bool os::Solaris::valid_ucontext(Thread* thread, ucontext_t* valid, ucontext_t* suspect) { | |
124 if (valid >= suspect || | |
125 valid->uc_stack.ss_flags != suspect->uc_stack.ss_flags || | |
126 valid->uc_stack.ss_sp != suspect->uc_stack.ss_sp || | |
127 valid->uc_stack.ss_size != suspect->uc_stack.ss_size) { | |
128 DEBUG_ONLY(tty->print_cr("valid_ucontext: failed test 1");) | |
129 return false; | |
130 } | |
131 | |
132 if (thread->is_Java_thread()) { | |
133 if (!valid_stack_address(thread, (address)suspect)) { | |
134 DEBUG_ONLY(tty->print_cr("valid_ucontext: uc_link not in thread stack");) | |
135 return false; | |
136 } | |
137 address _sp = (address)((intptr_t)suspect->uc_mcontext.gregs[REG_SP] + STACK_BIAS); | |
138 if (!valid_stack_address(thread, _sp) || | |
139 !frame::is_valid_stack_pointer(((JavaThread*)thread)->base_of_stack_pointer(), (intptr_t*)_sp)) { | |
140 DEBUG_ONLY(tty->print_cr("valid_ucontext: stackpointer not in thread stack");) | |
141 return false; | |
142 } | |
143 } | |
144 return true; | |
145 } | |
146 | |
147 // We will only follow one level of uc_link since there are libthread | |
148 // issues with ucontext linking and it is better to be safe and just | |
149 // let caller retry later. | |
150 ucontext_t* os::Solaris::get_valid_uc_in_signal_handler(Thread *thread, | |
151 ucontext_t *uc) { | |
152 | |
153 ucontext_t *retuc = NULL; | |
154 | |
155 // Sometimes the topmost register windows are not properly flushed. | |
156 // i.e., if the kernel would have needed to take a page fault | |
157 if (uc != NULL && uc->uc_mcontext.gwins != NULL) { | |
158 ::handle_unflushed_register_windows(uc->uc_mcontext.gwins); | |
159 } | |
160 | |
161 if (uc != NULL) { | |
162 if (uc->uc_link == NULL) { | |
163 // cannot validate without uc_link so accept current ucontext | |
164 retuc = uc; | |
165 } else if (os::Solaris::valid_ucontext(thread, uc, uc->uc_link)) { | |
166 // first ucontext is valid so try the next one | |
167 uc = uc->uc_link; | |
168 if (uc->uc_link == NULL) { | |
169 // cannot validate without uc_link so accept current ucontext | |
170 retuc = uc; | |
171 } else if (os::Solaris::valid_ucontext(thread, uc, uc->uc_link)) { | |
172 // the ucontext one level down is also valid so return it | |
173 retuc = uc; | |
174 } | |
175 } | |
176 } | |
177 return retuc; | |
178 } | |
179 | |
180 // Assumes ucontext is valid | |
181 ExtendedPC os::Solaris::ucontext_get_ExtendedPC(ucontext_t *uc) { | |
182 address pc = (address)uc->uc_mcontext.gregs[REG_PC]; | |
183 // set npc to zero to avoid using it for safepoint, good for profiling only | |
184 return ExtendedPC(pc); | |
185 } | |
186 | |
187 // Assumes ucontext is valid | |
188 intptr_t* os::Solaris::ucontext_get_sp(ucontext_t *uc) { | |
189 return (intptr_t*)((intptr_t)uc->uc_mcontext.gregs[REG_SP] + STACK_BIAS); | |
190 } | |
191 | |
192 // Solaris X86 only | |
193 intptr_t* os::Solaris::ucontext_get_fp(ucontext_t *uc) { | |
194 ShouldNotReachHere(); | |
195 return NULL; | |
196 } | |
197 | |
10405 | 198 address os::Solaris::ucontext_get_pc(ucontext_t *uc) { |
199 return (address) uc->uc_mcontext.gregs[REG_PC]; | |
200 } | |
201 | |
202 | |
0 | 203 // For Forte Analyzer AsyncGetCallTrace profiling support - thread |
204 // is currently interrupted by SIGPROF. | |
205 // | |
206 // ret_fp parameter is only used by Solaris X86. | |
207 // | |
208 // The difference between this and os::fetch_frame_from_context() is that | |
209 // here we try to skip nested signal frames. | |
210 ExtendedPC os::Solaris::fetch_frame_from_ucontext(Thread* thread, | |
211 ucontext_t* uc, intptr_t** ret_sp, intptr_t** ret_fp) { | |
212 | |
213 assert(thread != NULL, "just checking"); | |
214 assert(ret_sp != NULL, "just checking"); | |
215 assert(ret_fp == NULL, "just checking"); | |
216 | |
217 ucontext_t *luc = os::Solaris::get_valid_uc_in_signal_handler(thread, uc); | |
218 | |
219 return os::fetch_frame_from_context(luc, ret_sp, ret_fp); | |
220 } | |
221 | |
222 | |
223 // ret_fp parameter is only used by Solaris X86. | |
224 ExtendedPC os::fetch_frame_from_context(void* ucVoid, | |
225 intptr_t** ret_sp, intptr_t** ret_fp) { | |
226 | |
227 ExtendedPC epc; | |
228 ucontext_t *uc = (ucontext_t*)ucVoid; | |
229 | |
230 if (uc != NULL) { | |
231 epc = os::Solaris::ucontext_get_ExtendedPC(uc); | |
232 if (ret_sp) *ret_sp = os::Solaris::ucontext_get_sp(uc); | |
233 } else { | |
234 // construct empty ExtendedPC for return value checking | |
235 epc = ExtendedPC(NULL); | |
236 if (ret_sp) *ret_sp = (intptr_t *)NULL; | |
237 } | |
238 | |
239 return epc; | |
240 } | |
241 | |
242 frame os::fetch_frame_from_context(void* ucVoid) { | |
243 intptr_t* sp; | |
244 intptr_t* fp; | |
245 ExtendedPC epc = fetch_frame_from_context(ucVoid, &sp, &fp); | |
246 return frame(sp, frame::unpatchable, epc.pc()); | |
247 } | |
248 | |
249 frame os::get_sender_for_C_frame(frame* fr) { | |
250 return frame(fr->sender_sp(), frame::unpatchable, fr->sender_pc()); | |
251 } | |
252 | |
5903
da4be62fb889
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
2426
diff
changeset
|
253 // Returns an estimate of the current stack pointer. Result must be guaranteed to |
da4be62fb889
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
2426
diff
changeset
|
254 // point into the calling threads stack, and be no lower than the current stack |
da4be62fb889
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
2426
diff
changeset
|
255 // pointer. |
da4be62fb889
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
2426
diff
changeset
|
256 address os::current_stack_pointer() { |
da4be62fb889
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
2426
diff
changeset
|
257 volatile int dummy; |
da4be62fb889
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
2426
diff
changeset
|
258 address sp = (address)&dummy + 8; // %%%% need to confirm if this is right |
da4be62fb889
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
2426
diff
changeset
|
259 return sp; |
da4be62fb889
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
2426
diff
changeset
|
260 } |
da4be62fb889
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
2426
diff
changeset
|
261 |
0 | 262 frame os::current_frame() { |
263 intptr_t* sp = StubRoutines::Sparc::flush_callers_register_windows_func()(); | |
264 frame myframe(sp, frame::unpatchable, | |
265 CAST_FROM_FN_PTR(address, os::current_frame)); | |
266 if (os::is_first_C_frame(&myframe)) { | |
267 // stack is not walkable | |
268 return frame(NULL, NULL, NULL); | |
269 } else { | |
270 return os::get_sender_for_C_frame(&myframe); | |
271 } | |
272 } | |
273 | |
274 static int threadgetstate(thread_t tid, int *flags, lwpid_t *lwp, stack_t *ss, gregset_t rs, lwpstatus_t *lwpstatus) { | |
275 char lwpstatusfile[PROCFILE_LENGTH]; | |
276 int lwpfd, err; | |
277 | |
278 if (err = os::Solaris::thr_getstate(tid, flags, lwp, ss, rs)) | |
279 return (err); | |
280 if (*flags == TRS_LWPID) { | |
281 sprintf(lwpstatusfile, "/proc/%d/lwp/%d/lwpstatus", getpid(), | |
282 *lwp); | |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
283 if ((lwpfd = ::open(lwpstatusfile, O_RDONLY)) < 0) { |
0 | 284 perror("thr_mutator_status: open lwpstatus"); |
285 return (EINVAL); | |
286 } | |
287 if (pread(lwpfd, lwpstatus, sizeof (lwpstatus_t), (off_t)0) != | |
288 sizeof (lwpstatus_t)) { | |
289 perror("thr_mutator_status: read lwpstatus"); | |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
290 (void) ::close(lwpfd); |
0 | 291 return (EINVAL); |
292 } | |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
293 (void) ::close(lwpfd); |
0 | 294 } |
295 return (0); | |
296 } | |
297 | |
298 | |
299 bool os::is_allocatable(size_t bytes) { | |
300 #ifdef _LP64 | |
301 return true; | |
302 #else | |
303 return (bytes <= (size_t)3835*M); | |
304 #endif | |
305 } | |
306 | |
2191 | 307 extern "C" JNIEXPORT int |
308 JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, | |
309 int abort_if_unrecognized) { | |
0 | 310 ucontext_t* uc = (ucontext_t*) ucVoid; |
311 | |
312 Thread* t = ThreadLocalStorage::get_thread_slow(); | |
313 | |
11151 | 314 // Must do this before SignalHandlerMark, if crash protection installed we will longjmp away |
315 // (no destructors can be run) | |
316 os::WatcherThreadCrashProtection::check_crash_protection(sig, t); | |
317 | |
0 | 318 SignalHandlerMark shm(t); |
319 | |
320 if(sig == SIGPIPE || sig == SIGXFSZ) { | |
321 if (os::Solaris::chained_handler(sig, info, ucVoid)) { | |
322 return true; | |
323 } else { | |
324 if (PrintMiscellaneous && (WizardMode || Verbose)) { | |
325 char buf[64]; | |
326 warning("Ignoring %s - see 4229104 or 6499219", | |
327 os::exception_name(sig, buf, sizeof(buf))); | |
328 | |
329 } | |
330 return true; | |
331 } | |
332 } | |
333 | |
334 JavaThread* thread = NULL; | |
335 VMThread* vmthread = NULL; | |
336 if (os::Solaris::signal_handlers_are_installed) { | |
337 if (t != NULL ){ | |
338 if(t->is_Java_thread()) { | |
339 thread = (JavaThread*)t; | |
340 } | |
341 else if(t->is_VM_thread()){ | |
342 vmthread = (VMThread *)t; | |
343 } | |
344 } | |
345 } | |
346 | |
347 guarantee(sig != os::Solaris::SIGinterrupt(), "Can not chain VM interrupt signal, try -XX:+UseAltSigs"); | |
348 | |
349 if (sig == os::Solaris::SIGasync()) { | |
10405 | 350 if (thread || vmthread) { |
351 OSThread::SR_handler(t, uc); | |
0 | 352 return true; |
353 } else if (os::Solaris::chained_handler(sig, info, ucVoid)) { | |
354 return true; | |
355 } else { | |
356 // If os::Solaris::SIGasync not chained, and this is a non-vm and | |
357 // non-java thread | |
358 return true; | |
359 } | |
360 } | |
361 | |
362 if (info == NULL || info->si_code <= 0 || info->si_code == SI_NOINFO) { | |
363 // can't decode this kind of signal | |
364 info = NULL; | |
365 } else { | |
366 assert(sig == info->si_signo, "bad siginfo"); | |
367 } | |
368 | |
369 // decide if this trap can be handled by a stub | |
370 address stub = NULL; | |
371 | |
372 address pc = NULL; | |
373 address npc = NULL; | |
374 | |
375 //%note os_trap_1 | |
376 if (info != NULL && uc != NULL && thread != NULL) { | |
377 // factor me: getPCfromContext | |
378 pc = (address) uc->uc_mcontext.gregs[REG_PC]; | |
379 npc = (address) uc->uc_mcontext.gregs[REG_nPC]; | |
380 | |
381 // SafeFetch() support | |
11127 | 382 if (StubRoutines::is_safefetch_fault(pc)) { |
383 uc->uc_mcontext.gregs[REG_PC] = intptr_t(StubRoutines::continuation_for_safefetch_fault(pc)); | |
384 uc->uc_mcontext.gregs[REG_nPC] = uc->uc_mcontext.gregs[REG_PC] + 4; | |
385 return 1; | |
0 | 386 } |
387 | |
388 // Handle ALL stack overflow variations here | |
389 if (sig == SIGSEGV && info->si_code == SEGV_ACCERR) { | |
390 address addr = (address) info->si_addr; | |
391 if (thread->in_stack_yellow_zone(addr)) { | |
392 thread->disable_stack_yellow_zone(); | |
393 // Sometimes the register windows are not properly flushed. | |
394 if(uc->uc_mcontext.gwins != NULL) { | |
395 ::handle_unflushed_register_windows(uc->uc_mcontext.gwins); | |
396 } | |
397 if (thread->thread_state() == _thread_in_Java) { | |
398 // Throw a stack overflow exception. Guard pages will be reenabled | |
399 // while unwinding the stack. | |
400 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::STACK_OVERFLOW); | |
401 } else { | |
402 // Thread was in the vm or native code. Return and try to finish. | |
403 return true; | |
404 } | |
405 } else if (thread->in_stack_red_zone(addr)) { | |
406 // Fatal red zone violation. Disable the guard pages and fall through | |
407 // to handle_unexpected_exception way down below. | |
408 thread->disable_stack_red_zone(); | |
409 tty->print_raw_cr("An irrecoverable stack overflow has occurred."); | |
410 // Sometimes the register windows are not properly flushed. | |
411 if(uc->uc_mcontext.gwins != NULL) { | |
412 ::handle_unflushed_register_windows(uc->uc_mcontext.gwins); | |
413 } | |
414 } | |
415 } | |
416 | |
417 | |
418 if (thread->thread_state() == _thread_in_vm) { | |
419 if (sig == SIGBUS && info->si_code == BUS_OBJERR && thread->doing_unsafe_access()) { | |
420 stub = StubRoutines::handler_for_unsafe_access(); | |
421 } | |
422 } | |
423 | |
424 else if (thread->thread_state() == _thread_in_Java) { | |
425 // Java thread running in Java code => find exception handler if any | |
426 // a fault inside compiled code, the interpreter, or a stub | |
427 | |
428 // Support Safepoint Polling | |
429 if ( sig == SIGSEGV && (address)info->si_addr == os::get_polling_page() ) { | |
430 stub = SharedRuntime::get_poll_stub(pc); | |
431 } | |
432 | |
433 // Not needed on x86 solaris because verify_oops doesn't generate | |
434 // SEGV/BUS like sparc does. | |
435 if ( (sig == SIGSEGV || sig == SIGBUS) | |
436 && pc >= MacroAssembler::_verify_oop_implicit_branch[0] | |
437 && pc < MacroAssembler::_verify_oop_implicit_branch[1] ) { | |
438 stub = MacroAssembler::_verify_oop_implicit_branch[2]; | |
439 warning("fixed up memory fault in +VerifyOops at address " INTPTR_FORMAT, info->si_addr); | |
440 } | |
441 | |
442 // This is not factored because on x86 solaris the patching for | |
443 // zombies does not generate a SEGV. | |
444 else if (sig == SIGSEGV && nativeInstruction_at(pc)->is_zombie()) { | |
445 // zombie method (ld [%g0],%o7 instruction) | |
446 stub = SharedRuntime::get_handle_wrong_method_stub(); | |
447 | |
448 // At the stub it needs to look like a call from the caller of this | |
449 // method (not a call from the segv site). | |
450 pc = (address)uc->uc_mcontext.gregs[REG_O7]; | |
451 } | |
452 else if (sig == SIGBUS && info->si_code == BUS_OBJERR) { | |
453 // BugId 4454115: A read from a MappedByteBuffer can fault | |
454 // here if the underlying file has been truncated. | |
455 // Do not crash the VM in such a case. | |
456 CodeBlob* cb = CodeCache::find_blob_unsafe(pc); | |
457 nmethod* nm = cb->is_nmethod() ? (nmethod*)cb : NULL; | |
458 if (nm != NULL && nm->has_unsafe_access()) { | |
459 stub = StubRoutines::handler_for_unsafe_access(); | |
460 } | |
461 } | |
462 | |
463 else if (sig == SIGFPE && info->si_code == FPE_INTDIV) { | |
464 // integer divide by zero | |
465 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO); | |
466 } | |
467 else if (sig == SIGFPE && info->si_code == FPE_FLTDIV) { | |
468 // floating-point divide by zero | |
469 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO); | |
470 } | |
471 #ifdef COMPILER2 | |
472 else if (sig == SIGILL && nativeInstruction_at(pc)->is_ic_miss_trap()) { | |
473 #ifdef ASSERT | |
474 #ifdef TIERED | |
475 CodeBlob* cb = CodeCache::find_blob_unsafe(pc); | |
476 assert(cb->is_compiled_by_c2(), "Wrong compiler"); | |
477 #endif // TIERED | |
478 #endif // ASSERT | |
479 // Inline cache missed and user trap "Tne G0+ST_RESERVED_FOR_USER_0+2" taken. | |
480 stub = SharedRuntime::get_ic_miss_stub(); | |
481 // At the stub it needs to look like a call from the caller of this | |
482 // method (not a call from the segv site). | |
483 pc = (address)uc->uc_mcontext.gregs[REG_O7]; | |
484 } | |
485 #endif // COMPILER2 | |
486 | |
20816
6f8d03da5d08
[SPARC] Ignore SIGILL instruction when the trap is 0x10 (breakpoint op, used for GRAAL debugging)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
11153
diff
changeset
|
487 #ifdef GRAAL |
6f8d03da5d08
[SPARC] Ignore SIGILL instruction when the trap is 0x10 (breakpoint op, used for GRAAL debugging)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
11153
diff
changeset
|
488 else if (sig == SIGILL && info->si_trapno == 0x100 + ST_RESERVED_FOR_USER_0) { |
6f8d03da5d08
[SPARC] Ignore SIGILL instruction when the trap is 0x10 (breakpoint op, used for GRAAL debugging)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
11153
diff
changeset
|
489 printf("SIGILL 0x%x 0x%x\n", info->si_trapno, ST_RESERVED_FOR_USER_0); |
6f8d03da5d08
[SPARC] Ignore SIGILL instruction when the trap is 0x10 (breakpoint op, used for GRAAL debugging)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
11153
diff
changeset
|
490 uc->uc_mcontext.gregs[REG_PC] = (greg_t)pc+4; |
6f8d03da5d08
[SPARC] Ignore SIGILL instruction when the trap is 0x10 (breakpoint op, used for GRAAL debugging)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
11153
diff
changeset
|
491 uc->uc_mcontext.gregs[REG_nPC] = (greg_t)npc + 4; |
6f8d03da5d08
[SPARC] Ignore SIGILL instruction when the trap is 0x10 (breakpoint op, used for GRAAL debugging)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
11153
diff
changeset
|
492 return true; |
6f8d03da5d08
[SPARC] Ignore SIGILL instruction when the trap is 0x10 (breakpoint op, used for GRAAL debugging)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
11153
diff
changeset
|
493 } |
6f8d03da5d08
[SPARC] Ignore SIGILL instruction when the trap is 0x10 (breakpoint op, used for GRAAL debugging)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
11153
diff
changeset
|
494 #endif // GRAAL |
6f8d03da5d08
[SPARC] Ignore SIGILL instruction when the trap is 0x10 (breakpoint op, used for GRAAL debugging)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
11153
diff
changeset
|
495 |
0 | 496 else if (sig == SIGSEGV && info->si_code > 0 && !MacroAssembler::needs_explicit_null_check((intptr_t)info->si_addr)) { |
497 // Determination of interpreter/vtable stub/compiled code null exception | |
498 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL); | |
499 } | |
500 } | |
501 | |
502 // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks in | |
503 // and the heap gets shrunk before the field access. | |
504 if ((sig == SIGSEGV) || (sig == SIGBUS)) { | |
505 address addr = JNI_FastGetField::find_slowcase_pc(pc); | |
506 if (addr != (address)-1) { | |
507 stub = addr; | |
508 } | |
509 } | |
510 | |
511 // Check to see if we caught the safepoint code in the | |
512 // process of write protecting the memory serialization page. | |
513 // It write enables the page immediately after protecting it | |
514 // so just return. | |
515 if ((sig == SIGSEGV) && | |
516 os::is_memory_serialize_page(thread, (address)info->si_addr)) { | |
517 // Block current thread until the memory serialize page permission restored. | |
518 os::block_on_serialize_page_trap(); | |
519 return true; | |
520 } | |
521 } | |
522 | |
523 if (stub != NULL) { | |
524 // save all thread context in case we need to restore it | |
525 | |
526 thread->set_saved_exception_pc(pc); | |
527 thread->set_saved_exception_npc(npc); | |
528 | |
529 // simulate a branch to the stub (a "call" in the safepoint stub case) | |
530 // factor me: setPC | |
531 uc->uc_mcontext.gregs[REG_PC ] = (greg_t)stub; | |
532 uc->uc_mcontext.gregs[REG_nPC] = (greg_t)(stub + 4); | |
533 | |
534 #ifndef PRODUCT | |
535 if (TraceJumps) thread->record_jump(stub, NULL, __FILE__, __LINE__); | |
536 #endif /* PRODUCT */ | |
537 | |
538 return true; | |
539 } | |
540 | |
541 // signal-chaining | |
542 if (os::Solaris::chained_handler(sig, info, ucVoid)) { | |
543 return true; | |
544 } | |
545 | |
546 if (!abort_if_unrecognized) { | |
547 // caller wants another chance, so give it to him | |
548 return false; | |
549 } | |
550 | |
551 if (!os::Solaris::libjsig_is_loaded) { | |
552 struct sigaction oldAct; | |
553 sigaction(sig, (struct sigaction *)0, &oldAct); | |
554 if (oldAct.sa_sigaction != signalHandler) { | |
555 void* sighand = oldAct.sa_sigaction ? CAST_FROM_FN_PTR(void*, oldAct.sa_sigaction) | |
556 : CAST_FROM_FN_PTR(void*, oldAct.sa_handler); | |
605 | 557 warning("Unexpected Signal %d occurred under user-defined signal handler " INTPTR_FORMAT, sig, (intptr_t)sighand); |
0 | 558 } |
559 } | |
560 | |
561 if (pc == NULL && uc != NULL) { | |
562 pc = (address) uc->uc_mcontext.gregs[REG_PC]; | |
563 } | |
564 | |
1907 | 565 // Sometimes the register windows are not properly flushed. |
566 if(uc->uc_mcontext.gwins != NULL) { | |
567 ::handle_unflushed_register_windows(uc->uc_mcontext.gwins); | |
568 } | |
569 | |
0 | 570 // unmask current signal |
571 sigset_t newset; | |
572 sigemptyset(&newset); | |
573 sigaddset(&newset, sig); | |
574 sigprocmask(SIG_UNBLOCK, &newset, NULL); | |
575 | |
2095
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
1980
diff
changeset
|
576 // Determine which sort of error to throw. Out of swap may signal |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
1980
diff
changeset
|
577 // on the thread stack, which could get a mapping error when touched. |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
1980
diff
changeset
|
578 address addr = (address) info->si_addr; |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
1980
diff
changeset
|
579 if (sig == SIGBUS && info->si_code == BUS_OBJERR && info->si_errno == ENOMEM) { |
10161
746b070f5022
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
7206
diff
changeset
|
580 vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "Out of swap space to map in thread stack."); |
2095
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
1980
diff
changeset
|
581 } |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
1980
diff
changeset
|
582 |
0 | 583 VMError err(t, sig, pc, info, ucVoid); |
584 err.report_and_die(); | |
585 | |
586 ShouldNotReachHere(); | |
587 } | |
588 | |
589 void os::print_context(outputStream *st, void *context) { | |
590 if (context == NULL) return; | |
591 | |
592 ucontext_t *uc = (ucontext_t*)context; | |
593 st->print_cr("Registers:"); | |
594 | |
1907 | 595 st->print_cr(" G1=" INTPTR_FORMAT " G2=" INTPTR_FORMAT |
596 " G3=" INTPTR_FORMAT " G4=" INTPTR_FORMAT, | |
597 uc->uc_mcontext.gregs[REG_G1], | |
598 uc->uc_mcontext.gregs[REG_G2], | |
599 uc->uc_mcontext.gregs[REG_G3], | |
600 uc->uc_mcontext.gregs[REG_G4]); | |
601 st->print_cr(" G5=" INTPTR_FORMAT " G6=" INTPTR_FORMAT | |
602 " G7=" INTPTR_FORMAT " Y=" INTPTR_FORMAT, | |
603 uc->uc_mcontext.gregs[REG_G5], | |
604 uc->uc_mcontext.gregs[REG_G6], | |
605 uc->uc_mcontext.gregs[REG_G7], | |
606 uc->uc_mcontext.gregs[REG_Y]); | |
0 | 607 st->print_cr(" O0=" INTPTR_FORMAT " O1=" INTPTR_FORMAT |
608 " O2=" INTPTR_FORMAT " O3=" INTPTR_FORMAT, | |
609 uc->uc_mcontext.gregs[REG_O0], | |
610 uc->uc_mcontext.gregs[REG_O1], | |
611 uc->uc_mcontext.gregs[REG_O2], | |
612 uc->uc_mcontext.gregs[REG_O3]); | |
613 st->print_cr(" O4=" INTPTR_FORMAT " O5=" INTPTR_FORMAT | |
614 " O6=" INTPTR_FORMAT " O7=" INTPTR_FORMAT, | |
615 uc->uc_mcontext.gregs[REG_O4], | |
616 uc->uc_mcontext.gregs[REG_O5], | |
617 uc->uc_mcontext.gregs[REG_O6], | |
618 uc->uc_mcontext.gregs[REG_O7]); | |
619 | |
1907 | 620 |
621 intptr_t *sp = (intptr_t *)os::Solaris::ucontext_get_sp(uc); | |
622 st->print_cr(" L0=" INTPTR_FORMAT " L1=" INTPTR_FORMAT | |
623 " L2=" INTPTR_FORMAT " L3=" INTPTR_FORMAT, | |
624 sp[L0->sp_offset_in_saved_window()], | |
625 sp[L1->sp_offset_in_saved_window()], | |
626 sp[L2->sp_offset_in_saved_window()], | |
627 sp[L3->sp_offset_in_saved_window()]); | |
628 st->print_cr(" L4=" INTPTR_FORMAT " L5=" INTPTR_FORMAT | |
629 " L6=" INTPTR_FORMAT " L7=" INTPTR_FORMAT, | |
630 sp[L4->sp_offset_in_saved_window()], | |
631 sp[L5->sp_offset_in_saved_window()], | |
632 sp[L6->sp_offset_in_saved_window()], | |
633 sp[L7->sp_offset_in_saved_window()]); | |
634 st->print_cr(" I0=" INTPTR_FORMAT " I1=" INTPTR_FORMAT | |
635 " I2=" INTPTR_FORMAT " I3=" INTPTR_FORMAT, | |
636 sp[I0->sp_offset_in_saved_window()], | |
637 sp[I1->sp_offset_in_saved_window()], | |
638 sp[I2->sp_offset_in_saved_window()], | |
639 sp[I3->sp_offset_in_saved_window()]); | |
640 st->print_cr(" I4=" INTPTR_FORMAT " I5=" INTPTR_FORMAT | |
641 " I6=" INTPTR_FORMAT " I7=" INTPTR_FORMAT, | |
642 sp[I4->sp_offset_in_saved_window()], | |
643 sp[I5->sp_offset_in_saved_window()], | |
644 sp[I6->sp_offset_in_saved_window()], | |
645 sp[I7->sp_offset_in_saved_window()]); | |
0 | 646 |
647 st->print_cr(" PC=" INTPTR_FORMAT " nPC=" INTPTR_FORMAT, | |
648 uc->uc_mcontext.gregs[REG_PC], | |
649 uc->uc_mcontext.gregs[REG_nPC]); | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
650 st->cr(); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
651 st->cr(); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
652 |
0 | 653 st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp); |
654 print_hex_dump(st, (address)sp, (address)(sp + 32), sizeof(intptr_t)); | |
655 st->cr(); | |
656 | |
657 // Note: it may be unsafe to inspect memory near pc. For example, pc may | |
658 // point to garbage if entry point in an nmethod is corrupted. Leave | |
659 // this at the end, and hope for the best. | |
660 ExtendedPC epc = os::Solaris::ucontext_get_ExtendedPC(uc); | |
661 address pc = epc.pc(); | |
662 st->print_cr("Instructions: (pc=" PTR_FORMAT ")", pc); | |
1907 | 663 print_hex_dump(st, pc - 32, pc + 32, sizeof(char)); |
664 } | |
665 | |
666 void os::print_register_info(outputStream *st, void *context) { | |
667 if (context == NULL) return; | |
668 | |
669 ucontext_t *uc = (ucontext_t*)context; | |
670 intptr_t *sp = (intptr_t *)os::Solaris::ucontext_get_sp(uc); | |
671 | |
672 st->print_cr("Register to memory mapping:"); | |
673 st->cr(); | |
674 | |
675 // this is only for the "general purpose" registers | |
676 st->print("G1="); print_location(st, uc->uc_mcontext.gregs[REG_G1]); | |
677 st->print("G2="); print_location(st, uc->uc_mcontext.gregs[REG_G2]); | |
678 st->print("G3="); print_location(st, uc->uc_mcontext.gregs[REG_G3]); | |
679 st->print("G4="); print_location(st, uc->uc_mcontext.gregs[REG_G4]); | |
680 st->print("G5="); print_location(st, uc->uc_mcontext.gregs[REG_G5]); | |
681 st->print("G6="); print_location(st, uc->uc_mcontext.gregs[REG_G6]); | |
682 st->print("G7="); print_location(st, uc->uc_mcontext.gregs[REG_G7]); | |
683 st->cr(); | |
684 | |
685 st->print("O0="); print_location(st, uc->uc_mcontext.gregs[REG_O0]); | |
686 st->print("O1="); print_location(st, uc->uc_mcontext.gregs[REG_O1]); | |
687 st->print("O2="); print_location(st, uc->uc_mcontext.gregs[REG_O2]); | |
688 st->print("O3="); print_location(st, uc->uc_mcontext.gregs[REG_O3]); | |
689 st->print("O4="); print_location(st, uc->uc_mcontext.gregs[REG_O4]); | |
690 st->print("O5="); print_location(st, uc->uc_mcontext.gregs[REG_O5]); | |
691 st->print("O6="); print_location(st, uc->uc_mcontext.gregs[REG_O6]); | |
692 st->print("O7="); print_location(st, uc->uc_mcontext.gregs[REG_O7]); | |
693 st->cr(); | |
694 | |
695 st->print("L0="); print_location(st, sp[L0->sp_offset_in_saved_window()]); | |
696 st->print("L1="); print_location(st, sp[L1->sp_offset_in_saved_window()]); | |
697 st->print("L2="); print_location(st, sp[L2->sp_offset_in_saved_window()]); | |
698 st->print("L3="); print_location(st, sp[L3->sp_offset_in_saved_window()]); | |
699 st->print("L4="); print_location(st, sp[L4->sp_offset_in_saved_window()]); | |
700 st->print("L5="); print_location(st, sp[L5->sp_offset_in_saved_window()]); | |
701 st->print("L6="); print_location(st, sp[L6->sp_offset_in_saved_window()]); | |
702 st->print("L7="); print_location(st, sp[L7->sp_offset_in_saved_window()]); | |
703 st->cr(); | |
704 | |
705 st->print("I0="); print_location(st, sp[I0->sp_offset_in_saved_window()]); | |
706 st->print("I1="); print_location(st, sp[I1->sp_offset_in_saved_window()]); | |
707 st->print("I2="); print_location(st, sp[I2->sp_offset_in_saved_window()]); | |
708 st->print("I3="); print_location(st, sp[I3->sp_offset_in_saved_window()]); | |
709 st->print("I4="); print_location(st, sp[I4->sp_offset_in_saved_window()]); | |
710 st->print("I5="); print_location(st, sp[I5->sp_offset_in_saved_window()]); | |
711 st->print("I6="); print_location(st, sp[I6->sp_offset_in_saved_window()]); | |
712 st->print("I7="); print_location(st, sp[I7->sp_offset_in_saved_window()]); | |
713 st->cr(); | |
0 | 714 } |
715 | |
716 void os::Solaris::init_thread_fpu_state(void) { | |
717 // Nothing needed on Sparc. | |
718 } | |
719 | |
720 #if !defined(COMPILER2) && !defined(_LP64) | |
721 | |
722 // These routines are the initial value of atomic_xchg_entry(), | |
723 // atomic_cmpxchg_entry(), atomic_add_entry() and fence_entry() | |
724 // until initialization is complete. | |
725 // TODO - remove when the VM drops support for V8. | |
726 | |
727 typedef jint xchg_func_t (jint, volatile jint*); | |
728 typedef jint cmpxchg_func_t (jint, volatile jint*, jint); | |
729 typedef jlong cmpxchg_long_func_t(jlong, volatile jlong*, jlong); | |
730 typedef jint add_func_t (jint, volatile jint*); | |
731 | |
732 jint os::atomic_xchg_bootstrap(jint exchange_value, volatile jint* dest) { | |
733 // try to use the stub: | |
734 xchg_func_t* func = CAST_TO_FN_PTR(xchg_func_t*, StubRoutines::atomic_xchg_entry()); | |
735 | |
736 if (func != NULL) { | |
737 os::atomic_xchg_func = func; | |
738 return (*func)(exchange_value, dest); | |
739 } | |
740 assert(Threads::number_of_threads() == 0, "for bootstrap only"); | |
741 | |
742 jint old_value = *dest; | |
743 *dest = exchange_value; | |
744 return old_value; | |
745 } | |
746 | |
747 jint os::atomic_cmpxchg_bootstrap(jint exchange_value, volatile jint* dest, jint compare_value) { | |
748 // try to use the stub: | |
749 cmpxchg_func_t* func = CAST_TO_FN_PTR(cmpxchg_func_t*, StubRoutines::atomic_cmpxchg_entry()); | |
750 | |
751 if (func != NULL) { | |
752 os::atomic_cmpxchg_func = func; | |
753 return (*func)(exchange_value, dest, compare_value); | |
754 } | |
755 assert(Threads::number_of_threads() == 0, "for bootstrap only"); | |
756 | |
757 jint old_value = *dest; | |
758 if (old_value == compare_value) | |
759 *dest = exchange_value; | |
760 return old_value; | |
761 } | |
762 | |
763 jlong os::atomic_cmpxchg_long_bootstrap(jlong exchange_value, volatile jlong* dest, jlong compare_value) { | |
764 // try to use the stub: | |
765 cmpxchg_long_func_t* func = CAST_TO_FN_PTR(cmpxchg_long_func_t*, StubRoutines::atomic_cmpxchg_long_entry()); | |
766 | |
767 if (func != NULL) { | |
768 os::atomic_cmpxchg_long_func = func; | |
769 return (*func)(exchange_value, dest, compare_value); | |
770 } | |
771 assert(Threads::number_of_threads() == 0, "for bootstrap only"); | |
772 | |
773 jlong old_value = *dest; | |
774 if (old_value == compare_value) | |
775 *dest = exchange_value; | |
776 return old_value; | |
777 } | |
778 | |
779 jint os::atomic_add_bootstrap(jint add_value, volatile jint* dest) { | |
780 // try to use the stub: | |
781 add_func_t* func = CAST_TO_FN_PTR(add_func_t*, StubRoutines::atomic_add_entry()); | |
782 | |
783 if (func != NULL) { | |
784 os::atomic_add_func = func; | |
785 return (*func)(add_value, dest); | |
786 } | |
787 assert(Threads::number_of_threads() == 0, "for bootstrap only"); | |
788 | |
789 return (*dest) += add_value; | |
790 } | |
791 | |
792 xchg_func_t* os::atomic_xchg_func = os::atomic_xchg_bootstrap; | |
793 cmpxchg_func_t* os::atomic_cmpxchg_func = os::atomic_cmpxchg_bootstrap; | |
794 cmpxchg_long_func_t* os::atomic_cmpxchg_long_func = os::atomic_cmpxchg_long_bootstrap; | |
795 add_func_t* os::atomic_add_func = os::atomic_add_bootstrap; | |
796 | |
797 #endif // !_LP64 && !COMPILER2 | |
798 | |
799 #if defined(__sparc) && defined(COMPILER2) && defined(_GNU_SOURCE) | |
800 // See file build/solaris/makefiles/$compiler.make | |
801 // For compiler1 the architecture is v8 and frps isn't present in v8 | |
802 extern "C" void _mark_fpu_nosave() { | |
803 __asm__ __volatile__ ("wr %%g0, 0, %%fprs \n\t" : : :); | |
804 } | |
805 #endif //defined(__sparc) && defined(COMPILER2) | |
5903
da4be62fb889
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
2426
diff
changeset
|
806 |
da4be62fb889
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
2426
diff
changeset
|
807 #ifndef PRODUCT |
da4be62fb889
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
2426
diff
changeset
|
808 void os::verify_stack_alignment() { |
da4be62fb889
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
2426
diff
changeset
|
809 } |
da4be62fb889
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
2426
diff
changeset
|
810 #endif |