From c5398fdb30bf07d06c533b980c7d7a08b3a9740d Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 28 Aug 2017 13:58:51 +0200 Subject: Don't compile both bytecode and JIT code for regexps Usually one of the two is sufficient :) Change-Id: Ib7ec021411839578c8dd0d7b50d9ec91460c4670 Reviewed-by: Simon Hausmann Reviewed-by: Erik Verbruggen --- src/qml/jsruntime/qv4regexp.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/qml/jsruntime/qv4regexp.cpp') diff --git a/src/qml/jsruntime/qv4regexp.cpp b/src/qml/jsruntime/qv4regexp.cpp index fa3cbb5bcc..3032363cb4 100644 --- a/src/qml/jsruntime/qv4regexp.cpp +++ b/src/qml/jsruntime/qv4regexp.cpp @@ -62,7 +62,7 @@ uint RegExp::match(const QString &string, int start, uint *matchOffsets) WTF::String s(string); #if ENABLE(YARR_JIT) - if (!jitCode()->isFallBack() && jitCode()->has16BitCode()) + if (d()->hasValidJITCode()) return uint(jitCode()->execute(s.characters16(), start, s.length(), (int*)matchOffsets).start); #endif @@ -82,7 +82,7 @@ Heap::RegExp *RegExp::create(ExecutionEngine* engine, const QString& pattern, bo return result->d(); Scope scope(engine); - Scoped result(scope, engine->memoryManager->alloc(engine, pattern, ignoreCase, multiline)); + Scoped result(scope, engine->memoryManager->alloc(pattern, ignoreCase, multiline)); result->d()->cache = cache; cachedValue.set(engine, result); @@ -90,27 +90,34 @@ Heap::RegExp *RegExp::create(ExecutionEngine* engine, const QString& pattern, bo return result->d(); } -void Heap::RegExp::init(ExecutionEngine* engine, const QString &pattern, bool ignoreCase, bool multiline) +void Heap::RegExp::init(const QString &pattern, bool ignoreCase, bool multiline) { Base::init(); this->pattern = new QString(pattern); this->ignoreCase = ignoreCase; this->multiLine = multiline; + valid = false; const char* error = 0; - JSC::Yarr::YarrPattern yarrPattern(WTF::String(pattern), ignoreCase, multiline, &error); + JSC::Yarr::YarrPattern yarrPattern(WTF::String(pattern), ignoreCase, multiLine, &error); if (error) return; subPatternCount = yarrPattern.m_numSubpatterns; - OwnPtr p = JSC::Yarr::byteCompile(yarrPattern, engine->bumperPointerAllocator); - byteCode = p.take(); #if ENABLE(YARR_JIT) - jitCode = new JSC::Yarr::YarrCodeBlock; if (!yarrPattern.m_containsBackreferences) { - JSC::JSGlobalData dummy(engine->regExpAllocator); + jitCode = new JSC::Yarr::YarrCodeBlock; + JSC::JSGlobalData dummy(internalClass->engine->regExpAllocator); JSC::Yarr::jitCompile(yarrPattern, JSC::Yarr::Char16, &dummy, *jitCode); } #endif + if (hasValidJITCode()) { + valid = true; + return; + } + OwnPtr p = JSC::Yarr::byteCompile(yarrPattern, internalClass->engine->bumperPointerAllocator); + byteCode = p.take(); + if (byteCode) + valid = true; } void Heap::RegExp::destroy() -- cgit v1.2.3