Mercurial > hg > truffle
comparison src/os/windows/vm/os_windows.cpp @ 6948:e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 12 Nov 2012 23:14:12 +0100 |
parents | 957c266d8bc5 5ec0c42da025 |
children | 2cb439954abf |
comparison
equal
deleted
inserted
replaced
6711:ae13cc658b80 | 6948:e522a00b91aa |
---|---|
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" |
67 #include "utilities/vmError.hpp" | 67 #include "utilities/vmError.hpp" |
68 #ifdef TARGET_ARCH_x86 | 68 #ifdef TARGET_ARCH_x86 |
69 # include "assembler_x86.inline.hpp" | 69 # include "assembler_x86.inline.hpp" |
70 # include "nativeInst_x86.hpp" | 70 # include "nativeInst_x86.hpp" |
71 #endif | 71 #endif |
72 #ifdef COMPILER1 | |
73 #include "c1/c1_Runtime1.hpp" | |
74 #endif | |
75 #ifdef COMPILER2 | |
76 #include "opto/runtime.hpp" | |
77 #endif | |
78 | 72 |
79 #ifdef _DEBUG | 73 #ifdef _DEBUG |
80 #include <crtdbg.h> | 74 #include <crtdbg.h> |
81 #endif | 75 #endif |
82 | 76 |
114 static FILETIME process_creation_time; | 108 static FILETIME process_creation_time; |
115 static FILETIME process_exit_time; | 109 static FILETIME process_exit_time; |
116 static FILETIME process_user_time; | 110 static FILETIME process_user_time; |
117 static FILETIME process_kernel_time; | 111 static FILETIME process_kernel_time; |
118 | 112 |
119 #ifdef _WIN64 | |
120 PVOID topLevelVectoredExceptionHandler = NULL; | |
121 #endif | |
122 | |
123 #ifdef _M_IA64 | 113 #ifdef _M_IA64 |
124 #define __CPU__ ia64 | 114 #define __CPU__ ia64 |
125 #elif _M_AMD64 | 115 #elif _M_AMD64 |
126 #define __CPU__ amd64 | 116 #define __CPU__ amd64 |
127 #else | 117 #else |
140 timeBeginPeriod(1L); | 130 timeBeginPeriod(1L); |
141 break; | 131 break; |
142 case DLL_PROCESS_DETACH: | 132 case DLL_PROCESS_DETACH: |
143 if(ForceTimeHighResolution) | 133 if(ForceTimeHighResolution) |
144 timeEndPeriod(1L); | 134 timeEndPeriod(1L); |
145 #ifdef _WIN64 | |
146 if (topLevelVectoredExceptionHandler != NULL) { | |
147 RemoveVectoredExceptionHandler(topLevelVectoredExceptionHandler); | |
148 topLevelVectoredExceptionHandler = NULL; | |
149 } | |
150 #endif | |
151 break; | 135 break; |
152 default: | 136 default: |
153 break; | 137 break; |
154 } | 138 } |
155 return true; | 139 return true; |
412 thread->set_lgrp_id(lgrp_id); | 396 thread->set_lgrp_id(lgrp_id); |
413 } | 397 } |
414 } | 398 } |
415 | 399 |
416 | 400 |
417 if (UseVectoredExceptions) { | 401 // Install a win32 structured exception handler around every thread created |
418 // 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- |
419 thread->run(); | 403 // Java thread (e.g. VM thread). |
420 } | 404 __try { |
421 else { | 405 thread->run(); |
422 // Install a win32 structured exception handler around every thread created | 406 } __except(topLevelExceptionFilter( |
423 // by VM, so VM can genrate error dump when an exception occurred in non- | 407 (_EXCEPTION_POINTERS*)_exception_info())) { |
424 // Java thread (e.g. VM thread). | 408 // Nothing to do. |
425 __try { | |
426 thread->run(); | |
427 } __except(topLevelExceptionFilter( | |
428 (_EXCEPTION_POINTERS*)_exception_info())) { | |
429 // Nothing to do. | |
430 } | |
431 } | 409 } |
432 | 410 |
433 // One less thread is executing | 411 // One less thread is executing |
434 // 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 |
435 // which frees the CodeHeap containing the Atomic::add code | 413 // which frees the CodeHeap containing the Atomic::add code |
2495 return Handle_Exception(exceptionInfo, addr); | 2473 return Handle_Exception(exceptionInfo, addr); |
2496 } | 2474 } |
2497 } | 2475 } |
2498 #endif | 2476 #endif |
2499 | 2477 |
2500 #ifdef _WIN64 | |
2501 // Windows will sometimes generate an access violation | |
2502 // when we call malloc. Since we use VectoredExceptions | |
2503 // on 64 bit platforms, we see this exception. We must | |
2504 // pass this exception on so Windows can recover. | |
2505 // We check to see if the pc of the fault is in NTDLL.DLL | |
2506 // if so, we pass control on to Windows for handling. | |
2507 if (UseVectoredExceptions && _addr_in_ntdll(pc)) return EXCEPTION_CONTINUE_SEARCH; | |
2508 #endif | |
2509 | |
2510 // Stack overflow or null pointer exception in native code. | 2478 // Stack overflow or null pointer exception in native code. |
2511 report_error(t, exception_code, pc, exceptionInfo->ExceptionRecord, | 2479 report_error(t, exception_code, pc, exceptionInfo->ExceptionRecord, |
2512 exceptionInfo->ContextRecord); | 2480 exceptionInfo->ContextRecord); |
2513 return EXCEPTION_CONTINUE_SEARCH; | 2481 return EXCEPTION_CONTINUE_SEARCH; |
2514 } | 2482 } |
2533 } | 2501 } |
2534 #endif //_WIN64 | 2502 #endif //_WIN64 |
2535 } | 2503 } |
2536 | 2504 |
2537 if (exception_code != EXCEPTION_BREAKPOINT) { | 2505 if (exception_code != EXCEPTION_BREAKPOINT) { |
2538 #ifndef _WIN64 | |
2539 report_error(t, exception_code, pc, exceptionInfo->ExceptionRecord, | 2506 report_error(t, exception_code, pc, exceptionInfo->ExceptionRecord, |
2540 exceptionInfo->ContextRecord); | 2507 exceptionInfo->ContextRecord); |
2541 #else | |
2542 // Itanium Windows uses a VectoredExceptionHandler | |
2543 // Which means that C++ programatic exception handlers (try/except) | |
2544 // will get here. Continue the search for the right except block if | |
2545 // the exception code is not a fatal code. | |
2546 switch ( exception_code ) { | |
2547 case EXCEPTION_ACCESS_VIOLATION: | |
2548 case EXCEPTION_STACK_OVERFLOW: | |
2549 case EXCEPTION_ILLEGAL_INSTRUCTION: | |
2550 case EXCEPTION_ILLEGAL_INSTRUCTION_2: | |
2551 case EXCEPTION_INT_OVERFLOW: | |
2552 case EXCEPTION_INT_DIVIDE_BY_ZERO: | |
2553 case EXCEPTION_UNCAUGHT_CXX_EXCEPTION: | |
2554 { report_error(t, exception_code, pc, exceptionInfo->ExceptionRecord, | |
2555 exceptionInfo->ContextRecord); | |
2556 } | |
2557 break; | |
2558 default: | |
2559 break; | |
2560 } | |
2561 #endif | |
2562 } | 2508 } |
2563 return EXCEPTION_CONTINUE_SEARCH; | 2509 return EXCEPTION_CONTINUE_SEARCH; |
2564 } | 2510 } |
2565 | 2511 |
2566 #ifndef _WIN64 | 2512 #ifndef _WIN64 |
3711 } | 3657 } |
3712 | 3658 |
3713 os::large_page_init(); | 3659 os::large_page_init(); |
3714 | 3660 |
3715 // Setup Windows Exceptions | 3661 // Setup Windows Exceptions |
3716 | |
3717 // On Itanium systems, Structured Exception Handling does not | |
3718 // work since stack frames must be walkable by the OS. Since | |
3719 // much of our code is dynamically generated, and we do not have | |
3720 // proper unwind .xdata sections, the system simply exits | |
3721 // rather than delivering the exception. To work around | |
3722 // this we use VectorExceptions instead. | |
3723 #ifdef _WIN64 | |
3724 if (UseVectoredExceptions) { | |
3725 topLevelVectoredExceptionHandler = AddVectoredExceptionHandler( 1, topLevelExceptionFilter); | |
3726 } | |
3727 #endif | |
3728 | 3662 |
3729 // for debugging float code generation bugs | 3663 // for debugging float code generation bugs |
3730 if (ForceFloatExceptions) { | 3664 if (ForceFloatExceptions) { |
3731 #ifndef _WIN64 | 3665 #ifndef _WIN64 |
3732 static long fp_control_word = 0; | 3666 static long fp_control_word = 0; |