equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. 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. |
106 #ifndef _WIN64 |
106 #ifndef _WIN64 |
107 // A wrapper to install a structured exception handler for fast JNI accesors. |
107 // A wrapper to install a structured exception handler for fast JNI accesors. |
108 static address fast_jni_accessor_wrapper(BasicType); |
108 static address fast_jni_accessor_wrapper(BasicType); |
109 #endif |
109 #endif |
110 |
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 |
111 // Fast access to current thread |
115 protected: |
112 protected: |
116 static int _thread_ptr_offset; |
113 static int _thread_ptr_offset; |
117 private: |
114 private: |
118 static void initialize_thread_ptr_offset(); |
115 static void initialize_thread_ptr_offset(); |
120 static inline void set_thread_ptr_offset(int offset) { |
117 static inline void set_thread_ptr_offset(int offset) { |
121 _thread_ptr_offset = offset; |
118 _thread_ptr_offset = offset; |
122 } |
119 } |
123 static inline int get_thread_ptr_offset() { return _thread_ptr_offset; } |
120 static inline int get_thread_ptr_offset() { return _thread_ptr_offset; } |
124 }; |
121 }; |
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 |
122 |
141 /* |
123 /* |
142 * Crash protection for the watcher thread. Wrap the callback |
124 * Crash protection for the watcher thread. Wrap the callback |
143 * with a __try { call() } |
125 * with a __try { call() } |
144 * To be able to use this - don't take locks, don't rely on destructors, |
126 * To be able to use this - don't take locks, don't rely on destructors, |