aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4regexpobject.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2024-12-10 10:26:34 +0100
committerUlf Hermann <ulf.hermann@qt.io>2024-12-12 08:00:24 +0100
commitb4b691b040f2251820292a27bdcf01d4d7530bc6 (patch)
treeb44e3672f38dc53bb503fc336646ddc1ef050017 /src/qml/jsruntime/qv4regexpobject.cpp
parentc5b0fa28061fc3e99ce79ff9603d87791b41a197 (diff)
QtQml: Add some consistency to QV4::RegExp
The RegExp JIT should behave the same as the V4 JIT. In particular, it should honor the same JIT call threshold and not second guess any manually set thresholds. To do this we need to store the match count in 32 bits. In turn we can store the 5 flags we may have in 8 bits. To make this safe, pass typed flags to the initialization functions. Also, consider the flags when calculating hash values. Finally, in the init() function, we don't need to initialize members to zero, since that is already guaranteed by the memory manager. And we can delete the flagsAsString() method since it's unused. This requires shuffling some #includes into the places where they actually belong. [ChangeLog][QtQml] The JavaScript regular expression engine now honors QV4_JIT_CALL_THRESHOLD for its own JIT. If QV4_JIT_CALL_THRESHOLD is not set, it uses the JIT after 3 interpreted matches for any regular expression, rather than the previous 5. Matching a regular expression on a string longer than 1024 bytes counts as 3 matches. This is to retain the default behavior of JIT'ing regular expressions right away when encountering long strings. Task-number: QTBUG-131957 Change-Id: I269ccea55d34b191ef18d7cd5fccd4cad8aec7cd Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4regexpobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4regexpobject.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp
index 144cd39bcd..0f5050c704 100644
--- a/src/qml/jsruntime/qv4regexpobject.cpp
+++ b/src/qml/jsruntime/qv4regexpobject.cpp
@@ -91,7 +91,7 @@ void Heap::RegExpObject::init(const QRegularExpression &re)
Scoped<QV4::RegExpObject> o(scope, this);
QRegularExpression::PatternOptions options = re.patternOptions();
- uint flags = (options & QRegularExpression::CaseInsensitiveOption)
+ CompiledData::RegExp::Flags flags = (options & QRegularExpression::CaseInsensitiveOption)
? CompiledData::RegExp::RegExp_IgnoreCase
: CompiledData::RegExp::RegExp_NoFlags;
if (options & QRegularExpression::MultilineOption)
@@ -222,9 +222,9 @@ static bool isRegExp(ExecutionEngine *e, const QV4::Value *arg)
return re ? true : false;
}
-uint parseFlags(Scope &scope, const QV4::Value *f)
+static CompiledData::RegExp::Flags parseFlags(Scope &scope, const QV4::Value *f)
{
- uint flags = CompiledData::RegExp::RegExp_NoFlags;
+ CompiledData::RegExp::Flags flags = CompiledData::RegExp::RegExp_NoFlags;
if (!f->isUndefined()) {
ScopedString s(scope, f->toString(scope.engine));
if (scope.hasException())
@@ -269,7 +269,7 @@ ReturnedValue RegExpCtor::virtualCallAsConstructor(const FunctionObject *fo, con
ScopedValue f(scope, argc > 1 ? argv[1] : Value::undefinedValue());
Scoped<RegExpObject> re(scope, p);
QString pattern;
- uint flags = CompiledData::RegExp::RegExp_NoFlags;
+ CompiledData::RegExp::Flags flags = CompiledData::RegExp::RegExp_NoFlags;
if (re) {
if (f->isUndefined()) {