2011-02-04 Peter Varga <pvarga@webkit.org>
authorpvarga@webkit.org <pvarga@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Feb 2011 14:29:10 +0000 (14:29 +0000)
committerpvarga@webkit.org <pvarga@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Feb 2011 14:29:10 +0000 (14:29 +0000)
        Reviewed by Gavin Barraclough.

        Replace PCRE with Yarr in WebCore
        https://bugs.webkit.org/show_bug.cgi?id=53496

        * JavaScriptCore.exp:
        * JavaScriptCore.gyp/JavaScriptCore.gyp:
        * JavaScriptCore.gypi:
        * JavaScriptCore.pro:
        * JavaScriptCore.xcodeproj/project.pbxproj:
        * create_regex_tables:
        * runtime/RegExp.cpp:
        * wtf/Platform.h:
        * yarr/Yarr.h:
        * yarr/YarrJIT.cpp:
        * yarr/YarrJIT.h:
        * yarr/YarrParser.h:
        * yarr/YarrPattern.h:
        * yarr/YarrSyntaxChecker.h:
        * yarr/yarr.pri: Added.
2011-02-04  Peter Varga  <pvarga@webkit.org>

        Reviewed by Gavin Barraclough.

        Replace PCRE with Yarr in WebCore
        https://bugs.webkit.org/show_bug.cgi?id=53496

        No new tests needed.

        * Android.jscbindings.mk:
        * CMakeLists.txt:
        * ForwardingHeaders/pcre/pcre.h: Removed.
        * ForwardingHeaders/yarr/Yarr.h: Added.
        * ForwardingHeaders/yarr/YarrInterpreter.h: Added.
        * ForwardingHeaders/yarr/YarrPattern.h: Added.
        * WebCore.gyp/WebCore.gyp:
        * WebCore.pro:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.vcproj/copyForwardingHeaders.cmd:
        * platform/text/RegularExpression.cpp:
        (WebCore::RegularExpression::Private::create):
        (WebCore::RegularExpression::Private::Private):
        (WebCore::RegularExpression::Private::compile):
        (WebCore::RegularExpression::match):

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

28 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.exp
Source/JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp
Source/JavaScriptCore/JavaScriptCore.gypi
Source/JavaScriptCore/JavaScriptCore.pro
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/create_regex_tables
Source/JavaScriptCore/runtime/RegExp.cpp
Source/JavaScriptCore/wtf/Platform.h
Source/JavaScriptCore/yarr/Yarr.h
Source/JavaScriptCore/yarr/YarrJIT.cpp
Source/JavaScriptCore/yarr/YarrJIT.h
Source/JavaScriptCore/yarr/YarrParser.h
Source/JavaScriptCore/yarr/YarrPattern.h
Source/JavaScriptCore/yarr/YarrSyntaxChecker.h
Source/JavaScriptCore/yarr/yarr.pri [new file with mode: 0644]
Source/WebCore/Android.jscbindings.mk
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/ForwardingHeaders/pcre/pcre.h [deleted file]
Source/WebCore/ForwardingHeaders/yarr/Yarr.h [new file with mode: 0644]
Source/WebCore/ForwardingHeaders/yarr/YarrInterpreter.h [new file with mode: 0644]
Source/WebCore/ForwardingHeaders/yarr/YarrPattern.h [new file with mode: 0644]
Source/WebCore/WebCore.gyp/WebCore.gyp
Source/WebCore/WebCore.pro
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.vcproj/copyForwardingHeaders.cmd
Source/WebCore/platform/text/RegularExpression.cpp

index 885966fa2b3a4b556c426279bb184e077f32a7d9..26692d959144e4576a6134f98a2671df3a3b12cc 100644 (file)
@@ -1,3 +1,26 @@
+2011-02-04  Peter Varga  <pvarga@webkit.org>
+
+        Reviewed by Gavin Barraclough.
+
+        Replace PCRE with Yarr in WebCore
+        https://bugs.webkit.org/show_bug.cgi?id=53496
+
+        * JavaScriptCore.exp:
+        * JavaScriptCore.gyp/JavaScriptCore.gyp:
+        * JavaScriptCore.gypi:
+        * JavaScriptCore.pro:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * create_regex_tables:
+        * runtime/RegExp.cpp:
+        * wtf/Platform.h:
+        * yarr/Yarr.h:
+        * yarr/YarrJIT.cpp:
+        * yarr/YarrJIT.h:
+        * yarr/YarrParser.h:
+        * yarr/YarrPattern.h:
+        * yarr/YarrSyntaxChecker.h:
+        * yarr/yarr.pri: Added.
+
 2011-02-04  Ilya Tikhonovsky  <loislo@chromium.org>
 
         Unreviewed rollout two patches r77614 and r77612.
