--- a/src/hotspot/os/windows/os_windows.cpp Thu Feb 07 22:20:46 2019 +0100
+++ b/src/hotspot/os/windows/os_windows.cpp Thu Feb 07 17:23:24 2019 -0500
@@ -125,6 +125,11 @@
#define __CPU__ i486
#endif
+#if INCLUDE_AOT
+PVOID topLevelVectoredExceptionHandler = NULL;
+LONG WINAPI topLevelVectoredExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo);
+#endif
+
// save DLL module handle, used by GetModuleFileName
HINSTANCE vm_lib_handle;
@@ -143,6 +148,12 @@
if (ForceTimeHighResolution) {
timeEndPeriod(1L);
}
+#if INCLUDE_AOT
+ if (topLevelVectoredExceptionHandler != NULL) {
+ RemoveVectoredExceptionHandler(topLevelVectoredExceptionHandler);
+ topLevelVectoredExceptionHandler = NULL;
+ }
+#endif
break;
default:
break;
@@ -2325,6 +2336,25 @@
return true;
}
+#if INCLUDE_AOT
+LONG WINAPI topLevelVectoredExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
+ PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord;
+ address addr = (address) exceptionRecord->ExceptionInformation[1];
+ address pc = (address) exceptionInfo->ContextRecord->Rip;
+
+ // Handle the case where we get an implicit exception in AOT generated
+ // code. AOT DLL's loaded are not registered for structured exceptions.
+ // If the exception occurred in the codeCache or AOT code, pass control
+ // to our normal exception handler.
+ CodeBlob* cb = CodeCache::find_blob(pc);
+ if (cb != NULL) {
+ return topLevelExceptionFilter(exceptionInfo);
+ }
+
+ return EXCEPTION_CONTINUE_SEARCH;
+}
+#endif
+
//-----------------------------------------------------------------------------
LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
if (InterceptOSException) return EXCEPTION_CONTINUE_SEARCH;
@@ -4080,6 +4110,16 @@
// Setup Windows Exceptions
+#if INCLUDE_AOT
+ // If AOT is enabled we need to install a vectored exception handler
+ // in order to forward implicit exceptions from code in AOT
+ // generated DLLs. This is necessary since these DLLs are not
+ // registered for structured exceptions like codecache methods are.
+ if (UseAOT) {
+ topLevelVectoredExceptionHandler = AddVectoredExceptionHandler( 1, topLevelVectoredExceptionFilter);
+ }
+#endif
+
// for debugging float code generation bugs
if (ForceFloatExceptions) {
#ifndef _WIN64