rev 47415 : Add Thread Local handshakes and thread local polling
1 /*
2 * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 // no precompiled headers
26 #include "asm/macroAssembler.hpp"
27 #include "macroAssembler_sparc.hpp"
28 #include "classfile/classLoader.hpp"
29 #include "classfile/systemDictionary.hpp"
30 #include "classfile/vmSymbols.hpp"
31 #include "code/codeCache.hpp"
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"
52 #include "runtime/thread.inline.hpp"
53 #include "runtime/timer.hpp"
54 #include "utilities/events.hpp"
55 #include "utilities/vmError.hpp"
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 usable stack sizes required to get to user code. Space for
85 // HotSpot guard pages is added later.
86 size_t os::Posix::_compiler_thread_min_stack_allowed = 104 * K;
87 size_t os::Posix::_java_thread_min_stack_allowed = 86 * K;
88 size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * K;
89
90 int os::Solaris::max_register_window_saves_before_flushing() {
91 // We should detect this at run time. For now, filling
92 // in with a constant.
93 return 8;
94 }
95
96 static void handle_unflushed_register_windows(gwindows_t *win) {
97 int restore_count = win->wbcnt;
98 int i;
99
100 for(i=0; i<restore_count; i++) {
101 address sp = ((address)win->spbuf[i]) + STACK_BIAS;
102 address reg_win = (address)&win->wbuf[i];
103 memcpy(sp,reg_win,sizeof(struct rwindow));
104 }
105 }
106
107 char* os::non_memory_address_word() {
108 // Must never look like an address returned by reserve_memory,
109 // even in its subfields (as defined by the CPU immediate fields,
110 // if the CPU splits constants across multiple instructions).
111 // On SPARC, 0 != %hi(any real address), because there is no
112 // allocation in the first 1Kb of the virtual address space.
113 return (char*) 0;
114 }
115
116 // Validate a ucontext retrieved from walking a uc_link of a ucontext.
117 // There are issues with libthread giving out uc_links for different threads
118 // on the same uc_link chain and bad or circular links.
119 //
120 bool os::Solaris::valid_ucontext(Thread* thread, const ucontext_t* valid, const ucontext_t* suspect) {
121 if (valid >= suspect ||
122 valid->uc_stack.ss_flags != suspect->uc_stack.ss_flags ||
123 valid->uc_stack.ss_sp != suspect->uc_stack.ss_sp ||
124 valid->uc_stack.ss_size != suspect->uc_stack.ss_size) {
125 DEBUG_ONLY(tty->print_cr("valid_ucontext: failed test 1");)
126 return false;
127 }
128
129 if (thread->is_Java_thread()) {
130 if (!valid_stack_address(thread, (address)suspect)) {
131 DEBUG_ONLY(tty->print_cr("valid_ucontext: uc_link not in thread stack");)
132 return false;
133 }
134 address _sp = (address)((intptr_t)suspect->uc_mcontext.gregs[REG_SP] + STACK_BIAS);
135 if (!valid_stack_address(thread, _sp) ||
136 !frame::is_valid_stack_pointer(((JavaThread*)thread)->base_of_stack_pointer(), (intptr_t*)_sp)) {
137 DEBUG_ONLY(tty->print_cr("valid_ucontext: stackpointer not in thread stack");)
138 return false;
139 }
140 }
141 return true;
142 }
143
144 // We will only follow one level of uc_link since there are libthread
145 // issues with ucontext linking and it is better to be safe and just
146 // let caller retry later.
147 const ucontext_t* os::Solaris::get_valid_uc_in_signal_handler(Thread *thread,
148 const ucontext_t *uc) {
149
150 const ucontext_t *retuc = NULL;
151
152 // Sometimes the topmost register windows are not properly flushed.
153 // i.e., if the kernel would have needed to take a page fault
154 if (uc != NULL && uc->uc_mcontext.gwins != NULL) {
155 ::handle_unflushed_register_windows(uc->uc_mcontext.gwins);
156 }
157
158 if (uc != NULL) {
159 if (uc->uc_link == NULL) {
160 // cannot validate without uc_link so accept current ucontext
161 retuc = uc;
162 } else if (os::Solaris::valid_ucontext(thread, uc, uc->uc_link)) {
163 // first ucontext is valid so try the next one
164 uc = uc->uc_link;
165 if (uc->uc_link == NULL) {
166 // cannot validate without uc_link so accept current ucontext
167 retuc = uc;
168 } else if (os::Solaris::valid_ucontext(thread, uc, uc->uc_link)) {
169 // the ucontext one level down is also valid so return it
170 retuc = uc;
171 }
172 }
173 }
174 return retuc;
175 }
176
177 // Assumes ucontext is valid
178 ExtendedPC os::Solaris::ucontext_get_ExtendedPC(const ucontext_t *uc) {
179 address pc = (address)uc->uc_mcontext.gregs[REG_PC];
180 // set npc to zero to avoid using it for safepoint, good for profiling only
181 return ExtendedPC(pc);
182 }
183
184 void os::Solaris::ucontext_set_pc(ucontext_t* uc, address pc) {
185 uc->uc_mcontext.gregs [REG_PC] = (greg_t) pc;
186 uc->uc_mcontext.gregs [REG_nPC] = (greg_t) (pc + 4);
187 }
188
189 // Assumes ucontext is valid
190 intptr_t* os::Solaris::ucontext_get_sp(const ucontext_t *uc) {
191 return (intptr_t*)((intptr_t)uc->uc_mcontext.gregs[REG_SP] + STACK_BIAS);
192 }
193
194 // Solaris X86 only
195 intptr_t* os::Solaris::ucontext_get_fp(const ucontext_t *uc) {
196 ShouldNotReachHere();
197 return NULL;
198 }
199
200 address os::Solaris::ucontext_get_pc(const ucontext_t *uc) {
201 return (address) uc->uc_mcontext.gregs[REG_PC];
202 }
203
204
205 // For Forte Analyzer AsyncGetCallTrace profiling support - thread
206 // is currently interrupted by SIGPROF.
207 //
208 // ret_fp parameter is only used by Solaris X86.
209 //
210 // The difference between this and os::fetch_frame_from_context() is that
211 // here we try to skip nested signal frames.
212 // This method is also used for stack overflow signal handling.
213 ExtendedPC os::Solaris::fetch_frame_from_ucontext(Thread* thread,
214 const ucontext_t* uc, intptr_t** ret_sp, intptr_t** ret_fp) {
215
216 assert(thread != NULL, "just checking");
217 assert(ret_sp != NULL, "just checking");
218 assert(ret_fp == NULL, "just checking");
219
220 const ucontext_t *luc = os::Solaris::get_valid_uc_in_signal_handler(thread, uc);
221
222 return os::fetch_frame_from_context(luc, ret_sp, ret_fp);
223 }
224
225
226 // ret_fp parameter is only used by Solaris X86.
227 ExtendedPC os::fetch_frame_from_context(const void* ucVoid,
228 intptr_t** ret_sp, intptr_t** ret_fp) {
229
230 ExtendedPC epc;
231 const ucontext_t *uc = (const ucontext_t*)ucVoid;
232
233 if (uc != NULL) {
234 epc = os::Solaris::ucontext_get_ExtendedPC(uc);
235 if (ret_sp) *ret_sp = os::Solaris::ucontext_get_sp(uc);
236 } else {
237 // construct empty ExtendedPC for return value checking
238 epc = ExtendedPC(NULL);
239 if (ret_sp) *ret_sp = (intptr_t *)NULL;
240 }
241
242 return epc;
243 }
244
245 frame os::fetch_frame_from_context(const void* ucVoid) {
246 intptr_t* sp;
247 intptr_t* fp;
248 ExtendedPC epc = fetch_frame_from_context(ucVoid, &sp, &fp);
249 return frame(sp, frame::unpatchable, epc.pc());
250 }
251
252 frame os::fetch_frame_from_ucontext(Thread* thread, void* ucVoid) {
253 intptr_t* sp;
254 ExtendedPC epc = os::Solaris::fetch_frame_from_ucontext(thread, (ucontext_t*)ucVoid, &sp, NULL);
255 return frame(sp, frame::unpatchable, epc.pc());
256 }
257
258 bool os::Solaris::get_frame_at_stack_banging_point(JavaThread* thread, ucontext_t* uc, frame* fr) {
259 address pc = (address) os::Solaris::ucontext_get_pc(uc);
260 if (Interpreter::contains(pc)) {
261 *fr = os::fetch_frame_from_ucontext(thread, uc);
262 if (!fr->is_first_java_frame()) {
263 assert(fr->safe_for_sender(thread), "Safety check");
264 *fr = fr->java_sender();
265 }
266 } else {
267 // more complex code with compiled code
268 assert(!Interpreter::contains(pc), "Interpreted methods should have been handled above");
269 CodeBlob* cb = CodeCache::find_blob(pc);
270 if (cb == NULL || !cb->is_nmethod() || cb->is_frame_complete_at(pc)) {
271 // Not sure where the pc points to, fallback to default
272 // stack overflow handling
273 return false;
274 } else {
275 // Returned frame will be the caller of the method that faults on the stack bang.
276 // Register window not yet rotated (happens at SAVE after stack bang), so there is no new
277 // frame to go with the faulting PC. Using caller SP that is still in SP, and caller PC
278 // that was written to O7 at call.
279 intptr_t* sp = os::Solaris::ucontext_get_sp(uc);
280 address pc = (address)uc->uc_mcontext.gregs[REG_O7];
281 *fr = frame(sp, frame::unpatchable, pc);
282
283 if (!fr->is_java_frame()) {
284 assert(fr->safe_for_sender(thread), "Safety check");
285 *fr = fr->java_sender();
286 }
287 }
288 }
289 assert(fr->is_java_frame(), "Safety check");
290 return true;
291 }
292
293 frame os::get_sender_for_C_frame(frame* fr) {
294 return frame(fr->sender_sp(), frame::unpatchable, fr->sender_pc());
295 }
296
297 // Returns an estimate of the current stack pointer. Result must be guaranteed to
298 // point into the calling threads stack, and be no lower than the current stack
299 // pointer.
300 address os::current_stack_pointer() {
301 volatile int dummy;
302 address sp = (address)&dummy + 8; // %%%% need to confirm if this is right
303 return sp;
304 }
305
306 frame os::current_frame() {
307 intptr_t* sp = StubRoutines::Sparc::flush_callers_register_windows_func()();
308 frame myframe(sp, frame::unpatchable,
309 CAST_FROM_FN_PTR(address, os::current_frame));
310 if (os::is_first_C_frame(&myframe)) {
311 // stack is not walkable
312 return frame(NULL, NULL, false);
313 } else {
314 return os::get_sender_for_C_frame(&myframe);
315 }
316 }
317
318 bool os::is_allocatable(size_t bytes) {
319 return true;
320 }
321
322 extern "C" JNIEXPORT int
323 JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid,
324 int abort_if_unrecognized) {
325 ucontext_t* uc = (ucontext_t*) ucVoid;
326
327 Thread* t = Thread::current_or_null_safe();
328
329 // Must do this before SignalHandlerMark, if crash protection installed we will longjmp away
330 // (no destructors can be run)
331 os::ThreadCrashProtection::check_crash_protection(sig, t);
332
333 SignalHandlerMark shm(t);
334
335 if(sig == SIGPIPE || sig == SIGXFSZ) {
336 if (os::Solaris::chained_handler(sig, info, ucVoid)) {
337 return true;
338 } else {
339 // Ignoring SIGPIPE/SIGXFSZ - see bugs 4229104 or 6499219
340 return true;
341 }
342 }
343
344 JavaThread* thread = NULL;
345 VMThread* vmthread = NULL;
346 if (os::Solaris::signal_handlers_are_installed) {
347 if (t != NULL ){
348 if(t->is_Java_thread()) {
349 thread = (JavaThread*)t;
350 }
351 else if(t->is_VM_thread()){
352 vmthread = (VMThread *)t;
353 }
354 }
355 }
356
357 if (sig == ASYNC_SIGNAL) {
358 if (thread || vmthread) {
359 OSThread::SR_handler(t, uc);
360 return true;
361 } else if (os::Solaris::chained_handler(sig, info, ucVoid)) {
362 return true;
363 } else {
364 // If ASYNC_SIGNAL not chained, and this is a non-vm and
365 // non-java thread
366 return true;
367 }
368 }
369
370 if (info == NULL || info->si_code <= 0 || info->si_code == SI_NOINFO) {
371 // can't decode this kind of signal
372 info = NULL;
373 } else {
374 assert(sig == info->si_signo, "bad siginfo");
375 }
376
377 // decide if this trap can be handled by a stub
378 address stub = NULL;
379
380 address pc = NULL;
381 address npc = NULL;
382
383 //%note os_trap_1
384 if (info != NULL && uc != NULL && thread != NULL) {
385 // factor me: getPCfromContext
386 pc = (address) uc->uc_mcontext.gregs[REG_PC];
387 npc = (address) uc->uc_mcontext.gregs[REG_nPC];
388
389 // SafeFetch() support
390 if (StubRoutines::is_safefetch_fault(pc)) {
391 os::Solaris::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
392 return 1;
393 }
394
395 // Handle ALL stack overflow variations here
396 if (sig == SIGSEGV && info->si_code == SEGV_ACCERR) {
397 address addr = (address) info->si_addr;
398 if (thread->in_stack_yellow_reserved_zone(addr)) {
399 // Sometimes the register windows are not properly flushed.
400 if(uc->uc_mcontext.gwins != NULL) {
401 ::handle_unflushed_register_windows(uc->uc_mcontext.gwins);
402 }
403 if (thread->thread_state() == _thread_in_Java) {
404 if (thread->in_stack_reserved_zone(addr)) {
405 frame fr;
406 if (os::Solaris::get_frame_at_stack_banging_point(thread, uc, &fr)) {
407 assert(fr.is_java_frame(), "Must be a Java frame");
408 frame activation = SharedRuntime::look_for_reserved_stack_annotated_method(thread, fr);
409 if (activation.sp() != NULL) {
410 thread->disable_stack_reserved_zone();
411 RegisterMap map(thread);
412 int frame_size = activation.frame_size(&map);
413 thread->set_reserved_stack_activation((address)(((address)activation.sp()) - STACK_BIAS));
414 return true;
415 }
416 }
417 }
418 // Throw a stack overflow exception. Guard pages will be reenabled
419 // while unwinding the stack.
420 thread->disable_stack_yellow_reserved_zone();
421 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::STACK_OVERFLOW);
422 } else {
423 // Thread was in the vm or native code. Return and try to finish.
424 thread->disable_stack_yellow_reserved_zone();
425 return true;
426 }
427 } else if (thread->in_stack_red_zone(addr)) {
428 // Fatal red zone violation. Disable the guard pages and fall through
429 // to handle_unexpected_exception way down below.
430 thread->disable_stack_red_zone();
431 tty->print_raw_cr("An irrecoverable stack overflow has occurred.");
432 // Sometimes the register windows are not properly flushed.
433 if(uc->uc_mcontext.gwins != NULL) {
434 ::handle_unflushed_register_windows(uc->uc_mcontext.gwins);
435 }
436 }
437 }
438
439
440 if (thread->thread_state() == _thread_in_vm) {
441 if (sig == SIGBUS && thread->doing_unsafe_access()) {
442 stub = SharedRuntime::handle_unsafe_access(thread, npc);
443 }
444 }
445
446 else if (thread->thread_state() == _thread_in_Java) {
447 // Java thread running in Java code => find exception handler if any
448 // a fault inside compiled code, the interpreter, or a stub
449
450 // Support Safepoint Polling
451 if (sig == SIGSEGV && os::is_poll_address((address)info->si_addr)) {
452 stub = SharedRuntime::get_poll_stub(pc);
453 }
454
455 // Not needed on x86 solaris because verify_oops doesn't generate
456 // SEGV/BUS like sparc does.
457 if ( (sig == SIGSEGV || sig == SIGBUS)
458 && pc >= MacroAssembler::_verify_oop_implicit_branch[0]
459 && pc < MacroAssembler::_verify_oop_implicit_branch[1] ) {
460 stub = MacroAssembler::_verify_oop_implicit_branch[2];
461 warning("fixed up memory fault in +VerifyOops at address " INTPTR_FORMAT, info->si_addr);
462 }
463
464 // This is not factored because on x86 solaris the patching for
465 // zombies does not generate a SEGV.
466 else if (sig == SIGSEGV && nativeInstruction_at(pc)->is_zombie()) {
467 // zombie method (ld [%g0],%o7 instruction)
468 stub = SharedRuntime::get_handle_wrong_method_stub();
469
470 // At the stub it needs to look like a call from the caller of this
471 // method (not a call from the segv site).
472 pc = (address)uc->uc_mcontext.gregs[REG_O7];
473 }
474 else if (sig == SIGBUS && info->si_code == BUS_OBJERR) {
475 // BugId 4454115: A read from a MappedByteBuffer can fault
476 // here if the underlying file has been truncated.
477 // Do not crash the VM in such a case.
478 CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
479 CompiledMethod* nm = cb->as_compiled_method_or_null();
480 if (nm != NULL && nm->has_unsafe_access()) {
481 stub = SharedRuntime::handle_unsafe_access(thread, npc);
482 }
483 }
484
485 else if (sig == SIGFPE && info->si_code == FPE_INTDIV) {
486 // integer divide by zero
487 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO);
488 }
489 else if (sig == SIGFPE && info->si_code == FPE_FLTDIV) {
490 // floating-point divide by zero
491 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO);
492 }
493 #ifdef COMPILER2
494 else if (sig == SIGILL && nativeInstruction_at(pc)->is_ic_miss_trap()) {
495 #ifdef ASSERT
496 #ifdef TIERED
497 CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
498 assert(cb->is_compiled_by_c2(), "Wrong compiler");
499 #endif // TIERED
500 #endif // ASSERT
501 // Inline cache missed and user trap "Tne G0+ST_RESERVED_FOR_USER_0+2" taken.
502 stub = SharedRuntime::get_ic_miss_stub();
503 // At the stub it needs to look like a call from the caller of this
504 // method (not a call from the segv site).
505 pc = (address)uc->uc_mcontext.gregs[REG_O7];
506 }
507 #endif // COMPILER2
508
509 else if (sig == SIGSEGV && info->si_code > 0 && !MacroAssembler::needs_explicit_null_check((intptr_t)info->si_addr)) {
510 // Determination of interpreter/vtable stub/compiled code null exception
511 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
512 }
513 }
514
515 // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks in
516 // and the heap gets shrunk before the field access.
517 if ((sig == SIGSEGV) || (sig == SIGBUS)) {
518 address addr = JNI_FastGetField::find_slowcase_pc(pc);
519 if (addr != (address)-1) {
520 stub = addr;
521 }
522 }
523
524 // Check to see if we caught the safepoint code in the
525 // process of write protecting the memory serialization page.
526 // It write enables the page immediately after protecting it
527 // so just return.
528 if ((sig == SIGSEGV) &&
529 os::is_memory_serialize_page(thread, (address)info->si_addr)) {
530 // Block current thread until the memory serialize page permission restored.
531 os::block_on_serialize_page_trap();
532 return true;
533 }
534 }
535
536 if (stub != NULL) {
537 // save all thread context in case we need to restore it
538
539 thread->set_saved_exception_pc(pc);
540 thread->set_saved_exception_npc(npc);
541
542 // simulate a branch to the stub (a "call" in the safepoint stub case)
543 // factor me: setPC
544 os::Solaris::ucontext_set_pc(uc, stub);
545
546 return true;
547 }
548
549 // signal-chaining
550 if (os::Solaris::chained_handler(sig, info, ucVoid)) {
551 return true;
552 }
553
554 if (!abort_if_unrecognized) {
555 // caller wants another chance, so give it to him
556 return false;
557 }
558
559 if (!os::Solaris::libjsig_is_loaded) {
560 struct sigaction oldAct;
561 sigaction(sig, (struct sigaction *)0, &oldAct);
562 if (oldAct.sa_sigaction != signalHandler) {
563 void* sighand = oldAct.sa_sigaction ? CAST_FROM_FN_PTR(void*, oldAct.sa_sigaction)
564 : CAST_FROM_FN_PTR(void*, oldAct.sa_handler);
565 warning("Unexpected Signal %d occurred under user-defined signal handler " INTPTR_FORMAT, sig, (intptr_t)sighand);
566 }
567 }
568
569 if (pc == NULL && uc != NULL) {
570 pc = (address) uc->uc_mcontext.gregs[REG_PC];
571 }
572
573 // Sometimes the register windows are not properly flushed.
574 if(uc->uc_mcontext.gwins != NULL) {
575 ::handle_unflushed_register_windows(uc->uc_mcontext.gwins);
576 }
577
578 // unmask current signal
579 sigset_t newset;
580 sigemptyset(&newset);
581 sigaddset(&newset, sig);
582 sigprocmask(SIG_UNBLOCK, &newset, NULL);
583
584 // Determine which sort of error to throw. Out of swap may signal
585 // on the thread stack, which could get a mapping error when touched.
586 address addr = (address) info->si_addr;
587 if (sig == SIGBUS && info->si_code == BUS_OBJERR && info->si_errno == ENOMEM) {
588 vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "Out of swap space to map in thread stack.");
589 }
590
591 VMError::report_and_die(t, sig, pc, info, ucVoid);
592
593 ShouldNotReachHere();
594 return false;
595 }
596
597 void os::print_context(outputStream *st, const void *context) {
598 if (context == NULL) return;
599
600 const ucontext_t *uc = (const ucontext_t*)context;
601 st->print_cr("Registers:");
602
603 st->print_cr(" G1=" INTPTR_FORMAT " G2=" INTPTR_FORMAT
604 " G3=" INTPTR_FORMAT " G4=" INTPTR_FORMAT,
605 uc->uc_mcontext.gregs[REG_G1],
606 uc->uc_mcontext.gregs[REG_G2],
607 uc->uc_mcontext.gregs[REG_G3],
608 uc->uc_mcontext.gregs[REG_G4]);
609 st->print_cr(" G5=" INTPTR_FORMAT " G6=" INTPTR_FORMAT
610 " G7=" INTPTR_FORMAT " Y=" INTPTR_FORMAT,
611 uc->uc_mcontext.gregs[REG_G5],
612 uc->uc_mcontext.gregs[REG_G6],
613 uc->uc_mcontext.gregs[REG_G7],
614 uc->uc_mcontext.gregs[REG_Y]);
615 st->print_cr(" O0=" INTPTR_FORMAT " O1=" INTPTR_FORMAT
616 " O2=" INTPTR_FORMAT " O3=" INTPTR_FORMAT,
617 uc->uc_mcontext.gregs[REG_O0],
618 uc->uc_mcontext.gregs[REG_O1],
619 uc->uc_mcontext.gregs[REG_O2],
620 uc->uc_mcontext.gregs[REG_O3]);
621 st->print_cr(" O4=" INTPTR_FORMAT " O5=" INTPTR_FORMAT
622 " O6=" INTPTR_FORMAT " O7=" INTPTR_FORMAT,
623 uc->uc_mcontext.gregs[REG_O4],
624 uc->uc_mcontext.gregs[REG_O5],
625 uc->uc_mcontext.gregs[REG_O6],
626 uc->uc_mcontext.gregs[REG_O7]);
627
628
629 intptr_t *sp = (intptr_t *)os::Solaris::ucontext_get_sp(uc);
630 st->print_cr(" L0=" INTPTR_FORMAT " L1=" INTPTR_FORMAT
631 " L2=" INTPTR_FORMAT " L3=" INTPTR_FORMAT,
632 sp[L0->sp_offset_in_saved_window()],
633 sp[L1->sp_offset_in_saved_window()],
634 sp[L2->sp_offset_in_saved_window()],
635 sp[L3->sp_offset_in_saved_window()]);
636 st->print_cr(" L4=" INTPTR_FORMAT " L5=" INTPTR_FORMAT
637 " L6=" INTPTR_FORMAT " L7=" INTPTR_FORMAT,
638 sp[L4->sp_offset_in_saved_window()],
639 sp[L5->sp_offset_in_saved_window()],
640 sp[L6->sp_offset_in_saved_window()],
641 sp[L7->sp_offset_in_saved_window()]);
642 st->print_cr(" I0=" INTPTR_FORMAT " I1=" INTPTR_FORMAT
643 " I2=" INTPTR_FORMAT " I3=" INTPTR_FORMAT,
644 sp[I0->sp_offset_in_saved_window()],
645 sp[I1->sp_offset_in_saved_window()],
646 sp[I2->sp_offset_in_saved_window()],
647 sp[I3->sp_offset_in_saved_window()]);
648 st->print_cr(" I4=" INTPTR_FORMAT " I5=" INTPTR_FORMAT
649 " I6=" INTPTR_FORMAT " I7=" INTPTR_FORMAT,
650 sp[I4->sp_offset_in_saved_window()],
651 sp[I5->sp_offset_in_saved_window()],
652 sp[I6->sp_offset_in_saved_window()],
653 sp[I7->sp_offset_in_saved_window()]);
654
655 st->print_cr(" PC=" INTPTR_FORMAT " nPC=" INTPTR_FORMAT,
656 uc->uc_mcontext.gregs[REG_PC],
657 uc->uc_mcontext.gregs[REG_nPC]);
658 st->cr();
659 st->cr();
660
661 st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp);
662 print_hex_dump(st, (address)sp, (address)(sp + 32), sizeof(intptr_t));
663 st->cr();
664
665 // Note: it may be unsafe to inspect memory near pc. For example, pc may
666 // point to garbage if entry point in an nmethod is corrupted. Leave
667 // this at the end, and hope for the best.
668 ExtendedPC epc = os::Solaris::ucontext_get_ExtendedPC(uc);
669 address pc = epc.pc();
670 st->print_cr("Instructions: (pc=" PTR_FORMAT ")", pc);
671 print_hex_dump(st, pc - 32, pc + 32, sizeof(char));
672 }
673
674 void os::print_register_info(outputStream *st, const void *context) {
675 if (context == NULL) return;
676
677 const ucontext_t *uc = (const ucontext_t*)context;
678 intptr_t *sp = (intptr_t *)os::Solaris::ucontext_get_sp(uc);
679
680 st->print_cr("Register to memory mapping:");
681 st->cr();
682
683 // this is only for the "general purpose" registers
684 st->print("G1="); print_location(st, uc->uc_mcontext.gregs[REG_G1]);
685 st->print("G2="); print_location(st, uc->uc_mcontext.gregs[REG_G2]);
686 st->print("G3="); print_location(st, uc->uc_mcontext.gregs[REG_G3]);
687 st->print("G4="); print_location(st, uc->uc_mcontext.gregs[REG_G4]);
688 st->print("G5="); print_location(st, uc->uc_mcontext.gregs[REG_G5]);
689 st->print("G6="); print_location(st, uc->uc_mcontext.gregs[REG_G6]);
690 st->print("G7="); print_location(st, uc->uc_mcontext.gregs[REG_G7]);
691 st->cr();
692
693 st->print("O0="); print_location(st, uc->uc_mcontext.gregs[REG_O0]);
694 st->print("O1="); print_location(st, uc->uc_mcontext.gregs[REG_O1]);
695 st->print("O2="); print_location(st, uc->uc_mcontext.gregs[REG_O2]);
696 st->print("O3="); print_location(st, uc->uc_mcontext.gregs[REG_O3]);
697 st->print("O4="); print_location(st, uc->uc_mcontext.gregs[REG_O4]);
698 st->print("O5="); print_location(st, uc->uc_mcontext.gregs[REG_O5]);
699 st->print("O6="); print_location(st, uc->uc_mcontext.gregs[REG_O6]);
700 st->print("O7="); print_location(st, uc->uc_mcontext.gregs[REG_O7]);
701 st->cr();
702
703 st->print("L0="); print_location(st, sp[L0->sp_offset_in_saved_window()]);
704 st->print("L1="); print_location(st, sp[L1->sp_offset_in_saved_window()]);
705 st->print("L2="); print_location(st, sp[L2->sp_offset_in_saved_window()]);
706 st->print("L3="); print_location(st, sp[L3->sp_offset_in_saved_window()]);
707 st->print("L4="); print_location(st, sp[L4->sp_offset_in_saved_window()]);
708 st->print("L5="); print_location(st, sp[L5->sp_offset_in_saved_window()]);
709 st->print("L6="); print_location(st, sp[L6->sp_offset_in_saved_window()]);
710 st->print("L7="); print_location(st, sp[L7->sp_offset_in_saved_window()]);
711 st->cr();
712
713 st->print("I0="); print_location(st, sp[I0->sp_offset_in_saved_window()]);
714 st->print("I1="); print_location(st, sp[I1->sp_offset_in_saved_window()]);
715 st->print("I2="); print_location(st, sp[I2->sp_offset_in_saved_window()]);
716 st->print("I3="); print_location(st, sp[I3->sp_offset_in_saved_window()]);
717 st->print("I4="); print_location(st, sp[I4->sp_offset_in_saved_window()]);
718 st->print("I5="); print_location(st, sp[I5->sp_offset_in_saved_window()]);
719 st->print("I6="); print_location(st, sp[I6->sp_offset_in_saved_window()]);
720 st->print("I7="); print_location(st, sp[I7->sp_offset_in_saved_window()]);
721 st->cr();
722 }
723
724 void os::Solaris::init_thread_fpu_state(void) {
725 // Nothing needed on Sparc.
726 }
727
728 #ifndef PRODUCT
729 void os::verify_stack_alignment() {
730 }
731 #endif
732
733 int os::extra_bang_size_in_bytes() {
734 // SPARC does not require an additional stack bang.
735 return 0;
736 }
--- EOF ---