index 2fa16f7b618e977a3789f011382dc21317d98412..b335a418bf9c0d2bd497834d73c6d8c7771e52d6 100644 (file)
@@ -96,9 +96,6 @@ _WTFReportAssertionFailureWithMessage
 _WTFReportBacktrace
 _WTFReportError
 _WTFReportFatalError
-__Z12jsRegExpFreeP8JSRegExp
-__Z15jsRegExpCompilePKti24JSRegExpIgnoreCaseOption23JSRegExpMultilineOptionPjPPKc
-__Z15jsRegExpExecutePK8JSRegExpPKtiiPii
 __ZN14OpaqueJSString6createERKN3JSC7UStringE
 __ZN3JSC10Identifier11addSlowCaseEPNS_12JSGlobalDataEPN3WTF10StringImplE
 __ZN3JSC10Identifier11addSlowCaseEPNS_9ExecStateEPN3WTF10StringImplE
@@ -225,6 +222,9 @@ __ZN3JSC4Heap7protectENS_7JSValueE
 __ZN3JSC4Heap8allocateEm
 __ZN3JSC4Heap9unprotectENS_7JSValueE
 __ZN3JSC4callEPNS_9ExecStateENS_7JSValueENS_8CallTypeERKNS_8CallDataES2_RKNS_7ArgListE
+__ZN3JSC4Yarr11YarrPatternC1ERKNS_7UStringEbbPPKc
+__ZN3JSC4Yarr11byteCompileERNS0_11YarrPatternEPN3WTF20BumpPointerAllocatorE
+__ZN3JSC4Yarr9interpretEPNS0_15BytecodePatternEPKtjjPi
 __ZN3JSC6JSCell11getCallDataERNS_8CallDataE
 __ZN3JSC6JSCell11getJSNumberEv
 __ZN3JSC6JSCell14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
index 56304fa656a32ed6676d248ad53bf0a156928ad0..08e590b64d724a19880f03fcf21fbe0ce4b60faa 100644 (file)
       ],
     },
     {
-      'target_name': 'pcre',
+      'target_name': 'yarr',
       'type': '<(library)',
       'dependencies': [
         'wtf',
       'msvs_guid': '49909552-0B0C-4C14-8CF6-DB8A2ADE0934',
       'actions': [
         {
-          'action_name': 'dftables',
+          'action_name': 'retgen',
           'inputs': [
-            '../pcre/dftables',
+            '../create_regex_tables',
           ],
           'outputs': [
-            '<(INTERMEDIATE_DIR)/chartables.c',
+            '<(INTERMEDIATE_DIR)/RegExpJitTables.h',
           ],
-          'action': ['perl', '-w', '<@(_inputs)', '<@(_outputs)'],
+          'action': ['python', '<@(_inputs)', '<@(_outputs)'],
         },
       ],
       'include_dirs': [
         '<(INTERMEDIATE_DIR)',
+        '../runtime',
       ],
       'sources': [
         '<@(javascriptcore_files)',
         # First exclude everything ...
         ['exclude', '../'],
         # ... Then include what we want.
-        ['include', '../pcre/'],
-        # ucptable.cpp is #included by pcre_ucp_searchfunchs.cpp and is not
-        # intended to be compiled directly.
-        ['exclude', '../pcre/ucptable.cpp$'],
+        ['include', '../yarr/'],
+        # The Yarr JIT isn't used in WebCore.
+        ['exclude', '../yarr/YarrJIT\\.(h|cpp)$'],
       ],
       'export_dependent_settings': [
         'wtf',
index 85a413c05df7c69069bd8295192382da1b127c46..06e90f026b5f24c8d618373120986e825ced6393 100644 (file)
             'wtf/win/MainThreadWin.cpp',
             'wtf/win/OwnPtrWin.cpp',
             'wtf/wx/MainThreadWx.cpp',
-            'yarr/Yarr.h'
+            'yarr/Yarr.h',
             'yarr/YarrInterpreter.cpp',
             'yarr/YarrInterpreter.h',
             'yarr/YarrJIT.cpp',
index 912264773308ed8aa54118bf00453d7706831d20..056ac6a5d8a978d26f48b54a8c07af2589005aa1 100644 (file)
@@ -65,7 +65,7 @@ wince* {
     SOURCES += $$QT_SOURCE_TREE/src/3rdparty/ce-compat/ce_time.c
 }
 
-include(pcre/pcre.pri)
+include(yarr/yarr.pri)
 include(wtf/wtf.pri)
 
 INSTALLDEPS += all
@@ -213,10 +213,7 @@ SOURCES += \
     runtime/Structure.cpp \
     runtime/TimeoutChecker.cpp \
     runtime/UString.cpp \
-    yarr/YarrPattern.cpp \
-    yarr/YarrInterpreter.cpp \
     yarr/YarrJIT.cpp \
-    yarr/YarrSyntaxChecker.cpp
 
 # Generated files, simply list them for JavaScriptCore
 
index 407dc2997c9da93752908df18a03aba20e0a91e2..769cb9a1a813751734205898aea1439f84c20d22 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 */; };
+               451539B912DC994500EF7AC4 /* Yarr.h in Headers */ = {isa = PBXBuildFile; fileRef = 451539B812DC994500EF7AC4 /* Yarr.h */; settings = {ATTRIBUTES = (Private, ); }; };
                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, ); }; };
                86704B4212DB8A8100A9FE7B /* YarrSyntaxChecker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86704B4012DB8A8100A9FE7B /* YarrSyntaxChecker.cpp */; };
                86704B4312DB8A8100A9FE7B /* YarrSyntaxChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 86704B4112DB8A8100A9FE7B /* YarrSyntaxChecker.h */; };
                86704B8412DBA33700A9FE7B /* YarrInterpreter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86704B7D12DBA33700A9FE7B /* YarrInterpreter.cpp */; };
