<!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>[265735] trunk/Source/WTF</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/265735">265735</a></dd>
<dt>Author</dt> <dd>ysuzuki@apple.com</dd>
<dt>Date</dt> <dd>2020-08-15 11:40:50 -0700 (Sat, 15 Aug 2020)</dd>
</dl>

<h3>Log Message</h3>
<pre>Use std::call_once + LazyNeverDestroyed to initialize complex data structures
https://bugs.webkit.org/show_bug.cgi?id=215535
<rdar://problem/66774266>

Reviewed by Mark Lam.

NeverDestroyed<> is not thread-safe in Darwin build since it is not using C++11 thread-safe static variable semantics.
This patch uses LazyNeverDestroyed and call_once to initialize complex data structures so that we can ensure they are
initialized atomically.

We also move some of `singleton` definitions from headers to cpp files. This is important since this ensures that singleton
is only one instance which is generated in one translation unit.

* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/FastMalloc.cpp:
(WTF::MallocCallTracker::singleton):
* wtf/Language.cpp:
(WTF::observerMap):
(WTF::preferredLanguagesOverride):
* wtf/Logger.cpp:
(WTF::Logger::observers):
* wtf/Logger.h:
(WTF::Logger::observerLock):
(WTF::Logger::observers): Deleted.
* wtf/MemoryPressureHandler.cpp:
(WTF::MemoryPressureHandler::singleton):
* wtf/MemoryPressureHandler.h:
* wtf/RunLoop.cpp:
(WTF::RunLoop::current):
* wtf/Threading.cpp:
(WTF::Thread::initializeInThread):
* wtf/URL.cpp:
(WTF::aboutBlankURL):
(WTF::aboutSrcDocURL):
* wtf/cf/LanguageCF.cpp:
(WTF::preferredLanguages):
* wtf/cocoa/NSURLExtras.mm:
(WTF::rangeOfURLScheme):
* wtf/text/LineBreakIteratorPoolICU.cpp: Copied from Source/WTF/wtf/Logger.cpp.
(WTF::LineBreakIteratorPool::sharedPool):
* wtf/text/LineBreakIteratorPoolICU.h:
(WTF::LineBreakIteratorPool::sharedPool): Deleted.
* wtf/text/StringView.cpp:
* wtf/text/TextBreakIterator.cpp:
(WTF::TextBreakIteratorCache::singleton):
* wtf/text/TextBreakIterator.h:
(WTF::TextBreakIteratorCache::singleton): Deleted.
* wtf/threads/Signals.cpp:
(WTF::activeThreads):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFWTFxcodeprojprojectpbxproj">trunk/Source/WTF/WTF.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWTFwtfCMakeListstxt">trunk/Source/WTF/wtf/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWTFwtfFastMalloccpp">trunk/Source/WTF/wtf/FastMalloc.cpp</a></li>
<li><a href="#trunkSourceWTFwtfLanguagecpp">trunk/Source/WTF/wtf/Language.cpp</a></li>
<li><a href="#trunkSourceWTFwtfLoggercpp">trunk/Source/WTF/wtf/Logger.cpp</a></li>
<li><a href="#trunkSourceWTFwtfLoggerh">trunk/Source/WTF/wtf/Logger.h</a></li>
<li><a href="#trunkSourceWTFwtfMemoryPressureHandlercpp">trunk/Source/WTF/wtf/MemoryPressureHandler.cpp</a></li>
<li><a href="#trunkSourceWTFwtfMemoryPressureHandlerh">trunk/Source/WTF/wtf/MemoryPressureHandler.h</a></li>
<li><a href="#trunkSourceWTFwtfRunLoopcpp">trunk/Source/WTF/wtf/RunLoop.cpp</a></li>
<li><a href="#trunkSourceWTFwtfThreadingcpp">trunk/Source/WTF/wtf/Threading.cpp</a></li>
<li><a href="#trunkSourceWTFwtfURLcpp">trunk/Source/WTF/wtf/URL.cpp</a></li>
<li><a href="#trunkSourceWTFwtfcfLanguageCFcpp">trunk/Source/WTF/wtf/cf/LanguageCF.cpp</a></li>
<li><a href="#trunkSourceWTFwtfcocoaNSURLExtrasmm">trunk/Source/WTF/wtf/cocoa/NSURLExtras.mm</a></li>
<li><a href="#trunkSourceWTFwtftextLineBreakIteratorPoolICUh">trunk/Source/WTF/wtf/text/LineBreakIteratorPoolICU.h</a></li>
<li><a href="#trunkSourceWTFwtftextStringViewcpp">trunk/Source/WTF/wtf/text/StringView.cpp</a></li>
<li><a href="#trunkSourceWTFwtftextTextBreakIteratorcpp">trunk/Source/WTF/wtf/text/TextBreakIterator.cpp</a></li>
<li><a href="#trunkSourceWTFwtftextTextBreakIteratorh">trunk/Source/WTF/wtf/text/TextBreakIterator.h</a></li>
<li><a href="#trunkSourceWTFwtfthreadsSignalscpp">trunk/Source/WTF/wtf/threads/Signals.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWTFwtftextLineBreakIteratorPoolICUcpp">trunk/Source/WTF/wtf/text/LineBreakIteratorPoolICU.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (265734 => 265735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog       2020-08-15 17:49:39 UTC (rev 265734)
+++ trunk/Source/WTF/ChangeLog  2020-08-15 18:40:50 UTC (rev 265735)
</span><span class="lines">@@ -1,3 +1,56 @@
</span><ins>+2020-08-15  Yusuke Suzuki  <ysuzuki@apple.com>
+
+        Use std::call_once + LazyNeverDestroyed to initialize complex data structures
+        https://bugs.webkit.org/show_bug.cgi?id=215535
+        <rdar://problem/66774266>
+
+        Reviewed by Mark Lam.
+
+        NeverDestroyed<> is not thread-safe in Darwin build since it is not using C++11 thread-safe static variable semantics.
+        This patch uses LazyNeverDestroyed and call_once to initialize complex data structures so that we can ensure they are
+        initialized atomically.
+
+        We also move some of `singleton` definitions from headers to cpp files. This is important since this ensures that singleton
+        is only one instance which is generated in one translation unit.
+
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/CMakeLists.txt:
+        * wtf/FastMalloc.cpp:
+        (WTF::MallocCallTracker::singleton):
+        * wtf/Language.cpp:
+        (WTF::observerMap):
+        (WTF::preferredLanguagesOverride):
+        * wtf/Logger.cpp:
+        (WTF::Logger::observers):
+        * wtf/Logger.h:
+        (WTF::Logger::observerLock):
+        (WTF::Logger::observers): Deleted.
+        * wtf/MemoryPressureHandler.cpp:
+        (WTF::MemoryPressureHandler::singleton):
+        * wtf/MemoryPressureHandler.h:
+        * wtf/RunLoop.cpp:
+        (WTF::RunLoop::current):
+        * wtf/Threading.cpp:
+        (WTF::Thread::initializeInThread):
+        * wtf/URL.cpp:
+        (WTF::aboutBlankURL):
+        (WTF::aboutSrcDocURL):
+        * wtf/cf/LanguageCF.cpp:
+        (WTF::preferredLanguages):
+        * wtf/cocoa/NSURLExtras.mm:
+        (WTF::rangeOfURLScheme):
+        * wtf/text/LineBreakIteratorPoolICU.cpp: Copied from Source/WTF/wtf/Logger.cpp.
+        (WTF::LineBreakIteratorPool::sharedPool):
+        * wtf/text/LineBreakIteratorPoolICU.h:
+        (WTF::LineBreakIteratorPool::sharedPool): Deleted.
+        * wtf/text/StringView.cpp:
+        * wtf/text/TextBreakIterator.cpp:
+        (WTF::TextBreakIteratorCache::singleton):
+        * wtf/text/TextBreakIterator.h:
+        (WTF::TextBreakIteratorCache::singleton): Deleted.
+        * wtf/threads/Signals.cpp:
+        (WTF::activeThreads):
+
</ins><span class="cx"> 2020-08-11  Wenson Hsieh  <wenson_hsieh@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Text input autocorrect="off" attribute ignored on Mac
</span></span></pre></div>
<a id="trunkSourceWTFWTFxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (265734 => 265735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj   2020-08-15 17:49:39 UTC (rev 265734)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj      2020-08-15 18:40:50 UTC (rev 265735)
</span><span class="lines">@@ -178,6 +178,7 @@
</span><span class="cx">          E38D6E271F5522E300A75CC4 /* StringBuilderJSON.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38D6E261F5522E300A75CC4 /* StringBuilderJSON.cpp */; };
</span><span class="cx">          E392FA2722E92BFF00ECDC73 /* ResourceUsageCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E392FA2622E92BFF00ECDC73 /* ResourceUsageCocoa.cpp */; };
</span><span class="cx">          E3A32BC41FC830E2007D7E76 /* JSValueMalloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3A32BC21FC830E2007D7E76 /* JSValueMalloc.cpp */; };
</span><ins>+               E3B8E41D24E7CE92003655D8 /* LineBreakIteratorPoolICU.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3B8E41C24E7CE92003655D8 /* LineBreakIteratorPoolICU.cpp */; };
</ins><span class="cx">           E3BE09A724A5854D009DF2B4 /* ICUHelpers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3BE09A624A58545009DF2B4 /* ICUHelpers.cpp */; };
</span><span class="cx">          E4A0AD391A96245500536DF6 /* WorkQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4A0AD371A96245500536DF6 /* WorkQueue.cpp */; };
</span><span class="cx">          E4A0AD3D1A96253C00536DF6 /* WorkQueueCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4A0AD3C1A96253C00536DF6 /* WorkQueueCocoa.cpp */; };
</span><span class="lines">@@ -728,6 +729,7 @@
</span><span class="cx">          E392FA2622E92BFF00ECDC73 /* ResourceUsageCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceUsageCocoa.cpp; sourceTree = "<group>"; };
</span><span class="cx">          E3A32BC21FC830E2007D7E76 /* JSValueMalloc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSValueMalloc.cpp; sourceTree = "<group>"; };
</span><span class="cx">          E3A32BC31FC830E2007D7E76 /* JSValueMalloc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSValueMalloc.h; sourceTree = "<group>"; };
</span><ins>+               E3B8E41C24E7CE92003655D8 /* LineBreakIteratorPoolICU.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LineBreakIteratorPoolICU.cpp; sourceTree = "<group>"; };
</ins><span class="cx">           E3BE09A624A58545009DF2B4 /* ICUHelpers.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ICUHelpers.cpp; sourceTree = "<group>"; };
</span><span class="cx">          E3CF76902115D6BA0091DE48 /* CompactPointerTuple.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CompactPointerTuple.h; sourceTree = "<group>"; };
</span><span class="cx">          E3E158251EADA53C004A079D /* SystemFree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SystemFree.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -1383,6 +1385,7 @@
</span><span class="cx">                          50DE35F4215BB01500B979C7 /* ExternalStringImpl.h */,
</span><span class="cx">                          26147B0815DDCCDC00DDB907 /* IntegerToStringConversion.h */,
</span><span class="cx">                          93AC91A718942FC400244939 /* LChar.h */,
</span><ins>+                               E3B8E41C24E7CE92003655D8 /* LineBreakIteratorPoolICU.cpp */,
</ins><span class="cx">                           1C181C811D30797C00F5FA16 /* LineBreakIteratorPoolICU.h */,
</span><span class="cx">                          C2BCFC531F621F3F00C9222C /* LineEnding.cpp */,
</span><span class="cx">                          C2BCFC541F621F3F00C9222C /* LineEnding.h */,
</span><span class="lines">@@ -1681,6 +1684,7 @@
</span><span class="cx">                          C2BCFC401F61D13000C9222C /* Language.cpp in Sources */,
</span><span class="cx">                          C2BCFC421F61D61600C9222C /* LanguageCF.cpp in Sources */,
</span><span class="cx">                          1C503BE623AAE0AE0072E66B /* LanguageCocoa.mm in Sources */,
</span><ins>+                               E3B8E41D24E7CE92003655D8 /* LineBreakIteratorPoolICU.cpp in Sources */,
</ins><span class="cx">                           C2BCFC551F621F3F00C9222C /* LineEnding.cpp in Sources */,
</span><span class="cx">                          0FE1646A1B6FFC9600400E7C /* Lock.cpp in Sources */,
</span><span class="cx">                          0F60F32F1DFCBD1B00416D6C /* LockedPrintStream.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWTFwtfCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/CMakeLists.txt (265734 => 265735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/CMakeLists.txt      2020-08-15 17:49:39 UTC (rev 265734)
+++ trunk/Source/WTF/wtf/CMakeLists.txt 2020-08-15 18:40:50 UTC (rev 265735)
</span><span class="lines">@@ -476,6 +476,7 @@
</span><span class="cx">     text/Base64.cpp
</span><span class="cx">     text/CString.cpp
</span><span class="cx">     text/ExternalStringImpl.cpp
</span><ins>+    text/LineBreakIteratorPoolICU.cpp
</ins><span class="cx">     text/LineEnding.cpp
</span><span class="cx">     text/StringBuffer.cpp
</span><span class="cx">     text/StringBuilder.cpp
</span></span></pre></div>
<a id="trunkSourceWTFwtfFastMalloccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/FastMalloc.cpp (265734 => 265735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/FastMalloc.cpp      2020-08-15 17:49:39 UTC (rev 265734)
+++ trunk/Source/WTF/wtf/FastMalloc.cpp 2020-08-15 18:40:50 UTC (rev 265735)
</span><span class="lines">@@ -340,7 +340,11 @@
</span><span class="cx"> MallocCallTracker& MallocCallTracker::singleton()
</span><span class="cx"> {
</span><span class="cx">     AvoidRecordingScope avoidRecording;
</span><del>-    static NeverDestroyed<MallocCallTracker> tracker;
</del><ins>+    static LazyNeverDestroyed<MallocCallTracker> tracker;
+    static std::once_flag onceKey;
+    std::call_once(onceKey, [&] {
+        tracker.construct();
+    });
</ins><span class="cx">     return tracker;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWTFwtfLanguagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/Language.cpp (265734 => 265735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/Language.cpp        2020-08-15 17:49:39 UTC (rev 265734)
+++ trunk/Source/WTF/wtf/Language.cpp   2020-08-15 18:40:50 UTC (rev 265735)
</span><span class="lines">@@ -41,7 +41,11 @@
</span><span class="cx"> typedef HashMap<void*, LanguageChangeObserverFunction> ObserverMap;
</span><span class="cx"> static ObserverMap& observerMap()
</span><span class="cx"> {
</span><del>-    static NeverDestroyed<ObserverMap> map;
</del><ins>+    static LazyNeverDestroyed<ObserverMap> map;
+    static std::once_flag onceKey;
+    std::call_once(onceKey, [&] {
+        map.construct();
+    });
</ins><span class="cx">     return map.get();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -75,7 +79,11 @@
</span><span class="cx"> 
</span><span class="cx"> static Vector<String>& preferredLanguagesOverride()
</span><span class="cx"> {
</span><del>-    static NeverDestroyed<Vector<String>> override;
</del><ins>+    static LazyNeverDestroyed<Vector<String>> override;
+    static std::once_flag onceKey;
+    std::call_once(onceKey, [&] {
+        override.construct();
+    });
</ins><span class="cx">     return override;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWTFwtfLoggercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/Logger.cpp (265734 => 265735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/Logger.cpp  2020-08-15 17:49:39 UTC (rev 265734)
+++ trunk/Source/WTF/wtf/Logger.cpp     2020-08-15 18:40:50 UTC (rev 265735)
</span><span class="lines">@@ -26,11 +26,14 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "Logger.h"
</span><span class="cx"> 
</span><ins>+#include <mutex>
</ins><span class="cx"> #include <wtf/HexNumber.h>
</span><span class="cx"> #include <wtf/text/WTFString.h>
</span><span class="cx"> 
</span><span class="cx"> namespace WTF {
</span><span class="cx"> 
</span><ins>+Lock loggerObserverLock;
+
</ins><span class="cx"> String Logger::LogSiteIdentifier::toString() const
</span><span class="cx"> {
</span><span class="cx">     if (className)
</span><span class="lines">@@ -43,4 +46,14 @@
</span><span class="cx">     return makeString('(', hex(reinterpret_cast<uintptr_t>(argument)), ')');
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Vector<std::reference_wrapper<Logger::Observer>>& Logger::observers()
+{
+    static LazyNeverDestroyed<Vector<std::reference_wrapper<Observer>>> observers;
+    static std::once_flag onceKey;
+    std::call_once(onceKey, [&] {
+        observers.construct();
+    });
+    return observers;
+}
+
</ins><span class="cx"> } // namespace WTF
</span></span></pre></div>
<a id="trunkSourceWTFwtfLoggerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/Logger.h (265734 => 265735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/Logger.h    2020-08-15 17:49:39 UTC (rev 265734)
+++ trunk/Source/WTF/wtf/Logger.h       2020-08-15 18:40:50 UTC (rev 265735)
</span><span class="lines">@@ -112,6 +112,8 @@
</span><span class="cx">     }
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+WTF_EXPORT_PRIVATE extern Lock loggerObserverLock;
+
</ins><span class="cx"> class Logger : public ThreadSafeRefCounted<Logger> {
</span><span class="cx">     WTF_MAKE_NONCOPYABLE(Logger);
</span><span class="cx"> public:
</span><span class="lines">@@ -359,16 +361,11 @@
</span><span class="cx">             observer.didLogMessage(channel, level, { ConsoleLogValue<Argument>::toValue(arguments)... });
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    static Vector<std::reference_wrapper<Observer>>& observers()
-    {
-        static NeverDestroyed<Vector<std::reference_wrapper<Observer>>> observers;
-        return observers;
-    }
</del><ins>+    WTF_EXPORT_PRIVATE static Vector<std::reference_wrapper<Observer>>& observers();
</ins><span class="cx"> 
</span><span class="cx">     static Lock& observerLock()
</span><span class="cx">     {
</span><del>-        static Lock observerLock;
-        return observerLock;
</del><ins>+        return loggerObserverLock;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWTFwtfMemoryPressureHandlercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/MemoryPressureHandler.cpp (265734 => 265735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/MemoryPressureHandler.cpp   2020-08-15 17:49:39 UTC (rev 265734)
+++ trunk/Source/WTF/wtf/MemoryPressureHandler.cpp      2020-08-15 18:40:50 UTC (rev 265735)
</span><span class="lines">@@ -48,7 +48,11 @@
</span><span class="cx"> 
</span><span class="cx"> MemoryPressureHandler& MemoryPressureHandler::singleton()
</span><span class="cx"> {
</span><del>-    static NeverDestroyed<MemoryPressureHandler> memoryPressureHandler;
</del><ins>+    static LazyNeverDestroyed<MemoryPressureHandler> memoryPressureHandler;
+    static std::once_flag onceKey;
+    std::call_once(onceKey, [&] {
+        memoryPressureHandler.construct();
+    });
</ins><span class="cx">     return memoryPressureHandler;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWTFwtfMemoryPressureHandlerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/MemoryPressureHandler.h (265734 => 265735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/MemoryPressureHandler.h     2020-08-15 17:49:39 UTC (rev 265734)
+++ trunk/Source/WTF/wtf/MemoryPressureHandler.h        2020-08-15 18:40:50 UTC (rev 265735)
</span><span class="lines">@@ -58,7 +58,7 @@
</span><span class="cx"> 
</span><span class="cx"> class MemoryPressureHandler {
</span><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><del>-    friend class WTF::NeverDestroyed<MemoryPressureHandler>;
</del><ins>+    friend class WTF::LazyNeverDestroyed<MemoryPressureHandler>;
</ins><span class="cx"> public:
</span><span class="cx">     WTF_EXPORT_PRIVATE static MemoryPressureHandler& singleton();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWTFwtfRunLoopcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/RunLoop.cpp (265734 => 265735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/RunLoop.cpp 2020-08-15 17:49:39 UTC (rev 265734)
+++ trunk/Source/WTF/wtf/RunLoop.cpp    2020-08-15 18:40:50 UTC (rev 265735)
</span><span class="lines">@@ -60,7 +60,11 @@
</span><span class="cx"> 
</span><span class="cx"> RunLoop& RunLoop::current()
</span><span class="cx"> {
</span><del>-    static NeverDestroyed<ThreadSpecific<Holder>> runLoopHolder;
</del><ins>+    static LazyNeverDestroyed<ThreadSpecific<Holder>> runLoopHolder;
+    static std::once_flag onceKey;
+    std::call_once(onceKey, [&] {
+        runLoopHolder.construct();
+    });
</ins><span class="cx">     return runLoopHolder.get()->runLoop();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWTFwtfThreadingcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/Threading.cpp (265734 => 265735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/Threading.cpp       2020-08-15 17:49:39 UTC (rev 265734)
+++ trunk/Source/WTF/wtf/Threading.cpp  2020-08-15 18:40:50 UTC (rev 265735)
</span><span class="lines">@@ -87,7 +87,11 @@
</span><span class="cx"> 
</span><span class="cx"> HashSet<Thread*>& Thread::allThreads(const LockHolder&)
</span><span class="cx"> {
</span><del>-    static NeverDestroyed<HashSet<Thread*>> allThreads;
</del><ins>+    static LazyNeverDestroyed<HashSet<Thread*>> allThreads;
+    static std::once_flag onceKey;
+    std::call_once(onceKey, [&] {
+        allThreads.construct();
+    });
</ins><span class="cx">     return allThreads;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -134,7 +138,11 @@
</span><span class="cx"> #if USE(WEB_THREAD)
</span><span class="cx">     // On iOS, one AtomStringTable is shared between the main UI thread and the WebThread.
</span><span class="cx">     if (isWebThread() || isUIThread()) {
</span><del>-        static NeverDestroyed<AtomStringTable> sharedStringTable;
</del><ins>+        static LazyNeverDestroyed<AtomStringTable> sharedStringTable;
+        static std::once_flag onceKey;
+        std::call_once(onceKey, [&] {
+            sharedStringTable.construct();
+        });
</ins><span class="cx">         m_currentAtomStringTable = &sharedStringTable.get();
</span><span class="cx">     }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWTFwtfURLcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/URL.cpp (265734 => 265735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/URL.cpp     2020-08-15 17:49:39 UTC (rev 265734)
+++ trunk/Source/WTF/wtf/URL.cpp        2020-08-15 18:40:50 UTC (rev 265735)
</span><span class="lines">@@ -820,11 +820,11 @@
</span><span class="cx"> 
</span><span class="cx"> const URL& aboutBlankURL()
</span><span class="cx"> {
</span><del>-    static NeverDestroyed<URL> staticBlankURL;
</del><ins>+    static LazyNeverDestroyed<URL> staticBlankURL;
</ins><span class="cx">     static std::once_flag onceFlag;
</span><span class="cx">     std::call_once(onceFlag, [&] {
</span><span class="cx">         static constexpr const char* aboutBlank = "about:blank";
</span><del>-        staticBlankURL.get() = URL(URL(), StringImpl::createStaticStringImpl(aboutBlank, strlen(aboutBlank)));
</del><ins>+        staticBlankURL.construct(URL(), StringImpl::createStaticStringImpl(aboutBlank, strlen(aboutBlank)));
</ins><span class="cx">     });
</span><span class="cx">     return staticBlankURL;
</span><span class="cx"> }
</span><span class="lines">@@ -831,11 +831,11 @@
</span><span class="cx"> 
</span><span class="cx"> const URL& aboutSrcDocURL()
</span><span class="cx"> {
</span><del>-    static NeverDestroyed<URL> staticSrcDocURL;
</del><ins>+    static LazyNeverDestroyed<URL> staticSrcDocURL;
</ins><span class="cx">     static std::once_flag onceFlag;
</span><span class="cx">     std::call_once(onceFlag, [&] {
</span><span class="cx">         static constexpr const char* aboutSrcDoc = "about:srcdoc";
</span><del>-        staticSrcDocURL.get() = URL(URL(), StringImpl::createStaticStringImpl(aboutSrcDoc, strlen(aboutSrcDoc)));
</del><ins>+        staticSrcDocURL.construct(URL(), StringImpl::createStaticStringImpl(aboutSrcDoc, strlen(aboutSrcDoc)));
</ins><span class="cx">     });
</span><span class="cx">     return staticSrcDocURL;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWTFwtfcfLanguageCFcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/cf/LanguageCF.cpp (265734 => 265735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/cf/LanguageCF.cpp   2020-08-15 17:49:39 UTC (rev 265734)
+++ trunk/Source/WTF/wtf/cf/LanguageCF.cpp      2020-08-15 18:40:50 UTC (rev 265735)
</span><span class="lines">@@ -42,7 +42,11 @@
</span><span class="cx"> 
</span><span class="cx"> static Vector<String>& preferredLanguages()
</span><span class="cx"> {
</span><del>-    static NeverDestroyed<Vector<String>> languages;
</del><ins>+    static LazyNeverDestroyed<Vector<String>> languages;
+    static std::once_flag onceKey;
+    std::call_once(onceKey, [&] {
+        languages.construct();
+    });
</ins><span class="cx">     return languages;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWTFwtfcocoaNSURLExtrasmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/cocoa/NSURLExtras.mm (265734 => 265735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/cocoa/NSURLExtras.mm        2020-08-15 17:49:39 UTC (rev 265734)
+++ trunk/Source/WTF/wtf/cocoa/NSURLExtras.mm   2020-08-15 18:40:50 UTC (rev 265735)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #import "config.h"
</span><span class="cx"> #import "NSURLExtras.h"
</span><span class="cx"> 
</span><ins>+#import <mutex>
</ins><span class="cx"> #import <wtf/Function.h>
</span><span class="cx"> #import <wtf/RetainPtr.h>
</span><span class="cx"> #import <wtf/URLHelpers.h>
</span><span class="lines">@@ -424,8 +425,12 @@
</span><span class="cx">          even need to enforce the character set here.
</span><span class="cx">          */
</span><span class="cx">         NSString *acceptableCharacters = @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+.-";
</span><del>-        static NeverDestroyed<RetainPtr<NSCharacterSet>> InverseSchemeCharacterSet([[NSCharacterSet characterSetWithCharactersInString:acceptableCharacters] invertedSet]);
-        NSRange illegals = [string rangeOfCharacterFromSet:InverseSchemeCharacterSet.get().get() options:0 range:scheme];
</del><ins>+        static LazyNeverDestroyed<RetainPtr<NSCharacterSet>> inverseSchemeCharacterSet;
+        static std::once_flag onceKey;
+        std::call_once(onceKey, [&] {
+            inverseSchemeCharacterSet.construct([[NSCharacterSet characterSetWithCharactersInString:acceptableCharacters] invertedSet]);
+        });
+        NSRange illegals = [string rangeOfCharacterFromSet:inverseSchemeCharacterSet.get().get() options:0 range:scheme];
</ins><span class="cx">         if (illegals.location == NSNotFound)
</span><span class="cx">             return scheme;
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWTFwtftextLineBreakIteratorPoolICUcppfromrev265727trunkSourceWTFwtfLoggercpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WTF/wtf/text/LineBreakIteratorPoolICU.cpp (from rev 265727, trunk/Source/WTF/wtf/Logger.cpp) (0 => 265735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/LineBreakIteratorPoolICU.cpp                           (rev 0)
+++ trunk/Source/WTF/wtf/text/LineBreakIteratorPoolICU.cpp      2020-08-15 18:40:50 UTC (rev 265735)
</span><span class="lines">@@ -0,0 +1,41 @@
</span><ins>+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include <wtf/text/LineBreakIteratorPoolICU.h>
+
+namespace WTF {
+
+LineBreakIteratorPool& LineBreakIteratorPool::sharedPool()
+{
+    static LazyNeverDestroyed<WTF::ThreadSpecific<LineBreakIteratorPool>> pool;
+    static std::once_flag onceKey;
+    std::call_once(onceKey, [&] {
+        pool.construct();
+    });
+    return *pool.get();
+}
+
+} // namespace WTF
</ins></span></pre></div>
<a id="trunkSourceWTFwtftextLineBreakIteratorPoolICUh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/LineBreakIteratorPoolICU.h (265734 => 265735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/LineBreakIteratorPoolICU.h     2020-08-15 17:49:39 UTC (rev 265734)
+++ trunk/Source/WTF/wtf/text/LineBreakIteratorPoolICU.h        2020-08-15 18:40:50 UTC (rev 265735)
</span><span class="lines">@@ -41,11 +41,7 @@
</span><span class="cx"> public:
</span><span class="cx">     LineBreakIteratorPool() = default;
</span><span class="cx"> 
</span><del>-    static LineBreakIteratorPool& sharedPool()
-    {
-        static NeverDestroyed<WTF::ThreadSpecific<LineBreakIteratorPool>> pool;
-        return *pool.get();
-    }
</del><ins>+    WTF_EXPORT_PRIVATE static LineBreakIteratorPool& sharedPool();
</ins><span class="cx"> 
</span><span class="cx">     static AtomString makeLocaleWithBreakKeyword(const AtomString& locale, LineBreakIteratorMode mode)
</span><span class="cx">     {
</span></span></pre></div>
<a id="trunkSourceWTFwtftextStringViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/StringView.cpp (265734 => 265735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/StringView.cpp 2020-08-15 17:49:39 UTC (rev 265734)
+++ trunk/Source/WTF/wtf/text/StringView.cpp    2020-08-15 18:40:50 UTC (rev 265735)
</span><span class="lines">@@ -375,7 +375,11 @@
</span><span class="cx"> 
</span><span class="cx"> static HashMap<const StringImpl*, StringView::UnderlyingString*>& underlyingStrings()
</span><span class="cx"> {
</span><del>-    static NeverDestroyed<HashMap<const StringImpl*, StringView::UnderlyingString*>> map;
</del><ins>+    static LazyNeverDestroyed<HashMap<const StringImpl*, StringView::UnderlyingString*>> map;
+    static std::once_flag onceKey;
+    std::call_once(onceKey, [&] {
+        map.construct();
+    });
</ins><span class="cx">     return map;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWTFwtftextTextBreakIteratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/TextBreakIterator.cpp (265734 => 265735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/TextBreakIterator.cpp  2020-08-15 17:49:39 UTC (rev 265734)
+++ trunk/Source/WTF/wtf/text/TextBreakIterator.cpp     2020-08-15 18:40:50 UTC (rev 265735)
</span><span class="lines">@@ -31,6 +31,16 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WTF {
</span><span class="cx"> 
</span><ins>+TextBreakIteratorCache& TextBreakIteratorCache::singleton()
+{
+    static LazyNeverDestroyed<TextBreakIteratorCache> cache;
+    static std::once_flag onceKey;
+    std::call_once(onceKey, [&] {
+        cache.construct();
+    });
+    return cache.get();
+}
+
</ins><span class="cx"> #if !PLATFORM(MAC) && !PLATFORM(IOS_FAMILY)
</span><span class="cx"> 
</span><span class="cx"> static Variant<TextBreakIteratorICU, TextBreakIteratorPlatform> mapModeToBackingIterator(StringView string, TextBreakIterator::Mode mode, const AtomString& locale)
</span></span></pre></div>
<a id="trunkSourceWTFwtftextTextBreakIteratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/TextBreakIterator.h (265734 => 265735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/TextBreakIterator.h    2020-08-15 17:49:39 UTC (rev 265734)
+++ trunk/Source/WTF/wtf/text/TextBreakIterator.h       2020-08-15 18:40:50 UTC (rev 265735)
</span><span class="lines">@@ -21,6 +21,7 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma once
</span><span class="cx"> 
</span><ins>+#include <mutex>
</ins><span class="cx"> #include <wtf/NeverDestroyed.h>
</span><span class="cx"> #include <wtf/Variant.h>
</span><span class="cx"> #include <wtf/text/StringView.h>
</span><span class="lines">@@ -112,14 +113,10 @@
</span><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> // Use CachedTextBreakIterator instead of dealing with the cache directly.
</span><span class="cx"> private:
</span><del>-    friend class NeverDestroyed<TextBreakIteratorCache>;
</del><ins>+    friend class LazyNeverDestroyed<TextBreakIteratorCache>;
</ins><span class="cx">     friend class CachedTextBreakIterator;
</span><span class="cx"> 
</span><del>-    static TextBreakIteratorCache& singleton()
-    {
-        static NeverDestroyed<TextBreakIteratorCache> cache;
-        return cache.get();
-    }
</del><ins>+    WTF_EXPORT_PRIVATE static TextBreakIteratorCache& singleton();
</ins><span class="cx"> 
</span><span class="cx">     TextBreakIteratorCache(const TextBreakIteratorCache&) = delete;
</span><span class="cx">     TextBreakIteratorCache(TextBreakIteratorCache&&) = delete;
</span></span></pre></div>
<a id="trunkSourceWTFwtfthreadsSignalscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/threads/Signals.cpp (265734 => 265735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/threads/Signals.cpp 2020-08-15 17:49:39 UTC (rev 265734)
+++ trunk/Source/WTF/wtf/threads/Signals.cpp    2020-08-15 18:40:50 UTC (rev 265735)
</span><span class="lines">@@ -258,14 +258,13 @@
</span><span class="cx"> 
</span><span class="cx"> static ThreadGroup& activeThreads()
</span><span class="cx"> {
</span><ins>+    static LazyNeverDestroyed<std::shared_ptr<ThreadGroup>> activeThreads;
</ins><span class="cx">     static std::once_flag initializeKey;
</span><del>-    static ThreadGroup* activeThreadsPtr = nullptr;
</del><span class="cx">     std::call_once(initializeKey, [&] {
</span><span class="cx">         Config::AssertNotFrozenScope assertScope;
</span><del>-        static NeverDestroyed<std::shared_ptr<ThreadGroup>> activeThreads { ThreadGroup::create() };
-        activeThreadsPtr = activeThreads.get().get();
</del><ins>+        activeThreads.construct(ThreadGroup::create());
</ins><span class="cx">     });
</span><del>-    return *activeThreadsPtr;
</del><ins>+    return (*activeThreads.get());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void registerThreadForMachExceptionHandling(Thread& thread)
</span></span></pre>
</div>
</div>

</body>
</html>