JavaScriptCore: 010-12-01 Steve Falkenburg <sfalken@apple.com>
authorbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Dec 2010 21:53:59 +0000 (21:53 +0000)
committerbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Dec 2010 21:53:59 +0000 (21:53 +0000)
Reviewed by Adam Roben.

vcproj changes can't be applied cleanly by the Windows EWS bot
https://bugs.webkit.org/show_bug.cgi?id=50328

* JavaScriptCore.vcproj/JavaScriptCore.sln: Modified property svn:eol-style.
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Modified property svn:eol-style.
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreCF.vsprops: Added property svn:eol-style.
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreCFLite.vsprops: Added property svn:eol-style.
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreCommon.vsprops: Added property svn:eol-style.
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreGenerated.vcproj: Modified property svn:eol-style.
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreGeneratedCommon.vsprops: Added property svn:eol-style.
* JavaScriptCore.vcproj/JavaScriptCoreSubmit.sln: Modified property svn:eol-style.
* JavaScriptCore.vcproj/WTF/WTF.vcproj: Modified property svn:eol-style.
* JavaScriptCore.vcproj/WTF/WTFCommon.vsprops: Added property svn:eol-style.
* JavaScriptCore.vcproj/jsc/jsc.vcproj: Modified property svn:eol-style.
* JavaScriptCore.vcproj/jsc/jscCommon.vsprops: Added property svn:eol-style.
* JavaScriptCore.vcproj/testapi/testapi.vcproj: Modified property svn:eol-style.
* JavaScriptCore.vcproj/testapi/testapiCommon.vsprops: Added property svn:eol-style.

LayoutTests: Bug 50298 - /()()()()()()()()()(?:(\10a|b)(X|Y))+/.exec("bXXaYYaY") ASSERTs

Reviewed by Sam Weinig.

* fast/regex/script-tests/pcre-test-1.js:
    Enable regex643, this now works.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@73065 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/yarr/RegexCompiler.cpp
JavaScriptCore/yarr/RegexInterpreter.cpp
JavaScriptCore/yarr/RegexPattern.h
LayoutTests/ChangeLog
LayoutTests/fast/regex/pcre-test-1-expected.txt
LayoutTests/fast/regex/script-tests/pcre-test-1.js

index 00c347e..0bd4fb0 100644 (file)
 
 2010-12-01  Gavin Barraclough  <barraclough@apple.com>
 
-        Rubber stamped by Sam Weinig.
+        Reviewed by Sam Weinig.
 
-        Bug 50297 - \s in YARR should match BOMs.
+        Bug 50298 - /()()()()()()()()()(?:(\10a|b)(X|Y))+/.exec("bXXaYYaY") ASSERTs
 
-        * create_regex_tables:
+        For unmatched subpattens we previously used to set the subpattern end to -1,
+        but now we only set the start value. E.g. consider the following:
+            /a(b)?c/.exec("ac");
+        Previously we would generate an internal results array of:
+            [ 0, 2, -1, -1 ]
+        Since fairly recently we have generated results of:
+            [ 0, 2, -1, ??? ]
+        (With the end index of the subpattern uninitialized).
+
+        Update these ASSERTs to account for this.
+
+        Also, when stripping out self-referencing backreferences, (e.g. /(\1)/) we
+        were checking the wrong property on the pattern term. We should have been
+        looking at term.parentheses.subpatternId, but instead were checking
+        term.subpatternId. The latter is actually only the subpatternId for
+        back reference terms. Rename this to backReferenceSubpatternId.
+
+        * yarr/RegexInterpreter.cpp:
+        (JSC::Yarr::Interpreter::matchBackReference):
+        (JSC::Yarr::Interpreter::backtrackBackReference):
 
 2010-11-30  Gavin Barraclough  <barraclough@apple.com>
 
index a56b5b9..e40c791 100644 (file)
@@ -520,7 +520,7 @@ public:
             PatternTerm& term = currentAlternative->lastTerm();
             ASSERT((term.type == PatternTerm::TypeParenthesesSubpattern) || (term.type == PatternTerm::TypeParentheticalAssertion));
 
