Ignore:
Timestamp:
Jul 15, 2011, 11:49:24 AM (14 years ago)
Author:
[email protected]
Message:

currentThread is too slow!
https://bugs.webkit.org/show_bug.cgi?id=64577

Reviewed by Darin Adler and Dmitry Titov.

The problem is that currentThread results in a pthread_once call which always takes a lock.
With this change, currentThread is 10% faster than isMainThread in release mode and only
5% slower than isMainThread in debug.

  • wtf/ThreadIdentifierDataPthreads.cpp:

(WTF::ThreadIdentifierData::initializeOnce): Remove the pthread once stuff
which is no longer needed because this is called from initializeThreading().
(WTF::ThreadIdentifierData::identifier): Remove the initializeKeyOnce call because
intialization of the pthread key should already be done.
(WTF::ThreadIdentifierData::initialize): Ditto.

  • wtf/ThreadIdentifierDataPthreads.h:
  • wtf/ThreadingPthreads.cpp:

(WTF::initializeThreading): Acquire the pthread key here.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/wtf/ThreadIdentifierDataPthreads.h

    r76248 r91082  
    4343    ~ThreadIdentifierData();
    4444
     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
    4549    // Creates and puts an instance of ThreadIdentifierData into thread-specific storage.
    4650    static void initialize(ThreadIdentifier identifier);
     
    6367    static void destruct(void* data);
    6468
    65     static void initializeKeyOnceHelper();
    66     static void initializeKeyOnce();
    67 
    6869    ThreadIdentifier m_identifier;
    6970    bool m_isDestroyedOnce;
Note: See TracChangeset for help on using the changeset viewer.