Diff
Modified: branches/safari-613-branch/Source/WebCore/Sources.txt (292330 => 292331)
--- branches/safari-613-branch/Source/WebCore/Sources.txt 2022-04-04 21:55:30 UTC (rev 292330)
+++ branches/safari-613-branch/Source/WebCore/Sources.txt 2022-04-04 21:55:33 UTC (rev 292331)
@@ -1407,7 +1407,6 @@
html/canvas/WebGLVertexArrayObjectOES.cpp
html/forms/FileIconLoader.cpp
html/parser/CSSPreloadScanner.cpp
-html/parser/HTMLAtomStringCache.cpp
html/parser/HTMLConstructionSite.cpp
html/parser/HTMLDocumentParser.cpp
html/parser/HTMLElementStack.cpp
@@ -1415,6 +1414,7 @@
html/parser/HTMLEntitySearch.cpp
html/parser/HTMLFormattingElementList.cpp
html/parser/HTMLMetaCharsetParser.cpp
+html/parser/HTMLNameCache.cpp
html/parser/HTMLParserIdioms.cpp
html/parser/HTMLParserOptions.cpp
html/parser/HTMLParserScheduler.cpp
Modified: branches/safari-613-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj (292330 => 292331)
--- branches/safari-613-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2022-04-04 21:55:30 UTC (rev 292330)
+++ branches/safari-613-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2022-04-04 21:55:33 UTC (rev 292331)
@@ -5521,7 +5521,7 @@
F49328832769041B003E20F8 /* ModalContainerTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = F49328822769041B003E20F8 /* ModalContainerTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
F49786881FF45FA500E060AB /* PasteboardItemInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = F49786871FF45FA500E060AB /* PasteboardItemInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
F4A064C8277E48C900B06A17 /* FontCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = F4A064C6277E48C600B06A17 /* FontCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
- F4B0018926E7F21F006EAABE /* HTMLAtomStringCache.h in Headers */ = {isa = PBXBuildFile; fileRef = F4B0018726E7F21F006EAABE /* HTMLAtomStringCache.h */; };
+ F4B0018926E7F21F006EAABE /* HTMLNameCache.h in Headers */ = {isa = PBXBuildFile; fileRef = F4B0018726E7F21F006EAABE /* HTMLNameCache.h */; };
F4B2A909265030BA009E7286 /* DataDetectorHighlight.h in Headers */ = {isa = PBXBuildFile; fileRef = F4B2A90626502BA0009E7286 /* DataDetectorHighlight.h */; };
F4B422C4220C0568009E1E7D /* DOMPasteAccess.h in Headers */ = {isa = PBXBuildFile; fileRef = F4B422C2220C0000009E1E7D /* DOMPasteAccess.h */; settings = {ATTRIBUTES = (Private, ); }; };
F4BFB9851E1DDF9B00862C24 /* DumpEditingHistory.js in Copy Scripts */ = {isa = PBXBuildFile; fileRef = F48389831E1DDF2B0076B7EA /* DumpEditingHistory.js */; };
@@ -17768,8 +17768,8 @@
F49786871FF45FA500E060AB /* PasteboardItemInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PasteboardItemInfo.h; sourceTree = "<group>"; };
F49E98E421DEE6C1009AE55E /* EditAction.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = EditAction.cpp; sourceTree = "<group>"; };
F4A064C6277E48C600B06A17 /* FontCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontCocoa.h; sourceTree = "<group>"; };
- F4B0018726E7F21F006EAABE /* HTMLAtomStringCache.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HTMLAtomStringCache.h; sourceTree = "<group>"; };
- F4B0018826E7F21F006EAABE /* HTMLAtomStringCache.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLAtomStringCache.cpp; sourceTree = "<group>"; };
+ F4B0018726E7F21F006EAABE /* HTMLNameCache.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HTMLNameCache.h; sourceTree = "<group>"; };
+ F4B0018826E7F21F006EAABE /* HTMLNameCache.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLNameCache.cpp; sourceTree = "<group>"; };
F4B2A90626502BA0009E7286 /* DataDetectorHighlight.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DataDetectorHighlight.h; sourceTree = "<group>"; };
F4B2A90826502BC0009E7286 /* DataDetectorHighlight.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DataDetectorHighlight.mm; sourceTree = "<group>"; };
F4B2A90C265087E4009E7286 /* ImageOverlayControllerMac.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ImageOverlayControllerMac.mm; sourceTree = "<group>"; };
@@ -26264,8 +26264,6 @@
97C1F552122855CB00EDE617 /* AtomHTMLToken.h */,
977B3849122883E900B81FF8 /* CSSPreloadScanner.cpp */,
977B384A122883E900B81FF8 /* CSSPreloadScanner.h */,
- F4B0018826E7F21F006EAABE /* HTMLAtomStringCache.cpp */,
- F4B0018726E7F21F006EAABE /* HTMLAtomStringCache.h */,
977B384B122883E900B81FF8 /* HTMLConstructionSite.cpp */,
977B384C122883E900B81FF8 /* HTMLConstructionSite.h */,
977B384D122883E900B81FF8 /* HTMLDocumentParser.cpp */,
@@ -26283,6 +26281,8 @@
97BC849A12370A4B000C6161 /* HTMLInputStream.h */,
2BE8E2C812A58A0100FAD550 /* HTMLMetaCharsetParser.cpp */,
2BE8E2C612A589EC00FAD550 /* HTMLMetaCharsetParser.h */,
+ F4B0018826E7F21F006EAABE /* HTMLNameCache.cpp */,
+ F4B0018726E7F21F006EAABE /* HTMLNameCache.h */,
93E2A304123E9DC0009FE12A /* HTMLParserIdioms.cpp */,
93E2A305123E9DC0009FE12A /* HTMLParserIdioms.h */,
973F4187169B95EF0006BF60 /* HTMLParserOptions.cpp */,
@@ -34624,7 +34624,6 @@
A8CFF7AB0A156978000A4234 /* HTMLAnchorElement.h in Headers */,
CD1F9B7D270E667800617EB6 /* HTMLAnchorElementInlines.h in Headers */,
A8EA7D2E0A19385500A8EF5F /* HTMLAreaElement.h in Headers */,
- F4B0018926E7F21F006EAABE /* HTMLAtomStringCache.h in Headers */,
7C5F28FC1A827D8400C0F31F /* HTMLAttachmentElement.h in Headers */,
E44613A20CD6331000FADA75 /* HTMLAudioElement.h in Headers */,
A871DC1F0A15205700B12A68 /* HTMLBaseElement.h in Headers */,
@@ -34692,6 +34691,7 @@
71A3D1812562B85B0064E2A6 /* HTMLModelElement.h in Headers */,
7177AD57274295D1002F103B /* HTMLModelElementCamera.h in Headers */,
A8CFF7A70A156978000A4234 /* HTMLModElement.h in Headers */,
+ F4B0018926E7F21F006EAABE /* HTMLNameCache.h in Headers */,
A8DF3FD4097FA0FC0052981B /* HTMLNameCollection.h in Headers */,
A871D45A0A127CBC00B12A68 /* HTMLObjectElement.h in Headers */,
A8EA79F10A1916DF00A8EF5F /* HTMLOListElement.h in Headers */,
Modified: branches/safari-613-branch/Source/WebCore/dom/QualifiedName.h (292330 => 292331)
--- branches/safari-613-branch/Source/WebCore/dom/QualifiedName.h 2022-04-04 21:55:30 UTC (rev 292330)
+++ branches/safari-613-branch/Source/WebCore/dom/QualifiedName.h 2022-04-04 21:55:33 UTC (rev 292331)
@@ -72,6 +72,7 @@
};
WEBCORE_EXPORT QualifiedName(const AtomString& prefix, const AtomString& localName, const AtomString& namespaceURI);
+ QualifiedName(QualifiedNameImpl& impl) : m_impl(&impl) { }
explicit QualifiedName(WTF::HashTableDeletedValueType) : m_impl(WTF::HashTableDeletedValue) { }
bool isHashTableDeletedValue() const { return m_impl.isHashTableDeletedValue(); }
#ifdef QNAME_DEFAULT_CONSTRUCTOR
Modified: branches/safari-613-branch/Source/WebCore/html/parser/AtomHTMLToken.h (292330 => 292331)
--- branches/safari-613-branch/Source/WebCore/html/parser/AtomHTMLToken.h 2022-04-04 21:55:30 UTC (rev 292330)
+++ branches/safari-613-branch/Source/WebCore/html/parser/AtomHTMLToken.h 2022-04-04 21:55:33 UTC (rev 292331)
@@ -26,7 +26,7 @@
#pragma once
-#include "HTMLAtomStringCache.h"
+#include "HTMLNameCache.h"
#include "HTMLToken.h"
namespace WebCore {
@@ -209,11 +209,11 @@
if (attribute.name.isEmpty())
continue;
- auto localName = HTMLAtomStringCache::makeTagOrAttributeName(attribute.name);
+ auto qualifiedName = HTMLNameCache::makeAttributeQualifiedName(attribute.name);
// FIXME: This is N^2 for the number of attributes.
- if (!hasAttribute(m_attributes, localName))
- m_attributes.uncheckedAppend(Attribute(QualifiedName(nullAtom(), localName, nullAtom()), HTMLAtomStringCache::makeAttributeValue(attribute.value)));
+ if (!hasAttribute(m_attributes, qualifiedName.localName()))
+ m_attributes.uncheckedAppend(Attribute(WTFMove(qualifiedName), HTMLNameCache::makeAttributeValue(attribute.value)));
else
m_hasDuplicateAttribute = HasDuplicateAttribute::Yes;
}
@@ -227,7 +227,7 @@
ASSERT_NOT_REACHED();
return;
case HTMLToken::DOCTYPE:
- m_name = HTMLAtomStringCache::makeTagOrAttributeName(token.name());
+ m_name = HTMLNameCache::makeTagName(token.name());
m_doctypeData = token.releaseDoctypeData();
return;
case HTMLToken::EndOfFile:
@@ -235,7 +235,7 @@
case HTMLToken::StartTag:
case HTMLToken::EndTag:
m_selfClosing = token.selfClosing();
- m_name = HTMLAtomStringCache::makeTagOrAttributeName(token.name());
+ m_name = HTMLNameCache::makeTagName(token.name());
initializeAttributes(token.attributes());
return;
case HTMLToken::Comment:
Modified: branches/safari-613-branch/Source/WebCore/html/parser/HTMLAtomStringCache.cpp (292330 => 292331)
--- branches/safari-613-branch/Source/WebCore/html/parser/HTMLAtomStringCache.cpp 2022-04-04 21:55:30 UTC (rev 292330)
+++ branches/safari-613-branch/Source/WebCore/html/parser/HTMLAtomStringCache.cpp 2022-04-04 21:55:33 UTC (rev 292331)
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2021 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. AND ITS CONTRIBUTORS ``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 ITS 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 "HTMLAtomStringCache.h"
-
-namespace WebCore {
-
-HTMLAtomStringCache::Cache& HTMLAtomStringCache::cache(Type type)
-{
- static MainThreadNeverDestroyed<Cache> caches[2];
- return caches[static_cast<size_t>(type)].get();
-}
-
-} // namespace WebCore
Modified: branches/safari-613-branch/Source/WebCore/html/parser/HTMLAtomStringCache.h (292330 => 292331)
--- branches/safari-613-branch/Source/WebCore/html/parser/HTMLAtomStringCache.h 2022-04-04 21:55:30 UTC (rev 292330)
+++ branches/safari-613-branch/Source/WebCore/html/parser/HTMLAtomStringCache.h 2022-04-04 21:55:33 UTC (rev 292331)
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2021 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. AND ITS CONTRIBUTORS ``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 ITS 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 <wtf/NeverDestroyed.h>
-#include <wtf/Vector.h>
-#include <wtf/text/AtomString.h>
-
-namespace WebCore {
-
-class HTMLAtomStringCache {
-public:
- template<size_t inlineCapacity>
- ALWAYS_INLINE static AtomString makeTagOrAttributeName(const Vector<UChar, inlineCapacity>& string)
- {
- return make<Type::TagOrAttributeName>(string);
- }
-
- template<size_t inlineCapacity>
- ALWAYS_INLINE static AtomString makeAttributeValue(const Vector<UChar, inlineCapacity>& string)
- {
- return make<Type::AttributeValue>(string);
- }
-
- ALWAYS_INLINE static void clear()
- {
- // FIXME (webkit.org/b/230019): We should try to find more opportunities to clear this cache without hindering this performance optimization.
- cache(Type::TagOrAttributeName).fill({ });
- cache(Type::AttributeValue).fill({ });
- }
-
-private:
- enum class Type : bool { TagOrAttributeName, AttributeValue };
-
- template<HTMLAtomStringCache::Type type, size_t inlineCapacity>
- ALWAYS_INLINE static AtomString make(const Vector<UChar, inlineCapacity>& string)
- {
- if (string.isEmpty())
- return emptyAtom();
-
- auto length = string.size();
- if (length > maxStringLengthForCache)
- return AtomString(string);
-
- auto firstCharacter = string[0];
- auto lastCharacter = string[length - 1];
- auto& slot = cacheSlot(type, firstCharacter, lastCharacter, length);
- if (!equal(slot.impl(), string.data(), length)) {
- AtomString result(string);
- slot = result;
- return result;
- }
-
- return slot;
- }
-
- ALWAYS_INLINE static AtomString& cacheSlot(Type type, UChar firstCharacter, UChar lastCharacter, UChar length)
- {
- unsigned hash = (firstCharacter << 6) ^ ((lastCharacter << 14) ^ firstCharacter);
- hash += (hash >> 14) + (length << 14);
- hash ^= hash << 14;
- return cache(type)[(hash + (hash >> 6)) % capacity];
- }
-
- static constexpr auto maxStringLengthForCache = 36;
- static constexpr auto capacity = 512;
- using Cache = std::array<AtomString, capacity>;
- static Cache& cache(Type);
-};
-
-} // namespace WebCore
Modified: branches/safari-613-branch/Source/WebCore/page/MemoryRelease.cpp (292330 => 292331)
--- branches/safari-613-branch/Source/WebCore/page/MemoryRelease.cpp 2022-04-04 21:55:30 UTC (rev 292330)
+++ branches/safari-613-branch/Source/WebCore/page/MemoryRelease.cpp 2022-04-04 21:55:33 UTC (rev 292331)
@@ -38,8 +38,8 @@
#include "FontCache.h"
#include "Frame.h"
#include "GCController.h"
-#include "HTMLAtomStringCache.h"
#include "HTMLMediaElement.h"
+#include "HTMLNameCache.h"
#include "InlineStyleSheetOwner.h"
#include "InspectorInstrumentation.h"
#include "LayoutIntegrationLineLayout.h"
@@ -89,7 +89,7 @@
MemoryCache::singleton().pruneDeadResourcesToSize(0);
InlineStyleSheetOwner::clearCache();
- HTMLAtomStringCache::clear();
+ HTMLNameCache::clear();
}
static void releaseCriticalMemory(Synchronous synchronous, MaintainBackForwardCache maintainBackForwardCache, MaintainMemoryCache maintainMemoryCache)
Modified: branches/safari-613-branch/Source/WebCore/page/cocoa/MemoryReleaseCocoa.mm (292330 => 292331)
--- branches/safari-613-branch/Source/WebCore/page/cocoa/MemoryReleaseCocoa.mm 2022-04-04 21:55:30 UTC (rev 292330)
+++ branches/safari-613-branch/Source/WebCore/page/cocoa/MemoryReleaseCocoa.mm 2022-04-04 21:55:33 UTC (rev 292331)
@@ -28,7 +28,7 @@
#import "FontFamilySpecificationCoreText.h"
#import "GCController.h"
-#import "HTMLAtomStringCache.h"
+#import "HTMLNameCache.h"
#import "IOSurfacePool.h"
#import "LayerPool.h"
#import "LocaleCocoa.h"
@@ -101,7 +101,7 @@
GCController::singleton().deleteAllLinkedCode(JSC::DeleteAllCodeIfNotCollecting);
#endif
- HTMLAtomStringCache::clear();
+ HTMLNameCache::clear();
}
void registerMemoryReleaseNotifyCallbacks()