Changeset 91380 in webkit
- Timestamp:
- Jul 20, 2011, 11:21:44 AM (14 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r91351 r91380 1 2011-07-14 David Levin <[email protected]> 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-07-20 Mark Rowe <[email protected]> 2 23 -
trunk/Source/JavaScriptCore/wtf/ThreadIdentifierDataPthreads.cpp
r91094 r91380 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
r91094 r91380 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
r91206 r91380 82 82 threadMapMutex(); 83 83 initializeRandomNumberGenerator(); 84 ThreadIdentifierData::initializeOnce(); 84 85 } 85 86
Note:
See TracChangeset
for help on using the changeset viewer.