author | coleenp |
Fri, 16 Mar 2018 09:12:13 -0400 | |
changeset 49449 | ef5d5d343e2a |
parent 48019 | 827e4ac05579 |
child 52302 | 912b79d983d9 |
permissions | -rw-r--r-- |
4013 | 1 |
/* |
36181 | 2 |
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. |
4647
51451c7e9103
6917698: os::is_allocatable Zero fix for 32-bit platforms
twisti
parents:
4013
diff
changeset
|
3 |
* Copyright 2007, 2008, 2009, 2010 Red Hat, Inc. |
4013 | 4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5 |
* |
|
6 |
* This code is free software; you can redistribute it and/or modify it |
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
|
8 |
* published by the Free Software Foundation. |
|
9 |
* |
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
14 |
* accompanied this code). |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License version |
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
19 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5435
diff
changeset
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5435
diff
changeset
|
21 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5435
diff
changeset
|
22 |
* questions. |
4013 | 23 |
* |
24 |
*/ |
|
25 |
||
7397 | 26 |
// no precompiled headers |
47765
b7c7428eaab9
8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents:
47216
diff
changeset
|
27 |
#include "jvm.h" |
7397 | 28 |
#include "assembler_zero.inline.hpp" |
29 |
#include "classfile/classLoader.hpp" |
|
30 |
#include "classfile/systemDictionary.hpp" |
|
31 |
#include "classfile/vmSymbols.hpp" |
|
32 |
#include "code/icBuffer.hpp" |
|
33 |
#include "code/vtableStubs.hpp" |
|
34 |
#include "interpreter/interpreter.hpp" |
|
35 |
#include "memory/allocation.inline.hpp" |
|
36 |
#include "nativeInst_zero.hpp" |
|
37 |
#include "os_share_linux.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:
48019
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" |
|
4013 | 55 |
|
30129
351788433103
8076185: Provide SafeFetchX implementation for zero
dholmes
parents:
29573
diff
changeset
|
56 |
// See stubGenerator_zero.cpp |
351788433103
8076185: Provide SafeFetchX implementation for zero
dholmes
parents:
29573
diff
changeset
|
57 |
#include <setjmp.h> |
351788433103
8076185: Provide SafeFetchX implementation for zero
dholmes
parents:
29573
diff
changeset
|
58 |
extern sigjmp_buf* get_jmp_buf_for_continuation(); |
351788433103
8076185: Provide SafeFetchX implementation for zero
dholmes
parents:
29573
diff
changeset
|
59 |
|
4013 | 60 |
address os::current_stack_pointer() { |
31128
024d19662029
8087120: [GCC5] java.lang.StackOverflowError on Zero JVM initialization on non x86 platforms.
sgehwolf
parents:
30129
diff
changeset
|
61 |
// return the address of the current function |
024d19662029
8087120: [GCC5] java.lang.StackOverflowError on Zero JVM initialization on non x86 platforms.
sgehwolf
parents:
30129
diff
changeset
|
62 |
return (address)__builtin_frame_address(0); |
4013 | 63 |
} |
64 |
||
65 |
frame os::get_sender_for_C_frame(frame* fr) { |
|
66 |
ShouldNotCallThis(); |
|
36181 | 67 |
return frame(NULL, NULL); // silence compile warning. |
4013 | 68 |
} |
69 |
||
70 |
frame os::current_frame() { |
|
71 |
// The only thing that calls this is the stack printing code in |
|
72 |
// VMError::report: |
|
73 |
// - Step 110 (printing stack bounds) uses the sp in the frame |
|
74 |
// to determine the amount of free space on the stack. We |
|
75 |
// set the sp to a close approximation of the real value in |
|
76 |
// order to allow this step to complete. |
|
77 |
// - Step 120 (printing native stack) tries to walk the stack. |
|
78 |
// The frame we create has a NULL pc, which is ignored as an |
|
79 |
// invalid frame. |
|
80 |
frame dummy = frame(); |
|
81 |
dummy.set_sp((intptr_t *) current_stack_pointer()); |
|
82 |
return dummy; |
|
83 |
} |
|
84 |
||
85 |
char* os::non_memory_address_word() { |
|
86 |
// Must never look like an address returned by reserve_memory, |
|
87 |
// even in its subfields (as defined by the CPU immediate fields, |
|
88 |
// if the CPU splits constants across multiple instructions). |
|
89 |
#ifdef SPARC |
|
90 |
// On SPARC, 0 != %hi(any real address), because there is no |
|
91 |
// allocation in the first 1Kb of the virtual address space. |
|
92 |
return (char *) 0; |
|
93 |
#else |
|
94 |
// This is the value for x86; works pretty well for PPC too. |
|
95 |
return (char *) -1; |
|
96 |
#endif // SPARC |
|
97 |
} |
|
98 |
||
13859
7fe4578493fc
7190089: NMT ON: NMT failed assertion on thread's stack base address
zgu
parents:
11961
diff
changeset
|
99 |
void os::initialize_thread(Thread * thr){ |
4013 | 100 |
// Nothing to do. |
101 |
} |
|
102 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
34633
diff
changeset
|
103 |
address os::Linux::ucontext_get_pc(const ucontext_t* uc) { |
4013 | 104 |
ShouldNotCallThis(); |
36181 | 105 |
return NULL; // silence compile warnings |
4013 | 106 |
} |
107 |
||
29573
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
26576
diff
changeset
|
108 |
void os::Linux::ucontext_set_pc(ucontext_t * uc, address pc) { |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
26576
diff
changeset
|
109 |
ShouldNotCallThis(); |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
26576
diff
changeset
|
110 |
} |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
26576
diff
changeset
|
111 |
|
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
34633
diff
changeset
|
112 |
ExtendedPC os::fetch_frame_from_context(const void* ucVoid, |
4013 | 113 |
intptr_t** ret_sp, |
114 |
intptr_t** ret_fp) { |
|
115 |
ShouldNotCallThis(); |
|
36181 | 116 |
return NULL; // silence compile warnings |
4013 | 117 |
} |
118 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
34633
diff
changeset
|
119 |
frame os::fetch_frame_from_context(const void* ucVoid) { |
4013 | 120 |
ShouldNotCallThis(); |
36181 | 121 |
return frame(NULL, NULL); // silence compile warnings |
4013 | 122 |
} |
123 |
||
8106 | 124 |
extern "C" JNIEXPORT int |
4013 | 125 |
JVM_handle_linux_signal(int sig, |
126 |
siginfo_t* info, |
|
127 |
void* ucVoid, |
|
128 |
int abort_if_unrecognized) { |
|
129 |
ucontext_t* uc = (ucontext_t*) ucVoid; |
|
130 |
||
34633
2a6c7c7b30a7
8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents:
33105
diff
changeset
|
131 |
Thread* t = Thread::current_or_null_safe(); |
4013 | 132 |
|
133 |
SignalHandlerMark shm(t); |
|
134 |
||
30129
351788433103
8076185: Provide SafeFetchX implementation for zero
dholmes
parents:
29573
diff
changeset
|
135 |
// handle SafeFetch faults |
351788433103
8076185: Provide SafeFetchX implementation for zero
dholmes
parents:
29573
diff
changeset
|
136 |
if (sig == SIGSEGV || sig == SIGBUS) { |
351788433103
8076185: Provide SafeFetchX implementation for zero
dholmes
parents:
29573
diff
changeset
|
137 |
sigjmp_buf* const pjb = get_jmp_buf_for_continuation(); |
351788433103
8076185: Provide SafeFetchX implementation for zero
dholmes
parents:
29573
diff
changeset
|
138 |
if (pjb) { |
351788433103
8076185: Provide SafeFetchX implementation for zero
dholmes
parents:
29573
diff
changeset
|
139 |
siglongjmp(*pjb, 1); |
351788433103
8076185: Provide SafeFetchX implementation for zero
dholmes
parents:
29573
diff
changeset
|
140 |
} |
351788433103
8076185: Provide SafeFetchX implementation for zero
dholmes
parents:
29573
diff
changeset
|
141 |
} |
351788433103
8076185: Provide SafeFetchX implementation for zero
dholmes
parents:
29573
diff
changeset
|
142 |
|
4013 | 143 |
// Note: it's not uncommon that JNI code uses signal/sigset to |
144 |
// install then restore certain signal handler (e.g. to temporarily |
|
145 |
// block SIGPIPE, or have a SIGILL handler when detecting CPU |
|
146 |
// type). When that happens, JVM_handle_linux_signal() might be |
|
147 |
// invoked with junk info/ucVoid. To avoid unnecessary crash when |
|
148 |
// libjsig is not preloaded, try handle signals that do not require |
|
149 |
// siginfo/ucontext first. |
|
150 |
||
151 |
if (sig == SIGPIPE || sig == SIGXFSZ) { |
|
152 |
// allow chained handler to go first |
|
153 |
if (os::Linux::chained_handler(sig, info, ucVoid)) { |
|
154 |
return true; |
|
155 |
} else { |
|
37430
fd743dadef12
8151939: VM_Version_init() print buffer is too small
coleenp
parents:
36181
diff
changeset
|
156 |
// Ignoring SIGPIPE/SIGXFSZ - see bugs 4229104 or 6499219 |
4013 | 157 |
return true; |
158 |
} |
|
159 |
} |
|
160 |
||
161 |
JavaThread* thread = NULL; |
|
162 |
VMThread* vmthread = NULL; |
|
163 |
if (os::Linux::signal_handlers_are_installed) { |
|
164 |
if (t != NULL ){ |
|
165 |
if(t->is_Java_thread()) { |
|
166 |
thread = (JavaThread*)t; |
|
167 |
} |
|
168 |
else if(t->is_VM_thread()){ |
|
169 |
vmthread = (VMThread *)t; |
|
170 |
} |
|
171 |
} |
|
172 |
} |
|
173 |
||
174 |
if (info != NULL && thread != NULL) { |
|
175 |
// Handle ALL stack overflow variations here |
|
176 |
if (sig == SIGSEGV) { |
|
177 |
address addr = (address) info->si_addr; |
|
178 |
||
179 |
// check if fault address is within thread stack |
|
35201
996db89f378e
8139864: Improve handling of stack protection zones.
goetz
parents:
35077
diff
changeset
|
180 |
if (thread->on_local_stack(addr)) { |
4013 | 181 |
// stack overflow |
35201
996db89f378e
8139864: Improve handling of stack protection zones.
goetz
parents:
35077
diff
changeset
|
182 |
if (thread->in_stack_yellow_reserved_zone(addr)) { |
996db89f378e
8139864: Improve handling of stack protection zones.
goetz
parents:
35077
diff
changeset
|
183 |
thread->disable_stack_yellow_reserved_zone(); |
4013 | 184 |
ShouldNotCallThis(); |
185 |
} |
|
186 |
else if (thread->in_stack_red_zone(addr)) { |
|
187 |
thread->disable_stack_red_zone(); |
|
188 |
ShouldNotCallThis(); |
|
189 |
} |
|
190 |
else { |
|
191 |
// Accessing stack address below sp may cause SEGV if |
|
192 |
// current thread has MAP_GROWSDOWN stack. This should |
|
193 |
// only happen when current thread was created by user |
|
194 |
// code with MAP_GROWSDOWN flag and then attached to VM. |
|
195 |
// See notes in os_linux.cpp. |
|
196 |
if (thread->osthread()->expanding_stack() == 0) { |
|
197 |
thread->osthread()->set_expanding_stack(); |
|
198 |
if (os::Linux::manually_expand_stack(thread, addr)) { |
|
199 |
thread->osthread()->clear_expanding_stack(); |
|
200 |
return true; |
|
201 |
} |
|
202 |
thread->osthread()->clear_expanding_stack(); |
|
203 |
} |
|
204 |
else { |
|
205 |
fatal("recursive segv. expanding stack."); |
|
206 |
} |
|
207 |
} |
|
208 |
} |
|
209 |
} |
|
210 |
||
211 |
/*if (thread->thread_state() == _thread_in_Java) { |
|
212 |
ShouldNotCallThis(); |
|
213 |
} |
|
214 |
else*/ if (thread->thread_state() == _thread_in_vm && |
|
215 |
sig == SIGBUS && thread->doing_unsafe_access()) { |
|
216 |
ShouldNotCallThis(); |
|
217 |
} |
|
218 |
||
219 |
// jni_fast_Get<Primitive>Field can trap at certain pc's if a GC |
|
220 |
// kicks in and the heap gets shrunk before the field access. |
|
221 |
/*if (sig == SIGSEGV || sig == SIGBUS) { |
|
222 |
address addr = JNI_FastGetField::find_slowcase_pc(pc); |
|
223 |
if (addr != (address)-1) { |
|
224 |
stub = addr; |
|
225 |
} |
|
226 |
}*/ |
|
227 |
||
228 |
// Check to see if we caught the safepoint code in the process |
|
229 |
// of write protecting the memory serialization page. It write |
|
230 |
// enables the page immediately after protecting it so we can |
|
231 |
// just return to retry the write. |
|
232 |
if (sig == SIGSEGV && |
|
233 |
os::is_memory_serialize_page(thread, (address) info->si_addr)) { |
|
234 |
// Block current thread until permission is restored. |
|
235 |
os::block_on_serialize_page_trap(); |
|
236 |
return true; |
|
237 |
} |
|
238 |
} |
|
239 |
||
240 |
// signal-chaining |
|
241 |
if (os::Linux::chained_handler(sig, info, ucVoid)) { |
|
242 |
return true; |
|
243 |
} |
|
244 |
||
245 |
if (!abort_if_unrecognized) { |
|
246 |
// caller wants another chance, so give it to him |
|
247 |
return false; |
|
248 |
} |
|
249 |
||
250 |
#ifndef PRODUCT |
|
251 |
if (sig == SIGSEGV) { |
|
252 |
fatal("\n#" |
|
253 |
"\n# /--------------------\\" |
|
254 |
"\n# | segmentation fault |" |
|
255 |
"\n# \\---\\ /--------------/" |
|
256 |
"\n# /" |
|
257 |
"\n# [-] |\\_/| " |
|
258 |
"\n# (+)=C |o o|__ " |
|
259 |
"\n# | | =-*-=__\\ " |
|
260 |
"\n# OOO c_c_(___)"); |
|
261 |
} |
|
262 |
#endif // !PRODUCT |
|
263 |
||
264 |
char buf[64]; |
|
265 |
||
36181 | 266 |
sprintf(buf, "caught unhandled signal %d", sig); |
267 |
||
268 |
// Silence -Wformat-security warning for fatal() |
|
269 |
PRAGMA_DIAG_PUSH |
|
270 |
PRAGMA_FORMAT_NONLITERAL_IGNORED |
|
4013 | 271 |
fatal(buf); |
36181 | 272 |
PRAGMA_DIAG_POP |
273 |
return true; // silence compiler warnings |
|
4013 | 274 |
} |
275 |
||
276 |
void os::Linux::init_thread_fpu_state(void) { |
|
277 |
// Nothing to do |
|
278 |
} |
|
279 |
||
280 |
int os::Linux::get_fpu_control_word() { |
|
281 |
ShouldNotCallThis(); |
|
36181 | 282 |
return -1; // silence compile warnings |
4013 | 283 |
} |
284 |
||
285 |
void os::Linux::set_fpu_control_word(int fpu) { |
|
286 |
ShouldNotCallThis(); |
|
287 |
} |
|
288 |
||
289 |
bool os::is_allocatable(size_t bytes) { |
|
4647
51451c7e9103
6917698: os::is_allocatable Zero fix for 32-bit platforms
twisti
parents:
4013
diff
changeset
|
290 |
#ifdef _LP64 |
51451c7e9103
6917698: os::is_allocatable Zero fix for 32-bit platforms
twisti
parents:
4013
diff
changeset
|
291 |
return true; |
51451c7e9103
6917698: os::is_allocatable Zero fix for 32-bit platforms
twisti
parents:
4013
diff
changeset
|
292 |
#else |
51451c7e9103
6917698: os::is_allocatable Zero fix for 32-bit platforms
twisti
parents:
4013
diff
changeset
|
293 |
if (bytes < 2 * G) { |
51451c7e9103
6917698: os::is_allocatable Zero fix for 32-bit platforms
twisti
parents:
4013
diff
changeset
|
294 |
return true; |
51451c7e9103
6917698: os::is_allocatable Zero fix for 32-bit platforms
twisti
parents:
4013
diff
changeset
|
295 |
} |
51451c7e9103
6917698: os::is_allocatable Zero fix for 32-bit platforms
twisti
parents:
4013
diff
changeset
|
296 |
|
51451c7e9103
6917698: os::is_allocatable Zero fix for 32-bit platforms
twisti
parents:
4013
diff
changeset
|
297 |
char* addr = reserve_memory(bytes, NULL); |
51451c7e9103
6917698: os::is_allocatable Zero fix for 32-bit platforms
twisti
parents:
4013
diff
changeset
|
298 |
|
51451c7e9103
6917698: os::is_allocatable Zero fix for 32-bit platforms
twisti
parents:
4013
diff
changeset
|
299 |
if (addr != NULL) { |
51451c7e9103
6917698: os::is_allocatable Zero fix for 32-bit platforms
twisti
parents:
4013
diff
changeset
|
300 |
release_memory(addr, bytes); |
51451c7e9103
6917698: os::is_allocatable Zero fix for 32-bit platforms
twisti
parents:
4013
diff
changeset
|
301 |
} |
51451c7e9103
6917698: os::is_allocatable Zero fix for 32-bit platforms
twisti
parents:
4013
diff
changeset
|
302 |
|
51451c7e9103
6917698: os::is_allocatable Zero fix for 32-bit platforms
twisti
parents:
4013
diff
changeset
|
303 |
return addr != NULL; |
51451c7e9103
6917698: os::is_allocatable Zero fix for 32-bit platforms
twisti
parents:
4013
diff
changeset
|
304 |
#endif // _LP64 |
4013 | 305 |
} |
306 |
||
307 |
/////////////////////////////////////////////////////////////////////////////// |
|
308 |
// thread stack |
|
309 |
||
41070
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
40010
diff
changeset
|
310 |
size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K; |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
40010
diff
changeset
|
311 |
size_t os::Posix::_java_thread_min_stack_allowed = 64 * K; |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
40010
diff
changeset
|
312 |
size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K; |
4013 | 313 |
|
41070
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
40010
diff
changeset
|
314 |
size_t os::Posix::default_stack_size(os::ThreadType thr_type) { |
4013 | 315 |
#ifdef _LP64 |
316 |
size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M); |
|
317 |
#else |
|
318 |
size_t s = (thr_type == os::compiler_thread ? 2 * M : 512 * K); |
|
319 |
#endif // _LP64 |
|
320 |
return s; |
|
321 |
} |
|
322 |
||
323 |
static void current_stack_region(address *bottom, size_t *size) { |
|
324 |
pthread_attr_t attr; |
|
325 |
int res = pthread_getattr_np(pthread_self(), &attr); |
|
326 |
if (res != 0) { |
|
327 |
if (res == ENOMEM) { |
|
17087
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
14583
diff
changeset
|
328 |
vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "pthread_getattr_np"); |
4013 | 329 |
} |
330 |
else { |
|
42905 | 331 |
fatal("pthread_getattr_np failed with error = %d", res); |
4013 | 332 |
} |
333 |
} |
|
334 |
||
335 |
address stack_bottom; |
|
336 |
size_t stack_bytes; |
|
337 |
res = pthread_attr_getstack(&attr, (void **) &stack_bottom, &stack_bytes); |
|
338 |
if (res != 0) { |
|
42905 | 339 |
fatal("pthread_attr_getstack failed with error = %d", res); |
4013 | 340 |
} |
341 |
address stack_top = stack_bottom + stack_bytes; |
|
342 |
||
343 |
// The block of memory returned by pthread_attr_getstack() includes |
|
344 |
// guard pages where present. We need to trim these off. |
|
345 |
size_t page_bytes = os::Linux::page_size(); |
|
346 |
assert(((intptr_t) stack_bottom & (page_bytes - 1)) == 0, "unaligned stack"); |
|
347 |
||
348 |
size_t guard_bytes; |
|
349 |
res = pthread_attr_getguardsize(&attr, &guard_bytes); |
|
350 |
if (res != 0) { |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32080
diff
changeset
|
351 |
fatal("pthread_attr_getguardsize failed with errno = %d", res); |
4013 | 352 |
} |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
42905
diff
changeset
|
353 |
int guard_pages = align_up(guard_bytes, page_bytes) / page_bytes; |
4013 | 354 |
assert(guard_bytes == guard_pages * page_bytes, "unaligned guard"); |
355 |
||
356 |
#ifdef IA64 |
|
357 |
// IA64 has two stacks sharing the same area of memory, a normal |
|
358 |
// stack growing downwards and a register stack growing upwards. |
|
359 |
// Guard pages, if present, are in the centre. This code splits |
|
360 |
// the stack in two even without guard pages, though in theory |
|
361 |
// there's nothing to stop us allocating more to the normal stack |
|
362 |
// or more to the register stack if one or the other were found |
|
363 |
// to grow faster. |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
42905
diff
changeset
|
364 |
int total_pages = align_down(stack_bytes, page_bytes) / page_bytes; |
4013 | 365 |
stack_bottom += (total_pages - guard_pages) / 2 * page_bytes; |
366 |
#endif // IA64 |
|
367 |
||
368 |
stack_bottom += guard_bytes; |
|
369 |
||
370 |
pthread_attr_destroy(&attr); |
|
371 |
||
372 |
// The initial thread has a growable stack, and the size reported |
|
373 |
// by pthread_attr_getstack is the maximum size it could possibly |
|
374 |
// be given what currently mapped. This can be huge, so we cap it. |
|
48019
827e4ac05579
8191663: Zero variant broken after 8189170 and 8189871
glaubitz
parents:
47765
diff
changeset
|
375 |
if (os::is_primordial_thread()) { |
4013 | 376 |
stack_bytes = stack_top - stack_bottom; |
377 |
||
378 |
if (stack_bytes > JavaThread::stack_size_at_create()) |
|
379 |
stack_bytes = JavaThread::stack_size_at_create(); |
|
380 |
||
381 |
stack_bottom = stack_top - stack_bytes; |
|
382 |
} |
|
383 |
||
384 |
assert(os::current_stack_pointer() >= stack_bottom, "should do"); |
|
385 |
assert(os::current_stack_pointer() < stack_top, "should do"); |
|
386 |
||
387 |
*bottom = stack_bottom; |
|
388 |
*size = stack_top - stack_bottom; |
|
389 |
} |
|
390 |
||
391 |
address os::current_stack_base() { |
|
392 |
address bottom; |
|
393 |
size_t size; |
|
394 |
current_stack_region(&bottom, &size); |
|
395 |
return bottom + size; |
|
396 |
} |
|
397 |
||
398 |
size_t os::current_stack_size() { |
|
399 |
// stack size includes normal stack and HotSpot guard pages |
|
400 |
address bottom; |
|
401 |
size_t size; |
|
402 |
current_stack_region(&bottom, &size); |
|
403 |
return size; |
|
404 |
} |
|
405 |
||
406 |
///////////////////////////////////////////////////////////////////////////// |
|
407 |
// helper functions for fatal error handler |
|
408 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
34633
diff
changeset
|
409 |
void os::print_context(outputStream* st, const void* context) { |
4013 | 410 |
ShouldNotCallThis(); |
411 |
} |
|
412 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
34633
diff
changeset
|
413 |
void os::print_register_info(outputStream *st, const void *context) { |
7395 | 414 |
ShouldNotCallThis(); |
415 |
} |
|
416 |
||
4013 | 417 |
///////////////////////////////////////////////////////////////////////////// |
418 |
// Stubs for things that would be in linux_zero.s if it existed. |
|
419 |
// You probably want to disassemble these monkeys to check they're ok. |
|
420 |
||
421 |
extern "C" { |
|
422 |
int SpinPause() { |
|
36181 | 423 |
return -1; // silence compile warnings |
4013 | 424 |
} |
425 |
||
426 |
||
427 |
void _Copy_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) { |
|
428 |
if (from > to) { |
|
429 |
jshort *end = from + count; |
|
430 |
while (from < end) |
|
431 |
*(to++) = *(from++); |
|
432 |
} |
|
433 |
else if (from < to) { |
|
434 |
jshort *end = from; |
|
435 |
from += count - 1; |
|
436 |
to += count - 1; |
|
437 |
while (from >= end) |
|
438 |
*(to--) = *(from--); |
|
439 |
} |
|
440 |
} |
|
441 |
void _Copy_conjoint_jints_atomic(jint* from, jint* to, size_t count) { |
|
442 |
if (from > to) { |
|
443 |
jint *end = from + count; |
|
444 |
while (from < end) |
|
445 |
*(to++) = *(from++); |
|
446 |
} |
|
447 |
else if (from < to) { |
|
448 |
jint *end = from; |
|
449 |
from += count - 1; |
|
450 |
to += count - 1; |
|
451 |
while (from >= end) |
|
452 |
*(to--) = *(from--); |
|
453 |
} |
|
454 |
} |
|
455 |
void _Copy_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) { |
|
456 |
if (from > to) { |
|
457 |
jlong *end = from + count; |
|
458 |
while (from < end) |
|
459 |
os::atomic_copy64(from++, to++); |
|
460 |
} |
|
461 |
else if (from < to) { |
|
462 |
jlong *end = from; |
|
463 |
from += count - 1; |
|
464 |
to += count - 1; |
|
465 |
while (from >= end) |
|
466 |
os::atomic_copy64(from--, to--); |
|
467 |
} |
|
468 |
} |
|
469 |
||
470 |
void _Copy_arrayof_conjoint_bytes(HeapWord* from, |
|
471 |
HeapWord* to, |
|
472 |
size_t count) { |
|
6271 | 473 |
memmove(to, from, count); |
4013 | 474 |
} |
475 |
void _Copy_arrayof_conjoint_jshorts(HeapWord* from, |
|
476 |
HeapWord* to, |
|
477 |
size_t count) { |
|
6271 | 478 |
memmove(to, from, count * 2); |
4013 | 479 |
} |
480 |
void _Copy_arrayof_conjoint_jints(HeapWord* from, |
|
481 |
HeapWord* to, |
|
482 |
size_t count) { |
|
6271 | 483 |
memmove(to, from, count * 4); |
4013 | 484 |
} |
485 |
void _Copy_arrayof_conjoint_jlongs(HeapWord* from, |
|
486 |
HeapWord* to, |
|
487 |
size_t count) { |
|
6271 | 488 |
memmove(to, from, count * 8); |
4013 | 489 |
} |
490 |
}; |
|
491 |
||
492 |
///////////////////////////////////////////////////////////////////////////// |
|
493 |
// Implementations of atomic operations not supported by processors. |
|
494 |
// -- http://gcc.gnu.org/onlinedocs/gcc-4.2.1/gcc/Atomic-Builtins.html |
|
495 |
||
496 |
#ifndef _LP64 |
|
497 |
extern "C" { |
|
498 |
long long unsigned int __sync_val_compare_and_swap_8( |
|
499 |
volatile void *ptr, |
|
500 |
long long unsigned int oldval, |
|
501 |
long long unsigned int newval) { |
|
502 |
ShouldNotCallThis(); |
|
503 |
} |
|
504 |
}; |
|
505 |
#endif // !_LP64 |
|
11961
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
506 |
|
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
507 |
#ifndef PRODUCT |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
508 |
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
|
509 |
} |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
8921
diff
changeset
|
510 |
#endif |
26576
a9429d24d429
8050147: StoreLoad barrier interferes with stack usages
shade
parents:
22234
diff
changeset
|
511 |
|
a9429d24d429
8050147: StoreLoad barrier interferes with stack usages
shade
parents:
22234
diff
changeset
|
512 |
int os::extra_bang_size_in_bytes() { |
a9429d24d429
8050147: StoreLoad barrier interferes with stack usages
shade
parents:
22234
diff
changeset
|
513 |
// Zero does not require an additional stack banging. |
a9429d24d429
8050147: StoreLoad barrier interferes with stack usages
shade
parents:
22234
diff
changeset
|
514 |
return 0; |
a9429d24d429
8050147: StoreLoad barrier interferes with stack usages
shade
parents:
22234
diff
changeset
|
515 |
} |