Merge ThreadHolder to WTF::Thread itself
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Aug 2017 18:29:16 +0000 (18:29 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Aug 2017 18:29:16 +0000 (18:29 +0000)
commit2a09ca0c7f4101e04d71aa9f53ac741a3d6014f6
treebb30bd9335b511e7c9280377e79b8668f412f9e9
parentbcc42c562e21caa81014c03e53e6059d4712d0a1
Merge ThreadHolder to WTF::Thread itself
https://bugs.webkit.org/show_bug.cgi?id=175013

Reviewed by Mark Lam.

Currently, we store ThreadHolder* to the TLS, and ThreadHolder* holds Ref<Thread>.
When we get Thread& from the current thread TLS, we need to dereference the ThreadHolder*.
However, ideally, we can store Thread* directly to the current thread TLS.
While the ThreadHolder design is beautiful, it's worth optimizing by storing Thread* directly
since Thread::current() is so frequently executed.

This patch merges ThreadHolder to Thread. And we now store Thread* directly in the TLS.
When storing it to TLS, we call leakRef() to keep Thread ref count incremented by the TLS.
And when destroying the TLS, we call `deref()` to ensure that Thread* is dereferenced from
the TLS.

* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/ThreadHolder.cpp: Removed.
* wtf/ThreadHolder.h: Removed.
* wtf/ThreadHolderPthreads.cpp: Removed.
* wtf/ThreadHolderWin.cpp: Removed.
* wtf/Threading.cpp:
(WTF::Thread::entryPoint):
(WTF::initializeThreading):
* wtf/Threading.h:
(WTF::Thread::currentMayBeNull):
(WTF::Thread::current):
* wtf/ThreadingPthreads.cpp:
(WTF::Thread::waitForCompletion):
(WTF::Thread::initializeCurrentTLS):
(WTF::Thread::initializeTLSKey):
(WTF::Thread::initializeTLS):
(WTF::Thread::destructTLS):
(WTF::Thread::createCurrentThread): Deleted.
* wtf/ThreadingWin.cpp:
(WTF::Thread::initializeCurrentTLS):
(WTF::threadMapMutex):
(WTF::Thread::initializeTLSKey):
(WTF::Thread::currentDying):
(WTF::Thread::get):
(WTF::Thread::initializeTLS):
(WTF::Thread::destructTLS):
(WTF::waitForThreadCompletion):
(WTF::Thread::createCurrentThread): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220214 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WTF/ChangeLog
Source/WTF/WTF.xcodeproj/project.pbxproj
Source/WTF/wtf/CMakeLists.txt
Source/WTF/wtf/ThreadHolder.cpp [deleted file]
Source/WTF/wtf/ThreadHolder.h [deleted file]
Source/WTF/wtf/ThreadHolderPthreads.cpp [deleted file]
Source/WTF/wtf/ThreadHolderWin.cpp [deleted file]
Source/WTF/wtf/Threading.cpp
Source/WTF/wtf/Threading.h
Source/WTF/wtf/ThreadingPthreads.cpp
Source/WTF/wtf/ThreadingWin.cpp