129 // into serialization page - it can fault if we access this page
130 // right in the middle of protect/unprotect sequence by remote
131 // membar logic.
132 // __try/__except are very lightweight operations (only several
133 // instructions not affecting control flow directly on x86)
134 // so we can use it here, on very time critical path
135 __try {
136 write_memory_serialize_page(thread);
137 } __except (win32::serialize_fault_filter((_EXCEPTION_POINTERS*)_exception_info()))
138 {}
139 }
140
141 /*
142 * Crash protection for the watcher thread. Wrap the callback
143 * with a __try { call() }
144 * To be able to use this - don't take locks, don't rely on destructors,
145 * don't make OS library calls, don't allocate memory, don't print,
146 * don't call code that could leave the heap / memory in an inconsistent state,
147 * or anything else where we are not in control if we suddenly jump out.
148 */
149 class WatcherThreadCrashProtection : public StackObj {
150 public:
151 WatcherThreadCrashProtection();
152 bool call(os::CrashProtectionCallback& cb);
153 };
154
155 class PlatformEvent : public CHeapObj<mtInternal> {
156 private:
157 double CachePad [4] ; // increase odds that _Event is sole occupant of cache line
158 volatile int _Event ;
159 HANDLE _ParkHandle ;
160
161 public: // TODO-FIXME: make dtor private
162 ~PlatformEvent() { guarantee (0, "invariant") ; }
163
164 public:
165 PlatformEvent() {
166 _Event = 0 ;
167 _ParkHandle = CreateEvent (NULL, false, false, NULL) ;
168 guarantee (_ParkHandle != NULL, "invariant") ;
169 }
170
171 // Exercise caution using reset() and fired() - they may require MEMBARs
172 void reset() { _Event = 0 ; }
|
129 // into serialization page - it can fault if we access this page
130 // right in the middle of protect/unprotect sequence by remote
131 // membar logic.
132 // __try/__except are very lightweight operations (only several
133 // instructions not affecting control flow directly on x86)
134 // so we can use it here, on very time critical path
135 __try {
136 write_memory_serialize_page(thread);
137 } __except (win32::serialize_fault_filter((_EXCEPTION_POINTERS*)_exception_info()))
138 {}
139 }
140
141 /*
142 * Crash protection for the watcher thread. Wrap the callback
143 * with a __try { call() }
144 * To be able to use this - don't take locks, don't rely on destructors,
145 * don't make OS library calls, don't allocate memory, don't print,
146 * don't call code that could leave the heap / memory in an inconsistent state,
147 * or anything else where we are not in control if we suddenly jump out.
148 */
149 class ThreadCrashProtection : public StackObj {
150 public:
151 static bool is_crash_protected(Thread* thr) {
152 return _crash_protection != NULL && _protected_thread == thr;
153 }
154
155 ThreadCrashProtection();
156 bool call(os::CrashProtectionCallback& cb);
157 private:
158 static Thread* _protected_thread;
159 static ThreadCrashProtection* _crash_protection;
160 static volatile intptr_t _crash_mux;
161 };
162
163 class PlatformEvent : public CHeapObj<mtInternal> {
164 private:
165 double CachePad [4] ; // increase odds that _Event is sole occupant of cache line
166 volatile int _Event ;
167 HANDLE _ParkHandle ;
168
169 public: // TODO-FIXME: make dtor private
170 ~PlatformEvent() { guarantee (0, "invariant") ; }
171
172 public:
173 PlatformEvent() {
174 _Event = 0 ;
175 _ParkHandle = CreateEvent (NULL, false, false, NULL) ;
176 guarantee (_ParkHandle != NULL, "invariant") ;
177 }
178
179 // Exercise caution using reset() and fired() - they may require MEMBARs
180 void reset() { _Event = 0 ; }
|