Use less memory when compiling content extensions.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Apr 2015 19:56:57 +0000 (19:56 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Apr 2015 19:56:57 +0000 (19:56 +0000)
commita38f779bbedf3343087ef36d54b1b24680a0aec0
tree620f5b33d973ef45e3ac0e4a1566c99992a70194
parent852cdac6ba4d99e6c0de01a5fdecbd042603734a
Use less memory when compiling content extensions.
https://bugs.webkit.org/show_bug.cgi?id=144051

Patch by Alex Christensen <achristensen@webkit.org> on 2015-04-23
Reviewed by Darin Adler and Benjamin Poulain.

Source/WebCore:

No change in functionality, correctness already covered by existing tests.

Before this patch, a DFANode contained a HashSet of transitions.
Large vectors of DFANodes made many small HashSets, which was inefficient use of memory.
We now put all the actions and transitions into one big compact Vector and each node owns ranges in that vector.

* contentextensions/CombinedURLFilters.cpp:
(WebCore::ContentExtensions::recursiveMemoryUsed):
(WebCore::ContentExtensions::CombinedURLFilters::memoryUsed):
* contentextensions/CombinedURLFilters.h:
* contentextensions/ContentExtensionCompiler.cpp:
(WebCore::ContentExtensions::compileRuleList):
* contentextensions/ContentExtensionsDebugging.h:
* contentextensions/DFA.cpp:
(WebCore::ContentExtensions::DFA::memoryUsed):
(WebCore::ContentExtensions::DFANode::actions):
(WebCore::ContentExtensions::DFANode::transitions):
(WebCore::ContentExtensions::DFANode::fallbackTransitionDestination):
(WebCore::ContentExtensions::DFANode::changeFallbackTransition):
(WebCore::ContentExtensions::DFANode::addFallbackTransition):
(WebCore::ContentExtensions::DFANode::containsTransition):
(WebCore::ContentExtensions::DFANode::kill):
(WebCore::ContentExtensions::DFA::minimize):
(WebCore::ContentExtensions::DFA::DFA): Deleted.
(WebCore::ContentExtensions::DFA::operator=): Deleted.
* contentextensions/DFA.h:
* contentextensions/DFABytecodeCompiler.cpp:
(WebCore::ContentExtensions::DFABytecodeCompiler::compileNode):
(WebCore::ContentExtensions::DFABytecodeCompiler::compileNodeTransitions):
(WebCore::ContentExtensions::DFABytecodeCompiler::compile):
* contentextensions/DFABytecodeCompiler.h:
* contentextensions/DFAMinimizer.cpp:
(WebCore::ContentExtensions::DFAMinimizer::minimize):
* contentextensions/DFAMinimizer.h:
* contentextensions/DFANode.h:
(WebCore::ContentExtensions::DFANode::isKilled):
(WebCore::ContentExtensions::DFANode::hasFallbackTransition):
(WebCore::ContentExtensions::DFANode::hasActions):
(WebCore::ContentExtensions::DFANode::transitionsLength):
(WebCore::ContentExtensions::DFANode::actionsLength):
(WebCore::ContentExtensions::DFANode::actionsStart):
(WebCore::ContentExtensions::DFANode::setActions):
(WebCore::ContentExtensions::DFANode::setTransitions):
(WebCore::ContentExtensions::DFANode::resetTransitions):
(WebCore::ContentExtensions::DFANode::transitionsStart):
(WebCore::ContentExtensions::DFANode::setHasFallbackTransitionWithoutChangingDFA):
* contentextensions/NFA.cpp:
(WebCore::ContentExtensions::NFA::memoryUsed):
* contentextensions/NFA.h:
* contentextensions/NFAToDFA.cpp:
(WebCore::ContentExtensions::NodeIdSetToUniqueNodeIdSetSource::NodeIdSetToUniqueNodeIdSetSource):
(WebCore::ContentExtensions::NodeIdSetToUniqueNodeIdSetTranslator::translate):
(WebCore::ContentExtensions::getOrCreateDFANode):
(WebCore::ContentExtensions::NFAToDFA::convert):

Tools:

* TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:
(TestWebKitAPI::TEST_F):
* TestWebKitAPI/Tests/WebCore/DFAMinimizer.cpp:
(TestWebKitAPI::countLiveNodes):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183204 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
Source/WebCore/ChangeLog
Source/WebCore/contentextensions/CombinedURLFilters.cpp
Source/WebCore/contentextensions/CombinedURLFilters.h
Source/WebCore/contentextensions/ContentExtensionCompiler.cpp
Source/WebCore/contentextensions/ContentExtensionsDebugging.h
Source/WebCore/contentextensions/DFA.cpp
Source/WebCore/contentextensions/DFA.h
Source/WebCore/contentextensions/DFABytecodeCompiler.cpp
Source/WebCore/contentextensions/DFABytecodeCompiler.h
Source/WebCore/contentextensions/DFAMinimizer.cpp
Source/WebCore/contentextensions/DFAMinimizer.h
Source/WebCore/contentextensions/DFANode.h
Source/WebCore/contentextensions/NFA.cpp
Source/WebCore/contentextensions/NFA.h
Source/WebCore/contentextensions/NFAToDFA.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp
Tools/TestWebKitAPI/Tests/WebCore/DFAMinimizer.cpp