Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Side by Side Diff: third_party/WebKit/Source/platform/heap/StackFrameDepth.cpp

Issue 1409243011: Precisely determine Windows thread stack size (reland) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: gracefully handle yellow zone at the end of the stack Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/ThreadState.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // On Windows stack limits for the current thread are available in 101 return ThreadState::current()->threadStackSize();
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
109 #else 102 #else
110 #error "Stack frame size estimation not supported on this platform." 103 #error "Stack frame size estimation not supported on this platform."
111 return 0; 104 return 0;
112 #endif 105 #endif
113 } 106 }
114 107
115 void* StackFrameDepth::getStackStart() 108 void* StackFrameDepth::getStackStart()
116 { 109 {
117 #if defined(__GLIBC__) || OS(ANDROID) || OS(FREEBSD) 110 #if defined(__GLIBC__) || OS(ANDROID) || OS(FREEBSD)
118 pthread_attr_t attr; 111 pthread_attr_t attr;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 return reinterpret_cast<void*>(__readgsqword(offsetof(NT_TIB64, StackBase))) ; 147 return reinterpret_cast<void*>(__readgsqword(offsetof(NT_TIB64, StackBase))) ;
155 #else 148 #else
156 return reinterpret_cast<void*>(__readfsdword(offsetof(NT_TIB, StackBase))); 149 return reinterpret_cast<void*>(__readfsdword(offsetof(NT_TIB, StackBase)));
157 #endif 150 #endif
158 #else 151 #else
159 #error Unsupported getStackStart on this platform. 152 #error Unsupported getStackStart on this platform.
160 #endif 153 #endif
161 } 154 }
162 155
163 } // namespace blink 156 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/ThreadState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698