Changeset 289991 in webkit
- Timestamp:
- Feb 16, 2022 7:21:00 PM (2 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 1 deleted
- 7 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r289989 r289991 1 2022-02-16 Cameron McCormack <heycam@apple.com> 2 3 Cache an entire attribute QualifiedName when parsing HTML, not just its local name AtomString 4 https://bugs.webkit.org/show_bug.cgi?id=236570 5 <rdar://problem/88876545> 6 7 Reviewed by Darin Adler. 8 9 Bug 229907 added HTMLAtomStringCache, which uses a fast to compute hash 10 that works well to cache HTML tag names, attribute names, and attribute 11 values. When AtomHTMLToken initializes its list of Attributes, it uses 12 HTMLAtomStringCache to look up or create an AtomString for the 13 attribute's local name, and then creates a QualifiedName to wrap it. 14 QualifiedName construction involves looking up QualifiedNameCache, which 15 is a thread-specific cache of QualifiedNameImpl objects. If we make 16 HTMLAtomStringCache responsible for caching an attribute's QualifiedName 17 instead of just its local name AtomString, we can avoid the work of 18 looking up the QualifiedNameCache. 19 20 To reflect its broader responsibilities, HTMLAtomStringCache is renamed 21 to HTMLNameCache. 22 23 Doing this results in a 0.2-0.3% improvement on Speedometer 2, and a 24 0.3-0.4% improvement on PLT5 (with the lower end of those ranges being 25 on Apple Silicon and the higher end on Intel). 26 27 * Sources.txt: 28 * WebCore.xcodeproj/project.pbxproj: 29 * dom/QualifiedName.h: 30 (WebCore::QualifiedName::QualifiedName): 31 * html/parser/AtomHTMLToken.h: 32 (WebCore::AtomHTMLToken::initializeAttributes): 33 (WebCore::AtomHTMLToken::AtomHTMLToken): 34 * html/parser/HTMLAtomStringCache.h: Removed. 35 (WebCore::HTMLAtomStringCache::makeTagOrAttributeName): Deleted. 36 (WebCore::HTMLAtomStringCache::makeAttributeValue): Deleted. 37 (WebCore::HTMLAtomStringCache::clear): Deleted. 38 (WebCore::HTMLAtomStringCache::make): Deleted. 39 (WebCore::HTMLAtomStringCache::cacheSlot): Deleted. 40 * html/parser/HTMLNameCache.cpp: Renamed from Source/WebCore/html/parser/HTMLAtomStringCache.cpp. 41 (WebCore::HTMLNameCache::atomStringCache): 42 (WebCore::HTMLNameCache::qualifiedNameCache): 43 * html/parser/HTMLNameCache.h: Added. 44 (WebCore::HTMLNameCache::makeTagName): 45 (WebCore::HTMLNameCache::makeAttributeQualifiedName): 46 (WebCore::HTMLNameCache::makeAttributeValue): 47 (WebCore::HTMLNameCache::clear): 48 (WebCore::HTMLNameCache::makeAtomString): 49 (WebCore::HTMLNameCache::makeQualifiedName): 50 (WebCore::HTMLNameCache::slotIndex): 51 (WebCore::HTMLNameCache::atomStringCacheSlot): 52 (WebCore::HTMLNameCache::qualifiedNameCacheSlot): 53 * page/MemoryRelease.cpp: 54 (WebCore::releaseNoncriticalMemory): 55 * page/cocoa/MemoryReleaseCocoa.mm: 56 (WebCore::jettisonExpensiveObjectsOnTopLevelNavigation): 57 1 58 2022-02-16 Megan Gardner <megan_gardner@apple.com> 2 59 -
trunk/Source/WebCore/Sources.txt
r289978 r289991 1411 1411 html/forms/FileIconLoader.cpp 1412 1412 html/parser/CSSPreloadScanner.cpp 1413 html/parser/HTMLAtomStringCache.cpp1414 1413 html/parser/HTMLConstructionSite.cpp 1415 1414 html/parser/HTMLDocumentParser.cpp … … 1419 1418 html/parser/HTMLFormattingElementList.cpp 1420 1419 html/parser/HTMLMetaCharsetParser.cpp 1420 html/parser/HTMLNameCache.cpp 1421 1421 html/parser/HTMLParserIdioms.cpp 1422 1422 html/parser/HTMLParserOptions.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r289978 r289991 5551 5551 F49786881FF45FA500E060AB /* PasteboardItemInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = F49786871FF45FA500E060AB /* PasteboardItemInfo.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5552 5552 F4A064C8277E48C900B06A17 /* FontCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = F4A064C6277E48C600B06A17 /* FontCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5553 F4B0018926E7F21F006EAABE /* HTML AtomStringCache.h in Headers */ = {isa = PBXBuildFile; fileRef = F4B0018726E7F21F006EAABE /* HTMLAtomStringCache.h */; };5553 F4B0018926E7F21F006EAABE /* HTMLNameCache.h in Headers */ = {isa = PBXBuildFile; fileRef = F4B0018726E7F21F006EAABE /* HTMLNameCache.h */; }; 5554 5554 F4B2A909265030BA009E7286 /* DataDetectorHighlight.h in Headers */ = {isa = PBXBuildFile; fileRef = F4B2A90626502BA0009E7286 /* DataDetectorHighlight.h */; }; 5555 5555 F4B422C4220C0568009E1E7D /* DOMPasteAccess.h in Headers */ = {isa = PBXBuildFile; fileRef = F4B422C2220C0000009E1E7D /* DOMPasteAccess.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 17865 17865 F49E98E421DEE6C1009AE55E /* EditAction.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = EditAction.cpp; sourceTree = "<group>"; }; 17866 17866 F4A064C6277E48C600B06A17 /* FontCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontCocoa.h; sourceTree = "<group>"; }; 17867 F4B0018726E7F21F006EAABE /* HTML AtomStringCache.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HTMLAtomStringCache.h; sourceTree = "<group>"; };17868 F4B0018826E7F21F006EAABE /* HTML AtomStringCache.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLAtomStringCache.cpp; sourceTree = "<group>"; };17867 F4B0018726E7F21F006EAABE /* HTMLNameCache.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HTMLNameCache.h; sourceTree = "<group>"; }; 17868 F4B0018826E7F21F006EAABE /* HTMLNameCache.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLNameCache.cpp; sourceTree = "<group>"; }; 17869 17869 F4B2A90626502BA0009E7286 /* DataDetectorHighlight.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DataDetectorHighlight.h; sourceTree = "<group>"; }; 17870 17870 F4B2A90826502BC0009E7286 /* DataDetectorHighlight.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DataDetectorHighlight.mm; sourceTree = "<group>"; }; … … 26403 26403 977B3849122883E900B81FF8 /* CSSPreloadScanner.cpp */, 26404 26404 977B384A122883E900B81FF8 /* CSSPreloadScanner.h */, 26405 F4B0018826E7F21F006EAABE /* HTMLAtomStringCache.cpp */,26406 F4B0018726E7F21F006EAABE /* HTMLAtomStringCache.h */,26407 26405 977B384B122883E900B81FF8 /* HTMLConstructionSite.cpp */, 26408 26406 977B384C122883E900B81FF8 /* HTMLConstructionSite.h */, … … 26422 26420 2BE8E2C812A58A0100FAD550 /* HTMLMetaCharsetParser.cpp */, 26423 26421 2BE8E2C612A589EC00FAD550 /* HTMLMetaCharsetParser.h */, 26422 F4B0018826E7F21F006EAABE /* HTMLNameCache.cpp */, 26423 F4B0018726E7F21F006EAABE /* HTMLNameCache.h */, 26424 26424 93E2A304123E9DC0009FE12A /* HTMLParserIdioms.cpp */, 26425 26425 93E2A305123E9DC0009FE12A /* HTMLParserIdioms.h */, … … 34779 34779 CD1F9B7D270E667800617EB6 /* HTMLAnchorElementInlines.h in Headers */, 34780 34780 A8EA7D2E0A19385500A8EF5F /* HTMLAreaElement.h in Headers */, 34781 F4B0018926E7F21F006EAABE /* HTMLAtomStringCache.h in Headers */,34782 34781 7C5F28FC1A827D8400C0F31F /* HTMLAttachmentElement.h in Headers */, 34783 34782 E44613A20CD6331000FADA75 /* HTMLAudioElement.h in Headers */, … … 34846 34845 7177AD57274295D1002F103B /* HTMLModelElementCamera.h in Headers */, 34847 34846 A8CFF7A70A156978000A4234 /* HTMLModElement.h in Headers */, 34847 F4B0018926E7F21F006EAABE /* HTMLNameCache.h in Headers */, 34848 34848 A8DF3FD4097FA0FC0052981B /* HTMLNameCollection.h in Headers */, 34849 34849 A871D45A0A127CBC00B12A68 /* HTMLObjectElement.h in Headers */, -
trunk/Source/WebCore/dom/QualifiedName.h
r275410 r289991 73 73 74 74 WEBCORE_EXPORT QualifiedName(const AtomString& prefix, const AtomString& localName, const AtomString& namespaceURI); 75 QualifiedName(QualifiedNameImpl& impl) : m_impl(&impl) { } 75 76 explicit QualifiedName(WTF::HashTableDeletedValueType) : m_impl(WTF::HashTableDeletedValue) { } 76 77 bool isHashTableDeletedValue() const { return m_impl.isHashTableDeletedValue(); } -
trunk/Source/WebCore/html/parser/AtomHTMLToken.h
r286860 r289991 27 27 #pragma once 28 28 29 #include "HTML AtomStringCache.h"29 #include "HTMLNameCache.h" 30 30 #include "HTMLToken.h" 31 31 … … 210 210 continue; 211 211 212 auto localName = HTMLAtomStringCache::makeTagOrAttributeName(attribute.name);212 auto qualifiedName = HTMLNameCache::makeAttributeQualifiedName(attribute.name); 213 213 214 214 // FIXME: This is N^2 for the number of attributes. 215 if (!hasAttribute(m_attributes, localName))216 m_attributes.uncheckedAppend(Attribute( QualifiedName(nullAtom(), localName, nullAtom()), HTMLAtomStringCache::makeAttributeValue(attribute.value)));215 if (!hasAttribute(m_attributes, qualifiedName.localName())) 216 m_attributes.uncheckedAppend(Attribute(WTFMove(qualifiedName), HTMLNameCache::makeAttributeValue(attribute.value))); 217 217 else 218 218 m_hasDuplicateAttribute = HasDuplicateAttribute::Yes; … … 228 228 return; 229 229 case HTMLToken::DOCTYPE: 230 m_name = HTML AtomStringCache::makeTagOrAttributeName(token.name());230 m_name = HTMLNameCache::makeTagName(token.name()); 231 231 m_doctypeData = token.releaseDoctypeData(); 232 232 return; … … 236 236 case HTMLToken::EndTag: 237 237 m_selfClosing = token.selfClosing(); 238 m_name = HTML AtomStringCache::makeTagOrAttributeName(token.name());238 m_name = HTMLNameCache::makeTagName(token.name()); 239 239 initializeAttributes(token.attributes()); 240 240 return; -
trunk/Source/WebCore/html/parser/HTMLNameCache.cpp
r289990 r289991 25 25 26 26 #include "config.h" 27 #include "HTML AtomStringCache.h"27 #include "HTMLNameCache.h" 28 28 29 29 namespace WebCore { 30 30 31 HTML AtomStringCache::Cache& HTMLAtomStringCache::cache(Type type)31 HTMLNameCache::AtomStringCache& HTMLNameCache::atomStringCache(AtomStringType type) 32 32 { 33 static MainThreadNeverDestroyed< Cache> caches[2];33 static MainThreadNeverDestroyed<AtomStringCache> caches[2]; 34 34 return caches[static_cast<size_t>(type)].get(); 35 35 } 36 36 37 HTMLNameCache::QualifiedNameCache& HTMLNameCache::qualifiedNameCache() 38 { 39 static MainThreadNeverDestroyed<QualifiedNameCache> cache; 40 return cache.get(); 41 } 42 37 43 } // namespace WebCore -
trunk/Source/WebCore/page/MemoryRelease.cpp
r286625 r289991 39 39 #include "Frame.h" 40 40 #include "GCController.h" 41 #include "HTMLAtomStringCache.h"42 41 #include "HTMLMediaElement.h" 42 #include "HTMLNameCache.h" 43 43 #include "InlineStyleSheetOwner.h" 44 44 #include "InspectorInstrumentation.h" … … 90 90 91 91 InlineStyleSheetOwner::clearCache(); 92 HTML AtomStringCache::clear();92 HTMLNameCache::clear(); 93 93 } 94 94 -
trunk/Source/WebCore/page/cocoa/MemoryReleaseCocoa.mm
r282142 r289991 29 29 #import "FontFamilySpecificationCoreText.h" 30 30 #import "GCController.h" 31 #import "HTML AtomStringCache.h"31 #import "HTMLNameCache.h" 32 32 #import "IOSurfacePool.h" 33 33 #import "LayerPool.h" … … 102 102 #endif 103 103 104 HTML AtomStringCache::clear();104 HTMLNameCache::clear(); 105 105 } 106 106
Note: See TracChangeset
for help on using the changeset viewer.