-               86704B8512DBA33700A9FE7B /* YarrInterpreter.h in Headers */ = {isa = PBXBuildFile; fileRef = 86704B7E12DBA33700A9FE7B /* YarrInterpreter.h */; };
+               86704B8512DBA33700A9FE7B /* YarrInterpreter.h in Headers */ = {isa = PBXBuildFile; fileRef = 86704B7E12DBA33700A9FE7B /* YarrInterpreter.h */; settings = {ATTRIBUTES = (Private, ); }; };
                86704B8612DBA33700A9FE7B /* YarrJIT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86704B7F12DBA33700A9FE7B /* YarrJIT.cpp */; };
-               86704B8712DBA33700A9FE7B /* YarrJIT.h in Headers */ = {isa = PBXBuildFile; fileRef = 86704B8012DBA33700A9FE7B /* YarrJIT.h */; };
-               86704B8812DBA33700A9FE7B /* YarrParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 86704B8112DBA33700A9FE7B /* YarrParser.h */; };
+               86704B8712DBA33700A9FE7B /* YarrJIT.h in Headers */ = {isa = PBXBuildFile; fileRef = 86704B8012DBA33700A9FE7B /* YarrJIT.h */; settings = {ATTRIBUTES = (); }; };
+               86704B8812DBA33700A9FE7B /* YarrParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 86704B8112DBA33700A9FE7B /* YarrParser.h */; settings = {ATTRIBUTES = (); }; };
                86704B8912DBA33700A9FE7B /* YarrPattern.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86704B8212DBA33700A9FE7B /* YarrPattern.cpp */; };
-               86704B8A12DBA33700A9FE7B /* YarrPattern.h in Headers */ = {isa = PBXBuildFile; fileRef = 86704B8312DBA33700A9FE7B /* YarrPattern.h */; };
+               86704B8A12DBA33700A9FE7B /* YarrPattern.h in Headers */ = {isa = PBXBuildFile; fileRef = 86704B8312DBA33700A9FE7B /* YarrPattern.h */; settings = {ATTRIBUTES = (Private, ); }; };
                868BFA08117CEFD100B908B1 /* AtomicString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 868BFA00117CEFD100B908B1 /* AtomicString.cpp */; };
                868BFA09117CEFD100B908B1 /* AtomicString.h in Headers */ = {isa = PBXBuildFile; fileRef = 868BFA01117CEFD100B908B1 /* AtomicString.h */; settings = {ATTRIBUTES = (Private, ); }; };
                868BFA0A117CEFD100B908B1 /* AtomicStringImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 868BFA02117CEFD100B908B1 /* AtomicStringImpl.h */; settings = {ATTRIBUTES = (Private, ); }; };
