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

Side by Side Diff: third_party/WebKit/Source/wtf/ThreadingWin.cpp

Issue 2728453006: WTF: Initialize main-thread stack estimates when WTF starts up. (Closed)
Patch Set: fix cast for windows 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Google Inc. All rights reserved. 3 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * Copyright (C) 2009 Torch Mobile, Inc. All rights reserved. 4 * Copyright (C) 2009 Torch Mobile, Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 void initializeThreading() { 136 void initializeThreading() {
137 // This should only be called once. 137 // This should only be called once.
138 WTFThreadData::initialize(); 138 WTFThreadData::initialize();
139 139
140 initializeDates(); 140 initializeDates();
141 // Force initialization of static DoubleToStringConverter converter variable 141 // Force initialization of static DoubleToStringConverter converter variable
142 // inside EcmaScriptConverter function while we are in single thread mode. 142 // inside EcmaScriptConverter function while we are in single thread mode.
143 double_conversion::DoubleToStringConverter::EcmaScriptConverter(); 143 double_conversion::DoubleToStringConverter::EcmaScriptConverter();
144 } 144 }
145 145
146 namespace {
147 ThreadSpecificKey s_currentThreadKey;
148 } // namespace
149
150 void initializeCurrentThread() {
151 threadSpecificKeyCreate(&s_currentThreadKey, [](void*) {});
152 }
153
146 ThreadIdentifier currentThread() { 154 ThreadIdentifier currentThread() {
147 return wtfThreadData().threadId(); 155 static_assert(sizeof(ThreadIdentifier) <= sizeof(void*),
156 "ThreadIdentifier must fit in a void*.");
157 void* value = threadSpecificGet(s_currentThreadKey);
158 if (UNLIKELY(!value)) {
159 value = reinterpret_cast<void*>(internal::currentThreadSyscall());
160 DCHECK(value);
161 threadSpecificSet(s_currentThreadKey, value);
162 }
163 return reinterpret_cast<intptr_t>(threadSpecificGet(s_currentThreadKey));
148 } 164 }
149 165
150 MutexBase::MutexBase(bool recursive) { 166 MutexBase::MutexBase(bool recursive) {
151 m_mutex.m_recursionCount = 0; 167 m_mutex.m_recursionCount = 0;
152 InitializeCriticalSection(&m_mutex.m_internalMutex); 168 InitializeCriticalSection(&m_mutex.m_internalMutex);
153 } 169 }
154 170
155 MutexBase::~MutexBase() { 171 MutexBase::~MutexBase() {
156 DeleteCriticalSection(&m_mutex.m_internalMutex); 172 DeleteCriticalSection(&m_mutex.m_internalMutex);
157 } 173 }
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 } 404 }
389 405
390 void willCreateThread() { 406 void willCreateThread() {
391 s_threadCreated = true; 407 s_threadCreated = true;
392 } 408 }
393 #endif 409 #endif
394 410
395 } // namespace WTF 411 } // namespace WTF
396 412
397 #endif // OS(WIN) 413 #endif // OS(WIN)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698