equal
deleted
inserted
replaced
20 * or visit www.oracle.com if you need additional information or have any |
20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. |
21 * questions. |
22 * |
22 * |
23 */ |
23 */ |
24 |
24 |
25 // Must be at least Windows 2000 or XP to use VectoredExceptions and IsDebuggerPresent |
25 // Must be at least Windows 2000 or XP to use IsDebuggerPresent |
26 #define _WIN32_WINNT 0x500 |
26 #define _WIN32_WINNT 0x500 |
27 |
27 |
28 // no precompiled headers |
28 // no precompiled headers |
29 #include "classfile/classLoader.hpp" |
29 #include "classfile/classLoader.hpp" |
30 #include "classfile/systemDictionary.hpp" |
30 #include "classfile/systemDictionary.hpp" |
108 static FILETIME process_creation_time; |
108 static FILETIME process_creation_time; |
109 static FILETIME process_exit_time; |
109 static FILETIME process_exit_time; |
110 static FILETIME process_user_time; |
110 static FILETIME process_user_time; |
111 static FILETIME process_kernel_time; |
111 static FILETIME process_kernel_time; |
112 |
112 |
113 #ifdef _WIN64 |
|
114 PVOID topLevelVectoredExceptionHandler = NULL; |
|
115 #endif |
|
116 |
|
117 #ifdef _M_IA64 |
113 #ifdef _M_IA64 |
118 #define __CPU__ ia64 |
114 #define __CPU__ ia64 |
119 #elif _M_AMD64 |
115 #elif _M_AMD64 |
120 #define __CPU__ amd64 |
116 #define __CPU__ amd64 |
121 #else |
117 #else |
134 timeBeginPeriod(1L); |
130 timeBeginPeriod(1L); |
135 break; |
131 break; |
136 case DLL_PROCESS_DETACH: |
132 case DLL_PROCESS_DETACH: |
137 if(ForceTimeHighResolution) |
133 if(ForceTimeHighResolution) |
138 timeEndPeriod(1L); |
134 timeEndPeriod(1L); |
139 #ifdef _WIN64 |
|
140 if (topLevelVectoredExceptionHandler != NULL) { |
|
141 RemoveVectoredExceptionHandler(topLevelVectoredExceptionHandler); |
|
142 topLevelVectoredExceptionHandler = NULL; |
|
143 } |
|
144 #endif |
|
145 break; |
135 break; |
146 default: |
136 default: |
147 break; |
137 break; |
148 } |
138 } |
149 return true; |
139 return true; |
406 thread->set_lgrp_id(lgrp_id); |
396 thread->set_lgrp_id(lgrp_id); |
407 } |
397 } |
408 } |
398 } |
409 |
399 |
410 |
400 |
411 if (UseVectoredExceptions) { |
401 // Install a win32 structured exception handler around every thread created |
412 // If we are using vectored exception we don't need to set a SEH |
402 // by VM, so VM can genrate error dump when an exception occurred in non- |
413 thread->run(); |
403 // Java thread (e.g. VM thread). |
414 } |
404 __try { |
415 else { |
405 thread->run(); |
416 // Install a win32 structured exception handler around every thread created |
406 } __except(topLevelExceptionFilter( |
417 // by VM, so VM can genrate error dump when an exception occurred in non- |
407 (_EXCEPTION_POINTERS*)_exception_info())) { |
418 // Java thread (e.g. VM thread). |
408 // Nothing to do. |
419 __try { |
|
420 thread->run(); |
|
421 } __except(topLevelExceptionFilter( |
|
422 (_EXCEPTION_POINTERS*)_exception_info())) { |
|
423 // Nothing to do. |
|
424 } |
|
425 } |
409 } |
426 |
410 |
427 // One less thread is executing |
411 // One less thread is executing |
428 // When the VMThread gets here, the main thread may have already exited |
412 // When the VMThread gets here, the main thread may have already exited |
429 // which frees the CodeHeap containing the Atomic::add code |
413 // which frees the CodeHeap containing the Atomic::add code |
2487 return Handle_Exception(exceptionInfo, addr); |
2471 return Handle_Exception(exceptionInfo, addr); |
2488 } |
2472 } |
2489 } |
2473 } |
2490 #endif |
2474 #endif |
2491 |
2475 |
2492 #ifdef _WIN64 |
|
2493 // Windows will sometimes generate an access violation |
|
2494 // when we call malloc. Since we use VectoredExceptions |
|
2495 // on 64 bit platforms, we see this exception. We must |
|
2496 // pass this exception on so Windows can recover. |
|
2497 // We check to see if the pc of the fault is in NTDLL.DLL |
|
2498 // if so, we pass control on to Windows for handling. |
|
2499 if (UseVectoredExceptions && _addr_in_ntdll(pc)) return EXCEPTION_CONTINUE_SEARCH; |
|
2500 #endif |
|
2501 |
|
2502 // Stack overflow or null pointer exception in native code. |
2476 // Stack overflow or null pointer exception in native code. |
2503 report_error(t, exception_code, pc, exceptionInfo->ExceptionRecord, |
2477 report_error(t, exception_code, pc, exceptionInfo->ExceptionRecord, |
2504 exceptionInfo->ContextRecord); |
2478 exceptionInfo->ContextRecord); |
2505 return EXCEPTION_CONTINUE_SEARCH; |
2479 return EXCEPTION_CONTINUE_SEARCH; |
2506 } |
2480 } |
2525 } |
2499 } |
2526 #endif //_WIN64 |
2500 #endif //_WIN64 |
2527 } |
2501 } |
2528 |
2502 |
2529 if (exception_code != EXCEPTION_BREAKPOINT) { |
2503 if (exception_code != EXCEPTION_BREAKPOINT) { |
2530 #ifndef _WIN64 |
|
2531 report_error(t, exception_code, pc, exceptionInfo->ExceptionRecord, |
2504 report_error(t, exception_code, pc, exceptionInfo->ExceptionRecord, |
2532 exceptionInfo->ContextRecord); |
2505 exceptionInfo->ContextRecord); |
2533 #else |
|
2534 // Itanium Windows uses a VectoredExceptionHandler |
|
2535 // Which means that C++ programatic exception handlers (try/except) |
|
2536 // will get here. Continue the search for the right except block if |
|
2537 // the exception code is not a fatal code. |
|
2538 switch ( exception_code ) { |
|
2539 case EXCEPTION_ACCESS_VIOLATION: |
|
2540 case EXCEPTION_STACK_OVERFLOW: |
|
2541 case EXCEPTION_ILLEGAL_INSTRUCTION: |
|
2542 case EXCEPTION_ILLEGAL_INSTRUCTION_2: |
|
2543 case EXCEPTION_INT_OVERFLOW: |
|
2544 case EXCEPTION_INT_DIVIDE_BY_ZERO: |
|
2545 case EXCEPTION_UNCAUGHT_CXX_EXCEPTION: |
|
2546 { report_error(t, exception_code, pc, exceptionInfo->ExceptionRecord, |
|
2547 exceptionInfo->ContextRecord); |
|
2548 } |
|
2549 break; |
|
2550 default: |
|
2551 break; |
|
2552 } |
|
2553 #endif |
|
2554 } |
2506 } |
2555 return EXCEPTION_CONTINUE_SEARCH; |
2507 return EXCEPTION_CONTINUE_SEARCH; |
2556 } |
2508 } |
2557 |
2509 |
2558 #ifndef _WIN64 |
2510 #ifndef _WIN64 |
3703 } |
3655 } |
3704 |
3656 |
3705 os::large_page_init(); |
3657 os::large_page_init(); |
3706 |
3658 |
3707 // Setup Windows Exceptions |
3659 // Setup Windows Exceptions |
3708 |
|
3709 // On Itanium systems, Structured Exception Handling does not |
|
3710 // work since stack frames must be walkable by the OS. Since |
|
3711 // much of our code is dynamically generated, and we do not have |
|
3712 // proper unwind .xdata sections, the system simply exits |
|
3713 // rather than delivering the exception. To work around |
|
3714 // this we use VectorExceptions instead. |
|
3715 #ifdef _WIN64 |
|
3716 if (UseVectoredExceptions) { |
|
3717 topLevelVectoredExceptionHandler = AddVectoredExceptionHandler( 1, topLevelExceptionFilter); |
|
3718 } |
|
3719 #endif |
|
3720 |
3660 |
3721 // for debugging float code generation bugs |
3661 // for debugging float code generation bugs |
3722 if (ForceFloatExceptions) { |
3662 if (ForceFloatExceptions) { |
3723 #ifndef _WIN64 |
3663 #ifndef _WIN64 |
3724 static long fp_control_word = 0; |
3664 static long fp_control_word = 0; |