Changeset 92154 in webkit
- Timestamp:
- Aug 1, 2011, 5:10:21 PM (15 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
wtf/ThreadIdentifierDataPthreads.cpp (modified) (4 diffs)
-
wtf/ThreadIdentifierDataPthreads.h (modified) (2 diffs)
-
wtf/ThreadingPthreads.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r92148 r92154 1 2011-07-14 David Levin <levin@chromium.org> 2 3 currentThread is too slow! 4 https://bugs.webkit.org/show_bug.cgi?id=64577 5 6 Reviewed by Darin Adler and Dmitry Titov. 7 8 The problem is that currentThread results in a pthread_once call which always takes a lock. 9 With this change, currentThread is 10% faster than isMainThread in release mode and only 10 5% slower than isMainThread in debug. 11 12 * wtf/ThreadIdentifierDataPthreads.cpp: 13 (WTF::ThreadIdentifierData::initializeOnce): Remove the pthread once stuff 14 which is no longer needed because this is called from initializeThreading(). 15 (WTF::ThreadIdentifierData::identifier): Remove the initializeKeyOnce call because 16 intialization of the pthread key should already be done. 17 (WTF::ThreadIdentifierData::initialize): Ditto. 18 * wtf/ThreadIdentifierDataPthreads.h: 19 * wtf/ThreadingPthreads.cpp: 20 (WTF::initializeThreading): Acquire the pthread key here. 21 1 22 2011-08-01 Filip Pizlo <fpizlo@apple.com> 2 23 -
trunk/Source/JavaScriptCore/wtf/ThreadIdentifierDataPthreads.cpp
r91444 r92154 37 37 #include "Threading.h" 38 38 39 #include <limits.h> 40 39 41 namespace WTF { 40 42 41 pthread_key_t ThreadIdentifierData::m_key; 42 static pthread_once_t onceControl = PTHREAD_ONCE_INIT; 43 pthread_key_t ThreadIdentifierData::m_key = PTHREAD_KEYS_MAX; 43 44 44 45 void clearPthreadHandleForIdentifier(ThreadIdentifier); … … 49 50 } 50 51 52 void ThreadIdentifierData::initializeOnce() 53 { 54 if (pthread_key_create(&m_key, destruct)) 55 CRASH(); 56 } 57 51 58 ThreadIdentifier ThreadIdentifierData::identifier() 52 59 { 53 initializeKeyOnce();60 ASSERT(m_key != PTHREAD_KEYS_MAX); 54 61 ThreadIdentifierData* threadIdentifierData = static_cast<ThreadIdentifierData*>(pthread_getspecific(m_key)); 55 62 … … 60 67 { 61 68 ASSERT(!identifier()); 62 63 initializeKeyOnce();64 69 pthread_setspecific(m_key, new ThreadIdentifierData(id)); 65 70 } … … 80 85 } 81 86 82 void ThreadIdentifierData::initializeKeyOnceHelper()83 {84 if (pthread_key_create(&m_key, destruct))85 CRASH();86 }87 88 void ThreadIdentifierData::initializeKeyOnce()89 {90 if (pthread_once(&onceControl, initializeKeyOnceHelper))91 CRASH();92 }93 94 87 } // namespace WTF 95 88 -
trunk/Source/JavaScriptCore/wtf/ThreadIdentifierDataPthreads.h
r91444 r92154 43 43 ~ThreadIdentifierData(); 44 44 45 // One time initialization for this class as a whole. 46 // This method must be called before initialize() and it is not thread-safe. 47 static void initializeOnce(); 48 45 49 // Creates and puts an instance of ThreadIdentifierData into thread-specific storage. 46 50 static void initialize(ThreadIdentifier identifier); … … 63 67 static void destruct(void* data); 64 68 65 static void initializeKeyOnceHelper();66 static void initializeKeyOnce();67 68 69 ThreadIdentifier m_identifier; 69 70 bool m_isDestroyedOnce; -
trunk/Source/JavaScriptCore/wtf/ThreadingPthreads.cpp
r92068 r92154 87 87 threadMapMutex(); 88 88 initializeRandomNumberGenerator(); 89 ThreadIdentifierData::initializeOnce(); 89 90 wtfThreadData(); 90 91 #if ENABLE(WTF_MULTIPLE_THREADS)
Note:
See TracChangeset
for help on using the changeset viewer.