author | phh |
Sat, 30 Nov 2019 14:33:05 -0800 | |
changeset 59330 | 5b96c12f909d |
parent 59292 | 95b1385dd476 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
55490
3f3dc00a69a5
8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents:
53605
diff
changeset
|
2 |
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4891
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4891
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4891
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
// no precompiled headers |
47765
b7c7428eaab9
8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents:
47216
diff
changeset
|
26 |
#include "jvm.h" |
14626
0cf4eccf130f
8003240: x86: move MacroAssembler into separate file
twisti
parents:
13963
diff
changeset
|
27 |
#include "asm/macroAssembler.hpp" |
7397 | 28 |
#include "classfile/classLoader.hpp" |
29 |
#include "classfile/systemDictionary.hpp" |
|
30 |
#include "classfile/vmSymbols.hpp" |
|
34667 | 31 |
#include "code/codeCache.hpp" |
7397 | 32 |
#include "code/icBuffer.hpp" |
33 |
#include "code/vtableStubs.hpp" |
|
34 |
#include "interpreter/interpreter.hpp" |
|
49615
1b1de4b263c8
8200232: Build failures after JDK-8200106 (Move NoSafepointVerifier out from gcLocker.hpp)
shade
parents:
49449
diff
changeset
|
35 |
#include "logging/log.hpp" |
7397 | 36 |
#include "memory/allocation.inline.hpp" |
37 |
#include "os_share_solaris.hpp" |
|
38 |
#include "prims/jniFastGetField.hpp" |
|
39 |
#include "prims/jvm_misc.hpp" |
|
40 |
#include "runtime/arguments.hpp" |
|
41 |
#include "runtime/extendedPC.hpp" |
|
42 |
#include "runtime/frame.inline.hpp" |
|
49449
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
48468
diff
changeset
|
43 |
#include "runtime/interfaceSupport.inline.hpp" |
7397 | 44 |
#include "runtime/java.hpp" |
45 |
#include "runtime/javaCalls.hpp" |
|
46 |
#include "runtime/mutexLocker.hpp" |
|
47 |
#include "runtime/osThread.hpp" |
|
48 |
#include "runtime/sharedRuntime.hpp" |
|
49 |
#include "runtime/stubRoutines.hpp" |
|
14583
d70ee55535f4
8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
13963
diff
changeset
|
50 |
#include "runtime/thread.inline.hpp" |
7397 | 51 |
#include "runtime/timer.hpp" |
46625 | 52 |
#include "utilities/align.hpp" |
7397 | 53 |
#include "utilities/events.hpp" |
54 |
#include "utilities/vmError.hpp" |
|
1 | 55 |
|
56 |
// put OS-includes here |
|
57 |
# include <sys/types.h> |
|
58 |
# include <sys/mman.h> |
|
59 |
# include <pthread.h> |
|
60 |
# include <signal.h> |
|
61 |
# include <setjmp.h> |
|
62 |
# include <errno.h> |
|
63 |
# include <dlfcn.h> |
|
64 |
# include <stdio.h> |
|
65 |
# include <unistd.h> |
|
66 |
# include <sys/resource.h> |
|
67 |
# include <thread.h> |
|
68 |
# include <sys/stat.h> |
|
69 |
# include <sys/time.h> |
|
70 |
# include <sys/filio.h> |
|
71 |
# include <sys/utsname.h> |
|
72 |
# include <sys/systeminfo.h> |
|
73 |
# include <sys/socket.h> |
|
74 |
# include <sys/trap.h> |
|
75 |
# include <sys/lwp.h> |
|
76 |
# include <poll.h> |
|
77 |
# include <sys/lwp.h> |
|
78 |
# include <procfs.h> // see comment in <sys/procfs.h> |
|
79 |
||
80 |
#ifndef AMD64 |
|
81 |
// QQQ seems useless at this point |
|
82 |
# define _STRUCTURED_PROC 1 // this gets us the new structured proc interfaces of 5.6 & later |
|
83 |
#endif // AMD64 |
|
84 |
# include <sys/procfs.h> // see comment in <sys/procfs.h> |
|
85 |
||
86 |
||
87 |
#define MAX_PATH (2 * K) |
|
88 |
||
42906
1a8db9cf1407
8170655: [posix] Fix minimum stack size computations
goetz
parents:
41314
diff
changeset
|
89 |
// Minimum usable stack sizes required to get to user code. Space for |
1a8db9cf1407
8170655: [posix] Fix minimum stack size computations
goetz
parents:
41314
diff
changeset
|
90 |
// HotSpot guard pages is added later. |
1a8db9cf1407
8170655: [posix] Fix minimum stack size computations
goetz
parents:
41314
diff
changeset
|
91 |
#ifdef _LP64 |
43450
c83d7ccaf56e
8172731: runtime/Thread/TooSmallStackSize.java fails on solaris-x64 with product build
thartmann
parents:
42906
diff
changeset
|
92 |
// The adlc generated method 'State::MachNodeGenerator(int)' used by the C2 compiler |
c83d7ccaf56e
8172731: runtime/Thread/TooSmallStackSize.java fails on solaris-x64 with product build
thartmann
parents:
42906
diff
changeset
|
93 |
// threads requires a large stack with the Solaris Studio C++ compiler version 5.13 |
c83d7ccaf56e
8172731: runtime/Thread/TooSmallStackSize.java fails on solaris-x64 with product build
thartmann
parents:
42906
diff
changeset
|
94 |
// and product VM builds (debug builds require significantly less stack space). |
c83d7ccaf56e
8172731: runtime/Thread/TooSmallStackSize.java fails on solaris-x64 with product build
thartmann
parents:
42906
diff
changeset
|
95 |
size_t os::Posix::_compiler_thread_min_stack_allowed = 325 * K; |
42906
1a8db9cf1407
8170655: [posix] Fix minimum stack size computations
goetz
parents:
41314
diff
changeset
|
96 |
size_t os::Posix::_java_thread_min_stack_allowed = 48 * K; |
1a8db9cf1407
8170655: [posix] Fix minimum stack size computations
goetz
parents:
41314
diff
changeset
|
97 |
size_t os::Posix::_vm_internal_thread_min_stack_allowed = 224 * K; |
1a8db9cf1407
8170655: [posix] Fix minimum stack size computations
goetz
parents:
41314
diff
changeset
|
98 |
#else |
1a8db9cf1407
8170655: [posix] Fix minimum stack size computations
goetz
parents:
41314
diff
changeset
|
99 |
size_t os::Posix::_compiler_thread_min_stack_allowed = 32 * K; |
1a8db9cf1407
8170655: [posix] Fix minimum stack size computations
goetz
parents:
41314
diff
changeset
|
100 |
size_t os::Posix::_java_thread_min_stack_allowed = 32 * K; |
1a8db9cf1407
8170655: [posix] Fix minimum stack size computations
goetz
parents:
41314
diff
changeset
|
101 |
size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K; |
1a8db9cf1407
8170655: [posix] Fix minimum stack size computations
goetz
parents:
41314
diff
changeset
|
102 |
#endif // _LP64 |
1a8db9cf1407
8170655: [posix] Fix minimum stack size computations
goetz
parents:
41314
diff
changeset
|
103 |
|
1 | 104 |
#ifdef AMD64 |
105 |
#define REG_SP REG_RSP |
|
106 |
#define REG_PC REG_RIP |
|
107 |
#define REG_FP REG_RBP |
|
108 |
#else |
|
109 |
#define REG_SP UESP |
|
110 |
#define REG_PC EIP |
|
111 |
#define REG_FP EBP |
|
112 |
// 4900493 counter to prevent runaway LDTR refresh attempt |
|
113 |
||
114 |
static volatile int ldtr_refresh = 0; |
|
115 |
// the libthread instruction that faults because of the stale LDTR |
|
116 |
||
117 |
static const unsigned char movlfs[] = { 0x8e, 0xe0 // movl %eax,%fs |
|
118 |
}; |
|
119 |
#endif // AMD64 |
|
120 |
||
121 |
char* os::non_memory_address_word() { |
|
122 |
// Must never look like an address returned by reserve_memory, |
|
123 |
// even in its subfields (as defined by the CPU immediate fields, |
|
124 |
// if the CPU splits constants across multiple instructions). |
|
125 |
return (char*) -1; |
|
126 |
} |
|
127 |
||
128 |
// |
|
129 |
// Validate a ucontext retrieved from walking a uc_link of a ucontext. |
|
130 |
// There are issues with libthread giving out uc_links for different threads |
|
131 |
// on the same uc_link chain and bad or circular links. |
|
132 |
// |
|
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
133 |
bool os::Solaris::valid_ucontext(Thread* thread, const ucontext_t* valid, const ucontext_t* suspect) { |
1 | 134 |
if (valid >= suspect || |
135 |
valid->uc_stack.ss_flags != suspect->uc_stack.ss_flags || |
|
136 |
valid->uc_stack.ss_sp != suspect->uc_stack.ss_sp || |
|
137 |
valid->uc_stack.ss_size != suspect->uc_stack.ss_size) { |
|
138 |
DEBUG_ONLY(tty->print_cr("valid_ucontext: failed test 1");) |
|
139 |
return false; |
|
140 |
} |
|
141 |
||
142 |
if (thread->is_Java_thread()) { |
|
143 |
if (!valid_stack_address(thread, (address)suspect)) { |
|
144 |
DEBUG_ONLY(tty->print_cr("valid_ucontext: uc_link not in thread stack");) |
|
145 |
return false; |
|
146 |
} |
|
147 |
if (!valid_stack_address(thread, (address) suspect->uc_mcontext.gregs[REG_SP])) { |
|
148 |
DEBUG_ONLY(tty->print_cr("valid_ucontext: stackpointer not in thread stack");) |
|
149 |
return false; |
|
150 |
} |
|
151 |
} |
|
152 |
return true; |
|
153 |
} |
|
154 |
||
155 |
// We will only follow one level of uc_link since there are libthread |
|
156 |
// issues with ucontext linking and it is better to be safe and just |
|
157 |
// let caller retry later. |
|
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
158 |
const ucontext_t* os::Solaris::get_valid_uc_in_signal_handler(Thread *thread, |
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
159 |
const ucontext_t *uc) { |
1 | 160 |
|
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
161 |
const ucontext_t *retuc = NULL; |
1 | 162 |
|
163 |
if (uc != NULL) { |
|
164 |
if (uc->uc_link == NULL) { |
|
165 |
// cannot validate without uc_link so accept current ucontext |
|
166 |
retuc = uc; |
|
167 |
} else if (os::Solaris::valid_ucontext(thread, uc, uc->uc_link)) { |
|
168 |
// first ucontext is valid so try the next one |
|
169 |
uc = uc->uc_link; |
|
170 |
if (uc->uc_link == NULL) { |
|
171 |
// cannot validate without uc_link so accept current ucontext |
|
172 |
retuc = uc; |
|
173 |
} else if (os::Solaris::valid_ucontext(thread, uc, uc->uc_link)) { |
|
174 |
// the ucontext one level down is also valid so return it |
|
175 |
retuc = uc; |
|
176 |
} |
|
177 |
} |
|
178 |
} |
|
179 |
return retuc; |
|
180 |
} |
|
181 |
||
182 |
// Assumes ucontext is valid |
|
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
183 |
ExtendedPC os::Solaris::ucontext_get_ExtendedPC(const ucontext_t *uc) { |
1 | 184 |
return ExtendedPC((address)uc->uc_mcontext.gregs[REG_PC]); |
185 |
} |
|
186 |
||
29573
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
26576
diff
changeset
|
187 |
void os::Solaris::ucontext_set_pc(ucontext_t* uc, address pc) { |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
26576
diff
changeset
|
188 |
uc->uc_mcontext.gregs [REG_PC] = (greg_t) pc; |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
26576
diff
changeset
|
189 |
} |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
26576
diff
changeset
|
190 |
|
1 | 191 |
// Assumes ucontext is valid |
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
192 |
intptr_t* os::Solaris::ucontext_get_sp(const ucontext_t *uc) { |
1 | 193 |
return (intptr_t*)uc->uc_mcontext.gregs[REG_SP]; |
194 |
} |
|
195 |
||
196 |
// Assumes ucontext is valid |
|
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
197 |
intptr_t* os::Solaris::ucontext_get_fp(const ucontext_t *uc) { |
1 | 198 |
return (intptr_t*)uc->uc_mcontext.gregs[REG_FP]; |
199 |
} |
|
200 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
201 |
address os::Solaris::ucontext_get_pc(const ucontext_t *uc) { |
18025 | 202 |
return (address) uc->uc_mcontext.gregs[REG_PC]; |
203 |
} |
|
204 |
||
1 | 205 |
// For Forte Analyzer AsyncGetCallTrace profiling support - thread |
206 |
// is currently interrupted by SIGPROF. |
|
207 |
// |
|
208 |
// The difference between this and os::fetch_frame_from_context() is that |
|
209 |
// here we try to skip nested signal frames. |
|
35071
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
210 |
// This method is also used for stack overflow signal handling. |
1 | 211 |
ExtendedPC os::Solaris::fetch_frame_from_ucontext(Thread* thread, |
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
212 |
const ucontext_t* uc, intptr_t** ret_sp, intptr_t** ret_fp) { |
1 | 213 |
|
214 |
assert(thread != NULL, "just checking"); |
|
215 |
assert(ret_sp != NULL, "just checking"); |
|
216 |
assert(ret_fp != NULL, "just checking"); |
|
217 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
218 |
const ucontext_t *luc = os::Solaris::get_valid_uc_in_signal_handler(thread, uc); |
1 | 219 |
return os::fetch_frame_from_context(luc, ret_sp, ret_fp); |
220 |
} |
|
221 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
222 |
ExtendedPC os::fetch_frame_from_context(const void* ucVoid, |
1 | 223 |
intptr_t** ret_sp, intptr_t** ret_fp) { |
224 |
||
225 |
ExtendedPC epc; |
|
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
226 |
const ucontext_t *uc = (const ucontext_t*)ucVoid; |
1 | 227 |
|
228 |
if (uc != NULL) { |
|
229 |
epc = os::Solaris::ucontext_get_ExtendedPC(uc); |
|
230 |
if (ret_sp) *ret_sp = os::Solaris::ucontext_get_sp(uc); |
|
231 |
if (ret_fp) *ret_fp = os::Solaris::ucontext_get_fp(uc); |
|
232 |
} else { |
|
233 |
// construct empty ExtendedPC for return value checking |
|
234 |
epc = ExtendedPC(NULL); |
|
235 |
if (ret_sp) *ret_sp = (intptr_t *)NULL; |
|
236 |
if (ret_fp) *ret_fp = (intptr_t *)NULL; |
|
237 |
} |
|
238 |
||
239 |
return epc; |
|
240 |
} |
|
241 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
242 |
frame os::fetch_frame_from_context(const void* ucVoid) { |
1 | 243 |
intptr_t* sp; |
244 |
intptr_t* fp; |
|
245 |
ExtendedPC epc = fetch_frame_from_context(ucVoid, &sp, &fp); |
|
246 |
return frame(sp, fp, epc.pc()); |
|
247 |
} |
|
248 |
||
35071
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
249 |
frame os::fetch_frame_from_ucontext(Thread* thread, void* ucVoid) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
250 |
intptr_t* sp; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
251 |
intptr_t* fp; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
252 |
ExtendedPC epc = os::Solaris::fetch_frame_from_ucontext(thread, (ucontext_t*)ucVoid, &sp, &fp); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
253 |
return frame(sp, fp, epc.pc()); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
254 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
255 |
|
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
256 |
bool os::Solaris::get_frame_at_stack_banging_point(JavaThread* thread, ucontext_t* uc, frame* fr) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
257 |
address pc = (address) os::Solaris::ucontext_get_pc(uc); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
258 |
if (Interpreter::contains(pc)) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
259 |
// interpreter performs stack banging after the fixed frame header has |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
260 |
// been generated while the compilers perform it before. To maintain |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
261 |
// semantic consistency between interpreted and compiled frames, the |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
262 |
// method returns the Java sender of the current frame. |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
263 |
*fr = os::fetch_frame_from_ucontext(thread, uc); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
264 |
if (!fr->is_first_java_frame()) { |
41314
f815c3be1f2e
8146546: assert(fr->safe_for_sender(thread)) failed: Safety check
fparain
parents:
41070
diff
changeset
|
265 |
// get_frame_at_stack_banging_point() is only called when we |
f815c3be1f2e
8146546: assert(fr->safe_for_sender(thread)) failed: Safety check
fparain
parents:
41070
diff
changeset
|
266 |
// have well defined stacks so java_sender() calls do not need |
f815c3be1f2e
8146546: assert(fr->safe_for_sender(thread)) failed: Safety check
fparain
parents:
41070
diff
changeset
|
267 |
// to assert safe_for_sender() first. |
35071
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
268 |
*fr = fr->java_sender(); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
269 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
270 |
} else { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
271 |
// more complex code with compiled code |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
272 |
assert(!Interpreter::contains(pc), "Interpreted methods should have been handled above"); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
273 |
CodeBlob* cb = CodeCache::find_blob(pc); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
274 |
if (cb == NULL || !cb->is_nmethod() || cb->is_frame_complete_at(pc)) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
275 |
// Not sure where the pc points to, fallback to default |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
276 |
// stack overflow handling |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
277 |
return false; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
278 |
} else { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
279 |
// in compiled code, the stack banging is performed just after the return pc |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
280 |
// has been pushed on the stack |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
281 |
intptr_t* fp = os::Solaris::ucontext_get_fp(uc); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
282 |
intptr_t* sp = os::Solaris::ucontext_get_sp(uc); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
283 |
*fr = frame(sp + 1, fp, (address)*sp); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
284 |
if (!fr->is_java_frame()) { |
41314
f815c3be1f2e
8146546: assert(fr->safe_for_sender(thread)) failed: Safety check
fparain
parents:
41070
diff
changeset
|
285 |
// See java_sender() comment above. |
35071
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
286 |
*fr = fr->java_sender(); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
287 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
288 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
289 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
290 |
assert(fr->is_java_frame(), "Safety check"); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
291 |
return true; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
292 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
293 |
|
1 | 294 |
frame os::get_sender_for_C_frame(frame* fr) { |
295 |
return frame(fr->sender_sp(), fr->link(), fr->sender_pc()); |
|
296 |
} |
|
297 |
||
11961
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
298 |
extern "C" intptr_t *_get_current_sp(); // in .il file |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
299 |
|
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
300 |
address os::current_stack_pointer() { |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
301 |
return (address)_get_current_sp(); |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
302 |
} |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
303 |
|
1659
b9a3819ac7c6
6773838: There is no calling stack for Compiler thread in hs_err file on x86
coleenp
parents:
670
diff
changeset
|
304 |
extern "C" intptr_t *_get_current_fp(); // in .il file |
1 | 305 |
|
306 |
frame os::current_frame() { |
|
1659
b9a3819ac7c6
6773838: There is no calling stack for Compiler thread in hs_err file on x86
coleenp
parents:
670
diff
changeset
|
307 |
intptr_t* fp = _get_current_fp(); // it's inlined so want current fp |
40382
7537c0ce2df3
8133749: os::current_frame() is not returning the proper frame on ARM and solaris-x64
cjplummer
parents:
40010
diff
changeset
|
308 |
// fp is for os::current_frame. We want the fp for our caller. |
1 | 309 |
frame myframe((intptr_t*)os::current_stack_pointer(), |
310 |
(intptr_t*)fp, |
|
311 |
CAST_FROM_FN_PTR(address, os::current_frame)); |
|
40382
7537c0ce2df3
8133749: os::current_frame() is not returning the proper frame on ARM and solaris-x64
cjplummer
parents:
40010
diff
changeset
|
312 |
frame caller_frame = os::get_sender_for_C_frame(&myframe); |
7537c0ce2df3
8133749: os::current_frame() is not returning the proper frame on ARM and solaris-x64
cjplummer
parents:
40010
diff
changeset
|
313 |
|
7537c0ce2df3
8133749: os::current_frame() is not returning the proper frame on ARM and solaris-x64
cjplummer
parents:
40010
diff
changeset
|
314 |
if (os::is_first_C_frame(&caller_frame)) { |
1 | 315 |
// stack is not walkable |
354
3b42d6fdcb82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
1
diff
changeset
|
316 |
frame ret; // This will be a null useless frame |
3b42d6fdcb82
6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents:
1
diff
changeset
|
317 |
return ret; |
1 | 318 |
} else { |
40382
7537c0ce2df3
8133749: os::current_frame() is not returning the proper frame on ARM and solaris-x64
cjplummer
parents:
40010
diff
changeset
|
319 |
// return frame for our caller's caller |
7537c0ce2df3
8133749: os::current_frame() is not returning the proper frame on ARM and solaris-x64
cjplummer
parents:
40010
diff
changeset
|
320 |
return os::get_sender_for_C_frame(&caller_frame); |
1 | 321 |
} |
322 |
} |
|
323 |
||
324 |
#ifndef AMD64 |
|
325 |
||
326 |
// Detecting SSE support by OS |
|
327 |
// From solaris_i486.s |
|
328 |
extern "C" bool sse_check(); |
|
329 |
extern "C" bool sse_unavailable(); |
|
330 |
||
331 |
enum { SSE_UNKNOWN, SSE_NOT_SUPPORTED, SSE_SUPPORTED}; |
|
332 |
static int sse_status = SSE_UNKNOWN; |
|
333 |
||
334 |
||
335 |
static void check_for_sse_support() { |
|
336 |
if (!VM_Version::supports_sse()) { |
|
337 |
sse_status = SSE_NOT_SUPPORTED; |
|
338 |
return; |
|
339 |
} |
|
340 |
// looking for _sse_hw in libc.so, if it does not exist or |
|
341 |
// the value (int) is 0, OS has no support for SSE |
|
342 |
int *sse_hwp; |
|
343 |
void *h; |
|
344 |
||
345 |
if ((h=dlopen("/usr/lib/libc.so", RTLD_LAZY)) == NULL) { |
|
346 |
//open failed, presume no support for SSE |
|
347 |
sse_status = SSE_NOT_SUPPORTED; |
|
348 |
return; |
|
349 |
} |
|
350 |
if ((sse_hwp = (int *)dlsym(h, "_sse_hw")) == NULL) { |
|
351 |
sse_status = SSE_NOT_SUPPORTED; |
|
352 |
} else if (*sse_hwp == 0) { |
|
353 |
sse_status = SSE_NOT_SUPPORTED; |
|
354 |
} |
|
355 |
dlclose(h); |
|
356 |
||
357 |
if (sse_status == SSE_UNKNOWN) { |
|
358 |
bool (*try_sse)() = (bool (*)())sse_check; |
|
359 |
sse_status = (*try_sse)() ? SSE_SUPPORTED : SSE_NOT_SUPPORTED; |
|
360 |
} |
|
361 |
||
362 |
} |
|
363 |
||
2111 | 364 |
#endif // AMD64 |
365 |
||
1 | 366 |
bool os::supports_sse() { |
2111 | 367 |
#ifdef AMD64 |
368 |
return true; |
|
369 |
#else |
|
1 | 370 |
if (sse_status == SSE_UNKNOWN) |
371 |
check_for_sse_support(); |
|
372 |
return sse_status == SSE_SUPPORTED; |
|
2111 | 373 |
#endif // AMD64 |
1 | 374 |
} |
375 |
||
376 |
bool os::is_allocatable(size_t bytes) { |
|
377 |
#ifdef AMD64 |
|
378 |
return true; |
|
379 |
#else |
|
380 |
||
381 |
if (bytes < 2 * G) { |
|
382 |
return true; |
|
383 |
} |
|
384 |
||
385 |
char* addr = reserve_memory(bytes, NULL); |
|
386 |
||
387 |
if (addr != NULL) { |
|
388 |
release_memory(addr, bytes); |
|
389 |
} |
|
390 |
||
391 |
return addr != NULL; |
|
392 |
#endif // AMD64 |
|
393 |
||
394 |
} |
|
395 |
||
8106 | 396 |
extern "C" JNIEXPORT int |
397 |
JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, |
|
398 |
int abort_if_unrecognized) { |
|
1 | 399 |
ucontext_t* uc = (ucontext_t*) ucVoid; |
400 |
||
401 |
#ifndef AMD64 |
|
402 |
if (sig == SIGILL && info->si_addr == (caddr_t)sse_check) { |
|
403 |
// the SSE instruction faulted. supports_sse() need return false. |
|
404 |
uc->uc_mcontext.gregs[EIP] = (greg_t)sse_unavailable; |
|
405 |
return true; |
|
406 |
} |
|
407 |
#endif // !AMD64 |
|
408 |
||
34633
2a6c7c7b30a7
8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents:
33732
diff
changeset
|
409 |
Thread* t = Thread::current_or_null_safe(); |
1 | 410 |
|
18943 | 411 |
// Must do this before SignalHandlerMark, if crash protection installed we will longjmp away |
412 |
// (no destructors can be run) |
|
46644
a5813fb66270
8183925: Decouple crash protection from watcher thread
rehn
parents:
46625
diff
changeset
|
413 |
os::ThreadCrashProtection::check_crash_protection(sig, t); |
18943 | 414 |
|
1 | 415 |
SignalHandlerMark shm(t); |
416 |
||
417 |
if(sig == SIGPIPE || sig == SIGXFSZ) { |
|
418 |
if (os::Solaris::chained_handler(sig, info, ucVoid)) { |
|
419 |
return true; |
|
420 |
} else { |
|
37430
fd743dadef12
8151939: VM_Version_init() print buffer is too small
coleenp
parents:
35201
diff
changeset
|
421 |
// Ignoring SIGPIPE/SIGXFSZ - see bugs 4229104 or 6499219 |
1 | 422 |
return true; |
423 |
} |
|
424 |
} |
|
425 |
||
426 |
JavaThread* thread = NULL; |
|
427 |
VMThread* vmthread = NULL; |
|
428 |
||
429 |
if (os::Solaris::signal_handlers_are_installed) { |
|
430 |
if (t != NULL ){ |
|
431 |
if(t->is_Java_thread()) { |
|
432 |
thread = (JavaThread*)t; |
|
433 |
} |
|
434 |
else if(t->is_VM_thread()){ |
|
435 |
vmthread = (VMThread *)t; |
|
436 |
} |
|
437 |
} |
|
438 |
} |
|
439 |
||
46337
307e52ec20cd
8175817: Clean up Solaris signal code: SIGUSR2, SIGasync, SIGJVM1/2
dholmes
parents:
43450
diff
changeset
|
440 |
if (sig == ASYNC_SIGNAL) { |
18025 | 441 |
if(thread || vmthread){ |
442 |
OSThread::SR_handler(t, uc); |
|
1 | 443 |
return true; |
444 |
} else if (os::Solaris::chained_handler(sig, info, ucVoid)) { |
|
445 |
return true; |
|
446 |
} else { |
|
46337
307e52ec20cd
8175817: Clean up Solaris signal code: SIGUSR2, SIGasync, SIGJVM1/2
dholmes
parents:
43450
diff
changeset
|
447 |
// If ASYNC_SIGNAL not chained, and this is a non-vm and |
1 | 448 |
// non-java thread |
449 |
return true; |
|
450 |
} |
|
451 |
} |
|
452 |
||
453 |
if (info == NULL || info->si_code <= 0 || info->si_code == SI_NOINFO) { |
|
454 |
// can't decode this kind of signal |
|
455 |
info = NULL; |
|
456 |
} else { |
|
457 |
assert(sig == info->si_signo, "bad siginfo"); |
|
458 |
} |
|
459 |
||
460 |
// decide if this trap can be handled by a stub |
|
461 |
address stub = NULL; |
|
462 |
||
463 |
address pc = NULL; |
|
464 |
||
465 |
//%note os_trap_1 |
|
466 |
if (info != NULL && uc != NULL && thread != NULL) { |
|
467 |
// factor me: getPCfromContext |
|
468 |
pc = (address) uc->uc_mcontext.gregs[REG_PC]; |
|
469 |
||
18740 | 470 |
if (StubRoutines::is_safefetch_fault(pc)) { |
29573
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
26576
diff
changeset
|
471 |
os::Solaris::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc)); |
18740 | 472 |
return true; |
1 | 473 |
} |
474 |
||
475 |
// Handle ALL stack overflow variations here |
|
476 |
if (sig == SIGSEGV && info->si_code == SEGV_ACCERR) { |
|
477 |
address addr = (address) info->si_addr; |
|
35201
996db89f378e
8139864: Improve handling of stack protection zones.
goetz
parents:
35077
diff
changeset
|
478 |
if (thread->in_stack_yellow_reserved_zone(addr)) { |
1 | 479 |
if (thread->thread_state() == _thread_in_Java) { |
35071
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
480 |
if (thread->in_stack_reserved_zone(addr)) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
481 |
frame fr; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
482 |
if (os::Solaris::get_frame_at_stack_banging_point(thread, uc, &fr)) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
483 |
assert(fr.is_java_frame(), "Must be Java frame"); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
484 |
frame activation = SharedRuntime::look_for_reserved_stack_annotated_method(thread, fr); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
485 |
if (activation.sp() != NULL) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
486 |
thread->disable_stack_reserved_zone(); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
487 |
if (activation.is_interpreted_frame()) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
488 |
thread->set_reserved_stack_activation((address)( |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
489 |
activation.fp() + frame::interpreter_frame_initial_sp_offset)); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
490 |
} else { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
491 |
thread->set_reserved_stack_activation((address)activation.unextended_sp()); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
492 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
493 |
return true; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
494 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
495 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34667
diff
changeset
|
496 |
} |
1 | 497 |
// Throw a stack overflow exception. Guard pages will be reenabled |
498 |
// while unwinding the stack. |
|
35201
996db89f378e
8139864: Improve handling of stack protection zones.
goetz
parents:
35077
diff
changeset
|
499 |
thread->disable_stack_yellow_reserved_zone(); |
1 | 500 |
stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::STACK_OVERFLOW); |
501 |
} else { |
|
502 |
// Thread was in the vm or native code. Return and try to finish. |
|
35201
996db89f378e
8139864: Improve handling of stack protection zones.
goetz
parents:
35077
diff
changeset
|
503 |
thread->disable_stack_yellow_reserved_zone(); |
1 | 504 |
return true; |
505 |
} |
|
506 |
} else if (thread->in_stack_red_zone(addr)) { |
|
507 |
// Fatal red zone violation. Disable the guard pages and fall through |
|
508 |
// to handle_unexpected_exception way down below. |
|
509 |
thread->disable_stack_red_zone(); |
|
510 |
tty->print_raw_cr("An irrecoverable stack overflow has occurred."); |
|
511 |
} |
|
512 |
} |
|
513 |
||
23487
0f7e268cd9e3
8037226: compiler/7196199/Test7196199.java fails on 32-bit linux with MaxVectorSize > 16
kvn
parents:
22745
diff
changeset
|
514 |
if ((sig == SIGSEGV) && VM_Version::is_cpuinfo_segv_addr(pc)) { |
0f7e268cd9e3
8037226: compiler/7196199/Test7196199.java fails on 32-bit linux with MaxVectorSize > 16
kvn
parents:
22745
diff
changeset
|
515 |
// Verify that OS save/restore AVX registers. |
0f7e268cd9e3
8037226: compiler/7196199/Test7196199.java fails on 32-bit linux with MaxVectorSize > 16
kvn
parents:
22745
diff
changeset
|
516 |
stub = VM_Version::cpuinfo_cont_addr(); |
0f7e268cd9e3
8037226: compiler/7196199/Test7196199.java fails on 32-bit linux with MaxVectorSize > 16
kvn
parents:
22745
diff
changeset
|
517 |
} |
0f7e268cd9e3
8037226: compiler/7196199/Test7196199.java fails on 32-bit linux with MaxVectorSize > 16
kvn
parents:
22745
diff
changeset
|
518 |
|
55490
3f3dc00a69a5
8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents:
53605
diff
changeset
|
519 |
if (thread->thread_state() == _thread_in_vm || |
3f3dc00a69a5
8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents:
53605
diff
changeset
|
520 |
thread->thread_state() == _thread_in_native) { |
1 | 521 |
if (sig == SIGBUS && info->si_code == BUS_OBJERR && thread->doing_unsafe_access()) { |
38209
b2a58604e046
8156088: Reintegrate 8153892: Handle unsafe access error directly in signal handler instead of going through a stub
mikael
parents:
38190
diff
changeset
|
522 |
address next_pc = Assembler::locate_next_instruction(pc); |
55490
3f3dc00a69a5
8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents:
53605
diff
changeset
|
523 |
if (UnsafeCopyMemory::contains_pc(pc)) { |
3f3dc00a69a5
8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents:
53605
diff
changeset
|
524 |
next_pc = UnsafeCopyMemory::page_error_continue_pc(pc); |
3f3dc00a69a5
8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents:
53605
diff
changeset
|
525 |
} |
38209
b2a58604e046
8156088: Reintegrate 8153892: Handle unsafe access error directly in signal handler instead of going through a stub
mikael
parents:
38190
diff
changeset
|
526 |
stub = SharedRuntime::handle_unsafe_access(thread, next_pc); |
1 | 527 |
} |
528 |
} |
|
529 |
||
530 |
if (thread->thread_state() == _thread_in_Java) { |
|
531 |
// Support Safepoint Polling |
|
532 |
if ( sig == SIGSEGV && os::is_poll_address((address)info->si_addr)) { |
|
533 |
stub = SharedRuntime::get_poll_stub(pc); |
|
534 |
} |
|
535 |
else if (sig == SIGBUS && info->si_code == BUS_OBJERR) { |
|
536 |
// BugId 4454115: A read from a MappedByteBuffer can fault |
|
537 |
// here if the underlying file has been truncated. |
|
538 |
// Do not crash the VM in such a case. |
|
539 |
CodeBlob* cb = CodeCache::find_blob_unsafe(pc); |
|
22745 | 540 |
if (cb != NULL) { |
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
37430
diff
changeset
|
541 |
CompiledMethod* nm = cb->as_compiled_method_or_null(); |
55490
3f3dc00a69a5
8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents:
53605
diff
changeset
|
542 |
bool is_unsafe_arraycopy = thread->doing_unsafe_access() && UnsafeCopyMemory::contains_pc(pc); |
57822
df3397f95387
8229254: solaris_x64 build fails after JDK-8191278
bulasevich
parents:
55490
diff
changeset
|
543 |
if ((nm != NULL && nm->has_unsafe_access()) || is_unsafe_arraycopy) { |
38209
b2a58604e046
8156088: Reintegrate 8153892: Handle unsafe access error directly in signal handler instead of going through a stub
mikael
parents:
38190
diff
changeset
|
544 |
address next_pc = Assembler::locate_next_instruction(pc); |
55490
3f3dc00a69a5
8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents:
53605
diff
changeset
|
545 |
if (is_unsafe_arraycopy) { |
3f3dc00a69a5
8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents:
53605
diff
changeset
|
546 |
next_pc = UnsafeCopyMemory::page_error_continue_pc(pc); |
3f3dc00a69a5
8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents:
53605
diff
changeset
|
547 |
} |
38209
b2a58604e046
8156088: Reintegrate 8153892: Handle unsafe access error directly in signal handler instead of going through a stub
mikael
parents:
38190
diff
changeset
|
548 |
stub = SharedRuntime::handle_unsafe_access(thread, next_pc); |
22745 | 549 |
} |
1 | 550 |
} |
551 |
} |
|
552 |
else |
|
553 |
if (sig == SIGFPE && info->si_code == FPE_INTDIV) { |
|
554 |
// integer divide by zero |
|
555 |
stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO); |
|
556 |
} |
|
557 |
#ifndef AMD64 |
|
558 |
else if (sig == SIGFPE && info->si_code == FPE_FLTDIV) { |
|
559 |
// floating-point divide by zero |
|
560 |
stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO); |
|
561 |
} |
|
562 |
else if (sig == SIGFPE && info->si_code == FPE_FLTINV) { |
|
563 |
// The encoding of D2I in i486.ad can cause an exception prior |
|
564 |
// to the fist instruction if there was an invalid operation |
|
565 |
// pending. We want to dismiss that exception. From the win_32 |
|
566 |
// side it also seems that if it really was the fist causing |
|
567 |
// the exception that we do the d2i by hand with different |
|
568 |
// rounding. Seems kind of weird. QQQ TODO |
|
569 |
// Note that we take the exception at the NEXT floating point instruction. |
|
570 |
if (pc[0] == 0xDB) { |
|
571 |
assert(pc[0] == 0xDB, "not a FIST opcode"); |
|
572 |
assert(pc[1] == 0x14, "not a FIST opcode"); |
|
573 |
assert(pc[2] == 0x24, "not a FIST opcode"); |
|
574 |
return true; |
|
575 |
} else { |
|
576 |
assert(pc[-3] == 0xDB, "not an flt invalid opcode"); |
|
577 |
assert(pc[-2] == 0x14, "not an flt invalid opcode"); |
|
578 |
assert(pc[-1] == 0x24, "not an flt invalid opcode"); |
|
579 |
} |
|
580 |
} |
|
581 |
else if (sig == SIGFPE ) { |
|
582 |
tty->print_cr("caught SIGFPE, info 0x%x.", info->si_code); |
|
583 |
} |
|
584 |
#endif // !AMD64 |
|
585 |
||
586 |
// QQQ It doesn't seem that we need to do this on x86 because we should be able |
|
587 |
// to return properly from the handler without this extra stuff on the back side. |
|
588 |
||
52462
4ad404da0088
8213199: GC abstraction for Assembler::needs_explicit_null_check()
rkennke
parents:
52460
diff
changeset
|
589 |
else if (sig == SIGSEGV && info->si_code > 0 && |
4ad404da0088
8213199: GC abstraction for Assembler::needs_explicit_null_check()
rkennke
parents:
52460
diff
changeset
|
590 |
MacroAssembler::uses_implicit_null_check(info->si_addr)) { |
1 | 591 |
// Determination of interpreter/vtable stub/compiled code null exception |
592 |
stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL); |
|
593 |
} |
|
594 |
} |
|
595 |
||
596 |
// jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks in |
|
597 |
// and the heap gets shrunk before the field access. |
|
598 |
if ((sig == SIGSEGV) || (sig == SIGBUS)) { |
|
599 |
address addr = JNI_FastGetField::find_slowcase_pc(pc); |
|
600 |
if (addr != (address)-1) { |
|
601 |
stub = addr; |
|
602 |
} |
|
603 |
} |
|
604 |
} |
|
605 |
||
606 |
// Execution protection violation |
|
607 |
// |
|
608 |
// Preventative code for future versions of Solaris which may |
|
609 |
// enable execution protection when running the 32-bit VM on AMD64. |
|
610 |
// |
|
611 |
// This should be kept as the last step in the triage. We don't |
|
612 |
// have a dedicated trap number for a no-execute fault, so be |
|
613 |
// conservative and allow other handlers the first shot. |
|
614 |
// |
|
615 |
// Note: We don't test that info->si_code == SEGV_ACCERR here. |
|
616 |
// this si_code is so generic that it is almost meaningless; and |
|
617 |
// the si_code for this condition may change in the future. |
|
618 |
// Furthermore, a false-positive should be harmless. |
|
619 |
if (UnguardOnExecutionViolation > 0 && |
|
620 |
(sig == SIGSEGV || sig == SIGBUS) && |
|
621 |
uc->uc_mcontext.gregs[TRAPNO] == T_PGFLT) { // page fault |
|
622 |
int page_size = os::vm_page_size(); |
|
623 |
address addr = (address) info->si_addr; |
|
624 |
address pc = (address) uc->uc_mcontext.gregs[REG_PC]; |
|
625 |
// Make sure the pc and the faulting address are sane. |
|
626 |
// |
|
627 |
// If an instruction spans a page boundary, and the page containing |
|
628 |
// the beginning of the instruction is executable but the following |
|
629 |
// page is not, the pc and the faulting address might be slightly |
|
630 |
// different - we still want to unguard the 2nd page in this case. |
|
631 |
// |
|
632 |
// 15 bytes seems to be a (very) safe value for max instruction size. |
|
633 |
bool pc_is_near_addr = |
|
634 |
(pointer_delta((void*) addr, (void*) pc, sizeof(char)) < 15); |
|
635 |
bool instr_spans_page_boundary = |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
636 |
(align_down((intptr_t) pc ^ (intptr_t) addr, |
1 | 637 |
(intptr_t) page_size) > 0); |
638 |
||
639 |
if (pc == addr || (pc_is_near_addr && instr_spans_page_boundary)) { |
|
640 |
static volatile address last_addr = |
|
641 |
(address) os::non_memory_address_word(); |
|
642 |
||
643 |
// In conservative mode, don't unguard unless the address is in the VM |
|
644 |
if (addr != last_addr && |
|
645 |
(UnguardOnExecutionViolation > 1 || os::address_is_in_vm(addr))) { |
|
646 |
||
1664
fc9ed50498fb
6727377: VM stack guard pages on Windows should PAGE_READWRITE not PAGE_EXECUTE_READWRITE
coleenp
parents:
1659
diff
changeset
|
647 |
// Make memory rwx and retry |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
648 |
address page_start = align_down(addr, page_size); |
1664
fc9ed50498fb
6727377: VM stack guard pages on Windows should PAGE_READWRITE not PAGE_EXECUTE_READWRITE
coleenp
parents:
1659
diff
changeset
|
649 |
bool res = os::protect_memory((char*) page_start, page_size, |
fc9ed50498fb
6727377: VM stack guard pages on Windows should PAGE_READWRITE not PAGE_EXECUTE_READWRITE
coleenp
parents:
1659
diff
changeset
|
650 |
os::MEM_PROT_RWX); |
1 | 651 |
|
37430
fd743dadef12
8151939: VM_Version_init() print buffer is too small
coleenp
parents:
35201
diff
changeset
|
652 |
log_debug(os)("Execution protection violation " |
fd743dadef12
8151939: VM_Version_init() print buffer is too small
coleenp
parents:
35201
diff
changeset
|
653 |
"at " INTPTR_FORMAT |
fd743dadef12
8151939: VM_Version_init() print buffer is too small
coleenp
parents:
35201
diff
changeset
|
654 |
", unguarding " INTPTR_FORMAT ": %s, errno=%d", p2i(addr), |
fd743dadef12
8151939: VM_Version_init() print buffer is too small
coleenp
parents:
35201
diff
changeset
|
655 |
p2i(page_start), (res ? "success" : "failed"), errno); |
1 | 656 |
stub = pc; |
657 |
||
658 |
// Set last_addr so if we fault again at the same address, we don't end |
|
659 |
// up in an endless loop. |
|
660 |
// |
|
661 |
// There are two potential complications here. Two threads trapping at |
|
662 |
// the same address at the same time could cause one of the threads to |
|
663 |
// think it already unguarded, and abort the VM. Likely very rare. |
|
664 |
// |
|
665 |
// The other race involves two threads alternately trapping at |
|
666 |
// different addresses and failing to unguard the page, resulting in |
|
667 |
// an endless loop. This condition is probably even more unlikely than |
|
668 |
// the first. |
|
669 |
// |
|
670 |
// Although both cases could be avoided by using locks or thread local |
|
671 |
// last_addr, these solutions are unnecessary complication: this |
|
672 |
// handler is a best-effort safety net, not a complete solution. It is |
|
673 |
// disabled by default and should only be used as a workaround in case |
|
674 |
// we missed any no-execute-unsafe VM code. |
|
675 |
||
676 |
last_addr = addr; |
|
677 |
} |
|
678 |
} |
|
679 |
} |
|
680 |
||
681 |
if (stub != NULL) { |
|
682 |
// save all thread context in case we need to restore it |
|
683 |
||
684 |
if (thread != NULL) thread->set_saved_exception_pc(pc); |
|
685 |
// 12/02/99: On Sparc it appears that the full context is also saved |
|
686 |
// but as yet, no one looks at or restores that saved context |
|
29573
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
26576
diff
changeset
|
687 |
os::Solaris::ucontext_set_pc(uc, stub); |
1 | 688 |
return true; |
689 |
} |
|
690 |
||
691 |
// signal-chaining |
|
692 |
if (os::Solaris::chained_handler(sig, info, ucVoid)) { |
|
693 |
return true; |
|
694 |
} |
|
695 |
||
696 |
if (!abort_if_unrecognized) { |
|
697 |
// caller wants another chance, so give it to him |
|
698 |
return false; |
|
699 |
} |
|
700 |
||
701 |
if (!os::Solaris::libjsig_is_loaded) { |
|
702 |
struct sigaction oldAct; |
|
703 |
sigaction(sig, (struct sigaction *)0, &oldAct); |
|
704 |
if (oldAct.sa_sigaction != signalHandler) { |
|
705 |
void* sighand = oldAct.sa_sigaction ? CAST_FROM_FN_PTR(void*, oldAct.sa_sigaction) |
|
706 |
: CAST_FROM_FN_PTR(void*, oldAct.sa_handler); |
|
2131 | 707 |
warning("Unexpected Signal %d occurred under user-defined signal handler %#lx", sig, (long)sighand); |
1 | 708 |
} |
709 |
} |
|
710 |
||
711 |
if (pc == NULL && uc != NULL) { |
|
712 |
pc = (address) uc->uc_mcontext.gregs[REG_PC]; |
|
713 |
} |
|
714 |
||
715 |
// unmask current signal |
|
716 |
sigset_t newset; |
|
717 |
sigemptyset(&newset); |
|
718 |
sigaddset(&newset, sig); |
|
719 |
sigprocmask(SIG_UNBLOCK, &newset, NULL); |
|
720 |
||
7719
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7405
diff
changeset
|
721 |
// Determine which sort of error to throw. Out of swap may signal |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7405
diff
changeset
|
722 |
// on the thread stack, which could get a mapping error when touched. |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7405
diff
changeset
|
723 |
address addr = (address) info->si_addr; |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7405
diff
changeset
|
724 |
if (sig == SIGBUS && info->si_code == BUS_OBJERR && info->si_errno == ENOMEM) { |
17087
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
14633
diff
changeset
|
725 |
vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "Out of swap space to map in thread stack."); |
7719
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7405
diff
changeset
|
726 |
} |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7405
diff
changeset
|
727 |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
29573
diff
changeset
|
728 |
VMError::report_and_die(t, sig, pc, info, ucVoid); |
1 | 729 |
|
730 |
ShouldNotReachHere(); |
|
22745 | 731 |
return false; |
1 | 732 |
} |
733 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
734 |
void os::print_context(outputStream *st, const void *context) { |
1 | 735 |
if (context == NULL) return; |
736 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
737 |
const ucontext_t *uc = (const ucontext_t*)context; |
1 | 738 |
st->print_cr("Registers:"); |
739 |
#ifdef AMD64 |
|
740 |
st->print( "RAX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RAX]); |
|
741 |
st->print(", RBX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RBX]); |
|
742 |
st->print(", RCX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RCX]); |
|
743 |
st->print(", RDX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RDX]); |
|
744 |
st->cr(); |
|
745 |
st->print( "RSP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RSP]); |
|
746 |
st->print(", RBP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RBP]); |
|
747 |
st->print(", RSI=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RSI]); |
|
748 |
st->print(", RDI=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RDI]); |
|
749 |
st->cr(); |
|
7108 | 750 |
st->print( "R8 =" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R8]); |
751 |
st->print(", R9 =" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R9]); |
|
1 | 752 |
st->print(", R10=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R10]); |
753 |
st->print(", R11=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R11]); |
|
4891 | 754 |
st->cr(); |
755 |
st->print( "R12=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R12]); |
|
1 | 756 |
st->print(", R13=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R13]); |
757 |
st->print(", R14=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R14]); |
|
758 |
st->print(", R15=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R15]); |
|
759 |
st->cr(); |
|
760 |
st->print( "RIP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RIP]); |
|
761 |
st->print(", RFLAGS=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RFL]); |
|
762 |
#else |
|
763 |
st->print( "EAX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[EAX]); |
|
764 |
st->print(", EBX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[EBX]); |
|
765 |
st->print(", ECX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[ECX]); |
|
766 |
st->print(", EDX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[EDX]); |
|
767 |
st->cr(); |
|
768 |
st->print( "ESP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[UESP]); |
|
769 |
st->print(", EBP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[EBP]); |
|
770 |
st->print(", ESI=" INTPTR_FORMAT, uc->uc_mcontext.gregs[ESI]); |
|
771 |
st->print(", EDI=" INTPTR_FORMAT, uc->uc_mcontext.gregs[EDI]); |
|
772 |
st->cr(); |
|
773 |
st->print( "EIP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[EIP]); |
|
774 |
st->print(", EFLAGS=" INTPTR_FORMAT, uc->uc_mcontext.gregs[EFL]); |
|
775 |
#endif // AMD64 |
|
776 |
st->cr(); |
|
777 |
st->cr(); |
|
778 |
||
779 |
intptr_t *sp = (intptr_t *)os::Solaris::ucontext_get_sp(uc); |
|
780 |
st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp); |
|
781 |
print_hex_dump(st, (address)sp, (address)(sp + 8*sizeof(intptr_t)), sizeof(intptr_t)); |
|
782 |
st->cr(); |
|
783 |
||
784 |
// Note: it may be unsafe to inspect memory near pc. For example, pc may |
|
785 |
// point to garbage if entry point in an nmethod is corrupted. Leave |
|
786 |
// this at the end, and hope for the best. |
|
787 |
ExtendedPC epc = os::Solaris::ucontext_get_ExtendedPC(uc); |
|
788 |
address pc = epc.pc(); |
|
53605
853c68ff2ed7
8217879: hs_err should print more instructions in hex dump
shade
parents:
53238
diff
changeset
|
789 |
print_instructions(st, pc, sizeof(char)); |
853c68ff2ed7
8217879: hs_err should print more instructions in hex dump
shade
parents:
53238
diff
changeset
|
790 |
st->cr(); |
7108 | 791 |
} |
792 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
793 |
void os::print_register_info(outputStream *st, const void *context) { |
7108 | 794 |
if (context == NULL) return; |
795 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35071
diff
changeset
|
796 |
const ucontext_t *uc = (const ucontext_t*)context; |
7108 | 797 |
|
798 |
st->print_cr("Register to memory mapping:"); |
|
799 |
st->cr(); |
|
800 |
||
801 |
// this is horrendously verbose but the layout of the registers in the |
|
802 |
// context does not match how we defined our abstract Register set, so |
|
803 |
// we can't just iterate through the gregs area |
|
804 |
||
805 |
// this is only for the "general purpose" registers |
|
806 |
||
807 |
#ifdef AMD64 |
|
808 |
st->print("RAX="); print_location(st, uc->uc_mcontext.gregs[REG_RAX]); |
|
809 |
st->print("RBX="); print_location(st, uc->uc_mcontext.gregs[REG_RBX]); |
|
810 |
st->print("RCX="); print_location(st, uc->uc_mcontext.gregs[REG_RCX]); |
|
811 |
st->print("RDX="); print_location(st, uc->uc_mcontext.gregs[REG_RDX]); |
|
812 |
st->print("RSP="); print_location(st, uc->uc_mcontext.gregs[REG_RSP]); |
|
813 |
st->print("RBP="); print_location(st, uc->uc_mcontext.gregs[REG_RBP]); |
|
814 |
st->print("RSI="); print_location(st, uc->uc_mcontext.gregs[REG_RSI]); |
|
815 |
st->print("RDI="); print_location(st, uc->uc_mcontext.gregs[REG_RDI]); |
|
816 |
st->print("R8 ="); print_location(st, uc->uc_mcontext.gregs[REG_R8]); |
|
817 |
st->print("R9 ="); print_location(st, uc->uc_mcontext.gregs[REG_R9]); |
|
818 |
st->print("R10="); print_location(st, uc->uc_mcontext.gregs[REG_R10]); |
|
819 |
st->print("R11="); print_location(st, uc->uc_mcontext.gregs[REG_R11]); |
|
820 |
st->print("R12="); print_location(st, uc->uc_mcontext.gregs[REG_R12]); |
|
821 |
st->print("R13="); print_location(st, uc->uc_mcontext.gregs[REG_R13]); |
|
822 |
st->print("R14="); print_location(st, uc->uc_mcontext.gregs[REG_R14]); |
|
823 |
st->print("R15="); print_location(st, uc->uc_mcontext.gregs[REG_R15]); |
|
824 |
#else |
|
825 |
st->print("EAX="); print_location(st, uc->uc_mcontext.gregs[EAX]); |
|
826 |
st->print("EBX="); print_location(st, uc->uc_mcontext.gregs[EBX]); |
|
827 |
st->print("ECX="); print_location(st, uc->uc_mcontext.gregs[ECX]); |
|
828 |
st->print("EDX="); print_location(st, uc->uc_mcontext.gregs[EDX]); |
|
829 |
st->print("ESP="); print_location(st, uc->uc_mcontext.gregs[UESP]); |
|
830 |
st->print("EBP="); print_location(st, uc->uc_mcontext.gregs[EBP]); |
|
831 |
st->print("ESI="); print_location(st, uc->uc_mcontext.gregs[ESI]); |
|
832 |
st->print("EDI="); print_location(st, uc->uc_mcontext.gregs[EDI]); |
|
833 |
#endif |
|
834 |
||
835 |
st->cr(); |
|
1 | 836 |
} |
837 |
||
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5904
diff
changeset
|
838 |
|
1 | 839 |
#ifdef AMD64 |
840 |
void os::Solaris::init_thread_fpu_state(void) { |
|
841 |
// Nothing to do |
|
842 |
} |
|
843 |
#else |
|
844 |
// From solaris_i486.s |
|
845 |
extern "C" void fixcw(); |
|
846 |
||
847 |
void os::Solaris::init_thread_fpu_state(void) { |
|
848 |
// Set fpu to 53 bit precision. This happens too early to use a stub. |
|
849 |
fixcw(); |
|
850 |
} |
|
851 |
||
852 |
// These routines are the initial value of atomic_xchg_entry(), |
|
853 |
// atomic_cmpxchg_entry(), atomic_inc_entry() and fence_entry() |
|
854 |
// until initialization is complete. |
|
855 |
// TODO - replace with .il implementation when compiler supports it. |
|
856 |
||
48468 | 857 |
typedef int32_t xchg_func_t (int32_t, volatile int32_t*); |
858 |
typedef int32_t cmpxchg_func_t (int32_t, volatile int32_t*, int32_t); |
|
859 |
typedef int64_t cmpxchg_long_func_t(int64_t, volatile int64_t*, int64_t); |
|
860 |
typedef int32_t add_func_t (int32_t, volatile int32_t*); |
|
1 | 861 |
|
48468 | 862 |
int32_t os::atomic_xchg_bootstrap(int32_t exchange_value, volatile int32_t* dest) { |
1 | 863 |
// try to use the stub: |
864 |
xchg_func_t* func = CAST_TO_FN_PTR(xchg_func_t*, StubRoutines::atomic_xchg_entry()); |
|
865 |
||
866 |
if (func != NULL) { |
|
867 |
os::atomic_xchg_func = func; |
|
868 |
return (*func)(exchange_value, dest); |
|
869 |
} |
|
870 |
assert(Threads::number_of_threads() == 0, "for bootstrap only"); |
|
871 |
||
48468 | 872 |
int32_t old_value = *dest; |
1 | 873 |
*dest = exchange_value; |
874 |
return old_value; |
|
875 |
} |
|
876 |
||
48468 | 877 |
int32_t os::atomic_cmpxchg_bootstrap(int32_t exchange_value, volatile int32_t* dest, int32_t compare_value) { |
1 | 878 |
// try to use the stub: |
879 |
cmpxchg_func_t* func = CAST_TO_FN_PTR(cmpxchg_func_t*, StubRoutines::atomic_cmpxchg_entry()); |
|
880 |
||
881 |
if (func != NULL) { |
|
882 |
os::atomic_cmpxchg_func = func; |
|
883 |
return (*func)(exchange_value, dest, compare_value); |
|
884 |
} |
|
885 |
assert(Threads::number_of_threads() == 0, "for bootstrap only"); |
|
886 |
||
48468 | 887 |
int32_t old_value = *dest; |
1 | 888 |
if (old_value == compare_value) |
889 |
*dest = exchange_value; |
|
890 |
return old_value; |
|
891 |
} |
|
892 |
||
48468 | 893 |
int64_t os::atomic_cmpxchg_long_bootstrap(int64_t exchange_value, volatile int64_t* dest, int64_t compare_value) { |
1 | 894 |
// try to use the stub: |
895 |
cmpxchg_long_func_t* func = CAST_TO_FN_PTR(cmpxchg_long_func_t*, StubRoutines::atomic_cmpxchg_long_entry()); |
|
896 |
||
897 |
if (func != NULL) { |
|
898 |
os::atomic_cmpxchg_long_func = func; |
|
899 |
return (*func)(exchange_value, dest, compare_value); |
|
900 |
} |
|
901 |
assert(Threads::number_of_threads() == 0, "for bootstrap only"); |
|
902 |
||
48468 | 903 |
int64_t old_value = *dest; |
1 | 904 |
if (old_value == compare_value) |
905 |
*dest = exchange_value; |
|
906 |
return old_value; |
|
907 |
} |
|
908 |
||
48468 | 909 |
int32_t os::atomic_add_bootstrap(int32_t add_value, volatile int32_t* dest) { |
1 | 910 |
// try to use the stub: |
911 |
add_func_t* func = CAST_TO_FN_PTR(add_func_t*, StubRoutines::atomic_add_entry()); |
|
912 |
||
913 |
if (func != NULL) { |
|
914 |
os::atomic_add_func = func; |
|
915 |
return (*func)(add_value, dest); |
|
916 |
} |
|
917 |
assert(Threads::number_of_threads() == 0, "for bootstrap only"); |
|
918 |
||
919 |
return (*dest) += add_value; |
|
920 |
} |
|
921 |
||
922 |
xchg_func_t* os::atomic_xchg_func = os::atomic_xchg_bootstrap; |
|
923 |
cmpxchg_func_t* os::atomic_cmpxchg_func = os::atomic_cmpxchg_bootstrap; |
|
924 |
cmpxchg_long_func_t* os::atomic_cmpxchg_long_func = os::atomic_cmpxchg_long_bootstrap; |
|
925 |
add_func_t* os::atomic_add_func = os::atomic_add_bootstrap; |
|
926 |
||
5904
51e9775a3095
6939019: Source code adjustments for parfait compilation of hotspot
zgu
parents:
5547
diff
changeset
|
927 |
extern "C" void _solaris_raw_setup_fpu(address ptr); |
1 | 928 |
void os::setup_fpu() { |
929 |
address fpu_cntrl = StubRoutines::addr_fpu_cntrl_wrd_std(); |
|
930 |
_solaris_raw_setup_fpu(fpu_cntrl); |
|
931 |
} |
|
932 |
#endif // AMD64 |
|
11961
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
933 |
|
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
934 |
#ifndef PRODUCT |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
935 |
void os::verify_stack_alignment() { |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
936 |
#ifdef AMD64 |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
937 |
assert(((intptr_t)os::current_stack_pointer() & (StackAlignmentInBytes-1)) == 0, "incorrect stack alignment"); |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
938 |
#endif |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
939 |
} |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
940 |
#endif |
26576
a9429d24d429
8050147: StoreLoad barrier interferes with stack usages
shade
parents:
25351
diff
changeset
|
941 |
|
a9429d24d429
8050147: StoreLoad barrier interferes with stack usages
shade
parents:
25351
diff
changeset
|
942 |
int os::extra_bang_size_in_bytes() { |
a9429d24d429
8050147: StoreLoad barrier interferes with stack usages
shade
parents:
25351
diff
changeset
|
943 |
// JDK-8050147 requires the full cache line bang for x86. |
a9429d24d429
8050147: StoreLoad barrier interferes with stack usages
shade
parents:
25351
diff
changeset
|
944 |
return VM_Version::L1_line_size(); |
a9429d24d429
8050147: StoreLoad barrier interferes with stack usages
shade
parents:
25351
diff
changeset
|
945 |
} |