[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198
pvarga at webkit.org
pvarga at webkit.org
Sun Feb 20 23:42:04 UTC 2011
The following commit has been merged in the webkit-1.3 branch:
commit 66266275ae1f72ec85fd98b0dc3c09ba3883b40d
Author: pvarga at webkit.org <pvarga at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Jan 24 11:52:43 2011 +0000
2011-01-24 Peter Varga <pvarga at inf.u-szeged.hu>
Reviewed by Oliver Hunt.
Optimize regex patterns which contain empty alternatives
https://bugs.webkit.org/show_bug.cgi?id=51395
Eliminate the empty alternatives from the regex pattern and convert it to do
the matching in an easier way.
* fast/regex/script-tests/slow.js:
* fast/regex/slow-expected.txt:
2011-01-24 Peter Varga <pvarga at webkit.org>
Reviewed by Oliver Hunt.
Optimize regex patterns which contain empty alternatives
https://bugs.webkit.org/show_bug.cgi?id=51395
Eliminate the empty alternatives from the regex pattern and convert it to do
the matching in an easier way.
* yarr/YarrPattern.cpp:
(JSC::Yarr::YarrPatternConstructor::atomParenthesesEnd):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76502 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 69203d3..b1a0054 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
+2011-01-24 Peter Varga <pvarga at inf.u-szeged.hu>
+
+ Reviewed by Oliver Hunt.
+
+ Optimize regex patterns which contain empty alternatives
+ https://bugs.webkit.org/show_bug.cgi?id=51395
+
+ Eliminate the empty alternatives from the regex pattern and convert it to do
+ the matching in an easier way.
+
+ * fast/regex/script-tests/slow.js:
+ * fast/regex/slow-expected.txt:
+
2011-01-24 Pavel Podivilov <podivilov at chromium.org>
Unreviewed, test fix for r76497.
diff --git a/LayoutTests/fast/regex/script-tests/slow.js b/LayoutTests/fast/regex/script-tests/slow.js
index 54b6b81..83ccb91 100644
--- a/LayoutTests/fast/regex/script-tests/slow.js
+++ b/LayoutTests/fast/regex/script-tests/slow.js
@@ -2,6 +2,6 @@ description(
'Test for expressions that would hang when evaluated due to exponential matching behavior. If the test does not hang it is a success.'
);
-shouldBe('/(?:[^(?!)]||){23}z/.test("/(?:[^(?!)]||){23}z/")', 'false');
+shouldBe('/(?:[^(?!)]||){23}z/.test("/(?:[^(?!)]||){23}z/")', 'true');
var successfullyParsed = true;
diff --git a/LayoutTests/fast/regex/slow-expected.txt b/LayoutTests/fast/regex/slow-expected.txt
index 105f24f..d238a83 100644
--- a/LayoutTests/fast/regex/slow-expected.txt
+++ b/LayoutTests/fast/regex/slow-expected.txt
@@ -3,7 +3,7 @@ Test for expressions that would hang when evaluated due to exponential matching
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-PASS /(?:[^(?!)]||){23}z/.test("/(?:[^(?!)]||){23}z/") is false
+PASS /(?:[^(?!)]||){23}z/.test("/(?:[^(?!)]||){23}z/") is true
PASS successfullyParsed is true
TEST COMPLETE
diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index 14c9992..7d24a40 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,16 @@
+2011-01-24 Peter Varga <pvarga at webkit.org>
+
+ Reviewed by Oliver Hunt.
+
+ Optimize regex patterns which contain empty alternatives
+ https://bugs.webkit.org/show_bug.cgi?id=51395
+
+ Eliminate the empty alternatives from the regex pattern and convert it to do
+ the matching in an easier way.
+
+ * yarr/YarrPattern.cpp:
+ (JSC::Yarr::YarrPatternConstructor::atomParenthesesEnd):
+
2011-01-24 Andras Becsi <abecsi at webkit.org>
Reviewed by Csaba Osztrogonác.
diff --git a/Source/JavaScriptCore/yarr/YarrPattern.cpp b/Source/JavaScriptCore/yarr/YarrPattern.cpp
index 112b65d..3d6dbd3 100644
--- a/Source/JavaScriptCore/yarr/YarrPattern.cpp
+++ b/Source/JavaScriptCore/yarr/YarrPattern.cpp
@@ -488,24 +488,56 @@ public:
m_alternative = m_alternative->m_parent->m_parent;
PatternTerm& lastTerm = m_alternative->lastTerm();
-
+
unsigned numParenAlternatives = parenthesesDisjunction->m_alternatives.size();
unsigned numBOLAnchoredAlts = 0;
- // Bubble up BOL flags
+ bool containsEmptyAlternative = false;
+
for (unsigned i = 0; i < numParenAlternatives; i++) {
+ if (!parenthesesDisjunction->m_alternatives[i]->m_terms.size() && numParenAlternatives > 1) {
+ parenthesesDisjunction->m_alternatives.remove(i);
+ --numParenAlternatives;
+
+ containsEmptyAlternative = true;
+ continue;
+ }
+
+ // Bubble up BOL flags
if (parenthesesDisjunction->m_alternatives[i]->m_startsWithBOL)
numBOLAnchoredAlts++;
}
-
+
if (numBOLAnchoredAlts) {
m_alternative->m_containsBOL = true;
// If all the alternatives in parens start with BOL, then so does this one
if (numBOLAnchoredAlts == numParenAlternatives)
m_alternative->m_startsWithBOL = true;
}
-
+
lastTerm.parentheses.lastSubpatternId = m_pattern.m_numSubpatterns;
m_invertParentheticalAssertion = false;
+
+ if (containsEmptyAlternative) {
+ // Backup and remove the current disjunction's alternatives.
+ Vector<PatternAlternative*> alternatives;
+ alternatives.append(parenthesesDisjunction->m_alternatives);
+ parenthesesDisjunction->m_alternatives.clear();
+ PatternAlternative* alternative = parenthesesDisjunction->addNewAlternative();
+
+ // Insert a new non-capturing parentheses.
+ unsigned subpatternId = m_pattern.m_numSubpatterns + 1;
+ PatternDisjunction* newDisjunction = new PatternDisjunction(alternative);
+ m_pattern.m_disjunctions.append(newDisjunction);
+ alternative->m_terms.append(PatternTerm(PatternTerm::TypeParenthesesSubpattern, subpatternId, newDisjunction, false, false));
+ newDisjunction->m_alternatives.append(alternatives);
+
+ // Set the quantifier of the new parentheses to '?' and set the inherited properties.
+ PatternTerm& disjunctionTerm = alternative->lastTerm();
+ disjunctionTerm.quantify(1, QuantifierGreedy);
+ disjunctionTerm.parentheses.lastSubpatternId = m_pattern.m_numSubpatterns;
+ alternative->m_containsBOL = m_alternative->m_containsBOL;
+ alternative->m_startsWithBOL = m_alternative->m_startsWithBOL;
+ }
}
void atomBackReference(unsigned subpatternId)
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list