< prev index next >

src/os/windows/vm/os_windows.hpp

Print this page
rev 13142 : 8183198: Factor out thread state serialization into a proper helper function
Reviewed-by:


 106 #ifndef _WIN64
 107   // A wrapper to install a structured exception handler for fast JNI accesors.
 108   static address fast_jni_accessor_wrapper(BasicType);
 109 #endif
 110 
 111   // filter function to ignore faults on serializations page
 112   static LONG WINAPI serialize_fault_filter(struct _EXCEPTION_POINTERS* e);
 113 
 114   // Fast access to current thread
 115 protected:
 116   static int _thread_ptr_offset;
 117 private:
 118   static void initialize_thread_ptr_offset();
 119 public:
 120   static inline void set_thread_ptr_offset(int offset) {
 121     _thread_ptr_offset = offset;
 122   }
 123   static inline int get_thread_ptr_offset() { return _thread_ptr_offset; }
 124 };
 125 















 126 /*
 127  * Crash protection for the watcher thread. Wrap the callback
 128  * with a __try { call() }
 129  * To be able to use this - don't take locks, don't rely on destructors,
 130  * don't make OS library calls, don't allocate memory, don't print,
 131  * don't call code that could leave the heap / memory in an inconsistent state,
 132  * or anything else where we are not in control if we suddenly jump out.
 133  */
 134 class WatcherThreadCrashProtection : public StackObj {
 135 public:
 136   WatcherThreadCrashProtection();
 137   bool call(os::CrashProtectionCallback& cb);
 138 };
 139 
 140 class PlatformEvent : public CHeapObj<mtInternal> {
 141   private:
 142     double CachePad [4] ;   // increase odds that _Event is sole occupant of cache line
 143     volatile int _Event ;
 144     HANDLE _ParkHandle ;
 145 




 106 #ifndef _WIN64
 107   // A wrapper to install a structured exception handler for fast JNI accesors.
 108   static address fast_jni_accessor_wrapper(BasicType);
 109 #endif
 110 
 111   // filter function to ignore faults on serializations page
 112   static LONG WINAPI serialize_fault_filter(struct _EXCEPTION_POINTERS* e);
 113 
 114   // Fast access to current thread
 115 protected:
 116   static int _thread_ptr_offset;
 117 private:
 118   static void initialize_thread_ptr_offset();
 119 public:
 120   static inline void set_thread_ptr_offset(int offset) {
 121     _thread_ptr_offset = offset;
 122   }
 123   static inline int get_thread_ptr_offset() { return _thread_ptr_offset; }
 124 };
 125 
 126 static void write_memory_serialize_page_with_handler(JavaThread* thread) {
 127   // Due to chained nature of SEH handlers we have to be sure
 128   // that our handler is always last handler before an attempt to write
 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 


< prev index next >