Mercurial > hg > truffle
comparison src/os/windows/vm/os_windows.cpp @ 1214:0fc941df6fb7
6918421: 1/1 in-process JVM now ignores preset Windows unhandled exception filter
Summary: Add support for chaining Windows UnhandledExceptionFilter handlers
Reviewed-by: kamg, dholmes, never, acorn, ikrylov
author | dcubed |
---|---|
date | Tue, 02 Feb 2010 10:37:32 -0700 |
parents | 24fda36852ce |
children | f19bf22685cc |
comparison
equal
deleted
inserted
replaced
1184:7fbf850d87b7 | 1214:0fc941df6fb7 |
---|---|
1 /* | 1 /* |
2 * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. | 2 * Copyright 1997-2010 Sun Microsystems, Inc. All Rights Reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
140 void os::run_periodic_checks() { | 140 void os::run_periodic_checks() { |
141 return; | 141 return; |
142 } | 142 } |
143 | 143 |
144 #ifndef _WIN64 | 144 #ifndef _WIN64 |
145 // previous UnhandledExceptionFilter, if there is one | |
146 static LPTOP_LEVEL_EXCEPTION_FILTER prev_uef_handler = NULL; | |
147 | |
145 LONG WINAPI Handle_FLT_Exception(struct _EXCEPTION_POINTERS* exceptionInfo); | 148 LONG WINAPI Handle_FLT_Exception(struct _EXCEPTION_POINTERS* exceptionInfo); |
146 #endif | 149 #endif |
147 void os::init_system_properties_values() { | 150 void os::init_system_properties_values() { |
148 /* sysclasspath, java_home, dll_dir */ | 151 /* sysclasspath, java_home, dll_dir */ |
149 { | 152 { |
258 Arguments::set_endorsed_dirs(buf); | 261 Arguments::set_endorsed_dirs(buf); |
259 #undef ENDORSED_DIR | 262 #undef ENDORSED_DIR |
260 } | 263 } |
261 | 264 |
262 #ifndef _WIN64 | 265 #ifndef _WIN64 |
263 SetUnhandledExceptionFilter(Handle_FLT_Exception); | 266 // set our UnhandledExceptionFilter and save any previous one |
267 prev_uef_handler = SetUnhandledExceptionFilter(Handle_FLT_Exception); | |
264 #endif | 268 #endif |
265 | 269 |
266 // Done | 270 // Done |
267 return; | 271 return; |
268 } | 272 } |
1907 } | 1911 } |
1908 | 1912 |
1909 #ifndef _WIN64 | 1913 #ifndef _WIN64 |
1910 //----------------------------------------------------------------------------- | 1914 //----------------------------------------------------------------------------- |
1911 LONG WINAPI Handle_FLT_Exception(struct _EXCEPTION_POINTERS* exceptionInfo) { | 1915 LONG WINAPI Handle_FLT_Exception(struct _EXCEPTION_POINTERS* exceptionInfo) { |
1912 // handle exception caused by native mothod modifying control word | 1916 // handle exception caused by native method modifying control word |
1913 PCONTEXT ctx = exceptionInfo->ContextRecord; | 1917 PCONTEXT ctx = exceptionInfo->ContextRecord; |
1914 DWORD exception_code = exceptionInfo->ExceptionRecord->ExceptionCode; | 1918 DWORD exception_code = exceptionInfo->ExceptionRecord->ExceptionCode; |
1915 | 1919 |
1916 switch (exception_code) { | 1920 switch (exception_code) { |
1917 case EXCEPTION_FLT_DENORMAL_OPERAND: | 1921 case EXCEPTION_FLT_DENORMAL_OPERAND: |
1928 // Mask out pending FLT exceptions | 1932 // Mask out pending FLT exceptions |
1929 ctx->FloatSave.StatusWord &= 0xffffff00; | 1933 ctx->FloatSave.StatusWord &= 0xffffff00; |
1930 return EXCEPTION_CONTINUE_EXECUTION; | 1934 return EXCEPTION_CONTINUE_EXECUTION; |
1931 } | 1935 } |
1932 } | 1936 } |
1937 | |
1938 if (prev_uef_handler != NULL) { | |
1939 // We didn't handle this exception so pass it to the previous | |
1940 // UnhandledExceptionFilter. | |
1941 return (prev_uef_handler)(exceptionInfo); | |
1942 } | |
1943 | |
1933 return EXCEPTION_CONTINUE_SEARCH; | 1944 return EXCEPTION_CONTINUE_SEARCH; |
1934 } | 1945 } |
1935 #else //_WIN64 | 1946 #else //_WIN64 |
1936 /* | 1947 /* |
1937 On Windows, the mxcsr control bits are non-volatile across calls | 1948 On Windows, the mxcsr control bits are non-volatile across calls |