OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "platform/globals.h" // NOLINT | 5 #include "platform/globals.h" // NOLINT |
6 #if defined(TARGET_OS_WINDOWS) | 6 #if defined(TARGET_OS_WINDOWS) |
7 | 7 |
8 #include "vm/growable_array.h" | 8 #include "vm/growable_array.h" |
9 #include "vm/lockers.h" | 9 #include "vm/lockers.h" |
10 #include "vm/os_thread.h" | 10 #include "vm/os_thread.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 ThreadId OSThread::ThreadIdFromIntPtr(intptr_t id) { | 166 ThreadId OSThread::ThreadIdFromIntPtr(intptr_t id) { |
167 return static_cast<ThreadId>(id); | 167 return static_cast<ThreadId>(id); |
168 } | 168 } |
169 | 169 |
170 | 170 |
171 bool OSThread::Compare(ThreadId a, ThreadId b) { | 171 bool OSThread::Compare(ThreadId a, ThreadId b) { |
172 return a == b; | 172 return a == b; |
173 } | 173 } |
174 | 174 |
175 | 175 |
| 176 bool OSThread::GetCurrentStackBounds(uword* lower, uword* upper) { |
| 177 // On Windows stack limits for the current thread are available in |
| 178 // the thread information block (TIB). Its fields can be accessed through |
| 179 // FS segment register on x86 and GS segment register on x86_64. |
| 180 #ifdef _WIN64 |
| 181 *upper = static_cast<uword>(__readgsqword(offsetof(NT_TIB64, StackBase))); |
| 182 *lower = static_cast<uword>(__readgsqword(offsetof(NT_TIB64, StackLimit))); |
| 183 #else |
| 184 *upper = static_cast<uword>(__readfsdword(offsetof(NT_TIB, StackBase))); |
| 185 *lower = static_cast<uword>(__readfsdword(offsetof(NT_TIB, StackLimit))); |
| 186 #endif |
| 187 return true; |
| 188 } |
| 189 |
| 190 |
176 void OSThread::SetThreadLocal(ThreadLocalKey key, uword value) { | 191 void OSThread::SetThreadLocal(ThreadLocalKey key, uword value) { |
177 ASSERT(key != kUnsetThreadLocalKey); | 192 ASSERT(key != kUnsetThreadLocalKey); |
178 BOOL result = TlsSetValue(key, reinterpret_cast<void*>(value)); | 193 BOOL result = TlsSetValue(key, reinterpret_cast<void*>(value)); |
179 if (!result) { | 194 if (!result) { |
180 FATAL1("TlsSetValue failed %d", GetLastError()); | 195 FATAL1("TlsSetValue failed %d", GetLastError()); |
181 } | 196 } |
182 } | 197 } |
183 | 198 |
184 | 199 |
185 Mutex::Mutex() { | 200 Mutex::Mutex() { |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 #pragma data_seg(".CRT$XLB") | 694 #pragma data_seg(".CRT$XLB") |
680 PIMAGE_TLS_CALLBACK p_thread_callback_dart = OnDartThreadExit; | 695 PIMAGE_TLS_CALLBACK p_thread_callback_dart = OnDartThreadExit; |
681 | 696 |
682 // Reset the default section. | 697 // Reset the default section. |
683 #pragma data_seg() | 698 #pragma data_seg() |
684 | 699 |
685 #endif // _WIN64 | 700 #endif // _WIN64 |
686 } // extern "C" | 701 } // extern "C" |
687 | 702 |
688 #endif // defined(TARGET_OS_WINDOWS) | 703 #endif // defined(TARGET_OS_WINDOWS) |
OLD | NEW |