Title: [225667] trunk/Source/WebCore
- Revision
- 225667
- Author
- utatane....@gmail.com
- Date
- 2017-12-07 19:02:26 -0800 (Thu, 07 Dec 2017)
Log Message
Use WTF::RecursiveLockAdapter instead of using pthread_mutex_t with recursive lock option
https://bugs.webkit.org/show_bug.cgi?id=180449
Reviewed by Mark Lam.
Use WTF::RecursiveLockAdapter<StaticLock> instead. We can remove pthread_mutex_xxx,
pthread_once and FontLocker wrapper.
* platform/graphics/FontCache.cpp:
(WebCore::FontCache::getCachedFontPlatformData):
(WebCore::FontCache::fontForPlatformData):
(WebCore::FontCache::purgeInactiveFontData):
(WebCore::FontCache::inactiveFontCount):
(initFontCacheLockOnce): Deleted.
(FontLocker::FontLocker): Deleted.
(FontLocker::~FontLocker): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (225666 => 225667)
--- trunk/Source/WebCore/ChangeLog 2017-12-08 03:00:42 UTC (rev 225666)
+++ trunk/Source/WebCore/ChangeLog 2017-12-08 03:02:26 UTC (rev 225667)
@@ -1,3 +1,22 @@
+2017-12-07 Yusuke Suzuki <utatane....@gmail.com>
+
+ Use WTF::RecursiveLockAdapter instead of using pthread_mutex_t with recursive lock option
+ https://bugs.webkit.org/show_bug.cgi?id=180449
+
+ Reviewed by Mark Lam.
+
+ Use WTF::RecursiveLockAdapter<StaticLock> instead. We can remove pthread_mutex_xxx,
+ pthread_once and FontLocker wrapper.
+
+ * platform/graphics/FontCache.cpp:
+ (WebCore::FontCache::getCachedFontPlatformData):
+ (WebCore::FontCache::fontForPlatformData):
+ (WebCore::FontCache::purgeInactiveFontData):
+ (WebCore::FontCache::inactiveFontCount):
+ (initFontCacheLockOnce): Deleted.
+ (FontLocker::FontLocker): Deleted.
+ (FontLocker::~FontLocker): Deleted.
+
2017-12-07 Eric Carlson <eric.carl...@apple.com>
Simplify log channel configuration UI
Modified: trunk/Source/WebCore/platform/graphics/FontCache.cpp (225666 => 225667)
--- trunk/Source/WebCore/platform/graphics/FontCache.cpp 2017-12-08 03:00:42 UTC (rev 225666)
+++ trunk/Source/WebCore/platform/graphics/FontCache.cpp 2017-12-08 03:02:26 UTC (rev 225667)
@@ -50,37 +50,12 @@
#endif
#if PLATFORM(IOS)
-#include <wtf/Noncopyable.h>
+#include <wtf/Lock.h>
+#include <wtf/RecursiveLockAdapter.h>
-// FIXME: We may be able to simplify this code using C++11 threading primitives, including std::call_once().
-static pthread_mutex_t fontLock;
+using RecursiveStaticLock = WTF::RecursiveLockAdapter<StaticLock>;
+static RecursiveStaticLock fontLock;
-static void initFontCacheLockOnce()
-{
- pthread_mutexattr_t mutexAttribute;
- pthread_mutexattr_init(&mutexAttribute);
- pthread_mutexattr_settype(&mutexAttribute, PTHREAD_MUTEX_RECURSIVE);
- pthread_mutex_init(&fontLock, &mutexAttribute);
- pthread_mutexattr_destroy(&mutexAttribute);
-}
-
-static pthread_once_t initFontLockControl = PTHREAD_ONCE_INIT;
-
-class FontLocker {
- WTF_MAKE_NONCOPYABLE(FontLocker);
-public:
- FontLocker()
- {
- pthread_once(&initFontLockControl, initFontCacheLockOnce);
- int lockcode = pthread_mutex_lock(&fontLock);
- ASSERT_WITH_MESSAGE_UNUSED(lockcode, !lockcode, "fontLock lock failed with code:%d", lockcode);
- }
- ~FontLocker()
- {
- int lockcode = pthread_mutex_unlock(&fontLock);
- ASSERT_WITH_MESSAGE_UNUSED(lockcode, !lockcode, "fontLock unlock failed with code:%d", lockcode);
- }
-};
#endif // PLATFORM(IOS)
@@ -232,7 +207,7 @@
const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, bool checkingAlternateName)
{
#if PLATFORM(IOS)
- FontLocker fontLocker;
+ auto locker = holdLock(fontLock);
#endif
#if OS(WINDOWS) && ENABLE(OPENTYPE_VERTICAL)
@@ -360,7 +335,7 @@
Ref<Font> FontCache::fontForPlatformData(const FontPlatformData& platformData)
{
#if PLATFORM(IOS)
- FontLocker fontLocker;
+ auto locker = holdLock(fontLock);
#endif
auto addResult = cachedFonts().add(platformData, nullptr);
@@ -393,7 +368,7 @@
pruneSystemFallbackFonts();
#if PLATFORM(IOS)
- FontLocker fontLocker;
+ auto locker = holdLock(fontLock);
#endif
while (purgeCount) {
@@ -437,7 +412,7 @@
size_t FontCache::inactiveFontCount()
{
#if PLATFORM(IOS)
- FontLocker fontLocker;
+ auto locker = holdLock(fontLock);
#endif
unsigned count = 0;
for (auto& font : cachedFonts().values()) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes