currentThread is too slow!
authorlevin@chromium.org <levin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Jul 2011 18:49:24 +0000 (18:49 +0000)
committerlevin@chromium.org <levin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Jul 2011 18:49:24 +0000 (18:49 +0000)
commit7ed818fea8340513ffbf26e0f3ad5cc65941ba07
treeafcdd84cde343259f72e03c87d41a90290f42db7
parent348fbd2a329d79ec7db07423edfecbbbe62a63ad
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@91082 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/wtf/ThreadIdentifierDataPthreads.cpp
Source/JavaScriptCore/wtf/ThreadIdentifierDataPthreads.h
Source/JavaScriptCore/wtf/ThreadingPthreads.cpp