Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (217638 => 217639)
--- trunk/Source/WebCore/CMakeLists.txt 2017-05-31 23:25:04 UTC (rev 217638)
+++ trunk/Source/WebCore/CMakeLists.txt 2017-05-31 23:33:30 UTC (rev 217639)
@@ -1534,6 +1534,7 @@
dom/PromiseRejectionEvent.cpp
dom/PseudoElement.cpp
dom/QualifiedName.cpp
+ dom/QualifiedNameCache.cpp
dom/RadioButtonGroups.cpp
dom/Range.cpp
dom/RejectedPromiseTracker.cpp
Modified: trunk/Source/WebCore/ChangeLog (217638 => 217639)
--- trunk/Source/WebCore/ChangeLog 2017-05-31 23:25:04 UTC (rev 217638)
+++ trunk/Source/WebCore/ChangeLog 2017-05-31 23:33:30 UTC (rev 217639)
@@ -1,3 +1,32 @@
+2017-05-31 Chris Dumez <[email protected]>
+
+ Make QualifiedName cache per thread
+ https://bugs.webkit.org/show_bug.cgi?id=172778
+ <rdar://problem/32490942>
+
+ Reviewed by Geoffrey Garen.
+
+ Make QualifiedName cache per thread since it is currently used from multiple threads,
+ in an unsafe fashion. We started using QualifiedName objects in background threads
+ after r190602 which started using a CSSSelectorParser in the ContentExtensionParser.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * dom/QualifiedName.cpp:
+ (WebCore::QualifiedName::QualifiedName):
+ (WebCore::QualifiedName::QualifiedNameImpl::~QualifiedNameImpl):
+ * dom/QualifiedNameCache.cpp: Added.
+ (WebCore::QNameComponentsTranslator::hash):
+ (WebCore::QNameComponentsTranslator::equal):
+ (WebCore::QNameComponentsTranslator::translate):
+ (WebCore::QualifiedNameCache::getOrCreate):
+ (WebCore::QualifiedNameCache::remove):
+ * dom/QualifiedNameCache.h: Added.
+ * platform/ThreadGlobalData.cpp:
+ (WebCore::ThreadGlobalData::ThreadGlobalData):
+ (WebCore::ThreadGlobalData::destroy):
+ * platform/ThreadGlobalData.h:
+ (WebCore::ThreadGlobalData::qualifiedNameCache):
+
2017-05-31 Andy Estes <[email protected]>
Rename ENABLE_APPLE_PAY_DELEGATE to ENABLE_APPLE_PAY_SESSION_V3 and bump the supported version number
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (217638 => 217639)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-05-31 23:25:04 UTC (rev 217638)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-05-31 23:33:30 UTC (rev 217639)
@@ -3431,6 +3431,8 @@
83C1D434178D5AB500141E68 /* SVGPathSegLinetoVerticalRel.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C1D422178D5AB400141E68 /* SVGPathSegLinetoVerticalRel.h */; };
83C1D435178D5AB500141E68 /* SVGPathSegMovetoAbs.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C1D423178D5AB400141E68 /* SVGPathSegMovetoAbs.h */; };
83C1D436178D5AB500141E68 /* SVGPathSegMovetoRel.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C1D424178D5AB400141E68 /* SVGPathSegMovetoRel.h */; };
+ 83C1F5931EDF69D300410D27 /* QualifiedNameCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83C1F5911EDF69D300410D27 /* QualifiedNameCache.cpp */; };
+ 83C1F5941EDF69D300410D27 /* QualifiedNameCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C1F5921EDF69D300410D27 /* QualifiedNameCache.h */; };
83C45B8C1DC2B667008871BA /* ValidationBubbleMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83C45B8B1DC2B663008871BA /* ValidationBubbleMac.mm */; };
83C45B8E1DC2B68A008871BA /* ValidationBubble.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C45B8D1DC2B67C008871BA /* ValidationBubble.h */; settings = {ATTRIBUTES = (Private, ); }; };
83C5795D1DA5C301006FACA8 /* ScrollToOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 8350C3E71DA59B6200356446 /* ScrollToOptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -11535,6 +11537,8 @@
83C1D422178D5AB400141E68 /* SVGPathSegLinetoVerticalRel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPathSegLinetoVerticalRel.h; sourceTree = "<group>"; };
83C1D423178D5AB400141E68 /* SVGPathSegMovetoAbs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPathSegMovetoAbs.h; sourceTree = "<group>"; };
83C1D424178D5AB400141E68 /* SVGPathSegMovetoRel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPathSegMovetoRel.h; sourceTree = "<group>"; };
+ 83C1F5911EDF69D300410D27 /* QualifiedNameCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = QualifiedNameCache.cpp; sourceTree = "<group>"; };
+ 83C1F5921EDF69D300410D27 /* QualifiedNameCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QualifiedNameCache.h; sourceTree = "<group>"; };
83C45B8B1DC2B663008871BA /* ValidationBubbleMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ValidationBubbleMac.mm; sourceTree = "<group>"; };
83C45B8D1DC2B67C008871BA /* ValidationBubble.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ValidationBubble.h; sourceTree = "<group>"; };
83D26D3C1AFDCC50001B3873 /* ChildNode.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = ChildNode.idl; sourceTree = "<group>"; };
@@ -25906,6 +25910,8 @@
FF945ECA161F7F3600971BC8 /* PseudoElement.h */,
550A0BC7085F6039007353D6 /* QualifiedName.cpp */,
550A0BC8085F6039007353D6 /* QualifiedName.h */,
+ 83C1F5911EDF69D300410D27 /* QualifiedNameCache.cpp */,
+ 83C1F5921EDF69D300410D27 /* QualifiedNameCache.h */,
93F925420F7EF5B8007E37C9 /* RadioButtonGroups.cpp */,
93F925410F7EF5B8007E37C9 /* RadioButtonGroups.h */,
F523D30302DE4476018635CA /* Range.cpp */,
@@ -29717,6 +29723,7 @@
B2227A440D00BF220071B782 /* SVGMarkerElement.h in Headers */,
B2227A470D00BF220071B782 /* SVGMaskElement.h in Headers */,
0806E57A12893045007CED32 /* SVGMatrix.h in Headers */,
+ 83C1F5941EDF69D300410D27 /* QualifiedNameCache.h in Headers */,
08CA3D4412894A3800FFF260 /* SVGMatrixTearOff.h in Headers */,
7CE58D5C1DD7EC9C00128552 /* SVGMatrixValue.h in Headers */,
B2227A4B0D00BF220071B782 /* SVGMetadataElement.h in Headers */,
@@ -31780,6 +31787,7 @@
FDA15EA712B03EE1003A583A /* JSAudioDestinationNode.cpp in Sources */,
FDA15EAD12B03EE1003A583A /* JSAudioListener.cpp in Sources */,
FDA15EAF12B03EE1003A583A /* JSAudioNode.cpp in Sources */,
+ 83C1F5931EDF69D300410D27 /* QualifiedNameCache.cpp in Sources */,
FDA15EB312B03EE1003A583A /* JSAudioParam.cpp in Sources */,
FDA15EB512B03EE1003A583A /* JSAudioProcessingEvent.cpp in Sources */,
BE8EF042171C8FF9009B48C3 /* JSAudioTrack.cpp in Sources */,
Modified: trunk/Source/WebCore/dom/QualifiedName.cpp (217638 => 217639)
--- trunk/Source/WebCore/dom/QualifiedName.cpp 2017-05-31 23:25:04 UTC (rev 217638)
+++ trunk/Source/WebCore/dom/QualifiedName.cpp 2017-05-31 23:33:30 UTC (rev 217639)
@@ -26,68 +26,22 @@
#endif
#include "QualifiedName.h"
-#include "HTMLNames.h"
-#include "SVGNames.h"
-#include "XLinkNames.h"
-#include "XMLNSNames.h"
-#include "XMLNames.h"
+#include "QualifiedNameCache.h"
+#include "ThreadGlobalData.h"
#include <wtf/Assertions.h>
-#include <wtf/HashSet.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/StaticConstructors.h>
-#if ENABLE(MATHML)
-#include "MathMLNames.h"
-#endif
-
namespace WebCore {
-static const int staticQualifiedNamesCount = HTMLNames::HTMLTagsCount + HTMLNames::HTMLAttrsCount
-#if ENABLE(MATHML)
- + MathMLNames::MathMLTagsCount + MathMLNames::MathMLAttrsCount
-#endif
- + SVGNames::SVGTagsCount + SVGNames::SVGAttrsCount
- + XLinkNames::XLinkAttrsCount
- + XMLNSNames::XMLNSAttrsCount
- + XMLNames::XMLAttrsCount;
-
-struct QualifiedNameHashTraits : public HashTraits<QualifiedName::QualifiedNameImpl*> {
- static const int minimumTableSize = WTF::HashTableCapacityForSize<staticQualifiedNamesCount>::value;
-};
-
-typedef HashSet<QualifiedName::QualifiedNameImpl*, QualifiedNameHash, QualifiedNameHashTraits> QNameSet;
-
-struct QNameComponentsTranslator {
- static unsigned hash(const QualifiedNameComponents& components)
- {
- return hashComponents(components);
- }
- static bool equal(QualifiedName::QualifiedNameImpl* name, const QualifiedNameComponents& c)
- {
- return c.m_prefix == name->m_prefix.impl() && c.m_localName == name->m_localName.impl() && c.m_namespace == name->m_namespace.impl();
- }
- static void translate(QualifiedName::QualifiedNameImpl*& location, const QualifiedNameComponents& components, unsigned)
- {
- location = &QualifiedName::QualifiedNameImpl::create(components.m_prefix, components.m_localName, components.m_namespace).leakRef();
- }
-};
-
-static inline QNameSet& qualifiedNameCache()
-{
- static NeverDestroyed<QNameSet> nameCache;
- return nameCache;
-}
-
QualifiedName::QualifiedName(const AtomicString& p, const AtomicString& l, const AtomicString& n)
+ : m_impl(threadGlobalData().qualifiedNameCache().getOrCreate(QualifiedNameComponents { p.impl(), l.impl(), n.isEmpty() ? nullptr : n.impl() }))
{
- QualifiedNameComponents components = { p.impl(), l.impl(), n.isEmpty() ? nullptr : n.impl() };
- QNameSet::AddResult addResult = qualifiedNameCache().add<QNameComponentsTranslator>(components);
- m_impl = addResult.isNewEntry ? adoptRef(*addResult.iterator) : *addResult.iterator;
}
QualifiedName::QualifiedNameImpl::~QualifiedNameImpl()
{
- qualifiedNameCache().remove(this);
+ threadGlobalData().qualifiedNameCache().remove(*this);
}
// Global init routines
Added: trunk/Source/WebCore/dom/QualifiedNameCache.cpp (0 => 217639)
--- trunk/Source/WebCore/dom/QualifiedNameCache.cpp (rev 0)
+++ trunk/Source/WebCore/dom/QualifiedNameCache.cpp 2017-05-31 23:33:30 UTC (rev 217639)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2017 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 "QualifiedNameCache.h"
+
+namespace WebCore {
+
+struct QNameComponentsTranslator {
+ static unsigned hash(const QualifiedNameComponents& components)
+ {
+ return hashComponents(components);
+ }
+ static bool equal(QualifiedName::QualifiedNameImpl* name, const QualifiedNameComponents& c)
+ {
+ return c.m_prefix == name->m_prefix.impl() && c.m_localName == name->m_localName.impl() && c.m_namespace == name->m_namespace.impl();
+ }
+ static void translate(QualifiedName::QualifiedNameImpl*& location, const QualifiedNameComponents& components, unsigned)
+ {
+ location = &QualifiedName::QualifiedNameImpl::create(components.m_prefix, components.m_localName, components.m_namespace).leakRef();
+ }
+};
+
+Ref<QualifiedName::QualifiedNameImpl> QualifiedNameCache::getOrCreate(const QualifiedNameComponents& components)
+{
+ QNameSet::AddResult addResult = m_cache.add<QNameComponentsTranslator>(components);
+ return addResult.isNewEntry ? adoptRef(**addResult.iterator) : Ref<QualifiedName::QualifiedNameImpl> { **addResult.iterator };
+}
+
+void QualifiedNameCache::remove(QualifiedName::QualifiedNameImpl& impl)
+{
+ m_cache.remove(&impl);
+}
+
+} // namespace WebCore
Added: trunk/Source/WebCore/dom/QualifiedNameCache.h (0 => 217639)
--- trunk/Source/WebCore/dom/QualifiedNameCache.h (rev 0)
+++ trunk/Source/WebCore/dom/QualifiedNameCache.h 2017-05-31 23:33:30 UTC (rev 217639)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2017 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.
+ *
+ */
+
+#pragma once
+
+#include "HTMLNames.h"
+#include "QualifiedName.h"
+#include "SVGNames.h"
+#include "XLinkNames.h"
+#include "XMLNSNames.h"
+#include "XMLNames.h"
+#include <wtf/HashSet.h>
+#include <wtf/Ref.h>
+
+#if ENABLE(MATHML)
+#include "MathMLNames.h"
+#endif
+
+
+namespace WebCore {
+
+class QualifiedNameCache {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ QualifiedNameCache() = default;
+
+ Ref<QualifiedName::QualifiedNameImpl> getOrCreate(const QualifiedNameComponents&);
+ void remove(QualifiedName::QualifiedNameImpl&);
+
+private:
+ static const int staticQualifiedNamesCount = HTMLNames::HTMLTagsCount + HTMLNames::HTMLAttrsCount
+#if ENABLE(MATHML)
+ + MathMLNames::MathMLTagsCount + MathMLNames::MathMLAttrsCount
+#endif
+ + SVGNames::SVGTagsCount + SVGNames::SVGAttrsCount
+ + XLinkNames::XLinkAttrsCount
+ + XMLNSNames::XMLNSAttrsCount
+ + XMLNames::XMLAttrsCount;
+
+ struct QualifiedNameHashTraits : public HashTraits<QualifiedName::QualifiedNameImpl*> {
+ static const int minimumTableSize = WTF::HashTableCapacityForSize<staticQualifiedNamesCount>::value;
+ };
+
+ using QNameSet = HashSet<QualifiedName::QualifiedNameImpl*, QualifiedNameHash, QualifiedNameHashTraits>;
+ QNameSet m_cache;
+};
+
+}
Modified: trunk/Source/WebCore/platform/ThreadGlobalData.cpp (217638 => 217639)
--- trunk/Source/WebCore/platform/ThreadGlobalData.cpp 2017-05-31 23:25:04 UTC (rev 217638)
+++ trunk/Source/WebCore/platform/ThreadGlobalData.cpp 2017-05-31 23:33:30 UTC (rev 217639)
@@ -29,6 +29,7 @@
#include "CachedResourceRequestInitiators.h"
#include "EventNames.h"
+#include "QualifiedNameCache.h"
#include "TextCodecICU.h"
#include "ThreadTimers.h"
#include <wtf/MainThread.h>
@@ -52,6 +53,7 @@
: m_cachedResourceRequestInitiators(std::make_unique<CachedResourceRequestInitiators>())
, m_eventNames(EventNames::create())
, m_threadTimers(std::make_unique<ThreadTimers>())
+ , m_qualifiedNameCache(std::make_unique<QualifiedNameCache>())
#ifndef NDEBUG
, m_isMainThread(isMainThread())
#endif
@@ -82,6 +84,7 @@
m_eventNames = nullptr;
m_threadTimers = nullptr;
+ m_qualifiedNameCache = nullptr;
}
#if USE(WEB_THREAD)
Modified: trunk/Source/WebCore/platform/ThreadGlobalData.h (217638 => 217639)
--- trunk/Source/WebCore/platform/ThreadGlobalData.h 2017-05-31 23:25:04 UTC (rev 217638)
+++ trunk/Source/WebCore/platform/ThreadGlobalData.h 2017-05-31 23:33:30 UTC (rev 217639)
@@ -36,6 +36,7 @@
namespace WebCore {
+ class QualifiedNameCache;
class ThreadTimers;
struct CachedResourceRequestInitiators;
@@ -53,6 +54,7 @@
const CachedResourceRequestInitiators& cachedResourceRequestInitiators() { return *m_cachedResourceRequestInitiators; }
EventNames& eventNames() { return *m_eventNames; }
ThreadTimers& threadTimers() { return *m_threadTimers; }
+ QualifiedNameCache& qualifiedNameCache() { return *m_qualifiedNameCache; }
ICUConverterWrapper& cachedConverterICU() { return *m_cachedConverterICU; }
@@ -68,6 +70,7 @@
std::unique_ptr<CachedResourceRequestInitiators> m_cachedResourceRequestInitiators;
std::unique_ptr<EventNames> m_eventNames;
std::unique_ptr<ThreadTimers> m_threadTimers;
+ std::unique_ptr<QualifiedNameCache> m_qualifiedNameCache;
#ifndef NDEBUG
bool m_isMainThread;