<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[277877] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/277877">277877</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2021-05-21 13:12:49 -0700 (Fri, 21 May 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Replace more static Locks with CheckedLocks in WebKit / WebKitLegacy
https://bugs.webkit.org/show_bug.cgi?id=226093

Reviewed by Darin Adler.

Replace more static Locks with CheckedLocks so that we can benefit from Clang Thread Safety Analysis.

Source/WebKit:

* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated):
(WebKit::WebResourceLoadStatisticsStore::suspend):
(WebKit::WebResourceLoadStatisticsStore::resume):
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
* Platform/IPC/Connection.cpp:
(IPC::WTF_REQUIRES_LOCK):
(IPC::addAsyncReplyHandler):
(IPC::clearAsyncReplyHandlers):
(IPC::CompletionHandler<void):
* WebProcess/Network/WebSocketStream.cpp:
(WebKit::WebSocketStream::streamWithIdentifier):
(WebKit::WebSocketStream::networkProcessCrashed):
(WebKit::WebSocketStream::WebSocketStream):
(WebKit::WebSocketStream::~WebSocketStream):

Source/WebKitLegacy/mac:

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

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessClassifierWebResourceLoadStatisticsStorecpp">trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessClassifierWebResourceLoadStatisticsStoreh">trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h</a></li>
<li><a href="#trunkSourceWebKitPlatformIPCConnectioncpp">trunk/Source/WebKit/Platform/IPC/Connection.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessNetworkWebSocketStreamcpp">trunk/Source/WebKit/WebProcess/Network/WebSocketStream.cpp</a></li>
<li><a href="#trunkSourceWebKitLegacymacChangeLog">trunk/Source/WebKitLegacy/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitLegacymacDOMDOMInternalmm">trunk/Source/WebKitLegacy/mac/DOM/DOMInternal.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (277876 => 277877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2021-05-21 19:47:15 UTC (rev 277876)
+++ trunk/Source/WebKit/ChangeLog       2021-05-21 20:12:49 UTC (rev 277877)
</span><span class="lines">@@ -1,5 +1,30 @@
</span><span class="cx"> 2021-05-21  Chris Dumez  <cdumez@apple.com>
</span><span class="cx"> 
</span><ins>+        Replace more static Locks with CheckedLocks in WebKit / WebKitLegacy
+        https://bugs.webkit.org/show_bug.cgi?id=226093
+
+        Reviewed by Darin Adler.
+
+        Replace more static Locks with CheckedLocks so that we can benefit from Clang Thread Safety Analysis.
+
+        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated):
+        (WebKit::WebResourceLoadStatisticsStore::suspend):
+        (WebKit::WebResourceLoadStatisticsStore::resume):
+        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
+        * Platform/IPC/Connection.cpp:
+        (IPC::WTF_REQUIRES_LOCK):
+        (IPC::addAsyncReplyHandler):
+        (IPC::clearAsyncReplyHandlers):
+        (IPC::CompletionHandler<void):
+        * WebProcess/Network/WebSocketStream.cpp:
+        (WebKit::WebSocketStream::streamWithIdentifier):
+        (WebKit::WebSocketStream::networkProcessCrashed):
+        (WebKit::WebSocketStream::WebSocketStream):
+        (WebKit::WebSocketStream::~WebSocketStream):
+
+2021-05-21  Chris Dumez  <cdumez@apple.com>
+
</ins><span class="cx">         Use CheckedLock more in cases where we try-lock
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=226056
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessClassifierWebResourceLoadStatisticsStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp (277876 => 277877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp 2021-05-21 19:47:15 UTC (rev 277876)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp    2021-05-21 20:12:49 UTC (rev 277877)
</span><span class="lines">@@ -60,8 +60,8 @@
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><span class="cx"> WebResourceLoadStatisticsStore::State WebResourceLoadStatisticsStore::suspendedState { WebResourceLoadStatisticsStore::State::Running };
</span><del>-Lock WebResourceLoadStatisticsStore::suspendedStateLock;
-Condition WebResourceLoadStatisticsStore::suspendedStateChangeCondition;
</del><ins>+CheckedLock WebResourceLoadStatisticsStore::suspendedStateLock;
+CheckedCondition WebResourceLoadStatisticsStore::suspendedStateChangeCondition;
</ins><span class="cx"> 
</span><span class="cx"> const OptionSet<WebsiteDataType>& WebResourceLoadStatisticsStore::monitoredDataTypes()
</span><span class="cx"> {
</span><span class="lines">@@ -349,7 +349,13 @@
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        ASSERT(suspendedState != State::Suspended);
</del><ins>+#if ASSERT_ENABLED
+        {
+            Locker stateLocker { suspendedStateLock };
+            ASSERT(suspendedState != State::Suspended);
+        }
+#endif
+
</ins><span class="cx">         m_statisticsStore->mergeStatistics(WTFMove(statistics));
</span><span class="cx">         postTaskReply(WTFMove(completionHandler));
</span><span class="cx">         // We can cancel any pending request to process statistics since we're doing it synchronously below.
</span><span class="lines">@@ -1444,7 +1450,7 @@
</span><span class="cx"> void WebResourceLoadStatisticsStore::suspend(CompletionHandler<void()>&& completionHandler)
</span><span class="cx"> {
</span><span class="cx">     CompletionHandlerCallingScope completionHandlerCaller(WTFMove(completionHandler));
</span><del>-    Locker<Lock> stateLocker(suspendedStateLock);
</del><ins>+    Locker stateLocker { suspendedStateLock };
</ins><span class="cx">     if (suspendedState != State::Running)
</span><span class="cx">         return;
</span><span class="cx">     suspendedState = State::WillSuspend;
</span><span class="lines">@@ -1454,7 +1460,7 @@
</span><span class="cx">         for (auto& databaseStore : ResourceLoadStatisticsDatabaseStore::allStores())
</span><span class="cx">             databaseStore->interrupt();
</span><span class="cx">         
</span><del>-        Locker<Lock> stateLocker(suspendedStateLock);
</del><ins>+        Locker stateLocker { suspendedStateLock };
</ins><span class="cx">         ASSERT(suspendedState != State::Suspended);
</span><span class="cx"> 
</span><span class="cx">         if (suspendedState != State::WillSuspend) {
</span><span class="lines">@@ -1473,7 +1479,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebResourceLoadStatisticsStore::resume()
</span><span class="cx"> {
</span><del>-    Locker<Lock> stateLocker(suspendedStateLock);
</del><ins>+    Locker stateLocker { suspendedStateLock };
</ins><span class="cx">     auto previousState = suspendedState;
</span><span class="cx">     suspendedState = State::Running;
</span><span class="cx">     if (previousState == State::Suspended)
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessClassifierWebResourceLoadStatisticsStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h (277876 => 277877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h   2021-05-21 19:47:15 UTC (rev 277876)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h      2021-05-21 20:12:49 UTC (rev 277877)
</span><span class="lines">@@ -40,6 +40,8 @@
</span><span class="cx"> #include <WebCore/PrivateClickMeasurement.h>
</span><span class="cx"> #include <WebCore/RegistrableDomain.h>
</span><span class="cx"> #include <WebCore/ResourceLoadObserver.h>
</span><ins>+#include <wtf/CheckedCondition.h>
+#include <wtf/CheckedLock.h>
</ins><span class="cx"> #include <wtf/CompletionHandler.h>
</span><span class="cx"> #include <wtf/RunLoop.h>
</span><span class="cx"> #include <wtf/ThreadSafeRefCounted.h>
</span><span class="lines">@@ -361,9 +363,9 @@
</span><span class="cx">         WillSuspend,
</span><span class="cx">         Suspended
</span><span class="cx">     };
</span><del>-    static State suspendedState;
-    static Lock suspendedStateLock;
-    static Condition suspendedStateChangeCondition;
</del><ins>+    static CheckedLock suspendedStateLock;
+    static State suspendedState WTF_GUARDED_BY_LOCK(suspendedStateLock);
+    static CheckedCondition suspendedStateChangeCondition;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKitPlatformIPCConnectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Platform/IPC/Connection.cpp (277876 => 277877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Platform/IPC/Connection.cpp  2021-05-21 19:47:15 UTC (rev 277876)
+++ trunk/Source/WebKit/Platform/IPC/Connection.cpp     2021-05-21 20:12:49 UTC (rev 277877)
</span><span class="lines">@@ -274,15 +274,10 @@
</span><span class="cx">     return map;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static Lock& asyncReplyHandlerMapLock()
</del><ins>+static CheckedLock asyncReplyHandlerMapLock;
+static HashMap<uintptr_t, HashMap<uint64_t, CompletionHandler<void(Decoder*)>>>& asyncReplyHandlerMap() WTF_REQUIRES_LOCK(asyncReplyHandlerMapLock)
</ins><span class="cx"> {
</span><del>-    static Lock lock;
-    return lock;
-}
-
-static HashMap<uintptr_t, HashMap<uint64_t, CompletionHandler<void(Decoder*)>>>& asyncReplyHandlerMap(const LockHolder&)
-{
-    ASSERT(asyncReplyHandlerMapLock().isHeld());
</del><ins>+    ASSERT(asyncReplyHandlerMapLock.isHeld());
</ins><span class="cx">     static NeverDestroyed<HashMap<uintptr_t, HashMap<uint64_t, CompletionHandler<void(Decoder*)>>>> map;
</span><span class="cx">     return map.get();
</span><span class="cx"> }
</span><span class="lines">@@ -1219,8 +1214,8 @@
</span><span class="cx"> 
</span><span class="cx"> void addAsyncReplyHandler(Connection& connection, uint64_t identifier, CompletionHandler<void(Decoder*)>&& completionHandler)
</span><span class="cx"> {
</span><del>-    LockHolder locker(asyncReplyHandlerMapLock());
-    auto result = asyncReplyHandlerMap(locker).ensure(reinterpret_cast<uintptr_t>(&connection), [] {
</del><ins>+    Locker locker { asyncReplyHandlerMapLock };
+    auto result = asyncReplyHandlerMap().ensure(reinterpret_cast<uintptr_t>(&connection), [] {
</ins><span class="cx">         return HashMap<uint64_t, CompletionHandler<void(Decoder*)>>();
</span><span class="cx">     }).iterator->value.add(identifier, WTFMove(completionHandler));
</span><span class="cx">     ASSERT_UNUSED(result, result.isNewEntry);
</span><span class="lines">@@ -1230,8 +1225,8 @@
</span><span class="cx"> {
</span><span class="cx">     HashMap<uint64_t, CompletionHandler<void(Decoder*)>> map;
</span><span class="cx">     {
</span><del>-        LockHolder locker(asyncReplyHandlerMapLock());
-        map = asyncReplyHandlerMap(locker).take(reinterpret_cast<uintptr_t>(&connection));
</del><ins>+        Locker locker { asyncReplyHandlerMapLock };
+        map = asyncReplyHandlerMap().take(reinterpret_cast<uintptr_t>(&connection));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     for (auto& handler : map.values()) {
</span><span class="lines">@@ -1242,8 +1237,8 @@
</span><span class="cx"> 
</span><span class="cx"> CompletionHandler<void(Decoder*)> takeAsyncReplyHandler(Connection& connection, uint64_t identifier)
</span><span class="cx"> {
</span><del>-    LockHolder locker(asyncReplyHandlerMapLock());
-    auto& map = asyncReplyHandlerMap(locker);
</del><ins>+    Locker locker { asyncReplyHandlerMapLock };
+    auto& map = asyncReplyHandlerMap();
</ins><span class="cx">     auto iterator = map.find(reinterpret_cast<uintptr_t>(&connection));
</span><span class="cx">     if (iterator != map.end()) {
</span><span class="cx">         if (!iterator->value.isValidKey(identifier)) {
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessNetworkWebSocketStreamcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/Network/WebSocketStream.cpp (277876 => 277877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/Network/WebSocketStream.cpp       2021-05-21 19:47:15 UTC (rev 277876)
+++ trunk/Source/WebKit/WebProcess/Network/WebSocketStream.cpp  2021-05-21 20:12:49 UTC (rev 277877)
</span><span class="lines">@@ -34,13 +34,14 @@
</span><span class="cx"> #include <WebCore/CookieRequestHeaderFieldProxy.h>
</span><span class="cx"> #include <WebCore/SocketStreamError.h>
</span><span class="cx"> #include <WebCore/SocketStreamHandleClient.h>
</span><ins>+#include <wtf/CheckedLock.h>
</ins><span class="cx"> #include <wtf/NeverDestroyed.h>
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><del>-static Lock globalWebSocketStreamMapLock;
-static HashMap<WebSocketIdentifier, WebSocketStream*>& globalWebSocketStreamMap()
</del><ins>+static CheckedLock globalWebSocketStreamMapLock;
+static HashMap<WebSocketIdentifier, WebSocketStream*>& globalWebSocketStreamMap() WTF_REQUIRES_LOCK(globalWebSocketStreamMapLock)
</ins><span class="cx"> {
</span><span class="cx">     static NeverDestroyed<HashMap<WebSocketIdentifier, WebSocketStream*>> globalMap;
</span><span class="cx">     return globalMap;
</span><span class="lines">@@ -48,7 +49,7 @@
</span><span class="cx"> 
</span><span class="cx"> WebSocketStream* WebSocketStream::streamWithIdentifier(WebSocketIdentifier identifier)
</span><span class="cx"> {
</span><del>-    LockHolder locker(globalWebSocketStreamMapLock);
</del><ins>+    Locker stateLocker { globalWebSocketStreamMapLock };
</ins><span class="cx">     return globalWebSocketStreamMap().get(identifier);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -56,7 +57,7 @@
</span><span class="cx"> {
</span><span class="cx">     Vector<RefPtr<WebSocketStream>> sockets;
</span><span class="cx">     {
</span><del>-        LockHolder locker(globalWebSocketStreamMapLock);
</del><ins>+        Locker stateLocker { globalWebSocketStreamMapLock };
</ins><span class="cx">         sockets.reserveInitialCapacity(globalWebSocketStreamMap().size());
</span><span class="cx">         for (auto& stream : globalWebSocketStreamMap().values())
</span><span class="cx">             sockets.uncheckedAppend(stream);
</span><span class="lines">@@ -71,7 +72,7 @@
</span><span class="cx">         stream = nullptr;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    LockHolder locker(globalWebSocketStreamMapLock);
</del><ins>+    Locker stateLocker { globalWebSocketStreamMapLock };
</ins><span class="cx">     globalWebSocketStreamMap().clear();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -87,7 +88,7 @@
</span><span class="cx"> {
</span><span class="cx">     WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::CreateSocketStream(url, cachePartition, m_identifier), 0);
</span><span class="cx"> 
</span><del>-    LockHolder locker(globalWebSocketStreamMapLock);
</del><ins>+    Locker stateLocker { globalWebSocketStreamMapLock };
</ins><span class="cx">     ASSERT(!globalWebSocketStreamMap().contains(m_identifier));
</span><span class="cx">     globalWebSocketStreamMap().set(m_identifier, this);
</span><span class="cx"> }
</span><span class="lines">@@ -94,7 +95,7 @@
</span><span class="cx"> 
</span><span class="cx"> WebSocketStream::~WebSocketStream()
</span><span class="cx"> {
</span><del>-    LockHolder locker(globalWebSocketStreamMapLock);
</del><ins>+    Locker stateLocker { globalWebSocketStreamMapLock };
</ins><span class="cx">     ASSERT(globalWebSocketStreamMap().contains(m_identifier));
</span><span class="cx">     globalWebSocketStreamMap().remove(m_identifier);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (277876 => 277877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/ChangeLog  2021-05-21 19:47:15 UTC (rev 277876)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog     2021-05-21 20:12:49 UTC (rev 277877)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2021-05-21  Chris Dumez  <cdumez@apple.com>
+
+        Replace more static Locks with CheckedLocks in WebKit / WebKitLegacy
+        https://bugs.webkit.org/show_bug.cgi?id=226093
+
+        Reviewed by Darin Adler.
+
+        Replace more static Locks with CheckedLocks so that we can benefit from Clang Thread Safety Analysis.
+
+        * DOM/DOMInternal.mm:
+        (getDOMWrapper):
+        (addDOMWrapper):
+        (removeDOMWrapper):
+
</ins><span class="cx"> 2021-05-20  Alexey Shvayka  <shvaikalesh@gmail.com>
</span><span class="cx"> 
</span><span class="cx">         [WebIDL] Remove [ImplicitThis] and [CustomProxyToJSObject] extended attributes
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacDOMDOMInternalmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/DOM/DOMInternal.mm (277876 => 277877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/DOM/DOMInternal.mm 2021-05-21 19:47:15 UTC (rev 277876)
+++ trunk/Source/WebKitLegacy/mac/DOM/DOMInternal.mm    2021-05-21 20:12:49 UTC (rev 277877)
</span><span class="lines">@@ -32,8 +32,8 @@
</span><span class="cx"> #import <WebCore/ScriptController.h>
</span><span class="cx"> #import <WebCore/WebScriptObjectPrivate.h>
</span><span class="cx"> #import <WebCore/runtime_root.h>
</span><ins>+#import <wtf/CheckedLock.h>
</ins><span class="cx"> #import <wtf/HashMap.h>
</span><del>-#import <wtf/Lock.h>
</del><span class="cx"> #import <wtf/NeverDestroyed.h>
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span><span class="lines">@@ -44,10 +44,11 @@
</span><span class="cx"> // Wrapping WebCore implementation objects
</span><span class="cx"> 
</span><span class="cx"> #ifdef NEEDS_WRAPPER_CACHE_LOCK
</span><del>-static Lock wrapperCacheLock;
</del><ins>+static CheckedLock wrapperCacheLock;
+static HashMap<DOMObjectInternal*, NSObject *>& wrapperCache() WTF_REQUIRES_LOCK(wrapperCacheLock)
+#else
+static HashMap<DOMObjectInternal*, NSObject *>& wrapperCache()
</ins><span class="cx"> #endif
</span><del>-
-static HashMap<DOMObjectInternal*, NSObject *>& wrapperCache()
</del><span class="cx"> {
</span><span class="cx">     static NeverDestroyed<HashMap<DOMObjectInternal*, NSObject *>> map;
</span><span class="cx">     return map;
</span><span class="lines">@@ -56,7 +57,7 @@
</span><span class="cx"> NSObject* getDOMWrapper(DOMObjectInternal* impl)
</span><span class="cx"> {
</span><span class="cx"> #ifdef NEEDS_WRAPPER_CACHE_LOCK
</span><del>-    auto locker = holdLock(wrapperCacheLock);
</del><ins>+    Locker stateLocker { wrapperCacheLock };
</ins><span class="cx"> #endif
</span><span class="cx">     return wrapperCache().get(impl);
</span><span class="cx"> }
</span><span class="lines">@@ -64,7 +65,7 @@
</span><span class="cx"> void addDOMWrapper(NSObject* wrapper, DOMObjectInternal* impl)
</span><span class="cx"> {
</span><span class="cx"> #ifdef NEEDS_WRAPPER_CACHE_LOCK
</span><del>-    auto locker = holdLock(wrapperCacheLock);
</del><ins>+    Locker stateLocker { wrapperCacheLock };
</ins><span class="cx"> #endif
</span><span class="cx">     wrapperCache().set(impl, wrapper);
</span><span class="cx"> }
</span><span class="lines">@@ -72,7 +73,7 @@
</span><span class="cx"> void removeDOMWrapper(DOMObjectInternal* impl)
</span><span class="cx"> {
</span><span class="cx"> #ifdef NEEDS_WRAPPER_CACHE_LOCK
</span><del>-    auto locker = holdLock(wrapperCacheLock);
</del><ins>+    Locker stateLocker { wrapperCacheLock };
</ins><span class="cx"> #endif
</span><span class="cx">     wrapperCache().remove(impl);
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>