annotate src/os_cpu/windows_x86/vm/os_windows_x86.cpp @ 1601:126ea7725993

6953477: Increase portability and flexibility of building Hotspot Summary: A collection of portability improvements including shared code support for PPC, ARM platforms, software floating point, cross compilation support and improvements in error crash detail. Reviewed-by: phh, never, coleenp, dholmes
author bobv
date Tue, 03 Aug 2010 08:13:38 -0400
parents c18cbe5936b8
children 3e8fbc61cee8
rev   line source
duke@0 1 /*
trims@1472 2 * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
trims@1472 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1472 20 * or visit www.oracle.com if you need additional information or have any
trims@1472 21 * questions.
duke@0 22 *
duke@0 23 */
duke@0 24
duke@0 25 // do not include precompiled header file
duke@0 26 # include "incls/_os_windows_x86.cpp.incl"
duke@0 27 # include "unwind_windows_x86.hpp"
duke@0 28 #undef REG_SP
duke@0 29 #undef REG_FP
duke@0 30 #undef REG_PC
duke@0 31 #ifdef AMD64
duke@0 32 #define REG_SP Rsp
duke@0 33 #define REG_FP Rbp
duke@0 34 #define REG_PC Rip
duke@0 35 #else
duke@0 36 #define REG_SP Esp
duke@0 37 #define REG_FP Ebp
duke@0 38 #define REG_PC Eip
duke@0 39 #endif // AMD64
duke@0 40
duke@0 41 extern LONG WINAPI topLevelExceptionFilter(_EXCEPTION_POINTERS* );
duke@0 42
duke@0 43 // Install a win32 structured exception handler around thread.
duke@0 44 void os::os_exception_wrapper(java_call_t f, JavaValue* value, methodHandle* method, JavaCallArguments* args, Thread* thread) {
duke@0 45 __try {
duke@0 46
duke@0 47 #ifndef AMD64
duke@0 48 // We store the current thread in this wrapperthread location
duke@0 49 // and determine how far away this address is from the structured
duke@0 50 // execption pointer that FS:[0] points to. This get_thread
duke@0 51 // code can then get the thread pointer via FS.
duke@0 52 //
duke@0 53 // Warning: This routine must NEVER be inlined since we'd end up with
duke@0 54 // multiple offsets.
duke@0 55 //
duke@0 56 volatile Thread* wrapperthread = thread;
duke@0 57
duke@0 58 if ( ThreadLocalStorage::get_thread_ptr_offset() == 0 ) {
duke@0 59 int thread_ptr_offset;
duke@0 60 __asm {
duke@0 61 lea eax, dword ptr wrapperthread;
duke@0 62 sub eax, dword ptr FS:[0H];
duke@0 63 mov thread_ptr_offset, eax
duke@0 64 };
duke@0 65 ThreadLocalStorage::set_thread_ptr_offset(thread_ptr_offset);
duke@0 66 }
duke@0 67 #ifdef ASSERT
duke@0 68 // Verify that the offset hasn't changed since we initally captured
duke@0 69 // it. This might happen if we accidentally ended up with an
duke@0 70 // inlined version of this routine.
duke@0 71 else {
duke@0 72 int test_thread_ptr_offset;
duke@0 73 __asm {
duke@0 74 lea eax, dword ptr wrapperthread;
duke@0 75 sub eax, dword ptr FS:[0H];
duke@0 76 mov test_thread_ptr_offset, eax
duke@0 77 };
duke@0 78 assert(test_thread_ptr_offset == ThreadLocalStorage::get_thread_ptr_offset(),
duke@0 79 "thread pointer offset from SEH changed");
duke@0 80 }
duke@0 81 #endif // ASSERT
duke@0 82 #endif // !AMD64
duke@0 83
duke@0 84 f(value, method, args, thread);
duke@0 85 } __except(topLevelExceptionFilter((_EXCEPTION_POINTERS*)_exception_info())) {
duke@0 86 // Nothing to do.
duke@0 87 }
duke@0 88 }
duke@0 89
duke@0 90 #ifdef AMD64
duke@0 91
duke@0 92 // This is the language specific handler for exceptions
duke@0 93 // originating from dynamically generated code.
duke@0 94 // We call the standard structured exception handler
duke@0 95 // We only expect Continued Execution since we cannot unwind
duke@0 96 // from generated code.
duke@0 97 LONG HandleExceptionFromCodeCache(
duke@0 98 IN PEXCEPTION_RECORD ExceptionRecord,
duke@0 99 IN ULONG64 EstablisherFrame,
duke@0 100 IN OUT PCONTEXT ContextRecord,
duke@0 101 IN OUT PDISPATCHER_CONTEXT DispatcherContext) {
duke@0 102 EXCEPTION_POINTERS ep;
duke@0 103 LONG result;
duke@0 104
duke@0 105 ep.ExceptionRecord = ExceptionRecord;
duke@0 106 ep.ContextRecord = ContextRecord;
duke@0 107
duke@0 108 result = topLevelExceptionFilter(&ep);
duke@0 109
duke@0 110 // We better only get a CONTINUE_EXECUTION from our handler
duke@0 111 // since we don't have unwind information registered.
duke@0 112
duke@0 113 guarantee( result == EXCEPTION_CONTINUE_EXECUTION,
duke@0 114 "Unexpected result from topLevelExceptionFilter");
duke@0 115
duke@0 116 return(ExceptionContinueExecution);
duke@0 117 }
duke@0 118
duke@0 119
duke@0 120 // Structure containing the Windows Data Structures required
duke@0 121 // to register our Code Cache exception handler.
duke@0 122 // We put these in the CodeCache since the API requires
duke@0 123 // all addresses in these structures are relative to the Code
duke@0 124 // area registered with RtlAddFunctionTable.
duke@0 125 typedef struct {
duke@0 126 char ExceptionHandlerInstr[16]; // jmp HandleExceptionFromCodeCache
duke@0 127 RUNTIME_FUNCTION rt;
duke@0 128 UNWIND_INFO_EH_ONLY unw;
duke@0 129 } DynamicCodeData, *pDynamicCodeData;
duke@0 130
duke@0 131 #endif // AMD64
duke@0 132 //
duke@0 133 // Register our CodeCache area with the OS so it will dispatch exceptions
duke@0 134 // to our topLevelExceptionFilter when we take an exception in our
duke@0 135 // dynamically generated code.
duke@0 136 //
duke@0 137 // Arguments: low and high are the address of the full reserved
duke@0 138 // codeCache area
duke@0 139 //
duke@0 140 bool os::register_code_area(char *low, char *high) {
duke@0 141 #ifdef AMD64
duke@0 142
duke@0 143 ResourceMark rm;
duke@0 144
duke@0 145 pDynamicCodeData pDCD;
duke@0 146 PRUNTIME_FUNCTION prt;
duke@0 147 PUNWIND_INFO_EH_ONLY punwind;
duke@0 148
duke@0 149 // If we are using Vectored Exceptions we don't need this registration
duke@0 150 if (UseVectoredExceptions) return true;
duke@0 151
duke@0 152 BufferBlob* b = BufferBlob::create("CodeCache Exception Handler", sizeof (DynamicCodeData));
duke@0 153 CodeBuffer cb(b->instructions_begin(), b->instructions_size());
duke@0 154 MacroAssembler* masm = new MacroAssembler(&cb);
duke@0 155 pDCD = (pDynamicCodeData) masm->pc();
duke@0 156
duke@0 157 masm->jump(ExternalAddress((address)&HandleExceptionFromCodeCache));
duke@0 158 masm->flush();
duke@0 159
duke@0 160 // Create an Unwind Structure specifying no unwind info
duke@0 161 // other than an Exception Handler
duke@0 162 punwind = &pDCD->unw;
duke@0 163 punwind->Version = 1;
duke@0 164 punwind->Flags = UNW_FLAG_EHANDLER;
duke@0 165 punwind->SizeOfProlog = 0;
duke@0 166 punwind->CountOfCodes = 0;
duke@0 167 punwind->FrameRegister = 0;
duke@0 168 punwind->FrameOffset = 0;
duke@0 169 punwind->ExceptionHandler = (char *)(&(pDCD->ExceptionHandlerInstr[0])) -
duke@0 170 (char*)low;
duke@0 171 punwind->ExceptionData[0] = 0;
duke@0 172
duke@0 173 // This structure describes the covered dynamic code area.
duke@0 174 // Addresses are relative to the beginning on the code cache area
duke@0 175 prt = &pDCD->rt;
duke@0 176 prt->BeginAddress = 0;
duke@0 177 prt->EndAddress = (ULONG)(high - low);
duke@0 178 prt->UnwindData = ((char *)punwind - low);
duke@0 179
duke@0 180 guarantee(RtlAddFunctionTable(prt, 1, (ULONGLONG)low),
duke@0 181 "Failed to register Dynamic Code Exception Handler with RtlAddFunctionTable");
duke@0 182
duke@0 183 #endif // AMD64
duke@0 184 return true;
duke@0 185 }
duke@0 186
duke@0 187 void os::initialize_thread() {
duke@0 188 // Nothing to do.
duke@0 189 }
duke@0 190
duke@0 191 // Atomics and Stub Functions
duke@0 192
duke@0 193 typedef jint xchg_func_t (jint, volatile jint*);
duke@0 194 typedef intptr_t xchg_ptr_func_t (intptr_t, volatile intptr_t*);
duke@0 195 typedef jint cmpxchg_func_t (jint, volatile jint*, jint);
duke@0 196 typedef jlong cmpxchg_long_func_t (jlong, volatile jlong*, jlong);
duke@0 197 typedef jint add_func_t (jint, volatile jint*);
duke@0 198 typedef intptr_t add_ptr_func_t (intptr_t, volatile intptr_t*);
duke@0 199
duke@0 200 #ifdef AMD64
duke@0 201
duke@0 202 jint os::atomic_xchg_bootstrap(jint exchange_value, volatile jint* dest) {
duke@0 203 // try to use the stub:
duke@0 204 xchg_func_t* func = CAST_TO_FN_PTR(xchg_func_t*, StubRoutines::atomic_xchg_entry());
duke@0 205
duke@0 206 if (func != NULL) {
duke@0 207 os::atomic_xchg_func = func;
duke@0 208 return (*func)(exchange_value, dest);
duke@0 209 }
duke@0 210 assert(Threads::number_of_threads() == 0, "for bootstrap only");
duke@0 211
duke@0 212 jint old_value = *dest;
duke@0 213 *dest = exchange_value;
duke@0 214 return old_value;
duke@0 215 }
duke@0 216
duke@0 217 intptr_t os::atomic_xchg_ptr_bootstrap(intptr_t exchange_value, volatile intptr_t* dest) {
duke@0 218 // try to use the stub:
duke@0 219 xchg_ptr_func_t* func = CAST_TO_FN_PTR(xchg_ptr_func_t*, StubRoutines::atomic_xchg_ptr_entry());
duke@0 220
duke@0 221 if (func != NULL) {
duke@0 222 os::atomic_xchg_ptr_func = func;
duke@0 223 return (*func)(exchange_value, dest);
duke@0 224 }
duke@0 225 assert(Threads::number_of_threads() == 0, "for bootstrap only");
duke@0 226
duke@0 227 intptr_t old_value = *dest;
duke@0 228 *dest = exchange_value;
duke@0 229 return old_value;
duke@0 230 }
duke@0 231
duke@0 232
duke@0 233 jint os::atomic_cmpxchg_bootstrap(jint exchange_value, volatile jint* dest, jint compare_value) {
duke@0 234 // try to use the stub:
duke@0 235 cmpxchg_func_t* func = CAST_TO_FN_PTR(cmpxchg_func_t*, StubRoutines::atomic_cmpxchg_entry());
duke@0 236
duke@0 237 if (func != NULL) {
duke@0 238 os::atomic_cmpxchg_func = func;
duke@0 239 return (*func)(exchange_value, dest, compare_value);
duke@0 240 }
duke@0 241 assert(Threads::number_of_threads() == 0, "for bootstrap only");
duke@0 242
duke@0 243 jint old_value = *dest;
duke@0 244 if (old_value == compare_value)
duke@0 245 *dest = exchange_value;
duke@0 246 return old_value;
duke@0 247 }
duke@0 248 #endif // AMD64
duke@0 249
duke@0 250 jlong os::atomic_cmpxchg_long_bootstrap(jlong exchange_value, volatile jlong* dest, jlong compare_value) {
duke@0 251 // try to use the stub:
duke@0 252 cmpxchg_long_func_t* func = CAST_TO_FN_PTR(cmpxchg_long_func_t*, StubRoutines::atomic_cmpxchg_long_entry());
duke@0 253
duke@0 254 if (func != NULL) {
duke@0 255 os::atomic_cmpxchg_long_func = func;
duke@0 256 return (*func)(exchange_value, dest, compare_value);
duke@0 257 }
duke@0 258 assert(Threads::number_of_threads() == 0, "for bootstrap only");
duke@0 259
duke@0 260 jlong old_value = *dest;
duke@0 261 if (old_value == compare_value)
duke@0 262 *dest = exchange_value;
duke@0 263 return old_value;
duke@0 264 }
duke@0 265
duke@0 266 #ifdef AMD64
duke@0 267
duke@0 268 jint os::atomic_add_bootstrap(jint add_value, volatile jint* dest) {
duke@0 269 // try to use the stub:
duke@0 270 add_func_t* func = CAST_TO_FN_PTR(add_func_t*, StubRoutines::atomic_add_entry());
duke@0 271
duke@0 272 if (func != NULL) {
duke@0 273 os::atomic_add_func = func;
duke@0 274 return (*func)(add_value, dest);
duke@0 275 }
duke@0 276 assert(Threads::number_of_threads() == 0, "for bootstrap only");
duke@0 277
duke@0 278 return (*dest) += add_value;
duke@0 279 }
duke@0 280
duke@0 281 intptr_t os::atomic_add_ptr_bootstrap(intptr_t add_value, volatile intptr_t* dest) {
duke@0 282 // try to use the stub:
duke@0 283 add_ptr_func_t* func = CAST_TO_FN_PTR(add_ptr_func_t*, StubRoutines::atomic_add_ptr_entry());
duke@0 284
duke@0 285 if (func != NULL) {
duke@0 286 os::atomic_add_ptr_func = func;
duke@0 287 return (*func)(add_value, dest);
duke@0 288 }
duke@0 289 assert(Threads::number_of_threads() == 0, "for bootstrap only");
duke@0 290
duke@0 291 return (*dest) += add_value;
duke@0 292 }
duke@0 293
duke@0 294 xchg_func_t* os::atomic_xchg_func = os::atomic_xchg_bootstrap;
duke@0 295 xchg_ptr_func_t* os::atomic_xchg_ptr_func = os::atomic_xchg_ptr_bootstrap;
duke@0 296 cmpxchg_func_t* os::atomic_cmpxchg_func = os::atomic_cmpxchg_bootstrap;
duke@0 297 add_func_t* os::atomic_add_func = os::atomic_add_bootstrap;
duke@0 298 add_ptr_func_t* os::atomic_add_ptr_func = os::atomic_add_ptr_bootstrap;
duke@0 299
duke@0 300 #endif // AMD64
duke@0 301
duke@0 302 cmpxchg_long_func_t* os::atomic_cmpxchg_long_func = os::atomic_cmpxchg_long_bootstrap;
duke@0 303
duke@0 304 ExtendedPC os::fetch_frame_from_context(void* ucVoid,
duke@0 305 intptr_t** ret_sp, intptr_t** ret_fp) {
duke@0 306
duke@0 307 ExtendedPC epc;
duke@0 308 CONTEXT* uc = (CONTEXT*)ucVoid;
duke@0 309
duke@0 310 if (uc != NULL) {
duke@0 311 epc = ExtendedPC((address)uc->REG_PC);
duke@0 312 if (ret_sp) *ret_sp = (intptr_t*)uc->REG_SP;
duke@0 313 if (ret_fp) *ret_fp = (intptr_t*)uc->REG_FP;
duke@0 314 } else {
duke@0 315 // construct empty ExtendedPC for return value checking
duke@0 316 epc = ExtendedPC(NULL);
duke@0 317 if (ret_sp) *ret_sp = (intptr_t *)NULL;
duke@0 318 if (ret_fp) *ret_fp = (intptr_t *)NULL;
duke@0 319 }
duke@0 320
duke@0 321 return epc;
duke@0 322 }
duke@0 323
duke@0 324 frame os::fetch_frame_from_context(void* ucVoid) {
duke@0 325 intptr_t* sp;
duke@0 326 intptr_t* fp;
duke@0 327 ExtendedPC epc = fetch_frame_from_context(ucVoid, &sp, &fp);
duke@0 328 return frame(sp, fp, epc.pc());
duke@0 329 }
duke@0 330
duke@0 331 // VC++ does not save frame pointer on stack in optimized build. It
duke@0 332 // can be turned off by /Oy-. If we really want to walk C frames,
duke@0 333 // we can use the StackWalk() API.
duke@0 334 frame os::get_sender_for_C_frame(frame* fr) {
duke@0 335 return frame(fr->sender_sp(), fr->link(), fr->sender_pc());
duke@0 336 }
duke@0 337
duke@0 338
duke@0 339 #ifndef AMD64
duke@0 340 intptr_t* _get_previous_fp() {
duke@0 341 intptr_t **frameptr;
duke@0 342 __asm {
duke@0 343 mov frameptr, ebp
duke@0 344 };
duke@0 345 return *frameptr;
duke@0 346 }
duke@0 347 #endif // !AMD64
duke@0 348
duke@0 349 frame os::current_frame() {
duke@0 350
duke@0 351 #ifdef AMD64
duke@0 352 // apparently _asm not supported on windows amd64
duke@0 353 typedef intptr_t* get_fp_func ();
duke@0 354 get_fp_func* func = CAST_TO_FN_PTR(get_fp_func*,
never@304 355 StubRoutines::x86::get_previous_fp_entry());
duke@0 356 if (func == NULL) return frame(NULL, NULL, NULL);
duke@0 357 intptr_t* fp = (*func)();
duke@0 358 #else
duke@0 359 intptr_t* fp = _get_previous_fp();
duke@0 360 #endif // AMD64
duke@0 361
duke@0 362 frame myframe((intptr_t*)os::current_stack_pointer(),
duke@0 363 (intptr_t*)fp,
duke@0 364 CAST_FROM_FN_PTR(address, os::current_frame));
duke@0 365 if (os::is_first_C_frame(&myframe)) {
duke@0 366 // stack is not walkable
duke@0 367 return frame(NULL, NULL, NULL);
duke@0 368 } else {
duke@0 369 return os::get_sender_for_C_frame(&myframe);
duke@0 370 }
duke@0 371 }
duke@0 372
duke@0 373 void os::print_context(outputStream *st, void *context) {
duke@0 374 if (context == NULL) return;
duke@0 375
duke@0 376 CONTEXT* uc = (CONTEXT*)context;
duke@0 377
duke@0 378 st->print_cr("Registers:");
duke@0 379 #ifdef AMD64
bobv@1601 380 st->print( "RAX=" INTPTR_FORMAT, uc->Rax);
bobv@1601 381 st->print(", RBX=" INTPTR_FORMAT, uc->Rbx);
bobv@1601 382 st->print(", RCX=" INTPTR_FORMAT, uc->Rcx);
bobv@1601 383 st->print(", RDX=" INTPTR_FORMAT, uc->Rdx);
duke@0 384 st->cr();
bobv@1601 385 st->print( "RSP=" INTPTR_FORMAT, uc->Rsp);
bobv@1601 386 st->print(", RBP=" INTPTR_FORMAT, uc->Rbp);
bobv@1601 387 st->print(", RSI=" INTPTR_FORMAT, uc->Rsi);
bobv@1601 388 st->print(", RDI=" INTPTR_FORMAT, uc->Rdi);
duke@0 389 st->cr();
bobv@1601 390 st->print( "R8=" INTPTR_FORMAT, uc->R8);
bobv@1601 391 st->print(", R9=" INTPTR_FORMAT, uc->R9);
bobv@1601 392 st->print(", R10=" INTPTR_FORMAT, uc->R10);
bobv@1601 393 st->print(", R11=" INTPTR_FORMAT, uc->R11);
bobv@1601 394 st->cr();
bobv@1601 395 st->print( "R12=" INTPTR_FORMAT, uc->R12);
bobv@1601 396 st->print(", R13=" INTPTR_FORMAT, uc->R13);
bobv@1601 397 st->print(", R14=" INTPTR_FORMAT, uc->R14);
bobv@1601 398 st->print(", R15=" INTPTR_FORMAT, uc->R15);
bobv@1601 399 st->cr();
bobv@1601 400 st->print( "RIP=" INTPTR_FORMAT, uc->Rip);
duke@0 401 st->print(", EFLAGS=" INTPTR_FORMAT, uc->EFlags);
bobv@1601 402
bobv@1601 403 st->cr();
bobv@1601 404 st->cr();
bobv@1601 405
bobv@1601 406 st->print_cr("Register to memory mapping:");
bobv@1601 407 st->cr();
bobv@1601 408
bobv@1601 409 // this is only for the "general purpose" registers
bobv@1601 410
bobv@1601 411 st->print_cr("RAX=" INTPTR_FORMAT, uc->Rax);
bobv@1601 412 print_location(st, uc->Rax);
bobv@1601 413 st->cr();
bobv@1601 414 st->print_cr("RBX=" INTPTR_FORMAT, uc->Rbx);
bobv@1601 415 print_location(st, uc->Rbx);
bobv@1601 416 st->cr();
bobv@1601 417 st->print_cr("RCX=" INTPTR_FORMAT, uc->Rcx);
bobv@1601 418 print_location(st, uc->Rcx);
bobv@1601 419 st->cr();
bobv@1601 420 st->print_cr("RDX=" INTPTR_FORMAT, uc->Rdx);
bobv@1601 421 print_location(st, uc->Rdx);
bobv@1601 422 st->cr();
bobv@1601 423 st->print_cr("RSP=" INTPTR_FORMAT, uc->Rsp);
bobv@1601 424 print_location(st, uc->Rsp);
bobv@1601 425 st->cr();
bobv@1601 426 st->print_cr("RBP=" INTPTR_FORMAT, uc->Rbp);
bobv@1601 427 print_location(st, uc->Rbp);
bobv@1601 428 st->cr();
bobv@1601 429 st->print_cr("RSI=" INTPTR_FORMAT, uc->Rsi);
bobv@1601 430 print_location(st, uc->Rsi);
bobv@1601 431 st->cr();
bobv@1601 432 st->print_cr("RDI=" INTPTR_FORMAT, uc->Rdi);
bobv@1601 433 print_location(st, uc->Rdi);
bobv@1601 434 st->cr();
bobv@1601 435 st->print_cr("R8 =" INTPTR_FORMAT, uc->R8);
bobv@1601 436 print_location(st, uc->R8);
bobv@1601 437 st->cr();
bobv@1601 438 st->print_cr("R9 =" INTPTR_FORMAT, uc->R9);
bobv@1601 439 print_location(st, uc->R9);
bobv@1601 440 st->cr();
bobv@1601 441 st->print_cr("R10=" INTPTR_FORMAT, uc->R10);
bobv@1601 442 print_location(st, uc->R10);
bobv@1601 443 st->cr();
bobv@1601 444 st->print_cr("R11=" INTPTR_FORMAT, uc->R11);
bobv@1601 445 print_location(st, uc->R11);
bobv@1601 446 st->cr();
bobv@1601 447 st->print_cr("R12=" INTPTR_FORMAT, uc->R12);
bobv@1601 448 print_location(st, uc->R12);
bobv@1601 449 st->cr();
bobv@1601 450 st->print_cr("R13=" INTPTR_FORMAT, uc->R13);
bobv@1601 451 print_location(st, uc->R13);
bobv@1601 452 st->cr();
bobv@1601 453 st->print_cr("R14=" INTPTR_FORMAT, uc->R14);
bobv@1601 454 print_location(st, uc->R14);
bobv@1601 455 st->cr();
bobv@1601 456 st->print_cr("R15=" INTPTR_FORMAT, uc->R15);
bobv@1601 457 print_location(st, uc->R15);
duke@0 458 #else
duke@0 459 st->print( "EAX=" INTPTR_FORMAT, uc->Eax);
duke@0 460 st->print(", EBX=" INTPTR_FORMAT, uc->Ebx);
duke@0 461 st->print(", ECX=" INTPTR_FORMAT, uc->Ecx);
duke@0 462 st->print(", EDX=" INTPTR_FORMAT, uc->Edx);
duke@0 463 st->cr();
duke@0 464 st->print( "ESP=" INTPTR_FORMAT, uc->Esp);
duke@0 465 st->print(", EBP=" INTPTR_FORMAT, uc->Ebp);
duke@0 466 st->print(", ESI=" INTPTR_FORMAT, uc->Esi);
duke@0 467 st->print(", EDI=" INTPTR_FORMAT, uc->Edi);
duke@0 468 st->cr();
duke@0 469 st->print( "EIP=" INTPTR_FORMAT, uc->Eip);
duke@0 470 st->print(", EFLAGS=" INTPTR_FORMAT, uc->EFlags);
bobv@1601 471
bobv@1601 472 st->cr();
bobv@1601 473 st->cr();
bobv@1601 474
bobv@1601 475 st->print_cr("Register to memory mapping:");
bobv@1601 476 st->cr();
bobv@1601 477
bobv@1601 478 // this is only for the "general purpose" registers
bobv@1601 479
bobv@1601 480 st->print_cr("EAX=" INTPTR_FORMAT, uc->Eax);
bobv@1601 481 print_location(st, uc->Eax);
bobv@1601 482 st->cr();
bobv@1601 483 st->print_cr("EBX=" INTPTR_FORMAT, uc->Ebx);
bobv@1601 484 print_location(st, uc->Ebx);
bobv@1601 485 st->cr();
bobv@1601 486 st->print_cr("ECX=" INTPTR_FORMAT, uc->Ecx);
bobv@1601 487 print_location(st, uc->Ecx);
bobv@1601 488 st->cr();
bobv@1601 489 st->print_cr("EDX=" INTPTR_FORMAT, uc->Edx);
bobv@1601 490 print_location(st, uc->Edx);
bobv@1601 491 st->cr();
bobv@1601 492 st->print_cr("ESP=" INTPTR_FORMAT, uc->Esp);
bobv@1601 493 print_location(st, uc->Esp);
bobv@1601 494 st->cr();
bobv@1601 495 st->print_cr("EBP=" INTPTR_FORMAT, uc->Ebp);
bobv@1601 496 print_location(st, uc->Ebp);
bobv@1601 497 st->cr();
bobv@1601 498 st->print_cr("ESI=" INTPTR_FORMAT, uc->Esi);
bobv@1601 499 print_location(st, uc->Esi);
bobv@1601 500 st->cr();
bobv@1601 501 st->print_cr("EDI=" INTPTR_FORMAT, uc->Edi);
bobv@1601 502 print_location(st, uc->Edi);
duke@0 503 #endif // AMD64
duke@0 504 st->cr();
duke@0 505 st->cr();
duke@0 506
duke@0 507 intptr_t *sp = (intptr_t *)uc->REG_SP;
duke@0 508 st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp);
duke@0 509 print_hex_dump(st, (address)sp, (address)(sp + 32), sizeof(intptr_t));
duke@0 510 st->cr();
duke@0 511
duke@0 512 // Note: it may be unsafe to inspect memory near pc. For example, pc may
duke@0 513 // point to garbage if entry point in an nmethod is corrupted. Leave
duke@0 514 // this at the end, and hope for the best.
duke@0 515 address pc = (address)uc->REG_PC;
duke@0 516 st->print_cr("Instructions: (pc=" PTR_FORMAT ")", pc);
duke@0 517 print_hex_dump(st, pc - 16, pc + 16, sizeof(char));
duke@0 518 st->cr();
duke@0 519 }
duke@0 520
duke@0 521 extern "C" int SafeFetch32 (int * adr, int Err) {
duke@0 522 int rv = Err ;
duke@0 523 _try {
duke@0 524 rv = *((volatile int *) adr) ;
duke@0 525 } __except(EXCEPTION_EXECUTE_HANDLER) {
duke@0 526 }
duke@0 527 return rv ;
duke@0 528 }
duke@0 529
duke@0 530 extern "C" intptr_t SafeFetchN (intptr_t * adr, intptr_t Err) {
duke@0 531 intptr_t rv = Err ;
duke@0 532 _try {
duke@0 533 rv = *((volatile intptr_t *) adr) ;
duke@0 534 } __except(EXCEPTION_EXECUTE_HANDLER) {
duke@0 535 }
duke@0 536 return rv ;
duke@0 537 }
duke@0 538
duke@0 539 extern "C" int SpinPause () {
duke@0 540 #ifdef AMD64
duke@0 541 return 0 ;
duke@0 542 #else
duke@0 543 // pause == rep:nop
duke@0 544 // On systems that don't support pause a rep:nop
duke@0 545 // is executed as a nop. The rep: prefix is ignored.
duke@0 546 _asm {
duke@0 547 pause ;
duke@0 548 };
duke@0 549 return 1 ;
duke@0 550 #endif // AMD64
duke@0 551 }
duke@0 552
duke@0 553
duke@0 554 void os::setup_fpu() {
duke@0 555 #ifndef AMD64
duke@0 556 int fpu_cntrl_word = StubRoutines::fpu_cntrl_wrd_std();
duke@0 557 __asm fldcw fpu_cntrl_word;
duke@0 558 #endif // !AMD64
duke@0 559 }