| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "platform/heap/StackFrameDepth.h" | 6 #include "platform/heap/StackFrameDepth.h" |
| 7 | 7 |
| 8 #include "public/platform/Platform.h" | 8 #include "public/platform/Platform.h" |
| 9 | 9 |
| 10 #if OS(WIN) | 10 #if OS(WIN) |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 #if OS(FREEBSD) | 91 #if OS(FREEBSD) |
| 92 pthread_attr_destroy(&attr); | 92 pthread_attr_destroy(&attr); |
| 93 #endif | 93 #endif |
| 94 | 94 |
| 95 return 0; | 95 return 0; |
| 96 #elif OS(MACOSX) | 96 #elif OS(MACOSX) |
| 97 // FIXME: pthread_get_stacksize_np() returns shorter size than actual stack | 97 // FIXME: pthread_get_stacksize_np() returns shorter size than actual stack |
| 98 // size for the main thread on Mavericks(10.9). | 98 // size for the main thread on Mavericks(10.9). |
| 99 return 0; | 99 return 0; |
| 100 #elif OS(WIN) && COMPILER(MSVC) | 100 #elif OS(WIN) && COMPILER(MSVC) |
| 101 return ThreadState::current()->threadStackSize(); | 101 // On Windows stack limits for the current thread are available in |
| 102 // the thread information block (TIB). Its fields can be accessed through |
| 103 // FS segment register on x86 and GS segment register on x86_64. |
| 104 #ifdef _WIN64 |
| 105 return __readgsqword(offsetof(NT_TIB64, StackBase)) - __readgsqword(offsetof
(NT_TIB64, StackLimit)); |
| 106 #else |
| 107 return __readfsdword(offsetof(NT_TIB, StackBase)) - __readfsdword(offsetof(N
T_TIB, StackLimit)); |
| 108 #endif |
| 102 #else | 109 #else |
| 103 #error "Stack frame size estimation not supported on this platform." | 110 #error "Stack frame size estimation not supported on this platform." |
| 104 return 0; | 111 return 0; |
| 105 #endif | 112 #endif |
| 106 } | 113 } |
| 107 | 114 |
| 108 void* StackFrameDepth::getStackStart() | 115 void* StackFrameDepth::getStackStart() |
| 109 { | 116 { |
| 110 #if defined(__GLIBC__) || OS(ANDROID) || OS(FREEBSD) | 117 #if defined(__GLIBC__) || OS(ANDROID) || OS(FREEBSD) |
| 111 pthread_attr_t attr; | 118 pthread_attr_t attr; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 return reinterpret_cast<void*>(__readgsqword(offsetof(NT_TIB64, StackBase)))
; | 154 return reinterpret_cast<void*>(__readgsqword(offsetof(NT_TIB64, StackBase)))
; |
| 148 #else | 155 #else |
| 149 return reinterpret_cast<void*>(__readfsdword(offsetof(NT_TIB, StackBase))); | 156 return reinterpret_cast<void*>(__readfsdword(offsetof(NT_TIB, StackBase))); |
| 150 #endif | 157 #endif |
| 151 #else | 158 #else |
| 152 #error Unsupported getStackStart on this platform. | 159 #error Unsupported getStackStart on this platform. |
| 153 #endif | 160 #endif |
| 154 } | 161 } |
| 155 | 162 |
| 156 } // namespace blink | 163 } // namespace blink |
| OLD | NEW |