-            if ((term.type == PatternTerm::TypeParenthesesSubpattern) && term.invertOrCapture && (subpatternId == term.subpatternId)) {
+            if ((term.type == PatternTerm::TypeParenthesesSubpattern) && term.invertOrCapture && (subpatternId == term.parentheses.subpatternId)) {
                 m_alternative->m_terms.append(PatternTerm::ForwardReference());
                 return;
             }
index f362f6f..a51cd25 100644 (file)
@@ -515,8 +515,7 @@ public:
         if (matchEnd == -1)
             return true;
 
-        ASSERT((matchBegin == -1) == (matchEnd == -1));
-        ASSERT(matchBegin <= matchEnd);
+        ASSERT((matchBegin == -1) || (matchBegin <= matchEnd));
 
         if (matchBegin == matchEnd)
             return true;
@@ -558,8 +557,7 @@ public:
 
         int matchBegin = output[(term.atom.subpatternId << 1)];
         int matchEnd = output[(term.atom.subpatternId << 1) + 1];
-        ASSERT((matchBegin == -1) == (matchEnd == -1));
-        ASSERT(matchBegin <= matchEnd);
+        ASSERT((matchBegin == -1) || (matchBegin <= matchEnd));
 
         if (matchBegin == matchEnd)
             return false;
@@ -1828,7 +1826,7 @@ public:
                     break;
 
                 case PatternTerm::TypeBackReference:
-                    atomBackReference(term.subpatternId, term.inputPosition - currentCountAlreadyChecked, term.frameLocation, term.quantityCount, term.quantityType);
+                    atomBackReference(term.backReferenceSubpatternId, term.inputPosition - currentCountAlreadyChecked, term.frameLocation, term.quantityCount, term.quantityType);
                         break;
 
                 case PatternTerm::TypeForwardReference:
index c76c641..8a7d35b 100644 (file)
@@ -107,7 +107,7 @@ struct PatternTerm {
     union {
         UChar patternCharacter;
         CharacterClass* characterClass;
-        unsigned subpatternId;
+        unsigned backReferenceSubpatternId;
         struct {
             PatternDisjunction* disjunction;
             unsigned subpatternId;
@@ -162,7 +162,7 @@ struct PatternTerm {
         : type(TypeBackReference)
         , invertOrCapture(false)
     {
-        subpatternId = spatternId;
+        backReferenceSubpatternId = spatternId;
         quantityType = QuantifierFixedCount;
         quantityCount = 1;
     }
index 97f5a26..6e20daa 100644 (file)
@@ -1,3 +1,12 @@
+2010-12-01  Gavin Barraclough  <barraclough@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Bug 50298 - /()()()()()()()()()(?:(\10a|b)(X|Y))+/.exec("bXXaYYaY") ASSERTs
+
+        * fast/regex/script-tests/pcre-test-1.js:
+            Enable regex643, this now works.
+
 2010-12-01  Ojan Vafai  <ojan@chromium.org>
 
         [chromium] Green tree.
index 8f51f33..c105f41 100644 (file)
@@ -1270,6 +1270,7 @@ PASS regex637.exec(input1); is results
 PASS regex641.exec(input0); is results
 PASS regex642.exec(input0); is results
 PASS regex642.exec(input1); is results
+PASS regex643.exec(input0); is results
 PASS regex644.exec(input0); is results
 PASS regex644.exec(input1); is results
 PASS regex644.exec(input2); is results
index 4e186fa..abd13dd 100644 (file)
@@ -5112,12 +5112,10 @@ var input1 = "bXYaXXaX";
 var results = ["bX", "X"];
 shouldBe('regex642.exec(input1);', 'results');
 
-// FIXME: this regex trips an ASSERT in JSC.
-// https://bugs.webkit.org/show_bug.cgi?id=50298
-//var regex643 = /()()()()()()()()()(?:(\10a|b)(X|Y))+/;
-//var input0 = "bXXaYYaY";
-//var results = ["bX", "", "", "", "", "", "", "", "", "", "X"];
-//shouldBe('regex643.exec(input0);', 'results');
+var regex643 = /()()()()()()()()()(?:(\10a|b)(X|Y))+/;
+var input0 = "bXXaYYaY";
+var results = ["bX", "", "", "", "", "", "", "", "", "", "b", "X"];
+shouldBe('regex643.exec(input0);', 'results');
 
 var regex644 = /[[,abc,]+]/;
 var input0 = "abc]";