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

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

Issue 2728453006: WTF: Initialize main-thread stack estimates when WTF starts up. (Closed)
Patch Set: fix cast for windows Created 3 years, 10 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/wtf/ThreadingPthreads.cpp
diff --git a/third_party/WebKit/Source/wtf/ThreadingPthreads.cpp b/third_party/WebKit/Source/wtf/ThreadingPthreads.cpp
index 85a3976090948bb06a944969aa7b771ef9d023f1..a0154e530b46064e31af4b6a22cb4d2732a5e8b5 100644
--- a/third_party/WebKit/Source/wtf/ThreadingPthreads.cpp
+++ b/third_party/WebKit/Source/wtf/ThreadingPthreads.cpp
@@ -85,8 +85,25 @@ void initializeThreading() {
double_conversion::DoubleToStringConverter::EcmaScriptConverter();
}
+namespace {
+ThreadSpecificKey s_currentThreadKey;
+} // namespace
+
+void initializeCurrentThread() {
+ threadSpecificKeyCreate(&s_currentThreadKey, [](void*) {});
+}
+
ThreadIdentifier currentThread() {
- return wtfThreadData().threadId();
+ static_assert(sizeof(ThreadIdentifier) <= sizeof(void*),
+ "ThreadIdentifier must fit in a void*.");
+ void* value = threadSpecificGet(s_currentThreadKey);
+ if (UNLIKELY(!value)) {
+ value = reinterpret_cast<void*>(
+ static_cast<intptr_t>(internal::currentThreadSyscall()));
+ DCHECK(value);
+ threadSpecificSet(s_currentThreadKey, value);
+ }
+ return reinterpret_cast<intptr_t>(threadSpecificGet(s_currentThreadKey));
}
MutexBase::MutexBase(bool recursive) {

Powered by Google App Engine
This is Rietveld 408576698