Keep ElementAttributeData sharing cache open for a while after document parsing finishes.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 2 Dec 2012 12:03:44 +0000 (12:03 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 2 Dec 2012 12:03:44 +0000 (12:03 +0000)
commitb040bc0c7cf5d52116ac6f9d83d53e292a430d48
treeca978a2c6e11f0ccdbbc23b8c45a2ae701eb82f9
parent01d709ec0bc520de28fe3c80943a9677fb1f7200
Keep ElementAttributeData sharing cache open for a while after document parsing finishes.
<http://webkit.org/b/103720>

Reviewed by Antti Koivisto.

Allow web pages that generate content dynamically to benefit more from the ElementAttributeData sharing
cache by keeping it open for 10 seconds after document parsing finishes. This enables elements constructed
from HTML fragments to share attribute data with other identical elements.

Elements created via Document.createElement are still unsupported since we don't know the list of attributes
at the time of construction.

401kB progression on Membuster3.

Document now holds on to a DocumentSharedObjectPool, accessible via Document::sharedObjectPool().
It is non-null during parsing and for some time afterwards, and can be used to implement additional
caches that are not worth holding on to permanently.

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.xcodeproj/project.pbxproj:
* WebCore.vcproj/WebCore.vcproj:

    Add new class DocumentSharedObjectPool.

* dom/Document.cpp:
(WebCore::Document::Document):
(WebCore::Document::setParsing):
(WebCore::Document::finishedParsing):
(WebCore::Document::sharedObjectPoolClearTimerFired):
* dom/Document.h:
(WebCore::Document::sharedObjectPool):

    Create DocumentSharedObjectPool when parsing starts, kill it on a 10s timer after parsing finishes.

* dom/DocumentSharedObjectPool.cpp: Added.
(ImmutableElementAttributeDataCacheKey):
(WebCore::ImmutableElementAttributeDataCacheKey::ImmutableElementAttributeDataCacheKey):
(WebCore::ImmutableElementAttributeDataCacheKey::operator!=):
(WebCore::ImmutableElementAttributeDataCacheKey::hash):
(ImmutableElementAttributeDataCacheEntry):
(WebCore::ImmutableElementAttributeDataCacheEntry::ImmutableElementAttributeDataCacheEntry):
(WebCore::DocumentSharedObjectPool::cachedImmutableElementAttributeData):
(WebCore::DocumentSharedObjectPool::DocumentSharedObjectPool):
(WebCore::DocumentSharedObjectPool::~DocumentSharedObjectPool):
* dom/DocumentSharedObjectPool.h: Added.
(DocumentSharedObjectPool):
(WebCore::DocumentSharedObjectPool::create):
* dom/Element.cpp:
(WebCore::Element::parserSetAttributes):

    Moved the ElementAttributeData cache to DocumentSharedObjectPool.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@136334 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/DOMAllInOne.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/DocumentSharedObjectPool.cpp [new file with mode: 0644]
Source/WebCore/dom/DocumentSharedObjectPool.h [new file with mode: 0644]
Source/WebCore/dom/Element.cpp