Replace TCSpinLock with a new WTF::SpinLock based on WTF::Atomic.
authormark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Mar 2015 20:04:29 +0000 (20:04 +0000)
committermark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Mar 2015 20:04:29 +0000 (20:04 +0000)
commit1611335df4431d1b0b2c36fbf9d386a609844c79
tree8417edd75e4dc8b3eeb06a92de84773e6c0ef827
parent23635c013c4777865e434c77a30ab382bc354980
Replace TCSpinLock with a new WTF::SpinLock based on WTF::Atomic.
<https://webkit.org/b/142674>

Reviewed by Filip Pizlo.

Source/JavaScriptCore:

* API/JSValue.mm:
(handerForStructTag):
* API/JSWrapperMap.mm:
* dfg/DFGCommon.cpp:
(JSC::DFG::startCrashing):
(JSC::DFG::isCrashing):
- Changed to use a StaticSpinLock since that's what this code was trying to do
  anyway.
* heap/CopiedBlock.h:
(JSC::CopiedBlock::CopiedBlock):
* heap/CopiedSpace.cpp:
(JSC::CopiedSpace::CopiedSpace):
* heap/CopiedSpace.h:
* heap/GCThreadSharedData.cpp:
(JSC::GCThreadSharedData::GCThreadSharedData):
* heap/GCThreadSharedData.h:
* heap/ListableHandler.h:
(JSC::ListableHandler::List::List):
* parser/SourceProvider.cpp:
* profiler/ProfilerDatabase.cpp:
(JSC::Profiler::Database::addDatabaseToAtExit):
(JSC::Profiler::Database::removeDatabaseFromAtExit):
(JSC::Profiler::Database::removeFirstAtExitDatabase):

Source/WebCore:

No new tests because there is no new functionality. This is a refactoring effort.

* bindings/objc/WebScriptObject.mm:
* platform/ios/wak/WAKWindow.mm:
(-[WAKWindow initWithLayer:]):
(-[WAKWindow initWithFrame:]):

Source/WebKit2:

* WebProcess/WebPage/EventDispatcher.cpp:
(WebKit::EventDispatcher::EventDispatcher):
* WebProcess/WebPage/EventDispatcher.h:
* WebProcess/WebPage/ViewUpdateDispatcher.cpp:
(WebKit::ViewUpdateDispatcher::ViewUpdateDispatcher):
* WebProcess/WebPage/ViewUpdateDispatcher.h:

Source/WTF:

We no longer use TCMalloc in our code, and we now have C++11.  This replaces the
TCMalloc_SpinLock with a new WTF::SpinLock based on WTF::Atomic (which is a
wrapper around std::atomic).

Note that there is a StaticSpinLock and a SpinLock:

1. StaticSpinLock is an alias for SpinLockBase, and its initialization relies on
   static / global std:atomic being automatically initialized to 0 at compile time.
   Hence, StaticSpinLock should only be used for statics / globals (including
   static members of classes / structs).

2. SpinLock is derived from SpinLockBase, and adds a default constructor to
   initialize its internal atomic value to 0.  Because SpinLock has a constructor,
   it cannot be used for statics / globals.  Objects that want to embed a spin
   lock as an instance field should use SpinLock so that it is initialized properly.
   std::atomic will not automatically initialize instance fields to 0.  Hence,
   StaticSpinLock will not work correctly as instance fields of a class / struct.

* WTF.vcxproj/WTF.vcxproj:
* WTF.vcxproj/WTF.vcxproj.filters:
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/MetaAllocator.cpp:
(WTF::MetaAllocator::~MetaAllocator):
(WTF::MetaAllocator::MetaAllocator):
* wtf/MetaAllocator.h:
* wtf/SpinLock.h: Added.
(WTF::SpinLockBase::lock):
(WTF::SpinLockBase::unlock):
(WTF::SpinLockBase::isLocked):
(WTF::SpinLockBase::slowLock):
(WTF::SpinLock::SpinLock):
* wtf/TCSpinLock.h: Removed.
* wtf/text/AtomicString.cpp:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181485 268f45cc-cd09-0410-ab3c-d52691b4dbfc
30 files changed:
Source/JavaScriptCore/API/JSValue.mm
Source/JavaScriptCore/API/JSWrapperMap.mm
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/dfg/DFGCommon.cpp
Source/JavaScriptCore/heap/CopiedBlock.h
Source/JavaScriptCore/heap/CopiedSpace.cpp
Source/JavaScriptCore/heap/CopiedSpace.h
Source/JavaScriptCore/heap/GCThreadSharedData.cpp
Source/JavaScriptCore/heap/GCThreadSharedData.h
Source/JavaScriptCore/heap/ListableHandler.h
Source/JavaScriptCore/parser/SourceProvider.cpp
Source/JavaScriptCore/profiler/ProfilerDatabase.cpp
Source/WTF/ChangeLog
Source/WTF/WTF.vcxproj/WTF.vcxproj
Source/WTF/WTF.vcxproj/WTF.vcxproj.filters
Source/WTF/WTF.xcodeproj/project.pbxproj
Source/WTF/wtf/CMakeLists.txt
Source/WTF/wtf/MetaAllocator.cpp
Source/WTF/wtf/MetaAllocator.h
Source/WTF/wtf/SpinLock.h [new file with mode: 0644]
Source/WTF/wtf/TCSpinLock.h [deleted file]
Source/WTF/wtf/text/AtomicString.cpp
Source/WebCore/ChangeLog
Source/WebCore/bindings/objc/WebScriptObject.mm
Source/WebCore/platform/ios/wak/WAKWindow.mm
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp
Source/WebKit2/WebProcess/WebPage/EventDispatcher.h
Source/WebKit2/WebProcess/WebPage/ViewUpdateDispatcher.cpp
Source/WebKit2/WebProcess/WebPage/ViewUpdateDispatcher.h