+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.
_WTFReportBacktrace
_WTFReportError
_WTFReportFatalError
-__Z12jsRegExpFreeP8JSRegExp
-__Z15jsRegExpCompilePKti24JSRegExpIgnoreCaseOption23JSRegExpMultilineOptionPjPPKc
-__Z15jsRegExpExecutePK8JSRegExpPKtiiPii
__ZN14OpaqueJSString6createERKN3JSC7UStringE
__ZN3JSC10Identifier11addSlowCaseEPNS_12JSGlobalDataEPN3WTF10StringImplE
__ZN3JSC10Identifier11addSlowCaseEPNS_9ExecStateEPN3WTF10StringImplE
__ZN3JSC4Heap8allocateEm
__ZN3JSC4Heap9unprotectENS_7JSValueE
__ZN3JSC4callEPNS_9ExecStateENS_7JSValueENS_8CallTypeERKNS_8CallDataES2_RKNS_7ArgListE
+__ZN3JSC4Yarr11YarrPatternC1ERKNS_7UStringEbbPPKc
+__ZN3JSC4Yarr11byteCompileERNS0_11YarrPatternEPN3WTF20BumpPointerAllocatorE
+__ZN3JSC4Yarr9interpretEPNS0_15BytecodePatternEPKtjjPi
__ZN3JSC6JSCell11getCallDataERNS_8CallDataE
__ZN3JSC6JSCell11getJSNumberEv
__ZN3JSC6JSCell14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
],
},
{
- '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',
'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',
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
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
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, ); }; };
# (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)]},
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)
#include "Lexer.h"
#include "yarr/Yarr.h"
+#include "yarr/YarrJIT.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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. */
#define Yarr_h
#include "YarrInterpreter.h"
-#include "YarrJIT.h"
#include "YarrPattern.h"
namespace JSC { namespace Yarr {
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
#include "YarrJIT.h"
#include "ASCIICType.h"
-#include "JSGlobalData.h"
#include "LinkBuffer.h"
-#include "MacroAssembler.h"
#include "Yarr.h"
#if ENABLE(YARR_JIT)
#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)))
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
#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>
#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;
#ifndef YarrSyntaxChecker_h
#define YarrSyntaxChecker_h
-#include <UString.h>
+#include <runtime/UString.h>
namespace JSC { namespace Yarr {
--- /dev/null
+# Yet Another Regex Runtime - Qt4 build info
+
+SOURCES += \
+ yarr/YarrInterpreter.cpp \
+ yarr/YarrPattern.cpp \
+ yarr/YarrSyntaxChecker.cpp
+
$(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 \
"${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}"
+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.
+++ /dev/null
-#ifndef WebCore_FWD_pcre_h
-#define WebCore_FWD_pcre_h
-#include <JavaScriptCore/pcre.h>
-#endif
-
--- /dev/null
+#ifndef WebCore_FWD_Yarr_h
+#define WebCore_FWD_Yarr_h
+#include <JavaScriptCore/Yarr.h>
+#endif
+
--- /dev/null
+#ifndef WebCore_FWD_YarrInterpreter_h
+#define WebCore_FWD_YarrInterpreter_h
+#include <JavaScriptCore/YarrInterpreter.h>
+#endif
+
--- /dev/null
+#ifndef WebCore_FWD_YarrPattern_h
+#define WebCore_FWD_YarrPattern_h
+#include <JavaScriptCore/YarrPattern.h>
+#endif
+
'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',
bindings/generic/RuntimeEnabledFeatures.cpp
v8 {
- include($$PWD/../JavaScriptCore/pcre/pcre.pri)
+ include($$PWD/../JavaScriptCore/yarr/yarr.pri)
include($$PWD/../JavaScriptCore/wtf/wtf.pri)
SOURCES += \
</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>
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"
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"
/*
* 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))
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;
}