Unreviewed, rolling out r75595.
authorossy@webkit.org <ossy@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Jan 2011 11:16:40 +0000 (11:16 +0000)
committerossy@webkit.org <ossy@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Jan 2011 11:16:40 +0000 (11:16 +0000)
http://trac.webkit.org/changeset/75595
https://bugs.webkit.org/show_bug.cgi?id=52286

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2011-01-12
It broke fast/regex/pcre-test-1.html (Requested by Ossy on
#webkit).

* JavaScriptCore.gypi:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* runtime/RegExp.cpp:
* yarr/Yarr.h: Removed.
* yarr/YarrInterpreter.cpp:
* yarr/YarrInterpreter.h:
* yarr/YarrJIT.cpp:
(JSC::Yarr::jitCompile):
* yarr/YarrJIT.h:
(JSC::Yarr::execute):
* yarr/YarrParser.h:
* yarr/YarrPattern.cpp:
(JSC::Yarr::compile):
(JSC::Yarr::YarrPattern::YarrPattern):
* yarr/YarrPattern.h:

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

13 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.gypi
Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/runtime/RegExp.cpp
Source/JavaScriptCore/yarr/Yarr.h [deleted file]
Source/JavaScriptCore/yarr/YarrInterpreter.cpp
Source/JavaScriptCore/yarr/YarrInterpreter.h
Source/JavaScriptCore/yarr/YarrJIT.cpp
Source/JavaScriptCore/yarr/YarrJIT.h
Source/JavaScriptCore/yarr/YarrParser.h
Source/JavaScriptCore/yarr/YarrPattern.cpp
Source/JavaScriptCore/yarr/YarrPattern.h

index ea799099e77b94cfe2d61e76a92170fc2a13d47b..05437da50a3c58d963cb9949d7c682c99ef85fc2 100644 (file)
@@ -1,3 +1,29 @@
+2011-01-12  Sheriff Bot  <webkit.review.bot@gmail.com>
+
+        Unreviewed, rolling out r75595.
+        http://trac.webkit.org/changeset/75595
+        https://bugs.webkit.org/show_bug.cgi?id=52286
+
+        It broke fast/regex/pcre-test-1.html (Requested by Ossy on
+        #webkit).
+
+        * JavaScriptCore.gypi:
+        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * runtime/RegExp.cpp:
+        * yarr/Yarr.h: Removed.
+        * yarr/YarrInterpreter.cpp:
+        * yarr/YarrInterpreter.h:
+        * yarr/YarrJIT.cpp:
+        (JSC::Yarr::jitCompile):
+        * yarr/YarrJIT.h:
+        (JSC::Yarr::execute):
+        * yarr/YarrParser.h:
+        * yarr/YarrPattern.cpp:
+        (JSC::Yarr::compile):
+        (JSC::Yarr::YarrPattern::YarrPattern):
+        * yarr/YarrPattern.h:
+
 2011-01-12  Peter Varga  <pvarga@webkit.org>
 
         Reviewed by Gavin Barraclough.
index fa30116e7b12b8e553da32a5ffee077c003f34cc..a6c1db4edb9e5db47434cb09767af05d137e4dc7 100644 (file)
             'wtf/win/MainThreadWin.cpp',
             'wtf/win/OwnPtrWin.cpp',
             'wtf/wx/MainThreadWx.cpp',
-            'yarr/Yarr.h'
             'yarr/YarrInterpreter.cpp',
             'yarr/YarrInterpreter.h',
             'yarr/YarrJIT.cpp',
index c75e85aad00ad774963610483feab9f47602ba4c..f00c18dfedf3303a7e097955be98f21e0ff9a6b4 100644 (file)
                <Filter
                        Name="yarr"
                        >
-                       <File
-                               RelativePath="..\..\yarr\Yarr.h"
-                               >
-                       </File>
                        <File
                                RelativePath="..\..\yarr\YarrInterpreter.cpp"
                                >
index c867ffae018e3c2e9af4313f1141b8fe918f6742..a778036b87c2ecc8a1bebe77226ce1d8e33c6f37 100644 (file)
                41359CF70FDD89CB00206180 /* DateMath.h in Headers */ = {isa = PBXBuildFile; fileRef = 41359CF50FDD89CB00206180 /* DateMath.h */; settings = {ATTRIBUTES = (Private, ); }; };
                4409D8470FAF80A200523B87 /* OwnPtrCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 440B7AED0FAF7FCB0073323E /* OwnPtrCommon.h */; settings = {ATTRIBUTES = (Private, ); }; };
                44DD48530FAEA85000D6B4EB /* PassOwnPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 44DD48520FAEA85000D6B4EB /* PassOwnPtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               451539B912DC994500EF7AC4 /* Yarr.h in Headers */ = {isa = PBXBuildFile; fileRef = 451539B812DC994500EF7AC4 /* Yarr.h */; };
                511FC4C9117EE28700425272 /* MD5.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 511FC4C7117EE23D00425272 /* MD5.cpp */; };
                511FC4CB117EE2A800425272 /* MD5.h in Headers */ = {isa = PBXBuildFile; fileRef = 511FC4CA117EE2A800425272 /* MD5.h */; settings = {ATTRIBUTES = (Private, ); }; };
                5135FAF212D26ACE003C083B /* Decoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 5135FAD512D26856003C083B /* Decoder.h */; settings = {ATTRIBUTES = (Private, ); }; };
                440B7AED0FAF7FCB0073323E /* OwnPtrCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OwnPtrCommon.h; sourceTree = "<group>"; };
                449097EE0F8F81B50076A327 /* FeatureDefines.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = FeatureDefines.xcconfig; sourceTree = "<group>"; };
                44DD48520FAEA85000D6B4EB /* PassOwnPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PassOwnPtr.h; sourceTree = "<group>"; };
-               451539B812DC994500EF7AC4 /* Yarr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Yarr.h; path = yarr/Yarr.h; sourceTree = "<group>"; };
                45E12D8806A49B0F00E9DF84 /* jsc.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsc.cpp; sourceTree = "<group>"; tabWidth = 4; };
                511FC4C7117EE23D00425272 /* MD5.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MD5.cpp; sourceTree = "<group>"; };
                511FC4CA117EE2A800425272 /* MD5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MD5.h; sourceTree = "<group>"; };
                86EAC48C0F93E8B9008EC948 /* yarr */ = {
                        isa = PBXGroup;
                        children = (
-                               451539B812DC994500EF7AC4 /* Yarr.h */,
                                86704B7D12DBA33700A9FE7B /* YarrInterpreter.cpp */,
                                86704B7E12DBA33700A9FE7B /* YarrInterpreter.h */,
                                86704B7F12DBA33700A9FE7B /* YarrJIT.cpp */,
                                86704B8712DBA33700A9FE7B /* YarrJIT.h in Headers */,
                                86704B8812DBA33700A9FE7B /* YarrParser.h in Headers */,
                                86704B8A12DBA33700A9FE7B /* YarrPattern.h in Headers */,
-                               451539B912DC994500EF7AC4 /* Yarr.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 31a1abeb9df2247ea6d2699159b4c3e76ffb5731..4ab59bda05fa9c0550f34b73a487c25bc89b35e8 100644 (file)
 #include "RegExp.h"
 
 #include "Lexer.h"
-#include "yarr/Yarr.h"
+#include "yarr/YarrInterpreter.h"
+#include "yarr/YarrJIT.h"
+#include "yarr/YarrPattern.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <wtf/Assertions.h>
 #include <wtf/OwnArrayPtr.h>
 
+
 namespace JSC {
 
 struct RegExpRepresentation {
diff --git a/Source/JavaScriptCore/yarr/Yarr.h b/Source/JavaScriptCore/yarr/Yarr.h
deleted file mode 100644 (file)
index 57176bc..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
- * Copyright (C) 2010 Peter Varga (pvarga@inf.u-szeged.hu), University of Szeged
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef Yarr_h
-#define Yarr_h
-
-#include "YarrInterpreter.h"
-#include "YarrJIT.h"
-#include "YarrPattern.h"
-
-namespace JSC { namespace Yarr {
-
-#define YarrStackSpaceForBackTrackInfoPatternCharacter 1 // Only for !fixed quantifiers.
-#define YarrStackSpaceForBackTrackInfoCharacterClass 1 // Only for !fixed quantifiers.
-#define YarrStackSpaceForBackTrackInfoBackReference 2
-#define YarrStackSpaceForBackTrackInfoAlternative 1 // One per alternative.
-#define YarrStackSpaceForBackTrackInfoParentheticalAssertion 1
-#define YarrStackSpaceForBackTrackInfoParenthesesOnce 1 // Only for !fixed quantifiers.
-#define YarrStackSpaceForBackTrackInfoParenthesesTerminal 1
-#define YarrStackSpaceForBackTrackInfoParentheses 2
-
-static const unsigned quantifyInfinite = UINT_MAX;
-
-// The below limit restricts the number of "recursive" match calls in order to
-// avoid spending exponential time on complex regular expressions.
-static const unsigned matchLimit = 1000000;
-
-enum JSRegExpResult {
-    JSRegExpMatch = 1,
-    JSRegExpNoMatch = 0,
-    JSRegExpErrorNoMatch = -1,
-    JSRegExpErrorHitLimit = -2,
-    JSRegExpErrorNoMemory = -3,
-    JSRegExpErrorInternal = -4
-};
-
-PassOwnPtr<BytecodePattern> byteCompile(YarrPattern&, BumpPointerAllocator*);
-int interpret(BytecodePattern*, const UChar* input, unsigned start, unsigned length, int* output);
-
-#if ENABLE(YARR_JIT)
-void jitCompile(YarrPattern&, JSGlobalData*, YarrCodeBlock& jitObject);
-int execute(YarrCodeBlock& jitObject, const UChar* input, unsigned start, unsigned length, int* output);
-#endif
-
-} } // namespace JSC::Yarr
-
-#endif // Yarr_h
-
index d2dbf237c51f45b506ed1a3e9f15ea0628f1129b..a4ae88f0b8b6a31dfe55c873dc8d783ac31411a2 100644 (file)
@@ -27,7 +27,7 @@
 #include "config.h"
 #include "YarrInterpreter.h"
 
-#include "Yarr.h"
+#include "YarrPattern.h"
 #include <wtf/BumpPointerAllocator.h>
 
 #ifndef NDEBUG
@@ -1878,6 +1878,7 @@ int interpret(BytecodePattern* bytecode, const UChar* input, unsigned start, uns
     return Interpreter(bytecode, output, input, start, length).interpret();
 }
 
+
 COMPILE_ASSERT(sizeof(Interpreter::BackTrackInfoPatternCharacter) == (YarrStackSpaceForBackTrackInfoPatternCharacter * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoPatternCharacter);
 COMPILE_ASSERT(sizeof(Interpreter::BackTrackInfoCharacterClass) == (YarrStackSpaceForBackTrackInfoCharacterClass * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoCharacterClass);
 COMPILE_ASSERT(sizeof(Interpreter::BackTrackInfoBackReference) == (YarrStackSpaceForBackTrackInfoBackReference * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoBackReference);
index be703a9c888e56f7f90832470d1959dfe0e04d96..6ffe9b72aace3b627b65c1682877592552ca739d 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef YarrInterpreter_h
 #define YarrInterpreter_h
 
+#include "YarrParser.h"
 #include "YarrPattern.h"
 #include <wtf/PassOwnPtr.h>
 #include <wtf/unicode/Unicode.h>
@@ -37,6 +38,21 @@ using WTF::BumpPointerAllocator;
 
 namespace JSC { namespace Yarr {
 
+// TODO move the matchLimit constant and the JSRegExpResult enum to the JSRegExp.h when pcre is removed.
+
+// The below limit restricts the number of "recursive" match calls in order to
+// avoid spending exponential time on complex regular expressions.
+static const unsigned matchLimit = 1000000;
+
+enum JSRegExpResult {
+    JSRegExpMatch = 1,
+    JSRegExpNoMatch = 0,
+    JSRegExpErrorNoMatch = -1,
+    JSRegExpErrorHitLimit = -2,
+    JSRegExpErrorNoMemory = -3,
+    JSRegExpErrorInternal = -4
+};
+
 class ByteDisjunction;
 
 struct ByteTerm {
@@ -357,6 +373,9 @@ private:
     Vector<CharacterClass*> m_userCharacterClasses;
 };
 
+PassOwnPtr<BytecodePattern> byteCompile(YarrPattern&, BumpPointerAllocator*);
+int interpret(BytecodePattern*, const UChar* input, unsigned start, unsigned length, int* output);
+
 } } // namespace JSC::Yarr
 
 #endif // YarrInterpreter_h
index ae3cdf2ecd15cb7151ecc3cc036922086e2eea89..545fcf5fd90b07e15f1c36a0f13dea2cc73c77fd 100644 (file)
@@ -30,7 +30,7 @@
 #include "JSGlobalData.h"
 #include "LinkBuffer.h"
 #include "MacroAssembler.h"
-#include "Yarr.h"
+#include "YarrParser.h"
 
 #if ENABLE(YARR_JIT)
 
@@ -2203,13 +2203,10 @@ private:
 
 void jitCompile(YarrPattern& pattern, JSGlobalData* globalData, YarrCodeBlock& jitObject)
 {
-    YarrGenerator(pattern).compile(globalData, jitObject);
+    YarrGenerator generator(pattern);
+    generator.compile(globalData, jitObject);
 }
 
-int execute(YarrCodeBlock& jitObject, const UChar* input, unsigned start, unsigned length, int* output)
-{
-    return jitObject.execute(input, start, length, output);
-}
 
 }}
 
index 414b575063742c9443e26ab05ae8ad16be4d378f..dfdc777c06b4c72f404620c07d489c012f8f203d 100644 (file)
@@ -29,6 +29,7 @@
 #if ENABLE(YARR_JIT)
 
 #include "MacroAssembler.h"
+#include "YarrPattern.h"
 #include "UString.h"
 
 #if CPU(X86) && !COMPILER(MSVC)
@@ -75,6 +76,13 @@ private:
     bool m_needFallBack;
 };
 
+void jitCompile(YarrPattern&, JSGlobalData*, YarrCodeBlock& jitObject);
+
+inline int execute(YarrCodeBlock& jitObject, const UChar* input, unsigned start, unsigned length, int* output)
+{
+    return jitObject.execute(input, start, length, output);
+}
+
 } } // namespace JSC::Yarr
 
 #endif
index 8c5741a0debda5f8c719201801ed5800b5fa72d7..6c3fba55bdc5f33ed457944426a8debc804d088a 100644 (file)
 #define YarrParser_h
 
 #include "UString.h"
-#include "Yarr.h"
+#include <limits.h>
 #include <wtf/ASCIICType.h>
 #include <wtf/unicode/Unicode.h>
 
 namespace JSC { namespace Yarr {
 
+static const unsigned quantifyInfinite = UINT_MAX;
 #define REGEXP_ERROR_PREFIX "Invalid regular expression: "
 
 enum BuiltInCharacterClassID {
index e914f5281ef595aeef70fea4a48c7da47830619d..9ca04cba103f6aa7a017a18317f2c7a41efb478a 100644 (file)
@@ -27,8 +27,7 @@
 #include "config.h"
 #include "YarrPattern.h"
 
-#include "Yarr.h"
-#include "YarrParser.h"
+#include "YarrInterpreter.h"
 #include <wtf/Vector.h>
 
 using namespace WTF;
@@ -930,9 +929,10 @@ private:
     bool m_invertParentheticalAssertion;
 };
 
-const char* YarrPattern::compile(const UString& patternString)
+
+static const char* compile(const UString& patternString, YarrPattern& pattern)
 {
-    YarrPatternConstructor constructor(*this);
+    YarrPatternConstructor constructor(pattern);
 
     if (const char* error = parse(constructor, patternString))
         return error;
@@ -941,14 +941,17 @@ const char* YarrPattern::compile(const UString& patternString)
     // Quoting Netscape's "What's new in JavaScript 1.2",
     //      "Note: if the number of left parentheses is less than the number specified
     //       in \#, the \# is taken as an octal escape as described in the next row."
-    if (containsIllegalBackReference()) {
+    if (pattern.containsIllegalBackReference()) {
+        unsigned numSubpatterns = pattern.m_numSubpatterns;
+
         constructor.reset();
 #if !ASSERT_DISABLED
         const char* error =
 #endif
-            parse(constructor, patternString, m_numSubpatterns);
+            parse(constructor, patternString, numSubpatterns);
 
         ASSERT(!error);
+        ASSERT(numSubpatterns == pattern.m_numSubpatterns);
     }
 
     constructor.checkForTerminalParentheses();
@@ -958,7 +961,7 @@ const char* YarrPattern::compile(const UString& patternString)
     constructor.setupBeginChars();
 
     return 0;
-}
+};
 
 YarrPattern::YarrPattern(const UString& pattern, bool ignoreCase, bool multiline, const char** error)
     : m_ignoreCase(ignoreCase)
@@ -976,7 +979,7 @@ YarrPattern::YarrPattern(const UString& pattern, bool ignoreCase, bool multiline
     , nonspacesCached(0)
     , nonwordcharCached(0)
 {
-    *error = compile(pattern);
+    *error = compile(pattern, *this);
 }
 
 } }
index 2172dda6fda9380394012bcbf46899883addea20..14810c64bbf98bed57e6acf8003d0659eda7a6ca 100644 (file)
 
 namespace JSC { namespace Yarr {
 
+#define YarrStackSpaceForBackTrackInfoPatternCharacter 1 // Only for !fixed quantifiers.
+#define YarrStackSpaceForBackTrackInfoCharacterClass 1 // Only for !fixed quantifiers.
+#define YarrStackSpaceForBackTrackInfoBackReference 2
+#define YarrStackSpaceForBackTrackInfoAlternative 1 // One per alternative.
+#define YarrStackSpaceForBackTrackInfoParentheticalAssertion 1
+#define YarrStackSpaceForBackTrackInfoParenthesesOnce 1 // Only for !fixed quantifiers.
+#define YarrStackSpaceForBackTrackInfoParenthesesTerminal 1
+#define YarrStackSpaceForBackTrackInfoParentheses 2
+
 struct PatternDisjunction;
 
 struct CharacterRange {
@@ -401,8 +410,6 @@ struct YarrPattern {
     Vector<BeginChar> m_beginChars;
 
 private:
-    const char* compile(const UString& patternString);
-
     CharacterClass* newlineCached;
     CharacterClass* digitsCached;
     CharacterClass* spacesCached;