aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4regexp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/jsruntime/qv4regexp.cpp')
-rw-r--r--src/qml/jsruntime/qv4regexp.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/qml/jsruntime/qv4regexp.cpp b/src/qml/jsruntime/qv4regexp.cpp
index 6d6d446ca2..9e94c58432 100644
--- a/src/qml/jsruntime/qv4regexp.cpp
+++ b/src/qml/jsruntime/qv4regexp.cpp
@@ -62,11 +62,11 @@ uint RegExp::match(const QString &string, int start, uint *matchOffsets)
WTF::String s(string);
#if ENABLE(YARR_JIT)
- if (!jitCode().isFallBack() && jitCode().has16BitCode())
- return uint(jitCode().execute(s.characters16(), start, s.length(), (int*)matchOffsets).start);
+ if (!jitCode()->isFallBack() && jitCode()->has16BitCode())
+ return uint(jitCode()->execute(s.characters16(), start, s.length(), (int*)matchOffsets).start);
#endif
- return JSC::Yarr::interpret(byteCode().get(), s.characters16(), string.length(), start, matchOffsets);
+ return JSC::Yarr::interpret(byteCode(), s.characters16(), string.length(), start, matchOffsets);
}
Heap::RegExp *RegExp::create(ExecutionEngine* engine, const QString& pattern, bool ignoreCase, bool multiline)
@@ -90,33 +90,41 @@ Heap::RegExp *RegExp::create(ExecutionEngine* engine, const QString& pattern, bo
return result->d();
}
-Heap::RegExp::RegExp(ExecutionEngine* engine, const QString &pattern, bool ignoreCase, bool multiline)
- : pattern(pattern)
- , ignoreCase(ignoreCase)
- , multiLine(multiline)
+void Heap::RegExp::init(ExecutionEngine* engine, const QString &pattern, bool ignoreCase, bool multiline)
{
Base::init();
+ this->pattern = new QString(pattern);
+ this->ignoreCase = ignoreCase;
+ this->multiLine = multiline;
const char* error = 0;
JSC::Yarr::YarrPattern yarrPattern(WTF::String(pattern), ignoreCase, multiline, &error);
if (error)
return;
subPatternCount = yarrPattern.m_numSubpatterns;
- byteCode = JSC::Yarr::byteCompile(yarrPattern, engine->bumperPointerAllocator);
+ 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 && engine->iselFactory->jitCompileRegexps()) {
JSC::JSGlobalData dummy(engine->regExpAllocator);
- JSC::Yarr::jitCompile(yarrPattern, JSC::Yarr::Char16, &dummy, jitCode);
+ JSC::Yarr::jitCompile(yarrPattern, JSC::Yarr::Char16, &dummy, *jitCode);
}
#endif
}
-Heap::RegExp::~RegExp()
+void Heap::RegExp::destroy()
{
if (cache) {
RegExpCacheKey key(this);
cache->remove(key);
}
+#if ENABLE(YARR_JIT)
+ delete jitCode;
+#endif
+ delete byteCode;
+ delete pattern;
+ Base::destroy();
}
void RegExp::markObjects(Heap::Base *that, ExecutionEngine *e)