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

Unified Diff: Source/platform/heap/ThreadState.cpp

Issue 643883002: Oilpan: Avoid looking up TLS in ThreadState::current() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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
« Source/platform/heap/ThreadState.h ('K') | « Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/ThreadState.cpp
diff --git a/Source/platform/heap/ThreadState.cpp b/Source/platform/heap/ThreadState.cpp
index 0f9ad60c7a86af4e5bbdbb5d69f936234ae0bcf6..36f192604c9a467094a7c9f14cafec5c5646281a 100644
--- a/Source/platform/heap/ThreadState.cpp
+++ b/Source/platform/heap/ThreadState.cpp
@@ -110,11 +110,37 @@ static void* getStackStart()
#endif
}
+static size_t getUnderestimatedStackSize()
+{
+#if defined(__GLIBC__) || OS(ANDROID) || OS(FREEBSD)
+ // We cannot get the stack size in these platforms because
+ // pthread_getattr_np() can fail for the main thread.
+ // This is OK because ThreadState::current() doesn't use the stack size
+ // in these platforms.
+ return 0;
+#elif OS(MACOSX)
+ return pthread_get_stacksize_np(pthread_self());
+#elif OS(WIN) && COMPILER(MSVC)
+ // 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
+ return __readgsqword(offsetof(NT_TIB64, StackBase)) - __readgsqword(offsetof(NT_TIB64, StackLimit));
+#else
+ return __readfsdword(offsetof(NT_TIB, StackBase)) - __readfsdword(offsetof(NT_TIB, StackLimit));
+#endif
+#else
+ return 0;
+#endif
+}
+
// The maximum number of WrapperPersistentRegions to keep around in the
// m_pooledWrapperPersistentRegions pool.
static const size_t MaxPooledWrapperPersistentRegionCount = 2;
WTF::ThreadSpecific<ThreadState*>* ThreadState::s_threadSpecific = 0;
+uintptr_t ThreadState::s_mainThreadStackStart = 0;
+uintptr_t ThreadState::s_mainThreadUnderestimatedStackSize = 0;
uint8_t ThreadState::s_mainThreadStateStorage[sizeof(ThreadState)];
SafePointBarrier* ThreadState::s_safePointBarrier = 0;
bool ThreadState::s_inGC = false;
@@ -325,6 +351,11 @@ ThreadState::ThreadState()
ASSERT(!**s_threadSpecific);
**s_threadSpecific = this;
+ if (isMainThread()) {
+ s_mainThreadStackStart = reinterpret_cast<intptr_t>(m_startOfStack);
+ s_mainThreadUnderestimatedStackSize = getUnderestimatedStackSize();
+ }
+
InitializeHeaps<NumberOfHeaps>::init(m_heaps, this);
m_weakCallbackStack = new CallbackStack();
« Source/platform/heap/ThreadState.h ('K') | « Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698