aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-08-08 11:00:22 +0200
committerLars Knoll <lars.knoll@qt.io>2018-08-11 13:11:30 +0000
commit04b4a269e604731f855b8008acc94dcd70ea116c (patch)
tree1abc4f5067736704656a10f4c08e4933fcc3af72
parentd6d659a04832217d05930063a2aa484a5f0ec7ee (diff)
Enable the Yarr JIT for regexps with nested parenthesis
Change-Id: I4e7a44ae2b5759febec6f83ab9fa85612515ab04 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r--src/3rdparty/masm/wtf/Platform.h2
-rw-r--r--src/qml/jsruntime/qv4regexp.cpp8
-rw-r--r--src/qml/jsruntime/qv4regexpobject.cpp3
3 files changed, 11 insertions, 2 deletions
diff --git a/src/3rdparty/masm/wtf/Platform.h b/src/3rdparty/masm/wtf/Platform.h
index 81f79f7084..d5f69927db 100644
--- a/src/3rdparty/masm/wtf/Platform.h
+++ b/src/3rdparty/masm/wtf/Platform.h
@@ -1048,7 +1048,7 @@
#endif
#if ENABLE(YARR_JIT)
-#if 0 // CPU(ARM64) || (CPU(X86_64) && !OS(WINDOWS))
+#if CPU(ARM64) || (CPU(X86_64) && !OS(WINDOWS))
/* Enable JIT'ing Regular Expressions that have nested parenthesis. */
#define ENABLE_YARR_JIT_ALL_PARENS_EXPRESSIONS 1
#endif
diff --git a/src/qml/jsruntime/qv4regexp.cpp b/src/qml/jsruntime/qv4regexp.cpp
index e562482395..6963400a08 100644
--- a/src/qml/jsruntime/qv4regexp.cpp
+++ b/src/qml/jsruntime/qv4regexp.cpp
@@ -63,9 +63,15 @@ uint RegExp::match(const QString &string, int start, uint *matchOffsets)
WTF::String s(string);
#if ENABLE(YARR_JIT)
- if (d()->hasValidJITCode())
+ if (d()->hasValidJITCode()) {
+#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
+ char buffer[8192];
+ return uint(jitCode()->execute(s.characters16(), start, s.length(), (int*)matchOffsets, buffer, 8192).start);
+#else
return uint(jitCode()->execute(s.characters16(), start, s.length(), (int*)matchOffsets).start);
#endif
+ }
+#endif
return JSC::Yarr::interpret(byteCode(), s.characters16(), string.length(), start, matchOffsets);
}
diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp
index f8caf404e9..414ce8e78c 100644
--- a/src/qml/jsruntime/qv4regexpobject.cpp
+++ b/src/qml/jsruntime/qv4regexpobject.cpp
@@ -391,9 +391,12 @@ ReturnedValue RegExpPrototype::method_exec(const FunctionObject *b, const Value
int len = r->value()->captureCount();
array->arrayReserve(len);
ScopedValue v(scope);
+ int strlen = str->d()->length();
for (int i = 0; i < len; ++i) {
int start = matchOffsets[i * 2];
int end = matchOffsets[i * 2 + 1];
+ if (end > strlen)
+ end = strlen;
v = (start != -1) ? scope.engine->memoryManager->alloc<ComplexString>(str->d(), start, end - start)->asReturnedValue() : Encode::undefined();
array->arrayPut(i, v);
}