annotate src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp @ 17833:bfdf528be8e8

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