aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-05-27 22:00:01 +0200
committerMarc Mutz <marc.mutz@qt.io>2022-06-04 22:45:23 +0200
commita368e603451cd3c3d44776ff47351a1d93cb546b (patch)
tree56b018041a164292c8c9754d5d3fccd024247619 /src
parent744e7a55b143bd26cb1d1c19963e23d00d5ba2db (diff)
QJSEngine: optimize isInterrupted handling
The isInterrupted flag is just that: a flag, so it doesn't require acquire/release semantics when loading/storing. Use relaxed loads and stores instead. Change-Id: I6d733a6bebcfc7f2b786265fc28f9ba7e25bb1c7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/qml/jsapi/qjsengine.cpp8
-rw-r--r--src/qml/jsapi/qjsvalue.cpp6
-rw-r--r--src/qml/jsruntime/qv4scopedvalue_p.h2
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp4
4 files changed, 10 insertions, 10 deletions
diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp
index f66488e04c..7e52dc2e4d 100644
--- a/src/qml/jsapi/qjsengine.cpp
+++ b/src/qml/jsapi/qjsengine.cpp
@@ -478,7 +478,7 @@ void QJSEngine::installExtensions(QJSEngine::Extensions extensions, const QJSVal
*/
void QJSEngine::setInterrupted(bool interrupted)
{
- m_v4Engine->isInterrupted = interrupted;
+ m_v4Engine->isInterrupted.storeRelaxed(interrupted);
}
/*!
@@ -489,7 +489,7 @@ void QJSEngine::setInterrupted(bool interrupted)
*/
bool QJSEngine::isInterrupted() const
{
- return m_v4Engine->isInterrupted.loadAcquire();
+ return m_v4Engine->isInterrupted.loadRelaxed();
}
static QUrl urlForFileName(const QString &fileName)
@@ -571,7 +571,7 @@ QJSValue QJSEngine::evaluate(const QString& program, const QString& fileName, in
);
}
}
- if (v4->isInterrupted.loadAcquire())
+ if (v4->isInterrupted.loadRelaxed())
result = v4->newErrorObject(QStringLiteral("Interrupted"));
return QJSValuePrivate::fromReturnedValue(result->asReturnedValue());
@@ -611,7 +611,7 @@ QJSValue QJSEngine::importModule(const QString &fileName)
if (m_v4Engine->hasException)
return QJSValuePrivate::fromReturnedValue(m_v4Engine->catchException());
moduleUnit->evaluate();
- if (!m_v4Engine->isInterrupted.loadAcquire())
+ if (!m_v4Engine->isInterrupted.loadRelaxed())
return QJSValuePrivate::fromReturnedValue(moduleNamespace->asReturnedValue());
return QJSValuePrivate::fromReturnedValue(
diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp
index 03cd1e9aa9..c79953130e 100644
--- a/src/qml/jsapi/qjsvalue.cpp
+++ b/src/qml/jsapi/qjsvalue.cpp
@@ -713,7 +713,7 @@ QJSValue QJSValue::call(const QJSValueList &args) const
ScopedValue result(scope, f->call(jsCallData));
if (engine->hasException)
result = engine->catchException();
- if (engine->isInterrupted.loadAcquire())
+ if (engine->isInterrupted.loadRelaxed())
result = engine->newErrorObject(QStringLiteral("Interrupted"));
return QJSValuePrivate::fromReturnedValue(result->asReturnedValue());
@@ -767,7 +767,7 @@ QJSValue QJSValue::callWithInstance(const QJSValue &instance, const QJSValueList
ScopedValue result(scope, f->call(jsCallData));
if (engine->hasException)
result = engine->catchException();
- if (engine->isInterrupted.loadAcquire())
+ if (engine->isInterrupted.loadRelaxed())
result = engine->newErrorObject(QStringLiteral("Interrupted"));
return QJSValuePrivate::fromReturnedValue(result->asReturnedValue());
@@ -813,7 +813,7 @@ QJSValue QJSValue::callAsConstructor(const QJSValueList &args) const
ScopedValue result(scope, f->callAsConstructor(jsCallData));
if (engine->hasException)
result = engine->catchException();
- if (engine->isInterrupted.loadAcquire())
+ if (engine->isInterrupted.loadRelaxed())
result = engine->newErrorObject(QStringLiteral("Interrupted"));
return QJSValuePrivate::fromReturnedValue(result->asReturnedValue());
diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h
index beb8315225..5b6abfd819 100644
--- a/src/qml/jsruntime/qv4scopedvalue_p.h
+++ b/src/qml/jsruntime/qv4scopedvalue_p.h
@@ -70,7 +70,7 @@ struct ScopedValue;
#define CHECK_EXCEPTION() \
do { \
- if (scope.hasException() || scope.engine->isInterrupted.loadAcquire()) { \
+ if (scope.hasException() || scope.engine->isInterrupted.loadRelaxed()) { \
return QV4::Encode::undefined(); \
} \
} while (false)
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index e8d4f0a09c..d161ed53a2 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -360,7 +360,7 @@ static inline QV4::Value &stackValue(QV4::Value *stack, size_t slot, const JSTyp
#undef CHECK_EXCEPTION
#endif
#define CHECK_EXCEPTION \
- if (engine->hasException || engine->isInterrupted.loadAcquire()) \
+ if (engine->hasException || engine->isInterrupted.loadRelaxed()) \
goto handleUnwind
static inline Heap::CallContext *getScope(QV4::Value *stack, int level)
@@ -1525,7 +1525,7 @@ QV4::ReturnedValue VME::interpret(JSTypesStackFrame *frame, ExecutionEngine *eng
// We do start the exception handler in case of isInterrupted. The exception handler will
// immediately abort, due to the same isInterrupted. We don't skip the exception handler
// because the current behavior is easier to implement in the JIT.
- Q_ASSERT(engine->hasException || engine->isInterrupted.loadAcquire() || frame->unwindLevel);
+ Q_ASSERT(engine->hasException || engine->isInterrupted.loadRelaxed() || frame->unwindLevel);
if (!frame->unwindHandler) {
acc = Encode::undefined();
return acc;