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