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

Unified Diff: third_party/WebKit/Source/platform/heap/ThreadState.h

Issue 2623273007: Fast path for ThreadSpecific for main thread on TLS-slow platforms (Closed)
Patch Set: [WIP] Fast path for currentThread() for main thread on TLS-slow platforms Created 3 years, 11 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
Index: third_party/WebKit/Source/platform/heap/ThreadState.h
diff --git a/third_party/WebKit/Source/platform/heap/ThreadState.h b/third_party/WebKit/Source/platform/heap/ThreadState.h
index 1eb43ff1d3349894f20d17ac8f385744b2593c33..5de90fcbf9d64182a36154fa2ee9b18e8204cc55 100644
--- a/third_party/WebKit/Source/platform/heap/ThreadState.h
+++ b/third_party/WebKit/Source/platform/heap/ThreadState.h
@@ -45,6 +45,7 @@
#include "wtf/ThreadSpecific.h"
#include "wtf/Threading.h"
#include "wtf/ThreadingPrimitives.h"
+#include "wtf/WTFThreadData.h"
#include <memory>
namespace v8 {
@@ -182,18 +183,10 @@ class PLATFORM_EXPORT ThreadState {
static ThreadState* current() {
#if defined(__GLIBC__) || OS(ANDROID) || OS(FREEBSD)
- // TLS lookup is fast in these platforms.
return **s_threadSpecific;
#else
- uintptr_t dummy;
- uintptr_t addressDiff =
- s_mainThreadStackStart - reinterpret_cast<uintptr_t>(&dummy);
- // This is a fast way to judge if we are in the main thread.
- // If |&dummy| is within |s_mainThreadUnderestimatedStackSize| byte from
- // the stack start of the main thread, we judge that we are in
- // the main thread.
- if (LIKELY(addressDiff < s_mainThreadUnderestimatedStackSize)) {
- ASSERT(**s_threadSpecific == mainThreadState());
+ if (LIKELY(WTF::WTFThreadData::stackBasedIsMainThread())) {
+ DCHECK_EQ(**s_threadSpecific, mainThreadState());
haraken 2017/01/16 04:42:30 Ideally s_threadSpecific should be moved into WTFT
Charlie Harrison 2017/01/18 01:49:48 I've just turned this into **s_threadSpecific beca
return mainThreadState();
}
// TLS lookup is slow.
@@ -655,8 +648,6 @@ class PLATFORM_EXPORT ThreadState {
friend class SafePointScope;
static WTF::ThreadSpecific<ThreadState*>* s_threadSpecific;
- static uintptr_t s_mainThreadStackStart;
- static uintptr_t s_mainThreadUnderestimatedStackSize;
// We can't create a static member of type ThreadState here
// because it will introduce global constructor and destructor.
@@ -671,9 +662,6 @@ class PLATFORM_EXPORT ThreadState {
ThreadIdentifier m_thread;
std::unique_ptr<PersistentRegion> m_persistentRegion;
BlinkGC::StackState m_stackState;
-#if OS(WIN) && COMPILER(MSVC)
- size_t m_threadStackSize;
-#endif
intptr_t* m_startOfStack;
intptr_t* m_endOfStack;

Powered by Google App Engine
This is Rietveld 408576698