Diff
Modified: trunk/Source/WTF/ChangeLog (265734 => 265735)
--- 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)
@@ -1,3 +1,56 @@
+2020-08-15 Yusuke Suzuki <[email protected]>
+
+ 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):
+
2020-08-11 Wenson Hsieh <[email protected]>
Text input autocorrect="off" attribute ignored on Mac
Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (265734 => 265735)
--- 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)
@@ -178,6 +178,7 @@
E38D6E271F5522E300A75CC4 /* StringBuilderJSON.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38D6E261F5522E300A75CC4 /* StringBuilderJSON.cpp */; };
E392FA2722E92BFF00ECDC73 /* ResourceUsageCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E392FA2622E92BFF00ECDC73 /* ResourceUsageCocoa.cpp */; };
E3A32BC41FC830E2007D7E76 /* JSValueMalloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3A32BC21FC830E2007D7E76 /* JSValueMalloc.cpp */; };
+ E3B8E41D24E7CE92003655D8 /* LineBreakIteratorPoolICU.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3B8E41C24E7CE92003655D8 /* LineBreakIteratorPoolICU.cpp */; };
E3BE09A724A5854D009DF2B4 /* ICUHelpers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3BE09A624A58545009DF2B4 /* ICUHelpers.cpp */; };
E4A0AD391A96245500536DF6 /* WorkQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4A0AD371A96245500536DF6 /* WorkQueue.cpp */; };
E4A0AD3D1A96253C00536DF6 /* WorkQueueCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4A0AD3C1A96253C00536DF6 /* WorkQueueCocoa.cpp */; };
@@ -728,6 +729,7 @@
E392FA2622E92BFF00ECDC73 /* ResourceUsageCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceUsageCocoa.cpp; sourceTree = "<group>"; };
E3A32BC21FC830E2007D7E76 /* JSValueMalloc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSValueMalloc.cpp; sourceTree = "<group>"; };
E3A32BC31FC830E2007D7E76 /* JSValueMalloc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSValueMalloc.h; sourceTree = "<group>"; };
+ E3B8E41C24E7CE92003655D8 /* LineBreakIteratorPoolICU.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LineBreakIteratorPoolICU.cpp; sourceTree = "<group>"; };
E3BE09A624A58545009DF2B4 /* ICUHelpers.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ICUHelpers.cpp; sourceTree = "<group>"; };
E3CF76902115D6BA0091DE48 /* CompactPointerTuple.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CompactPointerTuple.h; sourceTree = "<group>"; };
E3E158251EADA53C004A079D /* SystemFree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SystemFree.h; sourceTree = "<group>"; };
@@ -1383,6 +1385,7 @@
50DE35F4215BB01500B979C7 /* ExternalStringImpl.h */,
26147B0815DDCCDC00DDB907 /* IntegerToStringConversion.h */,
93AC91A718942FC400244939 /* LChar.h */,
+ E3B8E41C24E7CE92003655D8 /* LineBreakIteratorPoolICU.cpp */,
1C181C811D30797C00F5FA16 /* LineBreakIteratorPoolICU.h */,
C2BCFC531F621F3F00C9222C /* LineEnding.cpp */,
C2BCFC541F621F3F00C9222C /* LineEnding.h */,
@@ -1681,6 +1684,7 @@
C2BCFC401F61D13000C9222C /* Language.cpp in Sources */,
C2BCFC421F61D61600C9222C /* LanguageCF.cpp in Sources */,
1C503BE623AAE0AE0072E66B /* LanguageCocoa.mm in Sources */,
+ E3B8E41D24E7CE92003655D8 /* LineBreakIteratorPoolICU.cpp in Sources */,
C2BCFC551F621F3F00C9222C /* LineEnding.cpp in Sources */,
0FE1646A1B6FFC9600400E7C /* Lock.cpp in Sources */,
0F60F32F1DFCBD1B00416D6C /* LockedPrintStream.cpp in Sources */,
Modified: trunk/Source/WTF/wtf/CMakeLists.txt (265734 => 265735)
--- 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)
@@ -476,6 +476,7 @@
text/Base64.cpp
text/CString.cpp
text/ExternalStringImpl.cpp
+ text/LineBreakIteratorPoolICU.cpp
text/LineEnding.cpp
text/StringBuffer.cpp
text/StringBuilder.cpp
Modified: trunk/Source/WTF/wtf/FastMalloc.cpp (265734 => 265735)
--- 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)
@@ -340,7 +340,11 @@
MallocCallTracker& MallocCallTracker::singleton()
{
AvoidRecordingScope avoidRecording;
- static NeverDestroyed<MallocCallTracker> tracker;
+ static LazyNeverDestroyed<MallocCallTracker> tracker;
+ static std::once_flag onceKey;
+ std::call_once(onceKey, [&] {
+ tracker.construct();
+ });
return tracker;
}
Modified: trunk/Source/WTF/wtf/Language.cpp (265734 => 265735)
--- 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)
@@ -41,7 +41,11 @@
typedef HashMap<void*, LanguageChangeObserverFunction> ObserverMap;
static ObserverMap& observerMap()
{
- static NeverDestroyed<ObserverMap> map;
+ static LazyNeverDestroyed<ObserverMap> map;
+ static std::once_flag onceKey;
+ std::call_once(onceKey, [&] {
+ map.construct();
+ });
return map.get();
}
@@ -75,7 +79,11 @@
static Vector<String>& preferredLanguagesOverride()
{
- static NeverDestroyed<Vector<String>> override;
+ static LazyNeverDestroyed<Vector<String>> override;
+ static std::once_flag onceKey;
+ std::call_once(onceKey, [&] {
+ override.construct();
+ });
return override;
}
Modified: trunk/Source/WTF/wtf/Logger.cpp (265734 => 265735)
--- 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)
@@ -26,11 +26,14 @@
#include "config.h"
#include "Logger.h"
+#include <mutex>
#include <wtf/HexNumber.h>
#include <wtf/text/WTFString.h>
namespace WTF {
+Lock loggerObserverLock;
+
String Logger::LogSiteIdentifier::toString() const
{
if (className)
@@ -43,4 +46,14 @@
return makeString('(', hex(reinterpret_cast<uintptr_t>(argument)), ')');
}
+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;
+}
+
} // namespace WTF
Modified: trunk/Source/WTF/wtf/Logger.h (265734 => 265735)
--- 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)
@@ -112,6 +112,8 @@
}
};
+WTF_EXPORT_PRIVATE extern Lock loggerObserverLock;
+
class Logger : public ThreadSafeRefCounted<Logger> {
WTF_MAKE_NONCOPYABLE(Logger);
public:
@@ -359,16 +361,11 @@
observer.didLogMessage(channel, level, { ConsoleLogValue<Argument>::toValue(arguments)... });
}
- static Vector<std::reference_wrapper<Observer>>& observers()
- {
- static NeverDestroyed<Vector<std::reference_wrapper<Observer>>> observers;
- return observers;
- }
+ WTF_EXPORT_PRIVATE static Vector<std::reference_wrapper<Observer>>& observers();
static Lock& observerLock()
{
- static Lock observerLock;
- return observerLock;
+ return loggerObserverLock;
}
Modified: trunk/Source/WTF/wtf/MemoryPressureHandler.cpp (265734 => 265735)
--- 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)
@@ -48,7 +48,11 @@
MemoryPressureHandler& MemoryPressureHandler::singleton()
{
- static NeverDestroyed<MemoryPressureHandler> memoryPressureHandler;
+ static LazyNeverDestroyed<MemoryPressureHandler> memoryPressureHandler;
+ static std::once_flag onceKey;
+ std::call_once(onceKey, [&] {
+ memoryPressureHandler.construct();
+ });
return memoryPressureHandler;
}
Modified: trunk/Source/WTF/wtf/MemoryPressureHandler.h (265734 => 265735)
--- 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)
@@ -58,7 +58,7 @@
class MemoryPressureHandler {
WTF_MAKE_FAST_ALLOCATED;
- friend class WTF::NeverDestroyed<MemoryPressureHandler>;
+ friend class WTF::LazyNeverDestroyed<MemoryPressureHandler>;
public:
WTF_EXPORT_PRIVATE static MemoryPressureHandler& singleton();
Modified: trunk/Source/WTF/wtf/RunLoop.cpp (265734 => 265735)
--- 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)
@@ -60,7 +60,11 @@
RunLoop& RunLoop::current()
{
- static NeverDestroyed<ThreadSpecific<Holder>> runLoopHolder;
+ static LazyNeverDestroyed<ThreadSpecific<Holder>> runLoopHolder;
+ static std::once_flag onceKey;
+ std::call_once(onceKey, [&] {
+ runLoopHolder.construct();
+ });
return runLoopHolder.get()->runLoop();
}
Modified: trunk/Source/WTF/wtf/Threading.cpp (265734 => 265735)
--- 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)
@@ -87,7 +87,11 @@
HashSet<Thread*>& Thread::allThreads(const LockHolder&)
{
- static NeverDestroyed<HashSet<Thread*>> allThreads;
+ static LazyNeverDestroyed<HashSet<Thread*>> allThreads;
+ static std::once_flag onceKey;
+ std::call_once(onceKey, [&] {
+ allThreads.construct();
+ });
return allThreads;
}
@@ -134,7 +138,11 @@
#if USE(WEB_THREAD)
// On iOS, one AtomStringTable is shared between the main UI thread and the WebThread.
if (isWebThread() || isUIThread()) {
- static NeverDestroyed<AtomStringTable> sharedStringTable;
+ static LazyNeverDestroyed<AtomStringTable> sharedStringTable;
+ static std::once_flag onceKey;
+ std::call_once(onceKey, [&] {
+ sharedStringTable.construct();
+ });
m_currentAtomStringTable = &sharedStringTable.get();
}
#endif
Modified: trunk/Source/WTF/wtf/URL.cpp (265734 => 265735)
--- 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)
@@ -820,11 +820,11 @@
const URL& aboutBlankURL()
{
- static NeverDestroyed<URL> staticBlankURL;
+ static LazyNeverDestroyed<URL> staticBlankURL;
static std::once_flag onceFlag;
std::call_once(onceFlag, [&] {
static constexpr const char* aboutBlank = "about:blank";
- staticBlankURL.get() = URL(URL(), StringImpl::createStaticStringImpl(aboutBlank, strlen(aboutBlank)));
+ staticBlankURL.construct(URL(), StringImpl::createStaticStringImpl(aboutBlank, strlen(aboutBlank)));
});
return staticBlankURL;
}
@@ -831,11 +831,11 @@
const URL& aboutSrcDocURL()
{
- static NeverDestroyed<URL> staticSrcDocURL;
+ static LazyNeverDestroyed<URL> staticSrcDocURL;
static std::once_flag onceFlag;
std::call_once(onceFlag, [&] {
static constexpr const char* aboutSrcDoc = "about:srcdoc";
- staticSrcDocURL.get() = URL(URL(), StringImpl::createStaticStringImpl(aboutSrcDoc, strlen(aboutSrcDoc)));
+ staticSrcDocURL.construct(URL(), StringImpl::createStaticStringImpl(aboutSrcDoc, strlen(aboutSrcDoc)));
});
return staticSrcDocURL;
}
Modified: trunk/Source/WTF/wtf/cf/LanguageCF.cpp (265734 => 265735)
--- 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)
@@ -42,7 +42,11 @@
static Vector<String>& preferredLanguages()
{
- static NeverDestroyed<Vector<String>> languages;
+ static LazyNeverDestroyed<Vector<String>> languages;
+ static std::once_flag onceKey;
+ std::call_once(onceKey, [&] {
+ languages.construct();
+ });
return languages;
}
Modified: trunk/Source/WTF/wtf/cocoa/NSURLExtras.mm (265734 => 265735)
--- 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)
@@ -29,6 +29,7 @@
#import "config.h"
#import "NSURLExtras.h"
+#import <mutex>
#import <wtf/Function.h>
#import <wtf/RetainPtr.h>
#import <wtf/URLHelpers.h>
@@ -424,8 +425,12 @@
even need to enforce the character set here.
*/
NSString *acceptableCharacters = @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+.-";
- static NeverDestroyed<RetainPtr<NSCharacterSet>> InverseSchemeCharacterSet([[NSCharacterSet characterSetWithCharactersInString:acceptableCharacters] invertedSet]);
- NSRange illegals = [string rangeOfCharacterFromSet:InverseSchemeCharacterSet.get().get() options:0 range:scheme];
+ 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];
if (illegals.location == NSNotFound)
return scheme;
}
Copied: trunk/Source/WTF/wtf/text/LineBreakIteratorPoolICU.cpp (from rev 265727, trunk/Source/WTF/wtf/Logger.cpp) (0 => 265735)
--- 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)
@@ -0,0 +1,41 @@
+/*
+ * 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
Modified: trunk/Source/WTF/wtf/text/LineBreakIteratorPoolICU.h (265734 => 265735)
--- 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)
@@ -41,11 +41,7 @@
public:
LineBreakIteratorPool() = default;
- static LineBreakIteratorPool& sharedPool()
- {
- static NeverDestroyed<WTF::ThreadSpecific<LineBreakIteratorPool>> pool;
- return *pool.get();
- }
+ WTF_EXPORT_PRIVATE static LineBreakIteratorPool& sharedPool();
static AtomString makeLocaleWithBreakKeyword(const AtomString& locale, LineBreakIteratorMode mode)
{
Modified: trunk/Source/WTF/wtf/text/StringView.cpp (265734 => 265735)
--- 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)
@@ -375,7 +375,11 @@
static HashMap<const StringImpl*, StringView::UnderlyingString*>& underlyingStrings()
{
- static NeverDestroyed<HashMap<const StringImpl*, StringView::UnderlyingString*>> map;
+ static LazyNeverDestroyed<HashMap<const StringImpl*, StringView::UnderlyingString*>> map;
+ static std::once_flag onceKey;
+ std::call_once(onceKey, [&] {
+ map.construct();
+ });
return map;
}
Modified: trunk/Source/WTF/wtf/text/TextBreakIterator.cpp (265734 => 265735)
--- 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)
@@ -31,6 +31,16 @@
namespace WTF {
+TextBreakIteratorCache& TextBreakIteratorCache::singleton()
+{
+ static LazyNeverDestroyed<TextBreakIteratorCache> cache;
+ static std::once_flag onceKey;
+ std::call_once(onceKey, [&] {
+ cache.construct();
+ });
+ return cache.get();
+}
+
#if !PLATFORM(MAC) && !PLATFORM(IOS_FAMILY)
static Variant<TextBreakIteratorICU, TextBreakIteratorPlatform> mapModeToBackingIterator(StringView string, TextBreakIterator::Mode mode, const AtomString& locale)
Modified: trunk/Source/WTF/wtf/text/TextBreakIterator.h (265734 => 265735)
--- 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)
@@ -21,6 +21,7 @@
#pragma once
+#include <mutex>
#include <wtf/NeverDestroyed.h>
#include <wtf/Variant.h>
#include <wtf/text/StringView.h>
@@ -112,14 +113,10 @@
WTF_MAKE_FAST_ALLOCATED;
// Use CachedTextBreakIterator instead of dealing with the cache directly.
private:
- friend class NeverDestroyed<TextBreakIteratorCache>;
+ friend class LazyNeverDestroyed<TextBreakIteratorCache>;
friend class CachedTextBreakIterator;
- static TextBreakIteratorCache& singleton()
- {
- static NeverDestroyed<TextBreakIteratorCache> cache;
- return cache.get();
- }
+ WTF_EXPORT_PRIVATE static TextBreakIteratorCache& singleton();
TextBreakIteratorCache(const TextBreakIteratorCache&) = delete;
TextBreakIteratorCache(TextBreakIteratorCache&&) = delete;
Modified: trunk/Source/WTF/wtf/threads/Signals.cpp (265734 => 265735)
--- 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)
@@ -258,14 +258,13 @@
static ThreadGroup& activeThreads()
{
+ static LazyNeverDestroyed<std::shared_ptr<ThreadGroup>> activeThreads;
static std::once_flag initializeKey;
- static ThreadGroup* activeThreadsPtr = nullptr;
std::call_once(initializeKey, [&] {
Config::AssertNotFrozenScope assertScope;
- static NeverDestroyed<std::shared_ptr<ThreadGroup>> activeThreads { ThreadGroup::create() };
- activeThreadsPtr = activeThreads.get().get();
+ activeThreads.construct(ThreadGroup::create());
});
- return *activeThreadsPtr;
+ return (*activeThreads.get());
}
void registerThreadForMachExceptionHandling(Thread& thread)