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

Unified Diff: third_party/WebKit/Source/wtf/StackUtil.cpp

Issue 2728453006: WTF: Initialize main-thread stack estimates when WTF starts up. (Closed)
Patch Set: comment about why currentThread works this way Created 3 years, 9 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/wtf/StackUtil.h ('k') | third_party/WebKit/Source/wtf/ThreadSpecific.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/StackUtil.cpp
diff --git a/third_party/WebKit/Source/wtf/StackUtil.cpp b/third_party/WebKit/Source/wtf/StackUtil.cpp
index f9e51b866b60fe64317289f43ee7783a86412b8f..0312ad8d8bd6a9f3fc45021445f5ce242d46e5d9 100644
--- a/third_party/WebKit/Source/wtf/StackUtil.cpp
+++ b/third_party/WebKit/Source/wtf/StackUtil.cpp
@@ -143,13 +143,21 @@ void* getStackStart() {
namespace internal {
-uintptr_t mainThreadUnderestimatedStackSize() {
+uintptr_t s_mainThreadStackStart = 0;
+uintptr_t s_mainThreadUnderestimatedStackSize = 0;
+
+void initializeMainThreadStackEstimate() {
+ // getStackStart is exclusive, not inclusive (i.e. it points past the last
+ // page of the stack in linear order). So, to ensure an inclusive comparison,
+ // subtract here and below.
+ s_mainThreadStackStart =
+ reinterpret_cast<uintptr_t>(getStackStart()) - sizeof(void*);
+
size_t underestimatedStackSize = getUnderestimatedStackSize();
- // See comment in mayNotBeMainThread as to why we subtract here.
if (underestimatedStackSize > sizeof(void*)) {
underestimatedStackSize = underestimatedStackSize - sizeof(void*);
}
- return underestimatedStackSize;
+ s_mainThreadUnderestimatedStackSize = underestimatedStackSize;
}
#if OS(WIN) && COMPILER(MSVC)
« no previous file with comments | « third_party/WebKit/Source/wtf/StackUtil.h ('k') | third_party/WebKit/Source/wtf/ThreadSpecific.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698