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