Ignore:
Timestamp:
Mar 13, 2015, 1:04:29 PM (10 years ago)
Author:
[email protected]
Message:

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).
  1. 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:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/profiler/ProfilerDatabase.cpp

    r163844 r181485  
    3636static std::atomic<int> databaseCounter;
    3737
    38 static SpinLock registrationLock = SPINLOCK_INITIALIZER;
     38static StaticSpinLock registrationLock;
    3939static std::atomic<int> didRegisterAtExit;
    4040static Database* firstDatabase;
     
    139139        atexit(atExitCallback);
    140140   
    141     TCMalloc_SpinLockHolder holder(&registrationLock);
     141    SpinLockHolder holder(registrationLock);
    142142    m_nextRegisteredDatabase = firstDatabase;
    143143    firstDatabase = this;
     
    146146void Database::removeDatabaseFromAtExit()
    147147{
    148     TCMalloc_SpinLockHolder holder(&registrationLock);
     148    SpinLockHolder holder(registrationLock);
    149149    for (Database** current = &firstDatabase; *current; current = &(*current)->m_nextRegisteredDatabase) {
    150150        if (*current != this)
     
    164164Database* Database::removeFirstAtExitDatabase()
    165165{
    166     TCMalloc_SpinLockHolder holder(&registrationLock);
     166    SpinLockHolder holder(registrationLock);
    167167    Database* result = firstDatabase;
    168168    if (result) {
Note: See TracChangeset for help on using the changeset viewer.