YARR: Coalesce constructed character classes
authormsaboff@apple.com <msaboff@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Dec 2017 18:27:18 +0000 (18:27 +0000)
committermsaboff@apple.com <msaboff@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Dec 2017 18:27:18 +0000 (18:27 +0000)
commit3628acf415e02c40b8a3884c88b41cf0cc21e016
treea60e7587a4bc7e161bdff340b06eae6e3c488fd5
parent05cf2334098e5097c3cf7a643fe1c2c2a77ee712
YARR: Coalesce constructed character classes
https://bugs.webkit.org/show_bug.cgi?id=180537

Reviewed by JF Bastien.

When adding characters or character ranges to a character class being constructed,
we now coalesce adjacent characters and character ranges.  When we create a
character class after construction is complete, we do a final coalescing pass
across the character list and ranges to catch any remaining coalescing
opportunities.

Added an optimization for character classes that will match any character.
This is somewhat common in code created before the /s (dotAll) flag was added
to the engine.

* yarr/YarrInterpreter.cpp:
(JSC::Yarr::Interpreter::checkCharacterClass):
* yarr/YarrJIT.cpp:
(JSC::Yarr::YarrGenerator::generateCharacterClassOnce):
(JSC::Yarr::YarrGenerator::generateCharacterClassFixed):
(JSC::Yarr::YarrGenerator::generateCharacterClassGreedy):
(JSC::Yarr::YarrGenerator::backtrackCharacterClassNonGreedy):
* yarr/YarrPattern.cpp:
(JSC::Yarr::CharacterClassConstructor::CharacterClassConstructor):
(JSC::Yarr::CharacterClassConstructor::reset):
(JSC::Yarr::CharacterClassConstructor::charClass):
(JSC::Yarr::CharacterClassConstructor::addSorted):
(JSC::Yarr::CharacterClassConstructor::addSortedRange):
(JSC::Yarr::CharacterClassConstructor::mergeRangesFrom):
(JSC::Yarr::CharacterClassConstructor::coalesceTables):
(JSC::Yarr::CharacterClassConstructor::anyCharacter):
(JSC::Yarr::YarrPatternConstructor::atomCharacterClassEnd):
(JSC::Yarr::PatternTerm::dump):
(JSC::Yarr::anycharCreate):
* yarr/YarrPattern.h:
(JSC::Yarr::CharacterClass::CharacterClass):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225683 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/yarr/YarrInterpreter.cpp
Source/JavaScriptCore/yarr/YarrJIT.cpp
Source/JavaScriptCore/yarr/YarrPattern.cpp
Source/JavaScriptCore/yarr/YarrPattern.h