diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-08-28 13:58:51 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2017-08-29 07:51:41 +0000 |
commit | c5398fdb30bf07d06c533b980c7d7a08b3a9740d (patch) | |
tree | 4f10e3d198c83d77f37f877bc111d51dc6f9ef56 /src/qml/jsruntime/qv4regexp.cpp | |
parent | 88dc4ea1237fe6990b612c2e64142c665e5818f6 (diff) |
Don't compile both bytecode and JIT code for regexps
Usually one of the two is sufficient :)
Change-Id: Ib7ec021411839578c8dd0d7b50d9ec91460c4670
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4regexp.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4regexp.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
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<RegExp> result(scope, engine->memoryManager->alloc<RegExp>(engine, pattern, ignoreCase, multiline)); + Scoped<RegExp> result(scope, engine->memoryManager->alloc<RegExp>(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<JSC::Yarr::BytecodePattern> 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<JSC::Yarr::BytecodePattern> p = JSC::Yarr::byteCompile(yarrPattern, internalClass->engine->bumperPointerAllocator); + byteCode = p.take(); + if (byteCode) + valid = true; } void Heap::RegExp::destroy() |