index d1cc1c23c7d1bab4cfc8a5cee8f6b25935e3e50b..c6ce99512634fb81fb2e5d3f32ad7c8b19b53ca6 100644 (file)
@@ -21,6 +21,8 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 
+import sys
+
 types = {
     "wordchar": { "UseTable" : True, "data": ['_', ('0','9'), ('A', 'Z'), ('a','z')]},
     "nonwordchar": { "UseTable" : True, "Inverse": "wordchar", "data": ['`', (0, ord('0') - 1), (ord('9') + 1, ord('A') - 1), (ord('Z') + 1, ord('_') - 1), (ord('z') + 1, 0xffff)]},
@@ -107,6 +109,12 @@ for name, classes in types.items():
     function += ("}\n\n")
     functions += function
 
-print(arrays)
-print(functions)
+if (len(sys.argv) > 1):
+    f = open(sys.argv[-1], "w")
+    f.write(arrays)
+    f.write(functions)
+    f.close()
+else:
+    print(arrays)
+    print(functions)
 
index ee2f0bb7eb5a844a1c2cff26df253bee7a71ac99..95ce5e9979976ce802694c5dfcc23d84053e4cb6 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "Lexer.h"
 #include "yarr/Yarr.h"
+#include "yarr/YarrJIT.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
index 07f57f0a3b0b44045d11a765498d8e6833edbf15..4776c13a742c935c41a7a60c650b153fac74c514 100644 (file)
 #define ENABLE_REGEXP_TRACING 0
 
 /* Yet Another Regex Runtime - turned on by default for JIT enabled ports. */
-#if ENABLE(JIT) && !defined(ENABLE_YARR_JIT)
+#if PLATFORM(CHROMIUM)
+#define ENABLE_YARR_JIT 0
+
+#elif ENABLE(JIT) && !defined(ENABLE_YARR_JIT)
 #define ENABLE_YARR_JIT 1
 
 /* Setting this flag compares JIT results with interpreter results. */
index 57176bcb13d485ec6b8d1dddb2e60c82ac597b21..de64fdd1b3788169370048bf77a8ac521e740f9e 100644 (file)
@@ -29,7 +29,6 @@
 #define Yarr_h
 
 #include "YarrInterpreter.h"
-#include "YarrJIT.h"
 #include "YarrPattern.h"
 
 namespace JSC { namespace Yarr {
@@ -61,11 +60,6 @@ enum JSRegExpResult {
 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 cdb7136ad702709e84b51e649640c2746c68a4f4..e34e6f4c16425ac272d65ea4faa50b3f570174df 100644 (file)
@@ -27,9 +27,7 @@
 #include "YarrJIT.h"
 
 #include "ASCIICType.h"
-#include "JSGlobalData.h"
 #include "LinkBuffer.h"
-#include "MacroAssembler.h"
 #include "Yarr.h"
 
 #if ENABLE(YARR_JIT)
index 414b575063742c9443e26ab05ae8ad16be4d378f..91c5b85c916f4e52f29ff91a7047fd307afa9d04 100644 (file)
 
 #if ENABLE(YARR_JIT)
 
+#include "JSGlobalData.h"
 #include "MacroAssembler.h"
 #include "UString.h"
+#include "YarrPattern.h"
 
 #if CPU(X86) && !COMPILER(MSVC)
 #define YARR_CALL __attribute__ ((regparm (3)))
@@ -75,6 +77,9 @@ private:
     bool m_needFallBack;
 };
 
+void jitCompile(YarrPattern&, JSGlobalData*, YarrCodeBlock& jitObject);
+int execute(YarrCodeBlock& jitObject, const UChar* input, unsigned start, unsigned length, int* output);
+
 } } // namespace JSC::Yarr
 
 #endif
index 8c5741a0debda5f8c719201801ed5800b5fa72d7..c59310a7cc476a19e3ed8447c086a78085202cb7 100644 (file)
@@ -26,7 +26,7 @@
 #ifndef YarrParser_h
 #define YarrParser_h
 
-#include "UString.h"
+#include <runtime/UString.h>
 #include "Yarr.h"
 #include <wtf/ASCIICType.h>
 #include <wtf/unicode/Unicode.h>
index d80f692be8146916094f5f11e67a83d06d6bead5..cfe804f99f5eee19693772225ad307d452ed6b64 100644 (file)
 #ifndef YarrPattern_h
 #define YarrPattern_h
 
+#include <runtime/UString.h>
 #include <wtf/Vector.h>
 #include <wtf/unicode/Unicode.h>
 
-#include <UString.h>
-
 namespace JSC { namespace Yarr {
 
 struct PatternDisjunction;
index e48cb9e5550228671ab8597f7967841abacdbf93..2013671eb573f9b6e023c30a3b5ad28a6ae9aefc 100644 (file)
@@ -26,7 +26,7 @@
 #ifndef YarrSyntaxChecker_h
 #define YarrSyntaxChecker_h
 
-#include <UString.h>
+#include <runtime/UString.h>
 
 namespace JSC { namespace Yarr {
 
diff --git a/Source/JavaScriptCore/yarr/yarr.pri b/Source/JavaScriptCore/yarr/yarr.pri
new file mode 100644 (file)
index 0000000..a7b1242
--- /dev/null
@@ -0,0 +1,7 @@
+# Yet Another Regex Runtime - Qt4 build info
+
+SOURCES += \
+    yarr/YarrInterpreter.cpp \
+    yarr/YarrPattern.cpp \
+    yarr/YarrSyntaxChecker.cpp
+
index 26cb4e47fd9ffb8f3f7f8830be2953d86c52dee8..c671ad9269ffd0a96c52c61d12e65bc8091581d9 100644 (file)
@@ -39,9 +39,9 @@ BINDING_C_INCLUDES := \
        $(JAVASCRIPTCORE_PATH)/parser \
        $(JAVASCRIPTCORE_PATH)/jit \
        $(JAVASCRIPTCORE_PATH)/interpreter \
-       $(JAVASCRIPTCORE_PATH)/pcre \
        $(JAVASCRIPTCORE_PATH)/profiler \
        $(JAVASCRIPTCORE_PATH)/runtime \
+       $(JAVASCRIPTCORE_PATH)/yarr \
        $(JAVASCRIPTCORE_PATH)/ForwardingHeaders \
        \
        $(base_intermediates)/Source/WebCore/bindings/js \
index 406a5bf526a549de8db43ca513b7996b9380eeba..638a2823f761cb4801811fb2a152b96de4c5b8d9 100644 (file)
@@ -73,11 +73,11 @@ SET(WebCore_INCLUDE_DIRECTORIES
     "${JAVASCRIPTCORE_DIR}/interpreter"
     "${JAVASCRIPTCORE_DIR}/jit"
     "${JAVASCRIPTCORE_DIR}/parser"
-    "${JAVASCRIPTCORE_DIR}/pcre"
     "${JAVASCRIPTCORE_DIR}/profiler"
     "${JAVASCRIPTCORE_DIR}/runtime"
     "${JAVASCRIPTCORE_DIR}/wtf"
     "${JAVASCRIPTCORE_DIR}/wtf/unicode"
+    "${JAVASCRIPTCORE_DIR}/yarr"
     "${DERIVED_SOURCES_DIR}"
     "${CMAKE_SOURCE_DIR}"
     "${CMAKE_BINARY_DIR}"
index 761619786180078aca5de0a251c560d7a3d1c5be..c3e1deb53eed52a862f12e3634a8c1b05870c8ac 100644 (file)
@@ -1,3 +1,29 @@
+2011-02-04  Peter Varga  <pvarga@webkit.org>
+
+
+        Reviewed by Gavin Barraclough.
+
+        Replace PCRE with Yarr in WebCore
+        https://bugs.webkit.org/show_bug.cgi?id=53496
+
+        No new tests needed.
+
+        * Android.jscbindings.mk:
+        * CMakeLists.txt:
+        * ForwardingHeaders/pcre/pcre.h: Removed.
+        * ForwardingHeaders/yarr/Yarr.h: Added.
+        * ForwardingHeaders/yarr/YarrInterpreter.h: Added.
+        * ForwardingHeaders/yarr/YarrPattern.h: Added.
+        * WebCore.gyp/WebCore.gyp:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.vcproj/copyForwardingHeaders.cmd:
+        * platform/text/RegularExpression.cpp:
+        (WebCore::RegularExpression::Private::create):
+        (WebCore::RegularExpression::Private::Private):
+        (WebCore::RegularExpression::Private::compile):
+        (WebCore::RegularExpression::match):
+
 2011-02-04  Pavel Feldman  <pfeldman@chromium.org>
 
         Reviewed by Yury Semikhatsky.
diff --git a/Source/WebCore/ForwardingHeaders/pcre/pcre.h b/Source/WebCore/ForwardingHeaders/pcre/pcre.h
deleted file mode 100644 (file)
index 198acc9..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#ifndef WebCore_FWD_pcre_h
-#define WebCore_FWD_pcre_h
-#include <JavaScriptCore/pcre.h>
-#endif
-
diff --git a/Source/WebCore/ForwardingHeaders/yarr/Yarr.h b/Source/WebCore/ForwardingHeaders/yarr/Yarr.h
new file mode 100644 (file)
index 0000000..9d38201
--- /dev/null
@@ -0,0 +1,5 @@
+#ifndef WebCore_FWD_Yarr_h
+#define WebCore_FWD_Yarr_h
+#include <JavaScriptCore/Yarr.h>
+#endif
+
diff --git a/Source/WebCore/ForwardingHeaders/yarr/YarrInterpreter.h b/Source/WebCore/ForwardingHeaders/yarr/YarrInterpreter.h
new file mode 100644 (file)
index 0000000..00b10a8
--- /dev/null
@@ -0,0 +1,5 @@
+#ifndef WebCore_FWD_YarrInterpreter_h
+#define WebCore_FWD_YarrInterpreter_h
+#include <JavaScriptCore/YarrInterpreter.h>
+#endif
+
diff --git a/Source/WebCore/ForwardingHeaders/yarr/YarrPattern.h b/Source/WebCore/ForwardingHeaders/yarr/YarrPattern.h
new file mode 100644 (file)
index 0000000..c2cf0b6
--- /dev/null
@@ -0,0 +1,5 @@
+#ifndef WebCore_FWD_YarrPattern_h
+#define WebCore_FWD_YarrPattern_h
+#include <JavaScriptCore/YarrPattern.h>
+#endif
+
index 70df557765016e4c268c02fea8489617ef094577..6c9fb7872ebcec0d90d87f0da4d5050f2b198f1d 100644 (file)
         'webcore_bindings_sources',
         'inspector_protocol_sources',
         'injected_script_source',
-        '../../JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp:pcre',
+        '../../JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp:yarr',
         '../../JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp:wtf',
         '<(chromium_src_dir)/build/temp_gyp/googleurl.gyp:googleurl',
         '<(chromium_src_dir)/skia/skia.gyp:skia',
       'type': 'none',
       'dependencies': [
         'webcore_bindings',
-        '../../JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp:pcre',
+        '../../JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp:yarr',
         '../../JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp:wtf',
         '<(chromium_src_dir)/build/temp_gyp/googleurl.gyp:googleurl',
         '<(chromium_src_dir)/skia/skia.gyp:skia',
       ],
       'export_dependent_settings': [
         'webcore_bindings',
-        '../../JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp:pcre',
+        '../../JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp:yarr',
         '../../JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp:wtf',
         '<(chromium_src_dir)/build/temp_gyp/googleurl.gyp:googleurl',
         '<(chromium_src_dir)/skia/skia.gyp:skia',
index ca2ea4a5d234ec7a136239cfbcbb237ac46a886c..38cdb6308622fae02731414de256d83d45bfeb57 100644 (file)
@@ -339,7 +339,7 @@ SOURCES += \
     bindings/generic/RuntimeEnabledFeatures.cpp
 
 v8 {
-    include($$PWD/../JavaScriptCore/pcre/pcre.pri)
+    include($$PWD/../JavaScriptCore/yarr/yarr.pri)
     include($$PWD/../JavaScriptCore/wtf/wtf.pri)
 
     SOURCES += \
index 6b7273351077b1de7c23ab79f987691aefcbe9df..6e9b79351afafcfa48d3c08773bbf5c0dff287b0 100755 (executable)
                                </File>
                        </Filter>
                        <Filter
-                               Name="pcre"
+                               Name="yarr"
                                >
                                <File
-                                       RelativePath="..\ForwardingHeaders\pcre\pcre.h"
+                                       RelativePath="..\ForwardingHeaders\yarr\Yarr.h"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\ForwardingHeaders\yarr\YarrInterpreter.h"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\ForwardingHeaders\yarr\YarrPattern.h"
                                        >
                                </File>
                        </Filter>
index 3da6287b6c07e6e00c7f57d5964382bf9536a4ae..3351e600884397629a9d34be96cedcc43b9123d9 100755 (executable)
@@ -7,12 +7,12 @@ mkdir 2>NUL "%CONFIGURATIONBUILDDIR%\include\WebCore\ForwardingHeaders\bindings"
 mkdir 2>NUL "%CONFIGURATIONBUILDDIR%\include\WebCore\ForwardingHeaders\parser"
 mkdir 2>NUL "%CONFIGURATIONBUILDDIR%\include\WebCore\ForwardingHeaders\runtime"
 mkdir 2>NUL "%CONFIGURATIONBUILDDIR%\include\WebCore\ForwardingHeaders\masm"
-mkdir 2>NUL "%CONFIGURATIONBUILDDIR%\include\WebCore\ForwardingHeaders\pcre"
 mkdir 2>NUL "%CONFIGURATIONBUILDDIR%\include\WebCore\ForwardingHeaders\profiler"
 mkdir 2>NUL "%CONFIGURATIONBUILDDIR%\include\WebCore\ForwardingHeaders\wtf"
 mkdir 2>NUL "%CONFIGURATIONBUILDDIR%\include\WebCore\ForwardingHeaders\wtf\text"
 mkdir 2>NUL "%CONFIGURATIONBUILDDIR%\include\WebCore\ForwardingHeaders\wtf\unicode"
 mkdir 2>NUL "%CONFIGURATIONBUILDDIR%\include\WebCore\ForwardingHeaders\wtf\unicode\icu"
+mkdir 2>NUL "%CONFIGURATIONBUILDDIR%\include\WebCore\ForwardingHeaders\yarr"
 
 xcopy /y /d "%ProjectDir%..\config.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
 xcopy /y /d "%CONFIGURATIONBUILDDIR%\obj\WebCore\DerivedSources\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
@@ -74,11 +74,11 @@ xcopy /y /d "%ProjectDir%..\ForwardingHeaders\bindings\*.h" "%CONFIGURATIONBUILD
 xcopy /y /d "%ProjectDir%..\ForwardingHeaders\parser\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore\ForwardingHeaders\parser"
 xcopy /y /d "%ProjectDir%..\ForwardingHeaders\runtime\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore\ForwardingHeaders\runtime"
 xcopy /y /d "%ProjectDir%..\ForwardingHeaders\masm\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore\ForwardingHeaders\masm"
-xcopy /y /d "%ProjectDir%..\ForwardingHeaders\pcre\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore\ForwardingHeaders\pcre"
 xcopy /y /d "%ProjectDir%..\ForwardingHeaders\profiler\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore\ForwardingHeaders\profiler"
 xcopy /y /d "%ProjectDir%..\ForwardingHeaders\wtf\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore\ForwardingHeaders\wtf"
 xcopy /y /d "%ProjectDir%..\ForwardingHeaders\wtf\text\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore\ForwardingHeaders\wtf\text"
 xcopy /y /d "%ProjectDir%..\ForwardingHeaders\wtf\unicode\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore\ForwardingHeaders\wtf\unicode"
 xcopy /y /d "%ProjectDir%..\ForwardingHeaders\wtf\unicode\icu\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore\ForwardingHeaders\wtf\unicode\icu"
+xcopy /y /d "%ProjectDir%..\ForwardingHeaders\yarr\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore\ForwardingHeaders\yarr"
 
 if exist "%CONFIGURATIONBUILDDIR%\buildfailed" del "%CONFIGURATIONBUILDDIR%\buildfailed"
index 9b063c92009a7e82eacba4b1e2f481bb34e2beb1..dcb1524991573a673351118a1f0bbb666a6c51de 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2004, 2008, 2009 Apple Inc. All rights reserved.
  * Copyright (C) 2008 Collabora Ltd.
+ * Copyright (C) 2011 Peter Varga (pvarga@webkit.org), University of Szeged
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include "config.h"
 #include "RegularExpression.h"
 
+#include <wtf/BumpPointerAllocator.h>
 #include "Logging.h"
-#include <pcre/pcre.h>
+#include "yarr/Yarr.h"
 
 namespace WebCore {
 
 class RegularExpression::Private : public RefCounted<RegularExpression::Private> {
 public:
-    static PassRefPtr<Private> create(const String& pattern, TextCaseSensitivity);
-    ~Private();
+    static PassRefPtr<Private> create(const String& pattern, TextCaseSensitivity caseSensitivity)
+    {
+        return adoptRef(new Private(pattern, caseSensitivity));
+    }
 
-    JSRegExp* regexp() const { return m_regexp; }
-    int lastMatchLength;    
+    int lastMatchLength;
 
-private:
-    Private(const String& pattern, TextCaseSensitivity);
-    static JSRegExp* compile(const String& pattern, TextCaseSensitivity);
+    unsigned m_numSubpatterns;
+    OwnPtr<JSC::Yarr::BytecodePattern> m_regExpByteCode;
 
-    JSRegExp* m_regexp;
-};
+private:
+    Private(const String& pattern, TextCaseSensitivity caseSensitivity)
+        : lastMatchLength(-1)
+        , m_regExpByteCode(compile(pattern, caseSensitivity))
+        , m_constructionError(0)
+    {
+    }
 
-inline JSRegExp* RegularExpression::Private::compile(const String& pattern, TextCaseSensitivity caseSensitivity)
-{
-    const char* errorMessage;
-    JSRegExp* regexp = jsRegExpCompile(pattern.characters(), pattern.length(),
-        caseSensitivity == TextCaseSensitive ? JSRegExpDoNotIgnoreCase : JSRegExpIgnoreCase, JSRegExpSingleLine,
-        0, &errorMessage);
-    if (!regexp)
-        LOG_ERROR("RegularExpression: pcre_compile failed with '%s'", errorMessage);
-    return regexp;
-}
+    PassOwnPtr<JSC::Yarr::BytecodePattern> compile(const String& patternString, TextCaseSensitivity caseSensitivity)
+    {
+        JSC::Yarr::YarrPattern pattern(JSC::UString(patternString.impl()), (caseSensitivity == TextCaseInsensitive), false, &m_constructionError);
+        if (m_constructionError) {
+            LOG_ERROR("RegularExpression: YARR compile failed with '%s'", m_constructionError);
+            return PassOwnPtr<JSC::Yarr::BytecodePattern>();
+        }
 
-inline RegularExpression::Private::Private(const String& pattern, TextCaseSensitivity caseSensitivity)
-    : lastMatchLength(-1)
-    , m_regexp(compile(pattern, caseSensitivity))
-{
-}
+        m_numSubpatterns = pattern.m_numSubpatterns;
 
-inline PassRefPtr<RegularExpression::Private> RegularExpression::Private::create(const String& pattern, TextCaseSensitivity caseSensitivity)
-{
-    return adoptRef(new Private(pattern, caseSensitivity));
-}
+        return JSC::Yarr::byteCompile(pattern, &m_regexAllocator);
+    }
 
-RegularExpression::Private::~Private()
-{
-    jsRegExpFree(m_regexp);
-}
+    BumpPointerAllocator m_regexAllocator;
+    const char* m_constructionError;
+};
 
 RegularExpression::RegularExpression(const String& pattern, TextCaseSensitivity caseSensitivity)
     : d(Private::create(pattern, caseSensitivity))
@@ -96,19 +93,22 @@ RegularExpression& RegularExpression::operator=(const RegularExpression& re)
 
 int RegularExpression::match(const String& str, int startFrom, int* matchLength) const
 {
-    if (!d->regexp())
+    if (!d->m_regExpByteCode)
         return -1;
 
     if (str.isNull())
         return -1;
 
-    // First 2 offsets are start and end offsets; 3rd entry is used internally by pcre
-    static const size_t maxOffsets = 3;
+    const size_t maxOffsets = (d->m_numSubpatterns + 1) * 2;
     int offsets[maxOffsets];
-    int result = jsRegExpExecute(d->regexp(), str.characters(), str.length(), startFrom, offsets, maxOffsets);
+
+    for (unsigned j = 0, i = 0; i < d->m_numSubpatterns + 1; j += 2, i++)
+        offsets[j] = -1;
+
+    int result = JSC::Yarr::interpret(d->m_regExpByteCode.get(), str.characters(), startFrom, str.length(), offsets);
+    ASSERT(result >= -1);
+
     if (result < 0) {
-        if (result != JSRegExpErrorNoMatch)
-            LOG_ERROR("RegularExpression: pcre_exec() failed with result %d", result);
         d->lastMatchLength = -1;
         return -1;
     }