--- a/hotspot/src/os/windows/vm/os_windows.cpp Fri Jul 07 23:04:06 2017 +0200
+++ b/hotspot/src/os/windows/vm/os_windows.cpp Fri Jul 07 23:11:33 2017 +0200
@@ -4822,8 +4822,11 @@
}
}
-os::WatcherThreadCrashProtection::WatcherThreadCrashProtection() {
- assert(Thread::current()->is_Watcher_thread(), "Must be WatcherThread");
+Thread* os::ThreadCrashProtection::_protected_thread = NULL;
+os::ThreadCrashProtection* os::ThreadCrashProtection::_crash_protection = NULL;
+volatile intptr_t os::ThreadCrashProtection::_crash_mux = 0;
+
+os::ThreadCrashProtection::ThreadCrashProtection() {
}
// See the caveats for this class in os_windows.hpp
@@ -4832,20 +4835,24 @@
// true.
// The callback is supposed to provide the method that should be protected.
//
-bool os::WatcherThreadCrashProtection::call(os::CrashProtectionCallback& cb) {
- assert(Thread::current()->is_Watcher_thread(), "Only for WatcherThread");
- assert(!WatcherThread::watcher_thread()->has_crash_protection(),
- "crash_protection already set?");
+bool os::ThreadCrashProtection::call(os::CrashProtectionCallback& cb) {
+
+ Thread::muxAcquire(&_crash_mux, "CrashProtection");
+
+ _protected_thread = Thread::current_or_null();
+ assert(_protected_thread != NULL, "Cannot crash protect a NULL thread");
bool success = true;
__try {
- WatcherThread::watcher_thread()->set_crash_protection(this);
+ _crash_protection = this;
cb.call();
} __except(EXCEPTION_EXECUTE_HANDLER) {
// only for protection, nothing to do
success = false;
}
- WatcherThread::watcher_thread()->set_crash_protection(NULL);
+ _crash_protection = NULL;
+ _protected_thread = NULL;
+ Thread::muxRelease(&_crash_mux);
return success;
}