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>
This commit is contained in:
parent
744e7a55b1
commit
a368e60345
|
@ -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(
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue