Index: runtime/vm/os_thread_win.cc |
diff --git a/runtime/vm/os_thread_win.cc b/runtime/vm/os_thread_win.cc |
index 759919514a1b492be29bf00e3f72351901d9adda..7d80d4d1ceeafa1d4d046e17d648a4876df988af 100644 |
--- a/runtime/vm/os_thread_win.cc |
+++ b/runtime/vm/os_thread_win.cc |
@@ -173,6 +173,21 @@ bool OSThread::Compare(ThreadId a, ThreadId b) { |
} |
+bool OSThread::GetCurrentStackBounds(uword* lower, uword* upper) { |
+// On Windows stack limits for the current thread are available in |
+// the thread information block (TIB). Its fields can be accessed through |
+// FS segment register on x86 and GS segment register on x86_64. |
+#ifdef _WIN64 |
+ *upper = static_cast<uword>(__readgsqword(offsetof(NT_TIB64, StackBase))); |
+ *lower = static_cast<uword>(__readgsqword(offsetof(NT_TIB64, StackLimit))); |
+#else |
+ *upper = static_cast<uword>(__readfsdword(offsetof(NT_TIB, StackBase))); |
+ *lower = static_cast<uword>(__readfsdword(offsetof(NT_TIB, StackLimit))); |
+#endif |
+ return true; |
+} |
+ |
+ |
void OSThread::SetThreadLocal(ThreadLocalKey key, uword value) { |
ASSERT(key != kUnsetThreadLocalKey); |
BOOL result = TlsSetValue(key, reinterpret_cast<void*>(value)); |