author | duke |
Wed, 05 Jul 2017 20:10:48 +0200 | |
changeset 27963 | 88d7c7c376e9 |
parent 27694 | 543f6042c268 |
child 33593 | 60764a78fa5c |
permissions | -rw-r--r-- |
1 | 1 |
/* |
22234
da823d78ad65
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
19952
diff
changeset
|
2 |
* Copyright (c) 1999, 2013, 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:
3261
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3261
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:
3261
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
// no precompiled headers |
14626
0cf4eccf130f
8003240: x86: move MacroAssembler into separate file
twisti
parents:
14284
diff
changeset
|
26 |
#include "asm/macroAssembler.hpp" |
7397 | 27 |
#include "classfile/classLoader.hpp" |
28 |
#include "classfile/systemDictionary.hpp" |
|
29 |
#include "classfile/vmSymbols.hpp" |
|
30 |
#include "code/icBuffer.hpp" |
|
31 |
#include "code/vtableStubs.hpp" |
|
19952
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
32 |
#include "decoder_windows.hpp" |
7397 | 33 |
#include "interpreter/interpreter.hpp" |
34 |
#include "jvm_windows.h" |
|
35 |
#include "memory/allocation.inline.hpp" |
|
36 |
#include "mutex_windows.inline.hpp" |
|
37 |
#include "nativeInst_x86.hpp" |
|
38 |
#include "os_share_windows.hpp" |
|
39 |
#include "prims/jniFastGetField.hpp" |
|
40 |
#include "prims/jvm.h" |
|
41 |
#include "prims/jvm_misc.hpp" |
|
42 |
#include "runtime/arguments.hpp" |
|
43 |
#include "runtime/extendedPC.hpp" |
|
44 |
#include "runtime/frame.inline.hpp" |
|
45 |
#include "runtime/interfaceSupport.hpp" |
|
46 |
#include "runtime/java.hpp" |
|
47 |
#include "runtime/javaCalls.hpp" |
|
48 |
#include "runtime/mutexLocker.hpp" |
|
49 |
#include "runtime/osThread.hpp" |
|
50 |
#include "runtime/sharedRuntime.hpp" |
|
51 |
#include "runtime/stubRoutines.hpp" |
|
14583
d70ee55535f4
8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
14284
diff
changeset
|
52 |
#include "runtime/thread.inline.hpp" |
7397 | 53 |
#include "runtime/timer.hpp" |
54 |
#include "utilities/events.hpp" |
|
55 |
#include "utilities/vmError.hpp" |
|
56 |
||
1 | 57 |
# include "unwind_windows_x86.hpp" |
58 |
#undef REG_SP |
|
59 |
#undef REG_FP |
|
60 |
#undef REG_PC |
|
61 |
#ifdef AMD64 |
|
62 |
#define REG_SP Rsp |
|
63 |
#define REG_FP Rbp |
|
64 |
#define REG_PC Rip |
|
65 |
#else |
|
66 |
#define REG_SP Esp |
|
67 |
#define REG_FP Ebp |
|
68 |
#define REG_PC Eip |
|
69 |
#endif // AMD64 |
|
70 |
||
71 |
extern LONG WINAPI topLevelExceptionFilter(_EXCEPTION_POINTERS* ); |
|
72 |
||
73 |
// Install a win32 structured exception handler around thread. |
|
74 |
void os::os_exception_wrapper(java_call_t f, JavaValue* value, methodHandle* method, JavaCallArguments* args, Thread* thread) { |
|
75 |
__try { |
|
76 |
||
77 |
#ifndef AMD64 |
|
78 |
// We store the current thread in this wrapperthread location |
|
79 |
// and determine how far away this address is from the structured |
|
80 |
// execption pointer that FS:[0] points to. This get_thread |
|
81 |
// code can then get the thread pointer via FS. |
|
82 |
// |
|
83 |
// Warning: This routine must NEVER be inlined since we'd end up with |
|
84 |
// multiple offsets. |
|
85 |
// |
|
86 |
volatile Thread* wrapperthread = thread; |
|
87 |
||
88 |
if ( ThreadLocalStorage::get_thread_ptr_offset() == 0 ) { |
|
89 |
int thread_ptr_offset; |
|
90 |
__asm { |
|
91 |
lea eax, dword ptr wrapperthread; |
|
92 |
sub eax, dword ptr FS:[0H]; |
|
93 |
mov thread_ptr_offset, eax |
|
94 |
}; |
|
95 |
ThreadLocalStorage::set_thread_ptr_offset(thread_ptr_offset); |
|
96 |
} |
|
97 |
#ifdef ASSERT |
|
98 |
// Verify that the offset hasn't changed since we initally captured |
|
99 |
// it. This might happen if we accidentally ended up with an |
|
100 |
// inlined version of this routine. |
|
101 |
else { |
|
102 |
int test_thread_ptr_offset; |
|
103 |
__asm { |
|
104 |
lea eax, dword ptr wrapperthread; |
|
105 |
sub eax, dword ptr FS:[0H]; |
|
106 |
mov test_thread_ptr_offset, eax |
|
107 |
}; |
|
108 |
assert(test_thread_ptr_offset == ThreadLocalStorage::get_thread_ptr_offset(), |
|
109 |
"thread pointer offset from SEH changed"); |
|
110 |
} |
|
111 |
#endif // ASSERT |
|
112 |
#endif // !AMD64 |
|
113 |
||
114 |
f(value, method, args, thread); |
|
115 |
} __except(topLevelExceptionFilter((_EXCEPTION_POINTERS*)_exception_info())) { |
|
116 |
// Nothing to do. |
|
117 |
} |
|
118 |
} |
|
119 |
||
120 |
#ifdef AMD64 |
|
121 |
||
122 |
// This is the language specific handler for exceptions |
|
123 |
// originating from dynamically generated code. |
|
124 |
// We call the standard structured exception handler |
|
125 |
// We only expect Continued Execution since we cannot unwind |
|
126 |
// from generated code. |
|
127 |
LONG HandleExceptionFromCodeCache( |
|
128 |
IN PEXCEPTION_RECORD ExceptionRecord, |
|
129 |
IN ULONG64 EstablisherFrame, |
|
130 |
IN OUT PCONTEXT ContextRecord, |
|
131 |
IN OUT PDISPATCHER_CONTEXT DispatcherContext) { |
|
132 |
EXCEPTION_POINTERS ep; |
|
133 |
LONG result; |
|
134 |
||
135 |
ep.ExceptionRecord = ExceptionRecord; |
|
136 |
ep.ContextRecord = ContextRecord; |
|
137 |
||
138 |
result = topLevelExceptionFilter(&ep); |
|
139 |
||
140 |
// We better only get a CONTINUE_EXECUTION from our handler |
|
141 |
// since we don't have unwind information registered. |
|
142 |
||
143 |
guarantee( result == EXCEPTION_CONTINUE_EXECUTION, |
|
144 |
"Unexpected result from topLevelExceptionFilter"); |
|
145 |
||
146 |
return(ExceptionContinueExecution); |
|
147 |
} |
|
148 |
||
149 |
||
150 |
// Structure containing the Windows Data Structures required |
|
151 |
// to register our Code Cache exception handler. |
|
152 |
// We put these in the CodeCache since the API requires |
|
153 |
// all addresses in these structures are relative to the Code |
|
154 |
// area registered with RtlAddFunctionTable. |
|
155 |
typedef struct { |
|
156 |
char ExceptionHandlerInstr[16]; // jmp HandleExceptionFromCodeCache |
|
157 |
RUNTIME_FUNCTION rt; |
|
158 |
UNWIND_INFO_EH_ONLY unw; |
|
159 |
} DynamicCodeData, *pDynamicCodeData; |
|
160 |
||
161 |
#endif // AMD64 |
|
162 |
// |
|
163 |
// Register our CodeCache area with the OS so it will dispatch exceptions |
|
164 |
// to our topLevelExceptionFilter when we take an exception in our |
|
165 |
// dynamically generated code. |
|
166 |
// |
|
167 |
// Arguments: low and high are the address of the full reserved |
|
168 |
// codeCache area |
|
169 |
// |
|
170 |
bool os::register_code_area(char *low, char *high) { |
|
171 |
#ifdef AMD64 |
|
172 |
||
173 |
ResourceMark rm; |
|
174 |
||
175 |
pDynamicCodeData pDCD; |
|
176 |
PRUNTIME_FUNCTION prt; |
|
177 |
PUNWIND_INFO_EH_ONLY punwind; |
|
178 |
||
6418 | 179 |
BufferBlob* blob = BufferBlob::create("CodeCache Exception Handler", sizeof(DynamicCodeData)); |
180 |
CodeBuffer cb(blob); |
|
1 | 181 |
MacroAssembler* masm = new MacroAssembler(&cb); |
182 |
pDCD = (pDynamicCodeData) masm->pc(); |
|
183 |
||
184 |
masm->jump(ExternalAddress((address)&HandleExceptionFromCodeCache)); |
|
185 |
masm->flush(); |
|
186 |
||
187 |
// Create an Unwind Structure specifying no unwind info |
|
188 |
// other than an Exception Handler |
|
189 |
punwind = &pDCD->unw; |
|
190 |
punwind->Version = 1; |
|
191 |
punwind->Flags = UNW_FLAG_EHANDLER; |
|
192 |
punwind->SizeOfProlog = 0; |
|
193 |
punwind->CountOfCodes = 0; |
|
194 |
punwind->FrameRegister = 0; |
|
195 |
punwind->FrameOffset = 0; |
|
196 |
punwind->ExceptionHandler = (char *)(&(pDCD->ExceptionHandlerInstr[0])) - |
|
197 |
(char*)low; |
|
198 |
punwind->ExceptionData[0] = 0; |
|
199 |
||
200 |
// This structure describes the covered dynamic code area. |
|
201 |
// Addresses are relative to the beginning on the code cache area |
|
202 |
prt = &pDCD->rt; |
|
203 |
prt->BeginAddress = 0; |
|
204 |
prt->EndAddress = (ULONG)(high - low); |
|
205 |
prt->UnwindData = ((char *)punwind - low); |
|
206 |
||
207 |
guarantee(RtlAddFunctionTable(prt, 1, (ULONGLONG)low), |
|
208 |
"Failed to register Dynamic Code Exception Handler with RtlAddFunctionTable"); |
|
209 |
||
210 |
#endif // AMD64 |
|
211 |
return true; |
|
212 |
} |
|
213 |
||
13859
7fe4578493fc
7190089: NMT ON: NMT failed assertion on thread's stack base address
zgu
parents:
11961
diff
changeset
|
214 |
void os::initialize_thread(Thread* thr) { |
1 | 215 |
// Nothing to do. |
216 |
} |
|
217 |
||
218 |
// Atomics and Stub Functions |
|
219 |
||
220 |
typedef jint xchg_func_t (jint, volatile jint*); |
|
221 |
typedef intptr_t xchg_ptr_func_t (intptr_t, volatile intptr_t*); |
|
222 |
typedef jint cmpxchg_func_t (jint, volatile jint*, jint); |
|
27691
733f189ad1f7
8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents:
26576
diff
changeset
|
223 |
typedef jbyte cmpxchg_byte_func_t (jbyte, volatile jbyte*, jbyte); |
1 | 224 |
typedef jlong cmpxchg_long_func_t (jlong, volatile jlong*, jlong); |
225 |
typedef jint add_func_t (jint, volatile jint*); |
|
226 |
typedef intptr_t add_ptr_func_t (intptr_t, volatile intptr_t*); |
|
227 |
||
228 |
#ifdef AMD64 |
|
229 |
||
230 |
jint os::atomic_xchg_bootstrap(jint exchange_value, volatile jint* dest) { |
|
231 |
// try to use the stub: |
|
232 |
xchg_func_t* func = CAST_TO_FN_PTR(xchg_func_t*, StubRoutines::atomic_xchg_entry()); |
|
233 |
||
234 |
if (func != NULL) { |
|
235 |
os::atomic_xchg_func = func; |
|
236 |
return (*func)(exchange_value, dest); |
|
237 |
} |
|
238 |
assert(Threads::number_of_threads() == 0, "for bootstrap only"); |
|
239 |
||
240 |
jint old_value = *dest; |
|
241 |
*dest = exchange_value; |
|
242 |
return old_value; |
|
243 |
} |
|
244 |
||
245 |
intptr_t os::atomic_xchg_ptr_bootstrap(intptr_t exchange_value, volatile intptr_t* dest) { |
|
246 |
// try to use the stub: |
|
247 |
xchg_ptr_func_t* func = CAST_TO_FN_PTR(xchg_ptr_func_t*, StubRoutines::atomic_xchg_ptr_entry()); |
|
248 |
||
249 |
if (func != NULL) { |
|
250 |
os::atomic_xchg_ptr_func = func; |
|
251 |
return (*func)(exchange_value, dest); |
|
252 |
} |
|
253 |
assert(Threads::number_of_threads() == 0, "for bootstrap only"); |
|
254 |
||
255 |
intptr_t old_value = *dest; |
|
256 |
*dest = exchange_value; |
|
257 |
return old_value; |
|
258 |
} |
|
259 |
||
260 |
||
261 |
jint os::atomic_cmpxchg_bootstrap(jint exchange_value, volatile jint* dest, jint compare_value) { |
|
262 |
// try to use the stub: |
|
263 |
cmpxchg_func_t* func = CAST_TO_FN_PTR(cmpxchg_func_t*, StubRoutines::atomic_cmpxchg_entry()); |
|
264 |
||
265 |
if (func != NULL) { |
|
266 |
os::atomic_cmpxchg_func = func; |
|
267 |
return (*func)(exchange_value, dest, compare_value); |
|
268 |
} |
|
269 |
assert(Threads::number_of_threads() == 0, "for bootstrap only"); |
|
270 |
||
271 |
jint old_value = *dest; |
|
272 |
if (old_value == compare_value) |
|
273 |
*dest = exchange_value; |
|
274 |
return old_value; |
|
275 |
} |
|
27691
733f189ad1f7
8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents:
26576
diff
changeset
|
276 |
|
733f189ad1f7
8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents:
26576
diff
changeset
|
277 |
jbyte os::atomic_cmpxchg_byte_bootstrap(jbyte exchange_value, volatile jbyte* dest, jbyte compare_value) { |
733f189ad1f7
8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents:
26576
diff
changeset
|
278 |
// try to use the stub: |
733f189ad1f7
8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents:
26576
diff
changeset
|
279 |
cmpxchg_byte_func_t* func = CAST_TO_FN_PTR(cmpxchg_byte_func_t*, StubRoutines::atomic_cmpxchg_byte_entry()); |
733f189ad1f7
8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents:
26576
diff
changeset
|
280 |
|
733f189ad1f7
8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents:
26576
diff
changeset
|
281 |
if (func != NULL) { |
733f189ad1f7
8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents:
26576
diff
changeset
|
282 |
os::atomic_cmpxchg_byte_func = func; |
733f189ad1f7
8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents:
26576
diff
changeset
|
283 |
return (*func)(exchange_value, dest, compare_value); |
733f189ad1f7
8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents:
26576
diff
changeset
|
284 |
} |
733f189ad1f7
8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents:
26576
diff
changeset
|
285 |
assert(Threads::number_of_threads() == 0, "for bootstrap only"); |
733f189ad1f7
8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents:
26576
diff
changeset
|
286 |
|
733f189ad1f7
8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents:
26576
diff
changeset
|
287 |
jbyte old_value = *dest; |
733f189ad1f7
8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents:
26576
diff
changeset
|
288 |
if (old_value == compare_value) |
733f189ad1f7
8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents:
26576
diff
changeset
|
289 |
*dest = exchange_value; |
733f189ad1f7
8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents:
26576
diff
changeset
|
290 |
return old_value; |
733f189ad1f7
8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents:
26576
diff
changeset
|
291 |
} |
733f189ad1f7
8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents:
26576
diff
changeset
|
292 |
|
1 | 293 |
#endif // AMD64 |
294 |
||
295 |
jlong os::atomic_cmpxchg_long_bootstrap(jlong exchange_value, volatile jlong* dest, jlong compare_value) { |
|
296 |
// try to use the stub: |
|
297 |
cmpxchg_long_func_t* func = CAST_TO_FN_PTR(cmpxchg_long_func_t*, StubRoutines::atomic_cmpxchg_long_entry()); |
|
298 |
||
299 |
if (func != NULL) { |
|
300 |
os::atomic_cmpxchg_long_func = func; |
|
301 |
return (*func)(exchange_value, dest, compare_value); |
|
302 |
} |
|
303 |
assert(Threads::number_of_threads() == 0, "for bootstrap only"); |
|
304 |
||
305 |
jlong old_value = *dest; |
|
306 |
if (old_value == compare_value) |
|
307 |
*dest = exchange_value; |
|
308 |
return old_value; |
|
309 |
} |
|
310 |
||
311 |
#ifdef AMD64 |
|
312 |
||
313 |
jint os::atomic_add_bootstrap(jint add_value, volatile jint* dest) { |
|
314 |
// try to use the stub: |
|
315 |
add_func_t* func = CAST_TO_FN_PTR(add_func_t*, StubRoutines::atomic_add_entry()); |
|
316 |
||
317 |
if (func != NULL) { |
|
318 |
os::atomic_add_func = func; |
|
319 |
return (*func)(add_value, dest); |
|
320 |
} |
|
321 |
assert(Threads::number_of_threads() == 0, "for bootstrap only"); |
|
322 |
||
323 |
return (*dest) += add_value; |
|
324 |
} |
|
325 |
||
326 |
intptr_t os::atomic_add_ptr_bootstrap(intptr_t add_value, volatile intptr_t* dest) { |
|
327 |
// try to use the stub: |
|
328 |
add_ptr_func_t* func = CAST_TO_FN_PTR(add_ptr_func_t*, StubRoutines::atomic_add_ptr_entry()); |
|
329 |
||
330 |
if (func != NULL) { |
|
331 |
os::atomic_add_ptr_func = func; |
|
332 |
return (*func)(add_value, dest); |
|
333 |
} |
|
334 |
assert(Threads::number_of_threads() == 0, "for bootstrap only"); |
|
335 |
||
336 |
return (*dest) += add_value; |
|
337 |
} |
|
338 |
||
339 |
xchg_func_t* os::atomic_xchg_func = os::atomic_xchg_bootstrap; |
|
340 |
xchg_ptr_func_t* os::atomic_xchg_ptr_func = os::atomic_xchg_ptr_bootstrap; |
|
341 |
cmpxchg_func_t* os::atomic_cmpxchg_func = os::atomic_cmpxchg_bootstrap; |
|
27691
733f189ad1f7
8058255: Native jbyte Atomic::cmpxchg for supported x86 platforms
jwilhelm
parents:
26576
diff
changeset
|
342 |
cmpxchg_byte_func_t* os::atomic_cmpxchg_byte_func = os::atomic_cmpxchg_byte_bootstrap; |
1 | 343 |
add_func_t* os::atomic_add_func = os::atomic_add_bootstrap; |
344 |
add_ptr_func_t* os::atomic_add_ptr_func = os::atomic_add_ptr_bootstrap; |
|
345 |
||
346 |
#endif // AMD64 |
|
347 |
||
348 |
cmpxchg_long_func_t* os::atomic_cmpxchg_long_func = os::atomic_cmpxchg_long_bootstrap; |
|
349 |
||
19952
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
350 |
#ifdef AMD64 |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
351 |
/* |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
352 |
* Windows/x64 does not use stack frames the way expected by Java: |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
353 |
* [1] in most cases, there is no frame pointer. All locals are addressed via RSP |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
354 |
* [2] in rare cases, when alloca() is used, a frame pointer is used, but this may |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
355 |
* not be RBP. |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
356 |
* See http://msdn.microsoft.com/en-us/library/ew5tede7.aspx |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
357 |
* |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
358 |
* So it's not possible to print the native stack using the |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
359 |
* while (...) {... fr = os::get_sender_for_C_frame(&fr); } |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
360 |
* loop in vmError.cpp. We need to roll our own loop. |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
361 |
*/ |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
362 |
bool os::platform_print_native_stack(outputStream* st, void* context, |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
363 |
char *buf, int buf_size) |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
364 |
{ |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
365 |
CONTEXT ctx; |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
366 |
if (context != NULL) { |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
367 |
memcpy(&ctx, context, sizeof(ctx)); |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
368 |
} else { |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
369 |
RtlCaptureContext(&ctx); |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
370 |
} |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
371 |
|
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
372 |
st->print_cr("Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)"); |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
373 |
|
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
374 |
STACKFRAME stk; |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
375 |
memset(&stk, 0, sizeof(stk)); |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
376 |
stk.AddrStack.Offset = ctx.Rsp; |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
377 |
stk.AddrStack.Mode = AddrModeFlat; |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
378 |
stk.AddrFrame.Offset = ctx.Rbp; |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
379 |
stk.AddrFrame.Mode = AddrModeFlat; |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
380 |
stk.AddrPC.Offset = ctx.Rip; |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
381 |
stk.AddrPC.Mode = AddrModeFlat; |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
382 |
|
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
383 |
int count = 0; |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
384 |
address lastpc = 0; |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
385 |
while (count++ < StackPrintLimit) { |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
386 |
intptr_t* sp = (intptr_t*)stk.AddrStack.Offset; |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
387 |
intptr_t* fp = (intptr_t*)stk.AddrFrame.Offset; // NOT necessarily the same as ctx.Rbp! |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
388 |
address pc = (address)stk.AddrPC.Offset; |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
389 |
|
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
390 |
if (pc != NULL && sp != NULL && fp != NULL) { |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
391 |
if (count == 2 && lastpc == pc) { |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
392 |
// Skip it -- StackWalk64() may return the same PC |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
393 |
// (but different SP) on the first try. |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
394 |
} else { |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
395 |
// Don't try to create a frame(sp, fp, pc) -- on WinX64, stk.AddrFrame |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
396 |
// may not contain what Java expects, and may cause the frame() constructor |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
397 |
// to crash. Let's just print out the symbolic address. |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
398 |
frame::print_C_frame(st, buf, buf_size, pc); |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
399 |
st->cr(); |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
400 |
} |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
401 |
lastpc = pc; |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
402 |
} else { |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
403 |
break; |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
404 |
} |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
405 |
|
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
406 |
PVOID p = WindowsDbgHelp::SymFunctionTableAccess64(GetCurrentProcess(), stk.AddrPC.Offset); |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
407 |
if (!p) { |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
408 |
// StackWalk64() can't handle this PC. Calling StackWalk64 again may cause crash. |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
409 |
break; |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
410 |
} |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
411 |
|
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
412 |
BOOL result = WindowsDbgHelp::StackWalk64( |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
413 |
IMAGE_FILE_MACHINE_AMD64, // __in DWORD MachineType, |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
414 |
GetCurrentProcess(), // __in HANDLE hProcess, |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
415 |
GetCurrentThread(), // __in HANDLE hThread, |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
416 |
&stk, // __inout LP STACKFRAME64 StackFrame, |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
417 |
&ctx, // __inout PVOID ContextRecord, |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
418 |
NULL, // __in_opt PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine, |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
419 |
WindowsDbgHelp::pfnSymFunctionTableAccess64(), |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
420 |
// __in_opt PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine, |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
421 |
WindowsDbgHelp::pfnSymGetModuleBase64(), |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
422 |
// __in_opt PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine, |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
423 |
NULL); // __in_opt PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
424 |
|
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
425 |
if (!result) { |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
426 |
break; |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
427 |
} |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
428 |
} |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
429 |
if (count > StackPrintLimit) { |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
430 |
st->print_cr("...<more frames>..."); |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
431 |
} |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
432 |
st->cr(); |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
433 |
|
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
434 |
return true; |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
435 |
} |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
436 |
#endif // AMD64 |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
437 |
|
1 | 438 |
ExtendedPC os::fetch_frame_from_context(void* ucVoid, |
439 |
intptr_t** ret_sp, intptr_t** ret_fp) { |
|
440 |
||
441 |
ExtendedPC epc; |
|
442 |
CONTEXT* uc = (CONTEXT*)ucVoid; |
|
443 |
||
444 |
if (uc != NULL) { |
|
445 |
epc = ExtendedPC((address)uc->REG_PC); |
|
446 |
if (ret_sp) *ret_sp = (intptr_t*)uc->REG_SP; |
|
447 |
if (ret_fp) *ret_fp = (intptr_t*)uc->REG_FP; |
|
448 |
} else { |
|
449 |
// construct empty ExtendedPC for return value checking |
|
450 |
epc = ExtendedPC(NULL); |
|
451 |
if (ret_sp) *ret_sp = (intptr_t *)NULL; |
|
452 |
if (ret_fp) *ret_fp = (intptr_t *)NULL; |
|
453 |
} |
|
454 |
||
455 |
return epc; |
|
456 |
} |
|
457 |
||
458 |
frame os::fetch_frame_from_context(void* ucVoid) { |
|
459 |
intptr_t* sp; |
|
460 |
intptr_t* fp; |
|
461 |
ExtendedPC epc = fetch_frame_from_context(ucVoid, &sp, &fp); |
|
462 |
return frame(sp, fp, epc.pc()); |
|
463 |
} |
|
464 |
||
465 |
// VC++ does not save frame pointer on stack in optimized build. It |
|
466 |
// can be turned off by /Oy-. If we really want to walk C frames, |
|
467 |
// we can use the StackWalk() API. |
|
468 |
frame os::get_sender_for_C_frame(frame* fr) { |
|
469 |
return frame(fr->sender_sp(), fr->link(), fr->sender_pc()); |
|
470 |
} |
|
471 |
||
11961
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
472 |
#ifndef AMD64 |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
473 |
// Returns an estimate of the current stack pointer. Result must be guaranteed |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
474 |
// to point into the calling threads stack, and be no lower than the current |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
475 |
// stack pointer. |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
476 |
address os::current_stack_pointer() { |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
477 |
int dummy; |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
478 |
address sp = (address)&dummy; |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
479 |
return sp; |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
480 |
} |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
481 |
#else |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
482 |
// Returns the current stack pointer. Accurate value needed for |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
483 |
// os::verify_stack_alignment(). |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
484 |
address os::current_stack_pointer() { |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
485 |
typedef address get_sp_func(); |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
486 |
get_sp_func* func = CAST_TO_FN_PTR(get_sp_func*, |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
487 |
StubRoutines::x86::get_previous_sp_entry()); |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
488 |
return (*func)(); |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
489 |
} |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
490 |
#endif |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
491 |
|
1 | 492 |
|
493 |
#ifndef AMD64 |
|
494 |
intptr_t* _get_previous_fp() { |
|
495 |
intptr_t **frameptr; |
|
496 |
__asm { |
|
497 |
mov frameptr, ebp |
|
498 |
}; |
|
499 |
return *frameptr; |
|
500 |
} |
|
501 |
#endif // !AMD64 |
|
502 |
||
503 |
frame os::current_frame() { |
|
504 |
||
505 |
#ifdef AMD64 |
|
506 |
// apparently _asm not supported on windows amd64 |
|
507 |
typedef intptr_t* get_fp_func (); |
|
508 |
get_fp_func* func = CAST_TO_FN_PTR(get_fp_func*, |
|
1066 | 509 |
StubRoutines::x86::get_previous_fp_entry()); |
15468
4a274f843f41
8006508: Wrong frame constructor is called in os_linux_x86.cpp
dholmes
parents:
14633
diff
changeset
|
510 |
if (func == NULL) return frame(); |
1 | 511 |
intptr_t* fp = (*func)(); |
19952
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
512 |
if (fp == NULL) { |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
513 |
return frame(); |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
18740
diff
changeset
|
514 |
} |
1 | 515 |
#else |
516 |
intptr_t* fp = _get_previous_fp(); |
|
517 |
#endif // AMD64 |
|
518 |
||
519 |
frame myframe((intptr_t*)os::current_stack_pointer(), |
|
520 |
(intptr_t*)fp, |
|
521 |
CAST_FROM_FN_PTR(address, os::current_frame)); |
|
522 |
if (os::is_first_C_frame(&myframe)) { |
|
523 |
// stack is not walkable |
|
15468
4a274f843f41
8006508: Wrong frame constructor is called in os_linux_x86.cpp
dholmes
parents:
14633
diff
changeset
|
524 |
return frame(); |
1 | 525 |
} else { |
526 |
return os::get_sender_for_C_frame(&myframe); |
|
527 |
} |
|
528 |
} |
|
529 |
||
530 |
void os::print_context(outputStream *st, void *context) { |
|
531 |
if (context == NULL) return; |
|
532 |
||
533 |
CONTEXT* uc = (CONTEXT*)context; |
|
534 |
||
535 |
st->print_cr("Registers:"); |
|
536 |
#ifdef AMD64 |
|
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
537 |
st->print( "RAX=" INTPTR_FORMAT, uc->Rax); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
538 |
st->print(", RBX=" INTPTR_FORMAT, uc->Rbx); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
539 |
st->print(", RCX=" INTPTR_FORMAT, uc->Rcx); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
540 |
st->print(", RDX=" INTPTR_FORMAT, uc->Rdx); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
541 |
st->cr(); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
542 |
st->print( "RSP=" INTPTR_FORMAT, uc->Rsp); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
543 |
st->print(", RBP=" INTPTR_FORMAT, uc->Rbp); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
544 |
st->print(", RSI=" INTPTR_FORMAT, uc->Rsi); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
545 |
st->print(", RDI=" INTPTR_FORMAT, uc->Rdi); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
546 |
st->cr(); |
7108 | 547 |
st->print( "R8 =" INTPTR_FORMAT, uc->R8); |
548 |
st->print(", R9 =" INTPTR_FORMAT, uc->R9); |
|
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
549 |
st->print(", R10=" INTPTR_FORMAT, uc->R10); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
550 |
st->print(", R11=" INTPTR_FORMAT, uc->R11); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
551 |
st->cr(); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
552 |
st->print( "R12=" INTPTR_FORMAT, uc->R12); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
553 |
st->print(", R13=" INTPTR_FORMAT, uc->R13); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
554 |
st->print(", R14=" INTPTR_FORMAT, uc->R14); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
555 |
st->print(", R15=" INTPTR_FORMAT, uc->R15); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
556 |
st->cr(); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
557 |
st->print( "RIP=" INTPTR_FORMAT, uc->Rip); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
558 |
st->print(", EFLAGS=" INTPTR_FORMAT, uc->EFlags); |
1 | 559 |
#else |
560 |
st->print( "EAX=" INTPTR_FORMAT, uc->Eax); |
|
561 |
st->print(", EBX=" INTPTR_FORMAT, uc->Ebx); |
|
562 |
st->print(", ECX=" INTPTR_FORMAT, uc->Ecx); |
|
563 |
st->print(", EDX=" INTPTR_FORMAT, uc->Edx); |
|
564 |
st->cr(); |
|
565 |
st->print( "ESP=" INTPTR_FORMAT, uc->Esp); |
|
566 |
st->print(", EBP=" INTPTR_FORMAT, uc->Ebp); |
|
567 |
st->print(", ESI=" INTPTR_FORMAT, uc->Esi); |
|
568 |
st->print(", EDI=" INTPTR_FORMAT, uc->Edi); |
|
569 |
st->cr(); |
|
570 |
st->print( "EIP=" INTPTR_FORMAT, uc->Eip); |
|
571 |
st->print(", EFLAGS=" INTPTR_FORMAT, uc->EFlags); |
|
572 |
#endif // AMD64 |
|
573 |
st->cr(); |
|
574 |
st->cr(); |
|
575 |
||
576 |
intptr_t *sp = (intptr_t *)uc->REG_SP; |
|
577 |
st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp); |
|
578 |
print_hex_dump(st, (address)sp, (address)(sp + 32), sizeof(intptr_t)); |
|
579 |
st->cr(); |
|
580 |
||
581 |
// Note: it may be unsafe to inspect memory near pc. For example, pc may |
|
582 |
// point to garbage if entry point in an nmethod is corrupted. Leave |
|
583 |
// this at the end, and hope for the best. |
|
584 |
address pc = (address)uc->REG_PC; |
|
585 |
st->print_cr("Instructions: (pc=" PTR_FORMAT ")", pc); |
|
7108 | 586 |
print_hex_dump(st, pc - 32, pc + 32, sizeof(char)); |
587 |
st->cr(); |
|
588 |
} |
|
589 |
||
590 |
||
591 |
void os::print_register_info(outputStream *st, void *context) { |
|
592 |
if (context == NULL) return; |
|
593 |
||
594 |
CONTEXT* uc = (CONTEXT*)context; |
|
595 |
||
596 |
st->print_cr("Register to memory mapping:"); |
|
597 |
st->cr(); |
|
598 |
||
599 |
// this is only for the "general purpose" registers |
|
600 |
||
601 |
#ifdef AMD64 |
|
602 |
st->print("RAX="); print_location(st, uc->Rax); |
|
603 |
st->print("RBX="); print_location(st, uc->Rbx); |
|
604 |
st->print("RCX="); print_location(st, uc->Rcx); |
|
605 |
st->print("RDX="); print_location(st, uc->Rdx); |
|
606 |
st->print("RSP="); print_location(st, uc->Rsp); |
|
607 |
st->print("RBP="); print_location(st, uc->Rbp); |
|
608 |
st->print("RSI="); print_location(st, uc->Rsi); |
|
609 |
st->print("RDI="); print_location(st, uc->Rdi); |
|
610 |
st->print("R8 ="); print_location(st, uc->R8); |
|
611 |
st->print("R9 ="); print_location(st, uc->R9); |
|
612 |
st->print("R10="); print_location(st, uc->R10); |
|
613 |
st->print("R11="); print_location(st, uc->R11); |
|
614 |
st->print("R12="); print_location(st, uc->R12); |
|
615 |
st->print("R13="); print_location(st, uc->R13); |
|
616 |
st->print("R14="); print_location(st, uc->R14); |
|
617 |
st->print("R15="); print_location(st, uc->R15); |
|
618 |
#else |
|
619 |
st->print("EAX="); print_location(st, uc->Eax); |
|
620 |
st->print("EBX="); print_location(st, uc->Ebx); |
|
621 |
st->print("ECX="); print_location(st, uc->Ecx); |
|
622 |
st->print("EDX="); print_location(st, uc->Edx); |
|
623 |
st->print("ESP="); print_location(st, uc->Esp); |
|
624 |
st->print("EBP="); print_location(st, uc->Ebp); |
|
625 |
st->print("ESI="); print_location(st, uc->Esi); |
|
626 |
st->print("EDI="); print_location(st, uc->Edi); |
|
627 |
#endif |
|
628 |
||
1 | 629 |
st->cr(); |
630 |
} |
|
631 |
||
632 |
extern "C" int SpinPause () { |
|
633 |
#ifdef AMD64 |
|
634 |
return 0 ; |
|
635 |
#else |
|
636 |
// pause == rep:nop |
|
637 |
// On systems that don't support pause a rep:nop |
|
638 |
// is executed as a nop. The rep: prefix is ignored. |
|
639 |
_asm { |
|
640 |
pause ; |
|
641 |
}; |
|
642 |
return 1 ; |
|
643 |
#endif // AMD64 |
|
644 |
} |
|
645 |
||
646 |
||
647 |
void os::setup_fpu() { |
|
648 |
#ifndef AMD64 |
|
649 |
int fpu_cntrl_word = StubRoutines::fpu_cntrl_wrd_std(); |
|
650 |
__asm fldcw fpu_cntrl_word; |
|
651 |
#endif // !AMD64 |
|
652 |
} |
|
11961
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
653 |
|
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
654 |
#ifndef PRODUCT |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
655 |
void os::verify_stack_alignment() { |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
656 |
#ifdef AMD64 |
27649
0e79b173cc5e
8054008: Using -XX:-LazyBootClassLoader crashes with ACCESS_VIOLATION on Win 64bit.
jiangli
parents:
26576
diff
changeset
|
657 |
// The current_stack_pointer() calls generated get_previous_sp stub routine. |
0e79b173cc5e
8054008: Using -XX:-LazyBootClassLoader crashes with ACCESS_VIOLATION on Win 64bit.
jiangli
parents:
26576
diff
changeset
|
658 |
// Only enable the assert after the routine becomes available. |
0e79b173cc5e
8054008: Using -XX:-LazyBootClassLoader crashes with ACCESS_VIOLATION on Win 64bit.
jiangli
parents:
26576
diff
changeset
|
659 |
if (StubRoutines::code1() != NULL) { |
0e79b173cc5e
8054008: Using -XX:-LazyBootClassLoader crashes with ACCESS_VIOLATION on Win 64bit.
jiangli
parents:
26576
diff
changeset
|
660 |
assert(((intptr_t)os::current_stack_pointer() & (StackAlignmentInBytes-1)) == 0, "incorrect stack alignment"); |
0e79b173cc5e
8054008: Using -XX:-LazyBootClassLoader crashes with ACCESS_VIOLATION on Win 64bit.
jiangli
parents:
26576
diff
changeset
|
661 |
} |
11961
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
662 |
#endif |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
663 |
} |
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
7405
diff
changeset
|
664 |
#endif |
26576
a9429d24d429
8050147: StoreLoad barrier interferes with stack usages
shade
parents:
22234
diff
changeset
|
665 |
|
a9429d24d429
8050147: StoreLoad barrier interferes with stack usages
shade
parents:
22234
diff
changeset
|
666 |
int os::extra_bang_size_in_bytes() { |
a9429d24d429
8050147: StoreLoad barrier interferes with stack usages
shade
parents:
22234
diff
changeset
|
667 |
// JDK-8050147 requires the full cache line bang for x86. |
a9429d24d429
8050147: StoreLoad barrier interferes with stack usages
shade
parents:
22234
diff
changeset
|
668 |
return VM_Version::L1_line_size(); |
a9429d24d429
8050147: StoreLoad barrier interferes with stack usages
shade
parents:
22234
diff
changeset
|
669 |
} |