[WTF] Remove StaticLock
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Apr 2018 17:22:21 +0000 (17:22 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Apr 2018 17:22:21 +0000 (17:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184332

Reviewed by Mark Lam.

Source/JavaScriptCore:

* API/JSValue.mm:
(handerForStructTag):
* API/JSVirtualMachine.mm:
(+[JSVMWrapperCache addWrapper:forJSContextGroupRef:]):
(+[JSVMWrapperCache wrapperForJSContextGroupRef:]):
* API/glib/JSCVirtualMachine.cpp:
(addWrapper):
(removeWrapper):
* assembler/testmasm.cpp:
* b3/air/testair.cpp:
* b3/testb3.cpp:
* bytecode/SuperSampler.cpp:
* dfg/DFGCommon.cpp:
* dfg/DFGCommonData.cpp:
* dynbench.cpp:
* heap/MachineStackMarker.cpp:
(JSC::MachineThreads::tryCopyOtherThreadStacks):
* inspector/remote/cocoa/RemoteConnectionToTargetCocoa.mm:
(Inspector::RemoteTargetHandleRunSourceGlobal):
(Inspector::RemoteTargetQueueTaskOnGlobalQueue):
* interpreter/CLoopStack.cpp:
* parser/SourceProvider.cpp:
* profiler/ProfilerDatabase.cpp:
* profiler/ProfilerUID.cpp:
(JSC::Profiler::UID::create):
* runtime/IntlObject.cpp:
(JSC::numberingSystemsForLocale):
* runtime/JSLock.cpp:
* runtime/JSLock.h:
* runtime/SamplingProfiler.cpp:
(JSC::SamplingProfiler::registerForReportAtExit):
* runtime/VM.cpp:
* wasm/WasmFaultSignalHandler.cpp:

Source/WebCore:

No behavior change.

* Modules/webdatabase/Database.cpp:
(WebCore::Database::Database):
(WebCore::Database::performOpenAndVerify):
(WebCore::Database::closeDatabase):
(WebCore::Database::getCachedVersion const):
(WebCore::Database::setCachedVersion):
* Modules/webdatabase/DatabaseTracker.cpp:
(WebCore::DatabaseTracker::openDatabaseMutex):
* Modules/webdatabase/DatabaseTracker.h:
* Modules/websockets/WebSocket.cpp:
(WebCore::WebSocket::allActiveWebSocketsMutex):
* Modules/websockets/WebSocket.h:
* bridge/objc/WebScriptObject.mm:
* crypto/CryptoAlgorithmRegistry.cpp:
(WebCore::CryptoAlgorithmRegistry::identifier):
(WebCore::CryptoAlgorithmRegistry::name):
(WebCore::CryptoAlgorithmRegistry::create):
(WebCore::CryptoAlgorithmRegistry::registerAlgorithm):
* dom/Node.cpp:
* platform/URL.cpp:
* platform/graphics/FontCache.cpp:
* platform/graphics/MediaPlayer.cpp:
* platform/ios/QuickLook.mm:
* platform/ios/WebSQLiteDatabaseTrackerClient.mm:
* platform/ios/wak/WebCoreThread.mm:
* platform/ios/wak/WebCoreThreadRun.cpp:
* platform/network/cf/LoaderRunLoopCF.cpp:
(WebCore::loaderRunLoop):
* platform/network/curl/CurlContext.cpp:
(WebCore::CurlShareHandle::mutexFor):
* platform/network/curl/CurlContext.h:
* platform/sql/SQLiteDatabaseTracker.cpp:
(WebCore::SQLiteDatabaseTracker::incrementTransactionInProgressCount):
(WebCore::SQLiteDatabaseTracker::decrementTransactionInProgressCount):
* platform/text/TextEncodingRegistry.cpp:
(WebCore::buildBaseTextCodecMaps):
(WebCore::newTextCodec):
(WebCore::atomicCanonicalTextEncodingName):
* workers/WorkerThread.cpp:
(WebCore::WorkerThread::workerThreadCount):
(WebCore::WorkerThread::WorkerThread):
(WebCore::WorkerThread::~WorkerThread):
(WebCore::WorkerThread::releaseFastMallocFreeMemoryInAllThreads):

Source/WebKitLegacy/ios:

* WebCoreSupport/WebFixedPositionContent.mm:

Source/WebKitLegacy/mac:

* DOM/DOMInternal.mm:
(getDOMWrapper):
(addDOMWrapper):
(removeDOMWrapper):

Source/WebKitLegacy/win:

* WebKitQuartzCoreAdditions/CAView.cpp:
(WKQCA::CAView::releaseAllD3DResources):
* WebLocalizableStrings.cpp:

Source/WTF:

Now, WTF::StaticLock is `using StaticLock = Lock`. Lock just works
in either static storage and dynamic storage. Remove StaticLock and
always use Lock.

We also remove StaticWordLock and StaticReadWriteLock. And we add
WTF::RecursiveLock, which is RecursiveLockAdapter<Lock>.

* wtf/HashTable.cpp:
(WTF::HashTableStats::recordCollisionAtCount):
(WTF::HashTableStats::dumpStats):
* wtf/Language.cpp:
(WTF::userPreferredLanguages):
* wtf/Lock.h:
* wtf/MainThread.cpp:
(WTF::dispatchFunctionsFromMainThread):
(WTF::callOnMainThread):
* wtf/ParkingLot.cpp:
* wtf/ReadWriteLock.h:
* wtf/RecursiveLockAdapter.h:
* wtf/StackStats.cpp:
(WTF::StackStats::CheckPoint::CheckPoint):
(WTF::StackStats::CheckPoint::~CheckPoint):
(WTF::StackStats::probe):
(WTF::StackStats::LayoutCheckPoint::LayoutCheckPoint):
(WTF::StackStats::LayoutCheckPoint::~LayoutCheckPoint):
* wtf/StackStats.h:
* wtf/ThreadMessage.cpp:
(WTF::sendMessageScoped):
* wtf/ThreadingPthreads.cpp:
* wtf/ThreadingWin.cpp:
* wtf/WordLock.h:
* wtf/cf/LanguageCF.cpp:
(WTF::languagePreferencesDidChange):
(WTF::platformUserPreferredLanguages):
* wtf/dtoa.cpp:
* wtf/text/AtomicStringImpl.cpp:
* wtf/text/StringView.cpp:
(WTF::StringView::invalidate):
(WTF::StringView::adoptUnderlyingString):
(WTF::StringView::setUnderlyingString):
* wtf/unicode/icu/CollatorICU.cpp:
(WTF::Collator::Collator):
(WTF::Collator::~Collator):
* wtf/win/LanguageWin.cpp:
(WTF::platformLanguage):

Tools:

* DumpRenderTree/JavaScriptThreading.cpp:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@230303 268f45cc-cd09-0410-ab3c-d52691b4dbfc

74 files changed:
Source/JavaScriptCore/API/JSValue.mm
Source/JavaScriptCore/API/JSVirtualMachine.mm
Source/JavaScriptCore/API/glib/JSCVirtualMachine.cpp
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/assembler/testmasm.cpp
Source/JavaScriptCore/b3/air/testair.cpp
Source/JavaScriptCore/b3/testb3.cpp
Source/JavaScriptCore/bytecode/SuperSampler.cpp
Source/JavaScriptCore/dfg/DFGCommon.cpp
Source/JavaScriptCore/dfg/DFGCommonData.cpp
Source/JavaScriptCore/dynbench.cpp
Source/JavaScriptCore/heap/MachineStackMarker.cpp
Source/JavaScriptCore/inspector/remote/cocoa/RemoteConnectionToTargetCocoa.mm
Source/JavaScriptCore/interpreter/CLoopStack.cpp
Source/JavaScriptCore/parser/SourceProvider.cpp
Source/JavaScriptCore/profiler/ProfilerDatabase.cpp
Source/JavaScriptCore/profiler/ProfilerUID.cpp
Source/JavaScriptCore/runtime/IntlObject.cpp
Source/JavaScriptCore/runtime/JSLock.cpp
Source/JavaScriptCore/runtime/JSLock.h
Source/JavaScriptCore/runtime/SamplingProfiler.cpp
Source/JavaScriptCore/runtime/VM.cpp
Source/JavaScriptCore/wasm/WasmFaultSignalHandler.cpp
Source/WTF/ChangeLog
Source/WTF/wtf/HashTable.cpp
Source/WTF/wtf/Language.cpp
Source/WTF/wtf/Lock.h
Source/WTF/wtf/MainThread.cpp
Source/WTF/wtf/ParkingLot.cpp
Source/WTF/wtf/ReadWriteLock.h
Source/WTF/wtf/RecursiveLockAdapter.h
Source/WTF/wtf/StackStats.cpp
Source/WTF/wtf/StackStats.h
Source/WTF/wtf/ThreadMessage.cpp
Source/WTF/wtf/ThreadingPthreads.cpp
Source/WTF/wtf/ThreadingWin.cpp
Source/WTF/wtf/WordLock.h
Source/WTF/wtf/cf/LanguageCF.cpp
Source/WTF/wtf/dtoa.cpp
Source/WTF/wtf/text/AtomicStringImpl.cpp
Source/WTF/wtf/text/StringView.cpp
Source/WTF/wtf/unicode/icu/CollatorICU.cpp
Source/WTF/wtf/win/LanguageWin.cpp
Source/WebCore/ChangeLog
Source/WebCore/Modules/webdatabase/Database.cpp
Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp
Source/WebCore/Modules/webdatabase/DatabaseTracker.h
Source/WebCore/Modules/websockets/WebSocket.cpp
Source/WebCore/Modules/websockets/WebSocket.h
Source/WebCore/bridge/objc/WebScriptObject.mm
Source/WebCore/crypto/CryptoAlgorithmRegistry.cpp
Source/WebCore/dom/Node.cpp
Source/WebCore/platform/URL.cpp
Source/WebCore/platform/graphics/FontCache.cpp
Source/WebCore/platform/graphics/MediaPlayer.cpp
Source/WebCore/platform/ios/QuickLook.mm
Source/WebCore/platform/ios/WebSQLiteDatabaseTrackerClient.mm
Source/WebCore/platform/ios/wak/WebCoreThread.mm
Source/WebCore/platform/ios/wak/WebCoreThreadRun.cpp
Source/WebCore/platform/network/cf/LoaderRunLoopCF.cpp
Source/WebCore/platform/network/curl/CurlContext.cpp
Source/WebCore/platform/network/curl/CurlContext.h
Source/WebCore/platform/sql/SQLiteDatabaseTracker.cpp
Source/WebCore/platform/text/TextEncodingRegistry.cpp
Source/WebCore/workers/WorkerThread.cpp
Source/WebKitLegacy/ios/ChangeLog
Source/WebKitLegacy/ios/WebCoreSupport/WebFixedPositionContent.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/DOM/DOMInternal.mm
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebKitQuartzCoreAdditions/CAView.cpp
Source/WebKitLegacy/win/WebLocalizableStrings.cpp
Tools/ChangeLog
Tools/DumpRenderTree/JavaScriptThreading.cpp

index c810f14..e8ad52e 100644 (file)
@@ -1115,7 +1115,7 @@ static StructHandlers* createStructHandlerMap()
 
 static StructTagHandler* handerForStructTag(const char* encodedType)
 {
-    static StaticLock handerForStructTagLock;
+    static Lock handerForStructTagLock;
     LockHolder lockHolder(&handerForStructTagLock);
 
     static StructHandlers* structHandlers = createStructHandlerMap();
index e7c9af8..9fd7346 100644 (file)
@@ -42,7 +42,7 @@
 
 static NSMapTable *globalWrapperCache = 0;
 
-static StaticLock wrapperCacheMutex;
+static Lock wrapperCacheMutex;
 
 static void initWrapperCache()
 {
@@ -68,13 +68,13 @@ static NSMapTable *wrapperCache()
 
 + (void)addWrapper:(JSVirtualMachine *)wrapper forJSContextGroupRef:(JSContextGroupRef)group
 {
-    std::lock_guard<StaticLock> lock(wrapperCacheMutex);
+    std::lock_guard<Lock> lock(wrapperCacheMutex);
     NSMapInsert(wrapperCache(), group, wrapper);
 }
 
 + (JSVirtualMachine *)wrapperForJSContextGroupRef:(JSContextGroupRef)group
 {
-    std::lock_guard<StaticLock> lock(wrapperCacheMutex);
+    std::lock_guard<Lock> lock(wrapperCacheMutex);
     return static_cast<JSVirtualMachine *>(NSMapGet(wrapperCache(), group));
 }
 
index f97c1db..c061afe 100644 (file)
@@ -47,7 +47,7 @@ struct _JSCVirtualMachinePrivate {
 
 WEBKIT_DEFINE_TYPE(JSCVirtualMachine, jsc_virtual_machine, G_TYPE_OBJECT)
 
-static StaticLock wrapperCacheMutex;
+static Lock wrapperCacheMutex;
 
 static HashMap<JSContextGroupRef, JSCVirtualMachine*>& wrapperMap()
 {
@@ -57,14 +57,14 @@ static HashMap<JSContextGroupRef, JSCVirtualMachine*>& wrapperMap()
 
 static void addWrapper(JSContextGroupRef group, JSCVirtualMachine* vm)
 {
-    std::lock_guard<StaticLock> lock(wrapperCacheMutex);
+    std::lock_guard<Lock> lock(wrapperCacheMutex);
     ASSERT(!wrapperMap().contains(group));
     wrapperMap().set(group, vm);
 }
 
 static void removeWrapper(JSContextGroupRef group)
 {
-    std::lock_guard<StaticLock> lock(wrapperCacheMutex);
+    std::lock_guard<Lock> lock(wrapperCacheMutex);
     ASSERT(wrapperMap().contains(group));
     wrapperMap().remove(group);
 }
index 59c8426..9cb8296 100644 (file)
@@ -1,3 +1,44 @@
+2018-04-05  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [WTF] Remove StaticLock
+        https://bugs.webkit.org/show_bug.cgi?id=184332
+
+        Reviewed by Mark Lam.
+
+        * API/JSValue.mm:
+        (handerForStructTag):
+        * API/JSVirtualMachine.mm:
+        (+[JSVMWrapperCache addWrapper:forJSContextGroupRef:]):
+        (+[JSVMWrapperCache wrapperForJSContextGroupRef:]):
+        * API/glib/JSCVirtualMachine.cpp:
+        (addWrapper):
+        (removeWrapper):
+        * assembler/testmasm.cpp:
+        * b3/air/testair.cpp:
+        * b3/testb3.cpp:
+        * bytecode/SuperSampler.cpp:
+        * dfg/DFGCommon.cpp:
+        * dfg/DFGCommonData.cpp:
+        * dynbench.cpp:
+        * heap/MachineStackMarker.cpp:
+        (JSC::MachineThreads::tryCopyOtherThreadStacks):
+        * inspector/remote/cocoa/RemoteConnectionToTargetCocoa.mm:
+        (Inspector::RemoteTargetHandleRunSourceGlobal):
+        (Inspector::RemoteTargetQueueTaskOnGlobalQueue):
+        * interpreter/CLoopStack.cpp:
+        * parser/SourceProvider.cpp:
+        * profiler/ProfilerDatabase.cpp:
+        * profiler/ProfilerUID.cpp:
+        (JSC::Profiler::UID::create):
+        * runtime/IntlObject.cpp:
+        (JSC::numberingSystemsForLocale):
+        * runtime/JSLock.cpp:
+        * runtime/JSLock.h:
+        * runtime/SamplingProfiler.cpp:
+        (JSC::SamplingProfiler::registerForReportAtExit):
+        * runtime/VM.cpp:
+        * wasm/WasmFaultSignalHandler.cpp:
+
 2018-04-04  Mark Lam  <mark.lam@apple.com>
 
         Add pointer profiling support to the DFG and supporting files.
index da45022..86c42b0 100644 (file)
@@ -80,7 +80,7 @@ namespace {
 using CPUState = Probe::CPUState;
 #endif
 
-StaticLock crashLock;
+Lock crashLock;
 
 typedef WTF::Function<void(CCallHelpers&)> Generator;
 
index 7b95264..d6bffe9 100644 (file)
@@ -71,7 +71,7 @@ using JSC::B3::Width64;
 
 namespace {
 
-StaticLock crashLock;
+Lock crashLock;
 
 // Nothing fancy for now; we just use the existing WTF assertion machinery.
 #define CHECK(x) do {                                                   \
@@ -123,7 +123,7 @@ void testSimple()
 template<typename T>
 void loadConstantImpl(BasicBlock* block, T value, B3::Air::Opcode move, Tmp tmp, Tmp scratch)
 {
-    static StaticLock lock;
+    static Lock lock;
     static StdMap<T, T*>* map; // I'm not messing with HashMap's problems with integers.
 
     LockHolder locker(lock);
index e7bf012..6dc9177 100644 (file)
@@ -97,7 +97,7 @@ bool shouldBeVerbose()
     return shouldDumpIR(B3Mode);
 }
 
-StaticLock crashLock;
+Lock crashLock;
 
 // Nothing fancy for now; we just use the existing WTF assertion machinery.
 #define CHECK(x) do {                                                   \
index f2efc67..a351870 100644 (file)
@@ -36,7 +36,7 @@ namespace JSC {
 
 volatile uint32_t g_superSamplerCount;
 
-static StaticLock lock;
+static Lock lock;
 static double in;
 static double out;
 
index cd2a12c..3a15b0f 100644 (file)
@@ -34,7 +34,7 @@
 
 namespace JSC { namespace DFG {
 
-static StaticLock crashLock;
+static Lock crashLock;
 
 void startCrashing()
 {
index eb387b2..b11aab1 100644 (file)
@@ -90,7 +90,7 @@ void CommonData::shrinkToFit()
     catchEntrypoints.shrinkToFit();
 }
 
-static StaticLock pcCodeBlockMapLock;
+static Lock pcCodeBlockMapLock;
 inline HashMap<void*, CodeBlock*>& pcCodeBlockMap(AbstractLocker&)
 {
     static NeverDestroyed<HashMap<void*, CodeBlock*>> pcCodeBlockMap;
index f799068..bb9d3b5 100644 (file)
@@ -39,7 +39,7 @@ using namespace JSC;
 
 namespace {
 
-StaticLock crashLock;
+Lock crashLock;
 const char* nameFilter;
 unsigned requestedIterationCount;
 
index ef7dd44..8f6c620 100644 (file)
@@ -139,8 +139,8 @@ bool MachineThreads::tryCopyOtherThreadStacks(const AbstractLocker& locker, void
 {
     // Prevent two VMs from suspending each other's threads at the same time,
     // which can cause deadlock: <rdar://problem/20300842>.
-    static StaticLock mutex;
-    std::lock_guard<StaticLock> lock(mutex);
+    static Lock mutex;
+    std::lock_guard<Lock> lock(mutex);
 
     *size = 0;
 
index b0a80fe..3e89413 100644 (file)
@@ -41,7 +41,7 @@
 
 namespace Inspector {
 
-static StaticLock rwiQueueMutex;
+static Lock rwiQueueMutex;
 static CFRunLoopSourceRef rwiRunLoopSource;
 static RemoteTargetQueue* rwiQueue;
 
@@ -53,7 +53,7 @@ static void RemoteTargetHandleRunSourceGlobal(void*)
 
     RemoteTargetQueue queueCopy;
     {
-        std::lock_guard<StaticLock> lock(rwiQueueMutex);
+        std::lock_guard<Lock> lock(rwiQueueMutex);
         queueCopy = *rwiQueue;
         rwiQueue->clear();
     }
@@ -68,7 +68,7 @@ static void RemoteTargetQueueTaskOnGlobalQueue(void (^task)())
     ASSERT(rwiQueue);
 
     {
-        std::lock_guard<StaticLock> lock(rwiQueueMutex);
+        std::lock_guard<Lock> lock(rwiQueueMutex);
         rwiQueue->append(task);
     }
 
index 9c464e3..abc10a8 100644 (file)
@@ -48,7 +48,7 @@ static size_t commitSize()
     return size;
 }
 
-static StaticLock stackStatisticsMutex;
+static Lock stackStatisticsMutex;
 
 CLoopStack::CLoopStack(VM& vm)
     : m_vm(vm)
index 94d9fbd..9a13eb2 100644 (file)
@@ -45,7 +45,7 @@ SourceProvider::~SourceProvider()
 {
 }
 
-static StaticLock providerIdLock;
+static Lock providerIdLock;
 
 void SourceProvider::getID()
 {
index d454e78..911d681 100644 (file)
@@ -37,7 +37,7 @@ namespace JSC { namespace Profiler {
 
 static std::atomic<int> databaseCounter;
 
-static StaticLock registrationLock;
+static Lock registrationLock;
 static std::atomic<int> didRegisterAtExit;
 static Database* firstDatabase;
 
index 228988b..b5cb114 100644 (file)
@@ -33,7 +33,7 @@ namespace JSC { namespace Profiler {
 
 UID UID::create()
 {
-    static StaticLock lock;
+    static Lock lock;
     static uint64_t counter;
     
     LockHolder locker(lock);
index 6a49538..3f54340 100644 (file)
@@ -853,8 +853,8 @@ Vector<String> numberingSystemsForLocale(const String& locale)
     Vector<String>& availableNumberingSystems = cachedNumberingSystems.get();
 
     if (UNLIKELY(availableNumberingSystems.isEmpty())) {
-        static StaticLock cachedNumberingSystemsMutex;
-        std::lock_guard<StaticLock> lock(cachedNumberingSystemsMutex);
+        static Lock cachedNumberingSystemsMutex;
+        std::lock_guard<Lock> lock(cachedNumberingSystemsMutex);
         if (availableNumberingSystems.isEmpty()) {
             UErrorCode status = U_ZERO_ERROR;
             UEnumeration* numberingSystemNames = unumsys_openAvailableNames(&status);
index b6bb130..f948e88 100644 (file)
@@ -36,7 +36,7 @@
 
 namespace JSC {
 
-StaticLock GlobalJSLock::s_sharedInstanceMutex;
+Lock GlobalJSLock::s_sharedInstanceMutex;
 
 GlobalJSLock::GlobalJSLock()
 {
index bedf2b5..c0b82e6 100644 (file)
@@ -60,7 +60,7 @@ public:
     JS_EXPORT_PRIVATE GlobalJSLock();
     JS_EXPORT_PRIVATE ~GlobalJSLock();
 private:
-    static StaticLock s_sharedInstanceMutex;
+    static Lock s_sharedInstanceMutex;
 };
 
 class JSLockHolder {
index 5e740c2..bb69658 100644 (file)
@@ -909,7 +909,7 @@ String SamplingProfiler::stackTracesAsJSON()
 
 void SamplingProfiler::registerForReportAtExit()
 {
-    static StaticLock registrationLock;
+    static Lock registrationLock;
     static HashSet<RefPtr<SamplingProfiler>>* profilesToReport;
 
     LockHolder holder(registrationLock);
index 0b1557e..7ad510f 100644 (file)
@@ -463,7 +463,7 @@ VM::VM(VMType vmType, HeapType heapType)
     VMInspector::instance().add(this);
 }
 
-static StaticReadWriteLock s_destructionLock;
+static ReadWriteLock s_destructionLock;
 
 void waitForVMDestruction()
 {
index 6191492..9657108 100644 (file)
@@ -47,7 +47,7 @@ static const bool verbose = false;
 }
 }
 
-static StaticLock codeLocationsLock;
+static Lock codeLocationsLock;
 static LazyNeverDestroyed<HashSet<std::tuple<void*, void*>>> codeLocations; // (start, end)
 
 #if ENABLE(WEBASSEMBLY_FAST_MEMORY)
index 6477a09..3e3860b 100644 (file)
@@ -1,3 +1,56 @@
+2018-04-05  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [WTF] Remove StaticLock
+        https://bugs.webkit.org/show_bug.cgi?id=184332
+
+        Reviewed by Mark Lam.
+
+        Now, WTF::StaticLock is `using StaticLock = Lock`. Lock just works
+        in either static storage and dynamic storage. Remove StaticLock and
+        always use Lock.
+
+        We also remove StaticWordLock and StaticReadWriteLock. And we add
+        WTF::RecursiveLock, which is RecursiveLockAdapter<Lock>.
+
+        * wtf/HashTable.cpp:
+        (WTF::HashTableStats::recordCollisionAtCount):
+        (WTF::HashTableStats::dumpStats):
+        * wtf/Language.cpp:
+        (WTF::userPreferredLanguages):
+        * wtf/Lock.h:
+        * wtf/MainThread.cpp:
+        (WTF::dispatchFunctionsFromMainThread):
+        (WTF::callOnMainThread):
+        * wtf/ParkingLot.cpp:
+        * wtf/ReadWriteLock.h:
+        * wtf/RecursiveLockAdapter.h:
+        * wtf/StackStats.cpp:
+        (WTF::StackStats::CheckPoint::CheckPoint):
+        (WTF::StackStats::CheckPoint::~CheckPoint):
+        (WTF::StackStats::probe):
+        (WTF::StackStats::LayoutCheckPoint::LayoutCheckPoint):
+        (WTF::StackStats::LayoutCheckPoint::~LayoutCheckPoint):
+        * wtf/StackStats.h:
+        * wtf/ThreadMessage.cpp:
+        (WTF::sendMessageScoped):
+        * wtf/ThreadingPthreads.cpp:
+        * wtf/ThreadingWin.cpp:
+        * wtf/WordLock.h:
+        * wtf/cf/LanguageCF.cpp:
+        (WTF::languagePreferencesDidChange):
+        (WTF::platformUserPreferredLanguages):
+        * wtf/dtoa.cpp:
+        * wtf/text/AtomicStringImpl.cpp:
+        * wtf/text/StringView.cpp:
+        (WTF::StringView::invalidate):
+        (WTF::StringView::adoptUnderlyingString):
+        (WTF::StringView::setUnderlyingString):
+        * wtf/unicode/icu/CollatorICU.cpp:
+        (WTF::Collator::Collator):
+        (WTF::Collator::~Collator):
+        * wtf/win/LanguageWin.cpp:
+        (WTF::platformLanguage):
+
 2018-04-04  Brent Fulgham  <bfulgham@apple.com>
 
         Failures from mach port reference handling should be fatal
index b06eaf6..0eb6036 100644 (file)
@@ -36,11 +36,11 @@ unsigned HashTableStats::numCollisions;
 unsigned HashTableStats::collisionGraph[4096];
 unsigned HashTableStats::maxCollisions;
 
-static StaticLock hashTableStatsMutex;
+static Lock hashTableStatsMutex;
 
 void HashTableStats::recordCollisionAtCount(unsigned count)
 {
-    std::lock_guard<StaticLock> lock(hashTableStatsMutex);
+    std::lock_guard<Lock> lock(hashTableStatsMutex);
 
     if (count > maxCollisions)
         maxCollisions = count;
@@ -50,7 +50,7 @@ void HashTableStats::recordCollisionAtCount(unsigned count)
 
 void HashTableStats::dumpStats()
 {
-    std::lock_guard<StaticLock> lock(hashTableStatsMutex);
+    std::lock_guard<Lock> lock(hashTableStatsMutex);
 
     dataLogF("\nWTF::HashTable statistics\n\n");
     dataLogF("%u accesses\n", numAccesses.load());
index aa2e8c1..e1f5e03 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace WTF {
 
-static StaticLock userPreferredLanguagesMutex;
+static Lock userPreferredLanguagesMutex;
 
 typedef HashMap<void*, LanguageChangeObserverFunction> ObserverMap;
 static ObserverMap& observerMap()
@@ -102,7 +102,7 @@ static Vector<String> isolatedCopy(const Vector<String>& strings)
 Vector<String> userPreferredLanguages()
 {
     {
-        std::lock_guard<StaticLock> lock(userPreferredLanguagesMutex);
+        std::lock_guard<Lock> lock(userPreferredLanguagesMutex);
         Vector<String>& override = preferredLanguagesOverride();
         if (!override.isEmpty())
             return isolatedCopy(override);
index 631de96..d3c7215 100644 (file)
@@ -132,14 +132,12 @@ private:
     Atomic<uint8_t> m_byte { 0 };
 };
 
-using StaticLock = Lock;
 using LockHolder = Locker<Lock>;
 
 } // namespace WTF
 
 using WTF::Lock;
 using WTF::LockHolder;
-using WTF::StaticLock;
 
 #endif // WTF_Lock_h
 
index 7475888..df2244d 100644 (file)
@@ -46,7 +46,7 @@ static bool callbacksPaused; // This global variable is only accessed from main
 static Thread* mainThread { nullptr };
 #endif
 
-static StaticLock mainThreadFunctionQueueMutex;
+static Lock mainThreadFunctionQueueMutex;
 
 static Deque<Function<void ()>>& functionQueue()
 {
@@ -119,7 +119,7 @@ void dispatchFunctionsFromMainThread()
 
     while (true) {
         {
-            std::lock_guard<StaticLock> lock(mainThreadFunctionQueueMutex);
+            std::lock_guard<Lock> lock(mainThreadFunctionQueueMutex);
             if (!functionQueue().size())
                 break;
 
@@ -149,7 +149,7 @@ void callOnMainThread(Function<void()>&& function)
     bool needToSchedule = false;
 
     {
-        std::lock_guard<StaticLock> lock(mainThreadFunctionQueueMutex);
+        std::lock_guard<Lock> lock(mainThreadFunctionQueueMutex);
         needToSchedule = functionQueue().size() == 0;
         functionQueue().append(WTFMove(function));
     }
index 539bc2a..c78c028 100644 (file)
@@ -205,7 +205,7 @@ struct Hashtable;
 
 // We track all allocated hashtables so that hashtable resizing doesn't anger leak detectors.
 Vector<Hashtable*>* hashtables;
-StaticWordLock hashtablesLock;
+WordLock hashtablesLock;
 
 struct Hashtable {
     unsigned size;
index 67f3094..4bfdd09 100644 (file)
@@ -85,10 +85,6 @@ public:
 inline ReadWriteLock::ReadLock& ReadWriteLock::read() { return *static_cast<ReadLock*>(this); }
 inline ReadWriteLock::WriteLock& ReadWriteLock::write() { return *static_cast<WriteLock*>(this); }
 
-using StaticReadWriteLock = ReadWriteLock;
-
 } // namespace WTF
 
 using WTF::ReadWriteLock;
-using WTF::StaticReadWriteLock;
-
index 031384d..f560572 100644 (file)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include <wtf/Lock.h>
 #include <wtf/Threading.h>
 
 namespace WTF {
@@ -86,6 +87,8 @@ private:
     LockType m_lock;
 };
 
-} // namespace WTF
+using RecursiveLock = RecursiveLockAdapter<Lock>;
 
+} // namespace WTF
 
+using WTF::RecursiveLock;
index 8cb4622..78f6285 100644 (file)
@@ -41,7 +41,7 @@
 namespace WTF {
 
 // CheckPoint management:
-StaticLock StackStats::s_sharedMutex;
+Lock StackStats::s_sharedMutex;
 StackStats::CheckPoint* StackStats::s_topCheckPoint = 0;
 StackStats::LayoutCheckPoint* StackStats::s_firstLayoutCheckPoint = 0;
 StackStats::LayoutCheckPoint* StackStats::s_topLayoutCheckPoint = 0;
@@ -68,7 +68,7 @@ StackStats::PerThreadStats::PerThreadStats()
 
 StackStats::CheckPoint::CheckPoint()
 {
-    std::lock_guard<StaticLock> lock(StackStats::s_sharedMutex);
+    std::lock_guard<Lock> lock(StackStats::s_sharedMutex);
     Thread& thread = Thread::current();
     StackStats::PerThreadStats& t = thread.stackStats();
     const StackBounds& stack = thread.stack();
@@ -126,7 +126,7 @@ StackStats::CheckPoint::CheckPoint()
 
 StackStats::CheckPoint::~CheckPoint()
 {
-    std::lock_guard<StaticLock> lock(StackStats::s_sharedMutex);
+    std::lock_guard<Lock> lock(StackStats::s_sharedMutex);
     Thread& thread = Thread::current();
     StackStats::PerThreadStats& t = thread.stackStats();
 
@@ -157,7 +157,7 @@ StackStats::CheckPoint::~CheckPoint()
 
 void StackStats::probe()
 {
-    std::lock_guard<StaticLock> lock(StackStats::s_sharedMutex);
+    std::lock_guard<Lock> lock(StackStats::s_sharedMutex);
     Thread& thread = Thread::current();
     StackStats::PerThreadStats& t = thread.stackStats();
     const StackBounds& stack = thread.stack();
@@ -218,7 +218,7 @@ StackStats::LayoutCheckPoint::LayoutCheckPoint()
     // probe first, we can avoid re-entering the lock.
     StackStats::probe();
 
-    std::lock_guard<StaticLock> lock(StackStats::s_sharedMutex);
+    std::lock_guard<Lock> lock(StackStats::s_sharedMutex);
     Thread& thread = Thread::current();
     StackStats::PerThreadStats& t = thread.stackStats();
     const StackBounds& stack = thread.stack();
@@ -287,7 +287,7 @@ StackStats::LayoutCheckPoint::LayoutCheckPoint()
 
 StackStats::LayoutCheckPoint::~LayoutCheckPoint()
 {
-    std::lock_guard<StaticLock> lock(StackStats::s_sharedMutex);
+    std::lock_guard<Lock> lock(StackStats::s_sharedMutex);
 
     // Pop to the previous layout checkpoint:
     StackStats::s_topLayoutCheckPoint = m_prev;
index 5464b4f..101779c 100644 (file)
@@ -120,7 +120,7 @@ public:
 
 private:
     // CheckPoint management:
-    static StaticLock s_sharedMutex;
+    static Lock s_sharedMutex;
     static CheckPoint* s_topCheckPoint;
     static LayoutCheckPoint* s_firstLayoutCheckPoint;
     static LayoutCheckPoint* s_topLayoutCheckPoint;
index 56d6bcf..8674cf5 100644 (file)
@@ -33,7 +33,7 @@ namespace WTF {
 
 MessageStatus sendMessageScoped(Thread& thread, const ThreadMessage& message)
 {
-    static StaticLock messageLock;
+    static Lock messageLock;
     auto lockholder = holdLock(messageLock);
 
     auto result = thread.suspend();
index 01edadc..ddac737 100644 (file)
@@ -68,7 +68,7 @@
 
 namespace WTF {
 
-static StaticLock globalSuspendLock;
+static Lock globalSuspendLock;
 
 Thread::~Thread()
 {
index 9799fc1..6f3d41d 100644 (file)
 
 namespace WTF {
 
-static StaticLock globalSuspendLock;
+static Lock globalSuspendLock;
 
 Thread::~Thread()
 {
index 7a90f8b..bf1354a 100644 (file)
@@ -101,14 +101,12 @@ protected:
     Atomic<uintptr_t> m_word { 0 };
 };
 
-using StaticWordLock = WordLock;
 using WordLockHolder = Locker<WordLock>;
 
 } // namespace WTF
 
 using WTF::WordLock;
 using WTF::WordLockHolder;
-using WTF::StaticWordLock;
 
 #endif // WTF_WordLock_h
 
index ac203d1..83d7b90 100644 (file)
@@ -38,7 +38,7 @@
 
 namespace WTF {
 
-static StaticLock preferredLanguagesMutex;
+static Lock preferredLanguagesMutex;
 
 static Vector<String>& preferredLanguages()
 {
@@ -76,7 +76,7 @@ static String httpStyleLanguageCode(CFStringRef language)
 static void languagePreferencesDidChange(CFNotificationCenterRef, void*, CFStringRef, const void*, CFDictionaryRef)
 {
     {
-        std::lock_guard<StaticLock> lock(preferredLanguagesMutex);
+        std::lock_guard<Lock> lock(preferredLanguagesMutex);
         preferredLanguages().clear();
     }
     
@@ -93,7 +93,7 @@ Vector<String> platformUserPreferredLanguages()
     });
 #endif
 
-    std::lock_guard<StaticLock> lock(preferredLanguagesMutex);
+    std::lock_guard<Lock> lock(preferredLanguagesMutex);
     Vector<String>& userPreferredLanguages = preferredLanguages();
 
     if (userPreferredLanguages.isEmpty()) {
index 972b289..edefd7f 100644 (file)
@@ -55,7 +55,7 @@
 
 namespace WTF {
 
-static StaticLock s_dtoaP5Mutex;
+static Lock s_dtoaP5Mutex;
 
 typedef union {
     double d;
index 1ca83cc..f103d9e 100644 (file)
@@ -47,7 +47,7 @@ using namespace Unicode;
 class AtomicStringTableLocker : public LockHolder {
     WTF_MAKE_NONCOPYABLE(AtomicStringTableLocker);
 
-    static StaticLock s_stringTableLock;
+    static Lock s_stringTableLock;
 public:
     AtomicStringTableLocker()
         : LockHolder(&s_stringTableLock)
@@ -55,7 +55,7 @@ public:
     }
 };
 
-StaticLock AtomicStringTableLocker::s_stringTableLock;
+Lock AtomicStringTableLocker::s_stringTableLock;
 
 #else
 
index 5807997..ec10919 100644 (file)
@@ -215,7 +215,7 @@ StringView::UnderlyingString::UnderlyingString(const StringImpl& string)
 {
 }
 
-static StaticLock underlyingStringsMutex;
+static Lock underlyingStringsMutex;
 
 static HashMap<const StringImpl*, StringView::UnderlyingString*>& underlyingStrings()
 {
@@ -227,7 +227,7 @@ void StringView::invalidate(const StringImpl& stringToBeDestroyed)
 {
     UnderlyingString* underlyingString;
     {
-        std::lock_guard<StaticLock> lock(underlyingStringsMutex);
+        std::lock_guard<Lock> lock(underlyingStringsMutex);
         underlyingString = underlyingStrings().take(&stringToBeDestroyed);
         if (!underlyingString)
             return;
@@ -244,7 +244,7 @@ bool StringView::underlyingStringIsValid() const
 void StringView::adoptUnderlyingString(UnderlyingString* underlyingString)
 {
     if (m_underlyingString) {
-        std::lock_guard<StaticLock> lock(underlyingStringsMutex);
+        std::lock_guard<Lock> lock(underlyingStringsMutex);
         if (!--m_underlyingString->refCount) {
             if (m_underlyingString->isValid) {
                 underlyingStrings().remove(&m_underlyingString->string);
@@ -261,7 +261,7 @@ void StringView::setUnderlyingString(const StringImpl* string)
     if (!string)
         underlyingString = nullptr;
     else {
-        std::lock_guard<StaticLock> lock(underlyingStringsMutex);
+        std::lock_guard<Lock> lock(underlyingStringsMutex);
         auto result = underlyingStrings().add(string, nullptr);
         if (result.isNewEntry)
             result.iterator->value = new UnderlyingString(*string);
index f5e32a1..ffcd5f7 100644 (file)
@@ -49,7 +49,7 @@ static UCollator* cachedCollator;
 static char* cachedCollatorLocale;
 static bool cachedCollatorShouldSortLowercaseFirst;
 
-static StaticLock cachedCollatorMutex;
+static Lock cachedCollatorMutex;
 
 #if !(OS(DARWIN) && USE(CF))
 
@@ -106,7 +106,7 @@ Collator::Collator(const char* locale, bool shouldSortLowercaseFirst)
     UErrorCode status = U_ZERO_ERROR;
 
     {
-        std::lock_guard<StaticLock> lock(cachedCollatorMutex);
+        std::lock_guard<Lock> lock(cachedCollatorMutex);
         if (cachedCollator && localesMatch(cachedCollatorLocale, locale) && cachedCollatorShouldSortLowercaseFirst == shouldSortLowercaseFirst) {
             m_collator = cachedCollator;
             m_locale = cachedCollatorLocale;
@@ -136,7 +136,7 @@ Collator::Collator(const char* locale, bool shouldSortLowercaseFirst)
 
 Collator::~Collator()
 {
-    std::lock_guard<StaticLock> lock(cachedCollatorMutex);
+    std::lock_guard<Lock> lock(cachedCollatorMutex);
     if (cachedCollator) {
         ucol_close(cachedCollator);
         fastFree(cachedCollatorLocale);
index 7601098..d31d957 100644 (file)
@@ -34,7 +34,7 @@
 
 namespace WTF {
 
-static StaticLock platformLanguageMutex;
+static Lock platformLanguageMutex;
 
 static String localeInfo(LCTYPE localeType, const String& fallback)
 {
@@ -56,7 +56,7 @@ static String localeInfo(LCTYPE localeType, const String& fallback)
 
 static String platformLanguage()
 {
-    std::lock_guard<StaticLock> lock(platformLanguageMutex);
+    std::lock_guard<Lock> lock(platformLanguageMutex);
 
     static String computedDefaultLanguage;
     if (!computedDefaultLanguage.isEmpty())
index 34853aa..4f3c86f 100644 (file)
@@ -1,3 +1,56 @@
+2018-04-05  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [WTF] Remove StaticLock
+        https://bugs.webkit.org/show_bug.cgi?id=184332
+
+        Reviewed by Mark Lam.
+
+        No behavior change.
+
+        * Modules/webdatabase/Database.cpp:
+        (WebCore::Database::Database):
+        (WebCore::Database::performOpenAndVerify):
+        (WebCore::Database::closeDatabase):
+        (WebCore::Database::getCachedVersion const):
+        (WebCore::Database::setCachedVersion):
+        * Modules/webdatabase/DatabaseTracker.cpp:
+        (WebCore::DatabaseTracker::openDatabaseMutex):
+        * Modules/webdatabase/DatabaseTracker.h:
+        * Modules/websockets/WebSocket.cpp:
+        (WebCore::WebSocket::allActiveWebSocketsMutex):
+        * Modules/websockets/WebSocket.h:
+        * bridge/objc/WebScriptObject.mm:
+        * crypto/CryptoAlgorithmRegistry.cpp:
+        (WebCore::CryptoAlgorithmRegistry::identifier):
+        (WebCore::CryptoAlgorithmRegistry::name):
+        (WebCore::CryptoAlgorithmRegistry::create):
+        (WebCore::CryptoAlgorithmRegistry::registerAlgorithm):
+        * dom/Node.cpp:
+        * platform/URL.cpp:
+        * platform/graphics/FontCache.cpp:
+        * platform/graphics/MediaPlayer.cpp:
+        * platform/ios/QuickLook.mm:
+        * platform/ios/WebSQLiteDatabaseTrackerClient.mm:
+        * platform/ios/wak/WebCoreThread.mm:
+        * platform/ios/wak/WebCoreThreadRun.cpp:
+        * platform/network/cf/LoaderRunLoopCF.cpp:
+        (WebCore::loaderRunLoop):
+        * platform/network/curl/CurlContext.cpp:
+        (WebCore::CurlShareHandle::mutexFor):
+        * platform/network/curl/CurlContext.h:
+        * platform/sql/SQLiteDatabaseTracker.cpp:
+        (WebCore::SQLiteDatabaseTracker::incrementTransactionInProgressCount):
+        (WebCore::SQLiteDatabaseTracker::decrementTransactionInProgressCount):
+        * platform/text/TextEncodingRegistry.cpp:
+        (WebCore::buildBaseTextCodecMaps):
+        (WebCore::newTextCodec):
+        (WebCore::atomicCanonicalTextEncodingName):
+        * workers/WorkerThread.cpp:
+        (WebCore::WorkerThread::workerThreadCount):
+        (WebCore::WorkerThread::WorkerThread):
+        (WebCore::WorkerThread::~WorkerThread):
+        (WebCore::WorkerThread::releaseFastMallocFreeMemoryInAllThreads):
+
 2018-04-04  Youenn Fablet  <youenn@apple.com>
 
         WebRTC data channel only applications require capture permissions for direct connections
index 461e01a..4915fcc 100644 (file)
@@ -155,7 +155,7 @@ static bool retrieveTextResultFromDatabase(SQLiteDatabase& db, const String& que
 }
 
 // FIXME: move all guid-related functions to a DatabaseVersionTracker class.
-static StaticLock guidMutex;
+static Lock guidMutex;
 
 static HashMap<DatabaseGUID, String>& guidToVersionMap()
 {
@@ -204,7 +204,7 @@ Database::Database(DatabaseContext& context, const String& name, const String& e
     , m_databaseAuthorizer(DatabaseAuthorizer::create(unqualifiedInfoTableName))
 {
     {
-        std::lock_guard<StaticLock> locker(guidMutex);
+        std::lock_guard<Lock> locker(guidMutex);
 
         m_guid = guidForOriginAndName(securityOrigin().securityOrigin()->toString(), name);
         guidToDatabaseMap().ensure(m_guid, [] {
@@ -356,7 +356,7 @@ ExceptionOr<void> Database::performOpenAndVerify(bool shouldSetVersionInNewDatab
 
     String currentVersion;
     {
-        std::lock_guard<StaticLock> locker(guidMutex);
+        std::lock_guard<Lock> locker(guidMutex);
 
         auto entry = guidToVersionMap().find(m_guid);
         if (entry != guidToVersionMap().end()) {
@@ -445,7 +445,7 @@ void Database::closeDatabase()
     DatabaseTracker::singleton().removeOpenDatabase(*this);
 
     {
-        std::lock_guard<StaticLock> locker(guidMutex);
+        std::lock_guard<Lock> locker(guidMutex);
 
         auto it = guidToDatabaseMap().find(m_guid);
         ASSERT(it != guidToDatabaseMap().end());
@@ -503,14 +503,14 @@ void Database::setExpectedVersion(const String& version)
 
 String Database::getCachedVersion() const
 {
-    std::lock_guard<StaticLock> locker(guidMutex);
+    std::lock_guard<Lock> locker(guidMutex);
 
     return guidToVersionMap().get(m_guid).isolatedCopy();
 }
 
 void Database::setCachedVersion(const String& actualVersion)
 {
-    std::lock_guard<StaticLock> locker(guidMutex);
+    std::lock_guard<Lock> locker(guidMutex);
 
     updateGUIDVersionMap(m_guid, actualVersion);
 }
index a0828a3..8fda62a 100644 (file)
@@ -1275,8 +1275,8 @@ bool DatabaseTracker::deleteDatabaseFileIfEmpty(const String& path)
     return SQLiteFileSystem::deleteDatabaseFile(path);
 }
 
-static StaticLock openDatabaseLock;
-StaticLock& DatabaseTracker::openDatabaseMutex()
+static Lock openDatabaseLock;
+Lock& DatabaseTracker::openDatabaseMutex()
 {
     return openDatabaseLock;
 }
@@ -1300,7 +1300,7 @@ void DatabaseTracker::setClient(DatabaseManagerClient* client)
     m_client = client;
 }
 
-static StaticLock notificationLock;
+static Lock notificationLock;
 
 using NotificationQueue = Vector<std::pair<SecurityOriginData, String>>;
 
index 2bd1147..f7c07b6 100644 (file)
@@ -101,7 +101,7 @@ public:
     // MobileSafari will grab this mutex on the main thread before dispatching the task to 
     // clean up zero byte database files.  Any operations to open new database will have to
     // wait for that task to finish by waiting on this mutex.
-    static StaticLock& openDatabaseMutex();
+    static Lock& openDatabaseMutex();
     
     WEBCORE_EXPORT static void emptyDatabaseFilesRemovalTaskWillBeScheduled();
     WEBCORE_EXPORT static void emptyDatabaseFilesRemovalTaskDidFinish();
index 828710c..1543501 100644 (file)
@@ -185,9 +185,9 @@ HashSet<WebSocket*>& WebSocket::allActiveWebSockets(const LockHolder&)
     return activeWebSockets;
 }
 
-StaticLock& WebSocket::allActiveWebSocketsMutex()
+Lock& WebSocket::allActiveWebSocketsMutex()
 {
-    static StaticLock mutex;
+    static Lock mutex;
     return mutex;
 }
 
index d8a90d9..90121f7 100644 (file)
@@ -60,7 +60,7 @@ public:
     virtual ~WebSocket();
 
     static HashSet<WebSocket*>& allActiveWebSockets(const LockHolder&);
-    static StaticLock& allActiveWebSocketsMutex();
+    static Lock& allActiveWebSocketsMutex();
 
     enum State {
         CONNECTING = 0,
index 4b38cb6..39e5665 100644 (file)
@@ -71,7 +71,7 @@ using JSC::makeSource;
 
 namespace WebCore {
 
-static StaticLock spinLock;
+static Lock spinLock;
 static CreateWrapperFunction createDOMWrapperFunction;
 static DisconnectWindowWrapperFunction disconnectWindowWrapperFunction;
 
index 22dcfcb..187a1da 100644 (file)
@@ -34,7 +34,7 @@
 
 namespace WebCore {
 
-static StaticLock registryMutex;
+static Lock registryMutex;
 
 CryptoAlgorithmRegistry& CryptoAlgorithmRegistry::singleton()
 {
@@ -52,7 +52,7 @@ std::optional<CryptoAlgorithmIdentifier> CryptoAlgorithmRegistry::identifier(con
     if (name.isEmpty())
         return std::nullopt;
 
-    std::lock_guard<StaticLock> lock(registryMutex);
+    std::lock_guard<Lock> lock(registryMutex);
 
     // FIXME: How is it helpful to call isolatedCopy on the argument to find?
     auto identifier = m_identifiers.find(name.isolatedCopy());
@@ -64,7 +64,7 @@ std::optional<CryptoAlgorithmIdentifier> CryptoAlgorithmRegistry::identifier(con
 
 String CryptoAlgorithmRegistry::name(CryptoAlgorithmIdentifier identifier)
 {
-    std::lock_guard<StaticLock> lock(registryMutex);
+    std::lock_guard<Lock> lock(registryMutex);
 
     auto contructor = m_constructors.find(static_cast<unsigned>(identifier));
     if (contructor == m_constructors.end())
@@ -75,7 +75,7 @@ String CryptoAlgorithmRegistry::name(CryptoAlgorithmIdentifier identifier)
 
 RefPtr<CryptoAlgorithm> CryptoAlgorithmRegistry::create(CryptoAlgorithmIdentifier identifier)
 {
-    std::lock_guard<StaticLock> lock(registryMutex);
+    std::lock_guard<Lock> lock(registryMutex);
 
     auto contructor = m_constructors.find(static_cast<unsigned>(identifier));
     if (contructor == m_constructors.end())
@@ -86,7 +86,7 @@ RefPtr<CryptoAlgorithm> CryptoAlgorithmRegistry::create(CryptoAlgorithmIdentifie
 
 void CryptoAlgorithmRegistry::registerAlgorithm(const String& name, CryptoAlgorithmIdentifier identifier, CryptoAlgorithmConstructor constructor)
 {
-    std::lock_guard<StaticLock> lock(registryMutex);
+    std::lock_guard<Lock> lock(registryMutex);
 
     ASSERT(!m_identifiers.contains(name));
     ASSERT(!m_constructors.contains(static_cast<unsigned>(identifier)));
index 5fc4cb1..4b1e872 100644 (file)
@@ -2154,7 +2154,7 @@ static EventTargetDataMap& eventTargetDataMap()
     return map;
 }
 
-static StaticLock s_eventTargetDataMapLock;
+static Lock s_eventTargetDataMapLock;
 
 EventTargetData* Node::eventTargetData()
 {
index e8b1b08..159e7fa 100644 (file)
@@ -275,7 +275,7 @@ static void assertProtocolIsGood(StringView protocol)
 
 #endif
 
-static StaticLock defaultPortForProtocolMapForTestingLock;
+static Lock defaultPortForProtocolMapForTestingLock;
 
 using DefaultPortForProtocolMapForTesting = HashMap<String, uint16_t>;
 static DefaultPortForProtocolMapForTesting*& defaultPortForProtocolMapForTesting()
index 13e902b..bc9720d 100644 (file)
@@ -53,8 +53,7 @@
 #include <wtf/Lock.h>
 #include <wtf/RecursiveLockAdapter.h>
 
-using RecursiveStaticLock = WTF::RecursiveLockAdapter<StaticLock>;
-static RecursiveStaticLock fontLock;
+static RecursiveLock fontLock;
 
 #endif // PLATFORM(IOS)
 
index 8a4686a..50a36ac 100644 (file)
@@ -207,7 +207,7 @@ struct MediaPlayerFactory {
 
 static void addMediaEngine(CreateMediaEnginePlayer&&, MediaEngineSupportedTypes, MediaEngineSupportsType, MediaEngineOriginsInMediaCache, MediaEngineClearMediaCache, MediaEngineClearMediaCacheForOrigins, MediaEngineSupportsKeySystem);
 
-static StaticLock mediaEngineVectorLock;
+static Lock mediaEngineVectorLock;
 
 static bool& haveMediaEnginesVector()
 {
index f3b0df6..37bad00 100644 (file)
@@ -46,7 +46,7 @@ NSSet *QLPreviewGetSupportedMIMETypesSet()
     return set;
 }
 
-static StaticLock qlPreviewConverterDictionaryLock;
+static Lock qlPreviewConverterDictionaryLock;
 
 static NSMutableDictionary *QLPreviewConverterDictionary()
 {
index 96fcbf1..e39c4ec 100644 (file)
@@ -84,7 +84,7 @@ void WebSQLiteDatabaseTrackerClient::hysteresisUpdated(PAL::HysteresisState stat
 
 }
 
-static StaticLock transactionBackgroundTaskIdentifierLock;
+static Lock transactionBackgroundTaskIdentifierLock;
 
 static NSUInteger transactionBackgroundTaskIdentifier;
 
index e86fe87..b281ecd 100644 (file)
@@ -91,11 +91,9 @@ extern void NSPopAutoreleasePool(NSAutoreleasePoolMark token);
 }
 #endif
 
-using StaticRecursiveLock = WTF::RecursiveLockAdapter<StaticLock>;
-
-static StaticRecursiveLock webLock;
-static StaticLock webThreadReleaseLock;
-static StaticRecursiveLock webCoreReleaseLock;
+static RecursiveLock webLock;
+static Lock webThreadReleaseLock;
+static RecursiveLock webCoreReleaseLock;
 
 static NSAutoreleasePoolMark autoreleasePoolMark;
 static CFRunLoopRef webThreadRunLoop;
@@ -117,7 +115,7 @@ static CFMutableArrayRef WebThreadReleaseObjArray;
 
 static void MainThreadAdoptAndRelease(id obj);
 
-static StaticLock delegateLock;
+static Lock delegateLock;
 static StaticCondition delegateCondition;
 static NSInvocation* delegateInvocation;
 static CFRunLoopSourceRef delegateSource = nullptr;
@@ -128,7 +126,7 @@ static BOOL sendingDelegateMessage;
 
 static CFRunLoopObserverRef mainRunLoopAutoUnlockObserver;
 
-static StaticLock startupLock;
+static Lock startupLock;
 static StaticCondition startupCondition;
 
 static WebThreadContext* webThreadContext;
index efefc22..233fd3c 100644 (file)
@@ -111,7 +111,7 @@ extern "C" {
 
 typedef WTF::Vector<WebThreadBlock> WebThreadRunQueue;
 
-static StaticLock runQueueMutex;
+static Lock runQueueMutex;
 static CFRunLoopSourceRef runSource;
 static WebThreadRunQueue* runQueue;
 
@@ -124,7 +124,7 @@ static void HandleRunSource(void *info)
 
     WebThreadRunQueue queueCopy;
     {
-        std::lock_guard<StaticLock> lock(runQueueMutex);
+        std::lock_guard<Lock> lock(runQueueMutex);
         queueCopy = *runQueue;
         runQueue->clear();
     }
@@ -148,7 +148,7 @@ static void _WebThreadRun(void (^block)(void), bool synchronous)
         state = new WebThreadBlockState;
 
     {
-        std::lock_guard<StaticLock> lock(runQueueMutex);
+        std::lock_guard<Lock> lock(runQueueMutex);
         runQueue->append(WebThreadBlock(block, state));
     }
 
index f08327f..cfd6ab0 100644 (file)
@@ -41,7 +41,7 @@ namespace WebCore {
 
 static CFRunLoopRef loaderRunLoopObject = 0;
 
-static StaticLock loaderRunLoopMutex;
+static Lock loaderRunLoopMutex;
 static StaticCondition loaderRunLoopConditionVariable;
 
 static void emptyPerform(void*) 
@@ -52,12 +52,12 @@ CFRunLoopRef loaderRunLoop()
 {
     ASSERT(isMainThread());
 
-    std::unique_lock<StaticLock> lock(loaderRunLoopMutex);
+    std::unique_lock<Lock> lock(loaderRunLoopMutex);
 
     if (!loaderRunLoopObject) {
         Thread::create("WebCore: CFNetwork Loader", [] {
             {
-                std::lock_guard<StaticLock> lock(loaderRunLoopMutex);
+                std::lock_guard<Lock> lock(loaderRunLoopMutex);
 
                 loaderRunLoopObject = CFRunLoopGetCurrent();
 
index 5c504ce..fb8043d 100644 (file)
@@ -199,11 +199,11 @@ void CurlShareHandle::unlockCallback(CURL*, curl_lock_data data, void*)
         mutex->unlock();
 }
 
-StaticLock* CurlShareHandle::mutexFor(curl_lock_data data)
+Lock* CurlShareHandle::mutexFor(curl_lock_data data)
 {
-    static StaticLock cookieMutex;
-    static StaticLock dnsMutex;
-    static StaticLock shareMutex;
+    static Lock cookieMutex;
+    static Lock dnsMutex;
+    static Lock shareMutex;
 
     switch (data) {
     case CURL_LOCK_DATA_COOKIE:
index 6ba70e1..ed39e59 100644 (file)
@@ -89,7 +89,7 @@ public:
 private:
     static void lockCallback(CURL*, curl_lock_data, curl_lock_access, void*);
     static void unlockCallback(CURL*, curl_lock_data, void*);
-    static StaticLock* mutexFor(curl_lock_data);
+    static Lock* mutexFor(curl_lock_data);
 
     CURLSH* m_shareHandle { nullptr };
 };
index 3754a4c..e2ae0ce 100644 (file)
@@ -36,7 +36,7 @@ namespace SQLiteDatabaseTracker {
 static SQLiteDatabaseTrackerClient* s_staticSQLiteDatabaseTrackerClient = nullptr;
 static unsigned s_transactionInProgressCounter = 0;
 
-static StaticLock transactionInProgressMutex;
+static Lock transactionInProgressMutex;
 
 void setClient(SQLiteDatabaseTrackerClient* client)
 {
@@ -50,7 +50,7 @@ void incrementTransactionInProgressCount()
     if (!s_staticSQLiteDatabaseTrackerClient)
         return;
 
-    std::lock_guard<StaticLock> lock(transactionInProgressMutex);
+    std::lock_guard<Lock> lock(transactionInProgressMutex);
 
     s_transactionInProgressCounter++;
     if (s_transactionInProgressCounter == 1)
@@ -62,7 +62,7 @@ void decrementTransactionInProgressCount()
     if (!s_staticSQLiteDatabaseTrackerClient)
         return;
 
-    std::lock_guard<StaticLock> lock(transactionInProgressMutex);
+    std::lock_guard<Lock> lock(transactionInProgressMutex);
 
     ASSERT(s_transactionInProgressCounter);
     s_transactionInProgressCounter--;
index fda3d11..52416cc 100644 (file)
@@ -90,7 +90,7 @@ struct TextEncodingNameHash {
 using TextEncodingNameMap = HashMap<const char*, const char*, TextEncodingNameHash>;
 using TextCodecMap = HashMap<const char*, NewTextCodecFunction>;
 
-static StaticLock encodingRegistryMutex;
+static Lock encodingRegistryMutex;
 
 static TextEncodingNameMap* textEncodingNameMap;
 static TextCodecMap* textCodecMap;
@@ -156,7 +156,7 @@ static void pruneBlacklistedCodecs()
     }
 }
 
-static void buildBaseTextCodecMaps(const std::lock_guard<StaticLock>&)
+static void buildBaseTextCodecMaps(const std::lock_guard<Lock>&)
 {
     ASSERT(!textCodecMap);
     ASSERT(!textEncodingNameMap);
@@ -244,7 +244,7 @@ static void extendTextCodecMaps()
 
 std::unique_ptr<TextCodec> newTextCodec(const TextEncoding& encoding)
 {
-    std::lock_guard<StaticLock> lock(encodingRegistryMutex);
+    std::lock_guard<Lock> lock(encodingRegistryMutex);
 
     ASSERT(textCodecMap);
     auto result = textCodecMap->find(encoding.name());
@@ -257,7 +257,7 @@ const char* atomicCanonicalTextEncodingName(const char* name)
     if (!name || !name[0])
         return nullptr;
 
-    std::lock_guard<StaticLock> lock(encodingRegistryMutex);
+    std::lock_guard<Lock> lock(encodingRegistryMutex);
 
     if (!textEncodingNameMap)
         buildBaseTextCodecMaps(lock);
index 4c21fac..f9a7903 100644 (file)
@@ -53,7 +53,7 @@
 
 namespace WebCore {
 
-static StaticLock threadSetMutex;
+static Lock threadSetMutex;
 
 static HashSet<WorkerThread*>& workerThreads()
 {
@@ -64,7 +64,7 @@ static HashSet<WorkerThread*>& workerThreads()
 
 unsigned WorkerThread::workerThreadCount()
 {
-    std::lock_guard<StaticLock> lock(threadSetMutex);
+    std::lock_guard<Lock> lock(threadSetMutex);
 
     return workerThreads().size();
 }
@@ -119,14 +119,14 @@ WorkerThread::WorkerThread(const URL& scriptURL, const String& identifier, const
     UNUSED_PARAM(connectionProxy);
 #endif
 
-    std::lock_guard<StaticLock> lock(threadSetMutex);
+    std::lock_guard<Lock> lock(threadSetMutex);
 
     workerThreads().add(this);
 }
 
 WorkerThread::~WorkerThread()
 {
-    std::lock_guard<StaticLock> lock(threadSetMutex);
+    std::lock_guard<Lock> lock(threadSetMutex);
 
     ASSERT(workerThreads().contains(this));
     workerThreads().remove(this);
@@ -315,7 +315,7 @@ void WorkerThread::stop(WTF::Function<void()>&& stoppedCallback)
 
 void WorkerThread::releaseFastMallocFreeMemoryInAllThreads()
 {
-    std::lock_guard<StaticLock> lock(threadSetMutex);
+    std::lock_guard<Lock> lock(threadSetMutex);
 
     for (auto* workerThread : workerThreads()) {
         workerThread->runLoop().postTask([] (ScriptExecutionContext&) {
index 60ff761..b8827e3 100644 (file)
@@ -1,3 +1,12 @@
+2018-04-05  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [WTF] Remove StaticLock
+        https://bugs.webkit.org/show_bug.cgi?id=184332
+
+        Reviewed by Mark Lam.
+
+        * WebCoreSupport/WebFixedPositionContent.mm:
+
 2018-03-28  Zalan Bujtas  <zalan@apple.com>
 
         Make it possible to override the screen size
index f27dba7..2f80824 100644 (file)
@@ -49,7 +49,7 @@
 using namespace WebCore;
 using namespace std;
 
-static StaticLock webFixedPositionContentDataLock;
+static Lock webFixedPositionContentDataLock;
 
 struct ViewportConstrainedLayerData {
     ViewportConstrainedLayerData()
index d962c8d..c70f966 100644 (file)
@@ -1,3 +1,15 @@
+2018-04-05  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [WTF] Remove StaticLock
+        https://bugs.webkit.org/show_bug.cgi?id=184332
+
+        Reviewed by Mark Lam.
+
+        * DOM/DOMInternal.mm:
+        (getDOMWrapper):
+        (addDOMWrapper):
+        (removeDOMWrapper):
+
 2018-04-04  Brent Fulgham  <bfulgham@apple.com>
 
         Failures from mach port reference handling should be fatal
index 6b179eb..e021c5b 100644 (file)
@@ -44,7 +44,7 @@
 // Wrapping WebCore implementation objects
 
 #ifdef NEEDS_WRAPPER_CACHE_LOCK
-static StaticLock wrapperCacheLock;
+static Lock wrapperCacheLock;
 #endif
 
 static HashMap<DOMObjectInternal*, NSObject *>& wrapperCache()
@@ -56,7 +56,7 @@ static HashMap<DOMObjectInternal*, NSObject *>& wrapperCache()
 NSObject* getDOMWrapper(DOMObjectInternal* impl)
 {
 #ifdef NEEDS_WRAPPER_CACHE_LOCK
-    std::lock_guard<StaticLock> lock(wrapperCacheLock);
+    std::lock_guard<Lock> lock(wrapperCacheLock);
 #endif
     return wrapperCache().get(impl);
 }
@@ -64,7 +64,7 @@ NSObject* getDOMWrapper(DOMObjectInternal* impl)
 void addDOMWrapper(NSObject* wrapper, DOMObjectInternal* impl)
 {
 #ifdef NEEDS_WRAPPER_CACHE_LOCK
-    std::lock_guard<StaticLock> lock(wrapperCacheLock);
+    std::lock_guard<Lock> lock(wrapperCacheLock);
 #endif
     wrapperCache().set(impl, wrapper);
 }
@@ -72,7 +72,7 @@ void addDOMWrapper(NSObject* wrapper, DOMObjectInternal* impl)
 void removeDOMWrapper(DOMObjectInternal* impl)
 {
 #ifdef NEEDS_WRAPPER_CACHE_LOCK
-    std::lock_guard<StaticLock> lock(wrapperCacheLock);
+    std::lock_guard<Lock> lock(wrapperCacheLock);
 #endif
     wrapperCache().remove(impl);
 }
index 6e365e9..a6a75ec 100644 (file)
@@ -1,3 +1,14 @@
+2018-04-05  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [WTF] Remove StaticLock
+        https://bugs.webkit.org/show_bug.cgi?id=184332
+
+        Reviewed by Mark Lam.
+
+        * WebKitQuartzCoreAdditions/CAView.cpp:
+        (WKQCA::CAView::releaseAllD3DResources):
+        * WebLocalizableStrings.cpp:
+
 2018-04-03  Chris Dumez  <cdumez@apple.com>
 
         Drop MainFrame class
index 5e35702..9407791 100644 (file)
@@ -68,7 +68,7 @@ private:
     CAView* m_view;
 };
 
-static StaticLock globalStateLock;
+static Lock globalStateLock;
 static HWND messageWindow;
 static const wchar_t messageWindowClassName[] = L"CAViewMessageWindow";
 
@@ -106,7 +106,7 @@ static HWND createMessageWindow()
 
 void CAView::releaseAllD3DResources()
 {
-    static StaticLock lock;
+    static Lock lock;
 
     if (!lock.tryLock()) {
         // Another thread is currently releasing 3D resources.
index 2e311ee..c55607f 100644 (file)
@@ -45,7 +45,7 @@ WebLocalizableStringsBundle WebKitLocalizableStringsBundle = { "com.apple.WebKit
 
 typedef HashMap<String, LocalizedString*> LocalizedStringMap;
 
-static StaticLock mainBundleLocStringsLock;
+static Lock mainBundleLocStringsLock;
 
 static LocalizedStringMap& mainBundleLocStrings()
 {
@@ -53,7 +53,7 @@ static LocalizedStringMap& mainBundleLocStrings()
     return map;
 }
 
-static StaticLock frameworkLocStringsLock;
+static Lock frameworkLocStringsLock;
 
 static LocalizedStringMap frameworkLocStrings()
 {
index dd1ce0b..53da09a 100644 (file)
@@ -1,3 +1,12 @@
+2018-04-05  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [WTF] Remove StaticLock
+        https://bugs.webkit.org/show_bug.cgi?id=184332
+
+        Reviewed by Mark Lam.
+
+        * DumpRenderTree/JavaScriptThreading.cpp:
+
 2018-04-05  Zalan Bujtas  <zalan@apple.com>
 
         [LayoutReloaded] Find the correct left edge for a line when floating boxes are in parent formatting context.
index 80a082b..5f98929 100644 (file)
@@ -45,7 +45,7 @@
 static const size_t javaScriptThreadsCount = 4;
 static bool javaScriptThreadsShouldTerminate;
 static JSContextGroupRef javaScriptThreadsGroup;
-static StaticLock javaScriptThreadsLock;
+static Lock javaScriptThreadsLock;
 
 typedef HashSet<RefPtr<Thread>> ThreadSet;
 static ThreadSet& javaScriptThreads()