diff options
Diffstat (limited to 'src')
101 files changed, 1169 insertions, 958 deletions
diff --git a/src/imports/folderlistmodel/fileinfothread.cpp b/src/imports/folderlistmodel/fileinfothread.cpp index 7338636784..5d911eec1e 100644 --- a/src/imports/folderlistmodel/fileinfothread.cpp +++ b/src/imports/folderlistmodel/fileinfothread.cpp @@ -66,7 +66,6 @@ FileInfoThread::FileInfoThread(QObject *parent) connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(dirChanged(QString))); connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(updateFile(QString))); #endif // !QT_NO_FILESYSTEMWATCHER - start(LowPriority); } FileInfoThread::~FileInfoThread() diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp index 9b0571a402..66af37c40c 100644 --- a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp +++ b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp @@ -538,6 +538,7 @@ void QQuickFolderListModel::componentComplete() QString localPath = QQmlFile::urlToLocalFileOrQrc(d->currentDir); if (localPath.isEmpty() || !QDir(localPath).exists()) setFolder(QUrl::fromLocalFile(QDir::currentPath())); + d->fileInfoThread.start(QThread::LowPriority); } /*! diff --git a/src/imports/layouts/plugin.cpp b/src/imports/layouts/plugin.cpp index 4552b7219b..248b12ac31 100644 --- a/src/imports/layouts/plugin.cpp +++ b/src/imports/layouts/plugin.cpp @@ -42,6 +42,13 @@ #include "qquicklinearlayout_p.h" #include "qquickstacklayout_p.h" +static void initResources() +{ +#ifdef QT_STATIC + Q_INIT_RESOURCE(qmake_QtQuick_Layouts); +#endif +} + QT_BEGIN_NAMESPACE //![class decl] @@ -50,6 +57,10 @@ class QtQuickLayoutsPlugin : public QQmlExtensionPlugin Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0") public: + QtQuickLayoutsPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) + { + initResources(); + } virtual void registerTypes(const char *uri) { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.Layouts")); diff --git a/src/imports/layouts/qquicklayout.cpp b/src/imports/layouts/qquicklayout.cpp index d4d4e1703d..abc8f97cec 100644 --- a/src/imports/layouts/qquicklayout.cpp +++ b/src/imports/layouts/qquicklayout.cpp @@ -40,7 +40,7 @@ #include "qquicklayout_p.h" #include <QEvent> #include <QtCore/qcoreapplication.h> -#include <QtCore/qnumeric.h> +#include <QtCore/private/qnumeric_p.h> #include <QtCore/qmath.h> #include <limits> @@ -134,7 +134,7 @@ QQuickLayoutAttached::QQuickLayoutAttached(QObject *parent) */ void QQuickLayoutAttached::setMinimumWidth(qreal width) { - if (qIsNaN(width)) + if (qt_is_nan(width)) return; m_isMinimumWidthSet = width >= 0; if (m_minimumWidth == width) @@ -162,7 +162,7 @@ void QQuickLayoutAttached::setMinimumWidth(qreal width) */ void QQuickLayoutAttached::setMinimumHeight(qreal height) { - if (qIsNaN(height)) + if (qt_is_nan(height)) return; m_isMinimumHeightSet = height >= 0; if (m_minimumHeight == height) @@ -186,7 +186,7 @@ void QQuickLayoutAttached::setMinimumHeight(qreal height) */ void QQuickLayoutAttached::setPreferredWidth(qreal width) { - if (qIsNaN(width) || m_preferredWidth == width) + if (qt_is_nan(width) || m_preferredWidth == width) return; m_preferredWidth = width; @@ -207,7 +207,7 @@ void QQuickLayoutAttached::setPreferredWidth(qreal width) */ void QQuickLayoutAttached::setPreferredHeight(qreal height) { - if (qIsNaN(height) || m_preferredHeight == height) + if (qt_is_nan(height) || m_preferredHeight == height) return; m_preferredHeight = height; @@ -232,7 +232,7 @@ void QQuickLayoutAttached::setPreferredHeight(qreal height) */ void QQuickLayoutAttached::setMaximumWidth(qreal width) { - if (qIsNaN(width)) + if (qt_is_nan(width)) return; m_isMaximumWidthSet = width >= 0; if (m_maximumWidth == width) @@ -259,7 +259,7 @@ void QQuickLayoutAttached::setMaximumWidth(qreal width) */ void QQuickLayoutAttached::setMaximumHeight(qreal height) { - if (qIsNaN(height)) + if (qt_is_nan(height)) return; m_isMaximumHeightSet = height >= 0; if (m_maximumHeight == height) diff --git a/src/imports/layouts/qquicklinearlayout.cpp b/src/imports/layouts/qquicklinearlayout.cpp index 2f8af4c58b..0b4a1968d7 100644 --- a/src/imports/layouts/qquicklinearlayout.cpp +++ b/src/imports/layouts/qquicklinearlayout.cpp @@ -40,7 +40,7 @@ #include "qquicklinearlayout_p.h" #include "qquickgridlayoutengine_p.h" #include "qquicklayoutstyleinfo_p.h" -#include <QtCore/qnumeric.h> +#include <QtCore/private/qnumeric_p.h> #include "qdebug.h" #include <limits> @@ -566,7 +566,7 @@ qreal QQuickGridLayout::columnSpacing() const void QQuickGridLayout::setColumnSpacing(qreal spacing) { Q_D(QQuickGridLayout); - if (qIsNaN(spacing) || columnSpacing() == spacing) + if (qt_is_nan(spacing) || columnSpacing() == spacing) return; d->engine.setSpacing(spacing, Qt::Horizontal); @@ -588,7 +588,7 @@ qreal QQuickGridLayout::rowSpacing() const void QQuickGridLayout::setRowSpacing(qreal spacing) { Q_D(QQuickGridLayout); - if (qIsNaN(spacing) || rowSpacing() == spacing) + if (qt_is_nan(spacing) || rowSpacing() == spacing) return; d->engine.setSpacing(spacing, Qt::Vertical); @@ -867,7 +867,7 @@ qreal QQuickLinearLayout::spacing() const void QQuickLinearLayout::setSpacing(qreal space) { Q_D(QQuickLinearLayout); - if (qIsNaN(space) || spacing() == space) + if (qt_is_nan(space) || spacing() == space) return; d->engine.setSpacing(space, Qt::Horizontal | Qt::Vertical); diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml index 0f73d97c1b..046ce507d4 100644 --- a/src/imports/testlib/TestCase.qml +++ b/src/imports/testlib/TestCase.qml @@ -972,6 +972,9 @@ Item { \sa mouseRelease(), mouseClick(), mouseDoubleClick(), mouseDoubleClickSequence(), mouseMove(), mouseDrag(), mouseWheel() */ function mousePress(item, x, y, button, modifiers, delay) { + if (!item) + qtest_fail("No item given to mousePress", 1) + if (button === undefined) button = Qt.LeftButton if (modifiers === undefined) @@ -1003,6 +1006,9 @@ Item { \sa mousePress(), mouseClick(), mouseDoubleClick(), mouseDoubleClickSequence(), mouseMove(), mouseDrag(), mouseWheel() */ function mouseRelease(item, x, y, button, modifiers, delay) { + if (!item) + qtest_fail("No item given to mouseRelease", 1) + if (button === undefined) button = Qt.LeftButton if (modifiers === undefined) @@ -1036,6 +1042,9 @@ Item { \sa mousePress(), mouseClick(), mouseDoubleClick(), mouseDoubleClickSequence(), mouseMove(), mouseRelease(), mouseWheel() */ function mouseDrag(item, x, y, dx, dy, button, modifiers, delay) { + if (!item) + qtest_fail("No item given to mouseDrag", 1) + if (item.x === undefined || item.y === undefined) return if (button === undefined) @@ -1083,6 +1092,9 @@ Item { \sa mousePress(), mouseRelease(), mouseDoubleClick(), mouseDoubleClickSequence(), mouseMove(), mouseDrag(), mouseWheel() */ function mouseClick(item, x, y, button, modifiers, delay) { + if (!item) + qtest_fail("No item given to mouseClick", 1) + if (button === undefined) button = Qt.LeftButton if (modifiers === undefined) @@ -1114,6 +1126,9 @@ Item { \sa mouseDoubleClickSequence(), mousePress(), mouseRelease(), mouseClick(), mouseMove(), mouseDrag(), mouseWheel() */ function mouseDoubleClick(item, x, y, button, modifiers, delay) { + if (!item) + qtest_fail("No item given to mouseDoubleClick", 1) + if (button === undefined) button = Qt.LeftButton if (modifiers === undefined) @@ -1152,6 +1167,9 @@ Item { \sa mouseDoubleClick(), mousePress(), mouseRelease(), mouseClick(), mouseMove(), mouseDrag(), mouseWheel() */ function mouseDoubleClickSequence(item, x, y, button, modifiers, delay) { + if (!item) + qtest_fail("No item given to mouseDoubleClickSequence", 1) + if (button === undefined) button = Qt.LeftButton if (modifiers === undefined) @@ -1181,6 +1199,9 @@ Item { \sa mousePress(), mouseRelease(), mouseClick(), mouseDoubleClick(), mouseDoubleClickSequence(), mouseDrag(), mouseWheel() */ function mouseMove(item, x, y, delay, buttons) { + if (!item) + qtest_fail("No item given to mouseMove", 1) + if (delay == undefined) delay = -1 if (buttons == undefined) @@ -1206,6 +1227,9 @@ Item { \sa mousePress(), mouseClick(), mouseDoubleClick(), mouseDoubleClickSequence(), mouseMove(), mouseRelease(), mouseDrag(), QWheelEvent::angleDelta() */ function mouseWheel(item, x, y, xDelta, yDelta, buttons, modifiers, delay) { + if (!item) + qtest_fail("No item given to mouseWheel", 1) + if (delay == undefined) delay = -1 if (buttons == undefined) diff --git a/src/particles/particleresources/noise.png b/src/particles/particleresources/noise.png Binary files differindex 3c723e1a5a..c74ce493a6 100644 --- a/src/particles/particleresources/noise.png +++ b/src/particles/particleresources/noise.png diff --git a/src/particles/qquickv4particledata.cpp b/src/particles/qquickv4particledata.cpp index 3d7f4ce5b8..99451057ce 100644 --- a/src/particles/qquickv4particledata.cpp +++ b/src/particles/qquickv4particledata.cpp @@ -43,6 +43,7 @@ #include <QDebug> #include <private/qv4engine_p.h> #include <private/qv4functionobject_p.h> +#include <QtCore/private/qnumeric_p.h> QT_BEGIN_NAMESPACE @@ -388,7 +389,7 @@ static QV4::ReturnedValue particleData_set_ ## VARIABLE (QV4::CallContext *ctx)\ if (!r || !r->d()->datum)\ ctx->engine()->throwError(QStringLiteral("Not a valid ParticleData object"));\ \ - r->d()->datum-> VARIABLE = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN();\ + r->d()->datum-> VARIABLE = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan();\ return QV4::Encode::undefined(); \ } @@ -409,7 +410,7 @@ static QV4::ReturnedValue particleData_set_ ## VARIABLE (QV4::CallContext *ctx)\ if (!r || !r->d()->datum)\ ctx->engine()->throwError(QStringLiteral("Not a valid ParticleData object"));\ \ - r->d()->datum-> SETTER (ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(), r->d()->particleSystem);\ + r->d()->datum-> SETTER (ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(), r->d()->particleSystem);\ return QV4::Encode::undefined(); \ } diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp index 877821e03f..075f56226d 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp @@ -374,7 +374,7 @@ void Collector::collect(QJsonArray *out, const QString &parentIName, const QStri dict.insert(QStringLiteral("iname"), iname); dict.insert(QStringLiteral("name"), nonEmptyName); - QV4::ScopedValue typeString(scope, QV4::Runtime::typeofValue(m_engine, value)); + QV4::ScopedValue typeString(scope, QV4::Runtime::method_typeofValue(m_engine, value)); dict.insert(QStringLiteral("type"), typeString->toQStringNoThrow()); switch (value.type()) { diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp index 96f60b24bb..b2db23d78c 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp @@ -134,7 +134,7 @@ const QV4::Object *collectProperty(const QV4::ScopedValue &value, QV4::Execution QJsonObject &dict) { QV4::Scope scope(engine); - QV4::ScopedValue typeString(scope, QV4::Runtime::typeofValue(engine, value)); + QV4::ScopedValue typeString(scope, QV4::Runtime::method_typeofValue(engine, value)); dict.insert(QStringLiteral("type"), typeString->toQStringNoThrow()); const QLatin1String valueKey("value"); diff --git a/src/plugins/qmltooling/qmldbg_native/qmldbg_native.pro b/src/plugins/qmltooling/qmldbg_native/qmldbg_native.pro index b3fe1681e8..e5489574be 100644 --- a/src/plugins/qmltooling/qmldbg_native/qmldbg_native.pro +++ b/src/plugins/qmltooling/qmldbg_native/qmldbg_native.pro @@ -1,5 +1,5 @@ TARGET = qmldbg_native -QT += qml-private core-private packetprotocol-private +QT = qml-private core-private packetprotocol-private HEADERS += \ $$PWD/../shared/qqmldebugpacket.h \ diff --git a/src/qml/animations/qabstractanimationjob.cpp b/src/qml/animations/qabstractanimationjob.cpp index 4bd02c1934..f7f6939e4b 100644 --- a/src/qml/animations/qabstractanimationjob.cpp +++ b/src/qml/animations/qabstractanimationjob.cpp @@ -588,8 +588,7 @@ void QAbstractAnimationJob::updateDirection(QAbstractAnimationJob::Direction dir void QAbstractAnimationJob::finished() { //TODO: update this code so it is valid to delete the animation in animationFinished - for (int i = 0; i < changeListeners.count(); ++i) { - const QAbstractAnimationJob::ChangeListener &change = changeListeners.at(i); + for (const auto &change : changeListeners) { if (change.types & QAbstractAnimationJob::Completion) { RETURN_IF_DELETED(change.listener->animationFinished(this)); } @@ -603,8 +602,7 @@ void QAbstractAnimationJob::finished() void QAbstractAnimationJob::stateChanged(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) { - for (int i = 0; i < changeListeners.count(); ++i) { - const QAbstractAnimationJob::ChangeListener &change = changeListeners.at(i); + for (const auto &change : changeListeners) { if (change.types & QAbstractAnimationJob::StateChange) { RETURN_IF_DELETED(change.listener->animationStateChanged(this, newState, oldState)); } @@ -613,8 +611,7 @@ void QAbstractAnimationJob::stateChanged(QAbstractAnimationJob::State newState, void QAbstractAnimationJob::currentLoopChanged() { - for (int i = 0; i < changeListeners.count(); ++i) { - const QAbstractAnimationJob::ChangeListener &change = changeListeners.at(i); + for (const auto &change : changeListeners) { if (change.types & QAbstractAnimationJob::CurrentLoop) { RETURN_IF_DELETED(change.listener->animationCurrentLoopChanged(this)); } @@ -625,8 +622,7 @@ void QAbstractAnimationJob::currentTimeChanged(int currentTime) { Q_ASSERT(m_hasCurrentTimeChangeListeners); - for (int i = 0; i < changeListeners.count(); ++i) { - const QAbstractAnimationJob::ChangeListener &change = changeListeners.at(i); + for (const auto &change : changeListeners) { if (change.types & QAbstractAnimationJob::CurrentTime) { RETURN_IF_DELETED(change.listener->animationCurrentTimeChanged(this, currentTime)); } @@ -638,17 +634,18 @@ void QAbstractAnimationJob::addAnimationChangeListener(QAnimationJobChangeListen if (changes & QAbstractAnimationJob::CurrentTime) m_hasCurrentTimeChangeListeners = true; - changeListeners.append(ChangeListener(listener, changes)); + changeListeners.push_back(ChangeListener(listener, changes)); } void QAbstractAnimationJob::removeAnimationChangeListener(QAnimationJobChangeListener *listener, QAbstractAnimationJob::ChangeTypes changes) { m_hasCurrentTimeChangeListeners = false; - changeListeners.removeOne(ChangeListener(listener, changes)); + const auto it = std::find(changeListeners.begin(), changeListeners.end(), ChangeListener(listener, changes)); + if (it != changeListeners.end()) + changeListeners.erase(it); - for (int i = 0; i < changeListeners.count(); ++i) { - const QAbstractAnimationJob::ChangeListener &change = changeListeners.at(i); + for (const auto &change: changeListeners) { if (change.types & QAbstractAnimationJob::CurrentTime) { m_hasCurrentTimeChangeListeners = true; break; diff --git a/src/qml/animations/qabstractanimationjob_p.h b/src/qml/animations/qabstractanimationjob_p.h index b04f523585..efc86a5823 100644 --- a/src/qml/animations/qabstractanimationjob_p.h +++ b/src/qml/animations/qabstractanimationjob_p.h @@ -54,7 +54,7 @@ #include <private/qtqmlglobal_p.h> #include <QtCore/QObject> #include <QtCore/private/qabstractanimation_p.h> -#include "private/qpodvector_p.h" +#include <vector> QT_BEGIN_NAMESPACE @@ -164,7 +164,7 @@ protected: QAbstractAnimationJob::ChangeTypes types; bool operator==(const ChangeListener &other) const { return listener == other.listener && types == other.types; } }; - QPODVector<ChangeListener,1> changeListeners; + std::vector<ChangeListener> changeListeners; QAbstractAnimationJob *m_nextSibling; QAbstractAnimationJob *m_previousSibling; diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp index 1960f1d65b..065e91109b 100644 --- a/src/qml/compiler/qqmlirbuilder.cpp +++ b/src/qml/compiler/qqmlirbuilder.cpp @@ -1790,7 +1790,12 @@ void JSCodeGen::beginFunctionBodyHook() #ifndef V4_BOOTSTRAP QV4::IR::Temp *temp = _block->TEMP(_qmlContextTemp); - move(temp, _block->NAME(QV4::IR::Name::builtin_qml_context, 0, 0)); + temp->type = QV4::IR::QObjectType; + temp->memberResolver = _function->New<QV4::IR::MemberExpressionResolver>(); + initMetaObjectResolver(temp->memberResolver, _scopeObject); + auto name = _block->NAME(QV4::IR::Name::builtin_qml_context, 0, 0); + name->type = temp->type; + move(temp, name); move(_block->TEMP(_importedScriptsTemp), _block->NAME(QV4::IR::Name::builtin_qml_imported_scripts_object, 0, 0)); #endif diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 8c617875e0..6f0b5f9b32 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -91,8 +91,8 @@ struct Unit; struct Location { - qint32 line; - qint32 column; + qint32 line : 20; + qint32 column : 12; Location(): line(-1), column(-1) {} @@ -109,8 +109,8 @@ struct RegExp RegExp_IgnoreCase = 0x02, RegExp_Multiline = 0x04 }; - quint32 flags; - quint32 stringIndex; + quint32 flags : 4; + quint32 stringIndex : 28; static int calculateSize() { return sizeof(RegExp); } }; @@ -125,16 +125,16 @@ struct Lookup Type_IndexedSetter = 4 }; - quint32 type_and_flags; - quint32 nameIndex; + quint32 type_and_flags : 4; + quint32 nameIndex : 28; static int calculateSize() { return sizeof(Lookup); } }; struct JSClassMember { - uint nameOffset : 31; - uint isAccessor : 1; + quint32 nameOffset : 31; + quint32 isAccessor : 1; }; struct JSClass @@ -147,7 +147,6 @@ struct JSClass struct String { - quint32 flags; // isArrayIndex qint32 size; // uint16 strdata[] @@ -326,7 +325,6 @@ struct Parameter quint32 nameIndex; quint32 type; quint32 customTypeNameIndex; - quint32 reserved; Location location; }; diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp index 5de29d38fd..aacf0e9928 100644 --- a/src/qml/compiler/qv4compiler.cpp +++ b/src/qml/compiler/qv4compiler.cpp @@ -82,7 +82,6 @@ void QV4::Compiler::StringTableGenerator::serialize(CompiledData::Unit *unit) const QString &qstr = strings.at(i); QV4::CompiledData::String *s = (QV4::CompiledData::String*)(stringData); - s->flags = 0; // ### s->size = qstr.length(); memcpy(s + 1, qstr.constData(), qstr.length()*sizeof(ushort)); @@ -385,15 +384,13 @@ int QV4::Compiler::JSUnitGenerator::writeFunction(char *f, int index, QV4::IR::F *writtenDeps++ = id; writtenDeps = (quint32 *)(f + function->dependingContextPropertiesOffset); - for (QV4::IR::PropertyDependencyMap::ConstIterator property = irFunction->contextObjectPropertyDependencies.constBegin(), end = irFunction->contextObjectPropertyDependencies.constEnd(); - property != end; ++property) { + for (auto property : irFunction->contextObjectPropertyDependencies) { *writtenDeps++ = property.key(); // property index *writtenDeps++ = property.value(); // notify index } writtenDeps = (quint32 *)(f + function->dependingScopePropertiesOffset); - for (QV4::IR::PropertyDependencyMap::ConstIterator property = irFunction->scopeObjectPropertyDependencies.constBegin(), end = irFunction->scopeObjectPropertyDependencies.constEnd(); - property != end; ++property) { + for (auto property : irFunction->scopeObjectPropertyDependencies) { *writtenDeps++ = property.key(); // property index *writtenDeps++ = property.value(); // notify index } diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h index 90010ccf52..93a7170e68 100644 --- a/src/qml/compiler/qv4instr_moth_p.h +++ b/src/qml/compiler/qv4instr_moth_p.h @@ -672,7 +672,7 @@ union Instr }; struct instr_binop { MOTH_INSTR_HEADER - QV4::Runtime::BinaryOperation alu; + uint alu; // offset inside the runtime methods Param lhs; Param rhs; Param result; @@ -757,7 +757,7 @@ union Instr }; struct instr_binopContext { MOTH_INSTR_HEADER - QV4::Runtime::BinaryOperationContext alu; + uint alu; // offset inside the runtime methods Param lhs; Param rhs; Param result; diff --git a/src/qml/compiler/qv4isel_moth.cpp b/src/qml/compiler/qv4isel_moth.cpp index be10d50e9b..edd8425678 100644 --- a/src/qml/compiler/qv4isel_moth.cpp +++ b/src/qml/compiler/qv4isel_moth.cpp @@ -54,7 +54,7 @@ using namespace QV4::Moth; namespace { -inline QV4::Runtime::BinaryOperation aluOpFunction(IR::AluOp op) +inline uint aluOpFunction(IR::AluOp op) { switch (op) { case IR::OpInvalid: @@ -70,43 +70,43 @@ inline QV4::Runtime::BinaryOperation aluOpFunction(IR::AluOp op) case IR::OpCompl: return 0; case IR::OpBitAnd: - return QV4::Runtime::bitAnd; + return offsetof(QV4::Runtime, bitAnd); case IR::OpBitOr: - return QV4::Runtime::bitOr; + return offsetof(QV4::Runtime, bitOr); case IR::OpBitXor: - return QV4::Runtime::bitXor; + return offsetof(QV4::Runtime, bitXor); case IR::OpAdd: return 0; case IR::OpSub: - return QV4::Runtime::sub; + return offsetof(QV4::Runtime, sub); case IR::OpMul: - return QV4::Runtime::mul; + return offsetof(QV4::Runtime, mul); case IR::OpDiv: - return QV4::Runtime::div; + return offsetof(QV4::Runtime, div); case IR::OpMod: - return QV4::Runtime::mod; + return offsetof(QV4::Runtime, mod); case IR::OpLShift: - return QV4::Runtime::shl; + return offsetof(QV4::Runtime, shl); case IR::OpRShift: - return QV4::Runtime::shr; + return offsetof(QV4::Runtime, shr); case IR::OpURShift: - return QV4::Runtime::ushr; + return offsetof(QV4::Runtime, ushr); case IR::OpGt: - return QV4::Runtime::greaterThan; + return offsetof(QV4::Runtime, greaterThan); case IR::OpLt: - return QV4::Runtime::lessThan; + return offsetof(QV4::Runtime, lessThan); case IR::OpGe: - return QV4::Runtime::greaterEqual; + return offsetof(QV4::Runtime, greaterEqual); case IR::OpLe: - return QV4::Runtime::lessEqual; + return offsetof(QV4::Runtime, lessEqual); case IR::OpEqual: - return QV4::Runtime::equal; + return offsetof(QV4::Runtime, equal); case IR::OpNotEqual: - return QV4::Runtime::notEqual; + return offsetof(QV4::Runtime, notEqual); case IR::OpStrictEqual: - return QV4::Runtime::strictEqual; + return offsetof(QV4::Runtime, strictEqual); case IR::OpStrictNotEqual: - return QV4::Runtime::strictNotEqual; + return offsetof(QV4::Runtime, strictNotEqual); case IR::OpInstanceof: return 0; case IR::OpIn: @@ -1040,11 +1040,11 @@ Param InstructionSelection::binopHelper(IR::AluOp oper, IR::Expr *leftSource, IR if (oper == IR::OpInstanceof || oper == IR::OpIn || oper == IR::OpAdd) { Instruction::BinopContext binop; if (oper == IR::OpInstanceof) - binop.alu = QV4::Runtime::instanceof; + binop.alu = offsetof(QV4::Runtime, instanceof); else if (oper == IR::OpIn) - binop.alu = QV4::Runtime::in; + binop.alu = offsetof(QV4::Runtime, in); else - binop.alu = QV4::Runtime::add; + binop.alu = offsetof(QV4::Runtime, add); binop.lhs = getParam(leftSource); binop.rhs = getParam(rightSource); binop.result = getResultParam(target); diff --git a/src/qml/compiler/qv4jsir_p.h b/src/qml/compiler/qv4jsir_p.h index eafecae494..94fa65cf71 100644 --- a/src/qml/compiler/qv4jsir_p.h +++ b/src/qml/compiler/qv4jsir_p.h @@ -55,6 +55,7 @@ #include <private/qqmljsastfwd_p.h> #include <private/qflagpointer_p.h> +#include <QtCore/private/qnumeric_p.h> #include <QtCore/QVector> #include <QtCore/QString> #include <QtCore/QBitArray> @@ -1060,7 +1061,32 @@ private: }; // Map from meta property index (existence implies dependency) to notify signal index -typedef QHash<int, int> PropertyDependencyMap; +struct KeyValuePair +{ + quint32 _key; + quint32 _value; + + KeyValuePair(): _key(0), _value(0) {} + KeyValuePair(quint32 key, quint32 value): _key(key), _value(value) {} + + quint32 key() const { return _key; } + quint32 value() const { return _value; } +}; + +class PropertyDependencyMap: public QVarLengthArray<KeyValuePair, 8> +{ +public: + void insert(quint32 key, quint32 value) + { + for (auto it = begin(), eit = end(); it != eit; ++it) { + if (it->_key == key) { + it->_value = value; + return; + } + } + append(KeyValuePair(key, value)); + } +}; // The Function owns (manages), among things, a list of basic-blocks. All the blocks have an index, // which corresponds to the index in the entry/index in the vector in which they are stored. This @@ -1344,7 +1370,7 @@ inline Expr *BasicBlock::CONST(Type type, double value) } else if (type == NullType) { value = 0; } else if (type == UndefinedType) { - value = qQNaN(); + value = qt_qnan(); } e->init(type, value); diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp index 6a4c1c54d6..6965d839ab 100644 --- a/src/qml/compiler/qv4ssa.cpp +++ b/src/qml/compiler/qv4ssa.cpp @@ -2435,13 +2435,22 @@ protected: virtual void visitExp(Exp *s) { _ty = run(s->expr); } virtual void visitMove(Move *s) { - TypingResult sourceTy = run(s->source); if (Temp *t = s->target->asTemp()) { + if (Name *n = s->source->asName()) { + if (n->builtin == Name::builtin_qml_context) { + _ty = TypingResult(t->memberResolver); + setType(n, _ty.type); + setType(t, _ty.type); + return; + } + } + TypingResult sourceTy = run(s->source); setType(t, sourceTy.type); _ty = sourceTy; return; } + TypingResult sourceTy = run(s->source); _ty = run(s->target); _ty.fullyTyped &= sourceTy.fullyTyped; } @@ -2658,7 +2667,7 @@ void convertConst(Const *c, Type targetType) break; case NullType: case UndefinedType: - c->value = qQNaN(); + c->value = qt_qnan(); c->type = targetType; default: Q_UNIMPLEMENTED(); @@ -3739,42 +3748,42 @@ bool tryOptimizingComparison(Expr *&expr) switch (b->op) { case OpGt: - leftConst->value = Runtime::compareGreaterThan(l, r); + leftConst->value = Runtime::method_compareGreaterThan(l, r); leftConst->type = BoolType; expr = leftConst; return true; case OpLt: - leftConst->value = Runtime::compareLessThan(l, r); + leftConst->value = Runtime::method_compareLessThan(l, r); leftConst->type = BoolType; expr = leftConst; return true; case OpGe: - leftConst->value = Runtime::compareGreaterEqual(l, r); + leftConst->value = Runtime::method_compareGreaterEqual(l, r); leftConst->type = BoolType; expr = leftConst; return true; case OpLe: - leftConst->value = Runtime::compareLessEqual(l, r); + leftConst->value = Runtime::method_compareLessEqual(l, r); leftConst->type = BoolType; expr = leftConst; return true; case OpStrictEqual: - leftConst->value = Runtime::compareStrictEqual(l, r); + leftConst->value = Runtime::method_compareStrictEqual(l, r); leftConst->type = BoolType; expr = leftConst; return true; case OpEqual: - leftConst->value = Runtime::compareEqual(l, r); + leftConst->value = Runtime::method_compareEqual(l, r); leftConst->type = BoolType; expr = leftConst; return true; case OpStrictNotEqual: - leftConst->value = Runtime::compareStrictNotEqual(l, r); + leftConst->value = Runtime::method_compareStrictNotEqual(l, r); leftConst->type = BoolType; expr = leftConst; return true; case OpNotEqual: - leftConst->value = Runtime::compareNotEqual(l, r); + leftConst->value = Runtime::method_compareNotEqual(l, r); leftConst->type = BoolType; expr = leftConst; return true; diff --git a/src/qml/doc/src/qmlfunctions.qdoc b/src/qml/doc/src/qmlfunctions.qdoc index 6f738752a7..26fc40ff37 100644 --- a/src/qml/doc/src/qmlfunctions.qdoc +++ b/src/qml/doc/src/qmlfunctions.qdoc @@ -338,9 +338,8 @@ One exception to this is that a QObject singleton type property may not be aliased (because the singleton type name does not identify an object within the same component as any other item). - \b{NOTE:} A QObject singleton type instance returned from a singleton type provider is owned by the QML - engine. For this reason, the singleton type provider function should \b{not} be implemented as a - singleton factory. + \b{NOTE:} A QObject singleton type instance returned from a singleton type provider is owned by + the QML engine unless the object has explicit QQmlEngine::CppOwnership flag set. Usage: \code diff --git a/src/qml/jit/qv4assembler_p.h b/src/qml/jit/qv4assembler_p.h index a5028bc683..6c7d27b2f4 100644 --- a/src/qml/jit/qv4assembler_p.h +++ b/src/qml/jit/qv4assembler_p.h @@ -63,6 +63,8 @@ #include <config.h> #include <wtf/Vector.h> +#include <climits> + #if ENABLE(ASSEMBLER) #include <assembler/MacroAssembler.h> @@ -73,11 +75,6 @@ QT_BEGIN_NAMESPACE namespace QV4 { namespace JIT { -#define OP(op) \ - { isel_stringIfy(op), op, 0, 0, 0 } -#define OPCONTEXT(op) \ - { isel_stringIfy(op), 0, op, 0, 0 } - class InstructionSelection; struct CompilationUnit : public QV4::CompiledData::CompilationUnit @@ -94,14 +91,6 @@ struct CompilationUnit : public QV4::CompiledData::CompilationUnit QList<QVector<QV4::Primitive> > constantValues; }; -struct RelativeCall { - JSC::MacroAssembler::Address addr; - - explicit RelativeCall(const JSC::MacroAssembler::Address &addr) - : addr(addr) - {} -}; - struct LookupCall { JSC::MacroAssembler::Address addr; uint getterSetterOffset; @@ -112,6 +101,13 @@ struct LookupCall { {} }; +struct RuntimeCall { + JSC::MacroAssembler::Address addr; + + inline RuntimeCall(uint offset = INT_MIN); + bool isValid() const { return addr.offset >= 0; } +}; + template <typename T> struct ExceptionCheck { enum { NeedsCheck = 1 }; @@ -321,12 +317,12 @@ public: typedef JSC::FunctionPtr FunctionPtr; - struct CallToLink { - Call call; - FunctionPtr externalFunction; +#ifndef QT_NO_DEBUG + struct CallInfo { Label label; const char* functionName; }; +#endif struct PointerToValue { PointerToValue(IR::Expr *value) : value(value) @@ -349,27 +345,23 @@ public: IR::BasicBlock *block; }; - void callAbsolute(const char* functionName, FunctionPtr function) { - CallToLink ctl; - ctl.call = call(); - ctl.externalFunction = function; - ctl.functionName = functionName; - ctl.label = label(); - _callsToLink.append(ctl); - } - - void callAbsolute(const char* /*functionName*/, Address addr) { - call(addr); - } - - void callAbsolute(const char* /*functionName*/, const RelativeCall &relativeCall) + void callAbsolute(const char* /*functionName*/, const LookupCall &lookupCall) { - call(relativeCall.addr); + call(lookupCall.addr); } - void callAbsolute(const char* /*functionName*/, const LookupCall &lookupCall) + void callAbsolute(const char *functionName, const RuntimeCall &runtimeCall) { - call(lookupCall.addr); + call(runtimeCall.addr); +#ifndef QT_NO_DEBUG + // the code below is to get proper function names in the disassembly + CallInfo info; + info.functionName = functionName; + info.label = label(); + _callInfos.append(info); +#else + Q_UNUSED(functionName) +#endif } void registerBlock(IR::BasicBlock*, IR::BasicBlock *nextBlock); @@ -1184,7 +1176,9 @@ private: IR::Function *_function; QHash<IR::BasicBlock *, Label> _addrs; QHash<IR::BasicBlock *, QVector<Jump> > _patches; - QList<CallToLink> _callsToLink; +#ifndef QT_NO_DEBUG + QVector<CallInfo> _callInfos; +#endif struct DataLabelPatch { DataLabelPtr dataLabel; @@ -1245,24 +1239,21 @@ void Assembler::copyValue(Result result, IR::Expr* source) } } +inline RuntimeCall::RuntimeCall(uint offset) + : addr(Assembler::EngineRegister, offset + qOffsetOf(QV4::ExecutionEngine, runtime)) +{ +} + template <typename T> inline bool prepareCall(T &, Assembler *) { return true; } -template <> inline bool prepareCall(RelativeCall &relativeCall, Assembler *as) -{ - as->loadPtr(Assembler::Address(Assembler::EngineRegister, qOffsetOf(QV4::ExecutionEngine, current)), Assembler::ScratchRegister); - as->loadPtr(Assembler::Address(Assembler::ScratchRegister, qOffsetOf(QV4::Heap::ExecutionContext, lookups)), - relativeCall.addr.base); - return true; -} - template <> inline bool prepareCall(LookupCall &lookupCall, Assembler *as) { // IMPORTANT! See generateLookupCall in qv4isel_masm_p.h for details! - // same as prepareCall(RelativeCall ....) : load the table from the context + // load the table from the context as->loadPtr(Assembler::Address(Assembler::EngineRegister, qOffsetOf(QV4::ExecutionEngine, current)), Assembler::ScratchRegister); as->loadPtr(Assembler::Address(Assembler::ScratchRegister, qOffsetOf(QV4::Heap::ExecutionContext, lookups)), lookupCall.addr.base); diff --git a/src/qml/jit/qv4binop.cpp b/src/qml/jit/qv4binop.cpp index 50b6cec975..c09fc6fdca 100644 --- a/src/qml/jit/qv4binop.cpp +++ b/src/qml/jit/qv4binop.cpp @@ -45,14 +45,14 @@ using namespace QV4; using namespace JIT; #define OP(op) \ - { isel_stringIfy(op), op, 0, 0, 0 } + { "Runtime::" isel_stringIfy(op), offsetof(QV4::Runtime, op), INT_MIN, 0, 0 } #define OPCONTEXT(op) \ - { isel_stringIfy(op), 0, op, 0, 0 } + { "Runtime::" isel_stringIfy(op), INT_MIN, offsetof(QV4::Runtime, op), 0, 0 } #define INLINE_OP(op, memOp, immOp) \ - { isel_stringIfy(op), op, 0, memOp, immOp } + { "Runtime::" isel_stringIfy(op), offsetof(QV4::Runtime, op), INT_MIN, memOp, immOp } #define INLINE_OPCONTEXT(op, memOp, immOp) \ - { isel_stringIfy(op), 0, op, memOp, immOp } + { "Runtime::" isel_stringIfy(op), INT_MIN, offsetof(QV4::Runtime, op), memOp, immOp } #define NULL_OP \ { 0, 0, 0, 0, 0 } @@ -67,32 +67,32 @@ const Binop::OpInfo Binop::operations[IR::LastAluOp + 1] = { NULL_OP, // OpIncrement NULL_OP, // OpDecrement - INLINE_OP(Runtime::bitAnd, &Binop::inline_and32, &Binop::inline_and32), // OpBitAnd - INLINE_OP(Runtime::bitOr, &Binop::inline_or32, &Binop::inline_or32), // OpBitOr - INLINE_OP(Runtime::bitXor, &Binop::inline_xor32, &Binop::inline_xor32), // OpBitXor + INLINE_OP(bitAnd, &Binop::inline_and32, &Binop::inline_and32), // OpBitAnd + INLINE_OP(bitOr, &Binop::inline_or32, &Binop::inline_or32), // OpBitOr + INLINE_OP(bitXor, &Binop::inline_xor32, &Binop::inline_xor32), // OpBitXor - INLINE_OPCONTEXT(Runtime::add, &Binop::inline_add32, &Binop::inline_add32), // OpAdd - INLINE_OP(Runtime::sub, &Binop::inline_sub32, &Binop::inline_sub32), // OpSub - INLINE_OP(Runtime::mul, &Binop::inline_mul32, &Binop::inline_mul32), // OpMul + INLINE_OPCONTEXT(add, &Binop::inline_add32, &Binop::inline_add32), // OpAdd + INLINE_OP(sub, &Binop::inline_sub32, &Binop::inline_sub32), // OpSub + INLINE_OP(mul, &Binop::inline_mul32, &Binop::inline_mul32), // OpMul - OP(Runtime::div), // OpDiv - OP(Runtime::mod), // OpMod + OP(div), // OpDiv + OP(mod), // OpMod - INLINE_OP(Runtime::shl, &Binop::inline_shl32, &Binop::inline_shl32), // OpLShift - INLINE_OP(Runtime::shr, &Binop::inline_shr32, &Binop::inline_shr32), // OpRShift - INLINE_OP(Runtime::ushr, &Binop::inline_ushr32, &Binop::inline_ushr32), // OpURShift + INLINE_OP(shl, &Binop::inline_shl32, &Binop::inline_shl32), // OpLShift + INLINE_OP(shr, &Binop::inline_shr32, &Binop::inline_shr32), // OpRShift + INLINE_OP(ushr, &Binop::inline_ushr32, &Binop::inline_ushr32), // OpURShift - OP(Runtime::greaterThan), // OpGt - OP(Runtime::lessThan), // OpLt - OP(Runtime::greaterEqual), // OpGe - OP(Runtime::lessEqual), // OpLe - OP(Runtime::equal), // OpEqual - OP(Runtime::notEqual), // OpNotEqual - OP(Runtime::strictEqual), // OpStrictEqual - OP(Runtime::strictNotEqual), // OpStrictNotEqual + OP(greaterThan), // OpGt + OP(lessThan), // OpLt + OP(greaterEqual), // OpGe + OP(lessEqual), // OpLe + OP(equal), // OpEqual + OP(notEqual), // OpNotEqual + OP(strictEqual), // OpStrictEqual + OP(strictNotEqual), // OpStrictNotEqual - OPCONTEXT(Runtime::instanceof), // OpInstanceof - OPCONTEXT(Runtime::in), // OpIn + OPCONTEXT(instanceof), // OpInstanceof + OPCONTEXT(in), // OpIn NULL_OP, // OpAnd NULL_OP // OpOr @@ -121,16 +121,18 @@ void Binop::generate(IR::Expr *lhs, IR::Expr *rhs, IR::Expr *target) if (op == IR::OpAdd && (lhs->type == IR::StringType || rhs->type == IR::StringType)) { - const Binop::OpInfo stringAdd = OPCONTEXT(Runtime::addString); + const Binop::OpInfo stringAdd = OPCONTEXT(addString); info = stringAdd; } - if (info.fallbackImplementation) { - as->generateFunctionCallImp(target, info.name, info.fallbackImplementation, + RuntimeCall fallBack(info.fallbackImplementation); + RuntimeCall context(info.contextImplementation); + if (fallBack.isValid()) { + as->generateFunctionCallImp(target, info.name, fallBack, Assembler::PointerToValue(lhs), Assembler::PointerToValue(rhs)); - } else if (info.contextImplementation) { - as->generateFunctionCallImp(target, info.name, info.contextImplementation, + } else if (context.isValid()) { + as->generateFunctionCallImp(target, info.name, context, Assembler::EngineRegister, Assembler::PointerToValue(lhs), Assembler::PointerToValue(rhs)); diff --git a/src/qml/jit/qv4binop_p.h b/src/qml/jit/qv4binop_p.h index 791e335970..c246ee43b0 100644 --- a/src/qml/jit/qv4binop_p.h +++ b/src/qml/jit/qv4binop_p.h @@ -77,8 +77,8 @@ struct Binop { struct OpInfo { const char *name; - QV4::Runtime::BinaryOperation fallbackImplementation; - QV4::Runtime::BinaryOperationContext contextImplementation; + int fallbackImplementation; // offsetOf(Runtime,...) + int contextImplementation; // offsetOf(Runtime,...) MemRegOp inlineMemRegOp; ImmRegOp inlineImmRegOp; }; diff --git a/src/qml/jit/qv4isel_masm.cpp b/src/qml/jit/qv4isel_masm.cpp index bf658fe689..149037939b 100644 --- a/src/qml/jit/qv4isel_masm.cpp +++ b/src/qml/jit/qv4isel_masm.cpp @@ -159,12 +159,6 @@ JSC::MacroAssemblerCodeRef Assembler::link(int *codeSize) JSC::JSGlobalData dummy(_executableAllocator); JSC::LinkBuffer linkBuffer(dummy, this, 0); - QHash<void*, const char*> functions; - foreach (CallToLink ctl, _callsToLink) { - linkBuffer.link(ctl.call, ctl.externalFunction); - functions[linkBuffer.locationOf(ctl.label).dataLocation()] = ctl.functionName; - } - foreach (const DataLabelPatch &p, _dataLabelPatches) linkBuffer.patch(p.dataLabel, linkBuffer.locationOf(p.target)); @@ -193,6 +187,12 @@ JSC::MacroAssemblerCodeRef Assembler::link(int *codeSize) static const bool showCode = qEnvironmentVariableIsSet("QV4_SHOW_ASM"); if (showCode) { + QHash<void*, const char*> functions; +#ifndef QT_NO_DEBUG + foreach (CallInfo call, _callInfos) + functions[linkBuffer.locationOf(call.label).dataLocation()] = call.functionName; +#endif + QBuffer buf; buf.open(QIODevice::WriteOnly); WTF::setDataFile(new QIODevicePrintStream(&buf)); @@ -393,12 +393,12 @@ void InstructionSelection::callBuiltinInvalid(IR::Name *func, IR::ExprList *args if (useFastLookups && func->global) { uint index = registerGlobalGetterLookup(*func->id); - generateFunctionCall(result, Runtime::callGlobalLookup, + generateRuntimeCall(result, callGlobalLookup, Assembler::EngineRegister, Assembler::TrustedImm32(index), baseAddressForCallData()); } else { - generateFunctionCall(result, Runtime::callActivationProperty, + generateRuntimeCall(result, callActivationProperty, Assembler::EngineRegister, Assembler::StringToIndex(*func->id), baseAddressForCallData()); @@ -410,11 +410,11 @@ void InstructionSelection::callBuiltinTypeofQmlContextProperty(IR::Expr *base, int propertyIndex, IR::Expr *result) { if (kind == IR::Member::MemberOfQmlScopeObject) { - generateFunctionCall(result, Runtime::typeofScopeObjectProperty, Assembler::EngineRegister, + generateRuntimeCall(result, typeofScopeObjectProperty, Assembler::EngineRegister, Assembler::PointerToValue(base), Assembler::TrustedImm32(propertyIndex)); } else if (kind == IR::Member::MemberOfQmlContextObject) { - generateFunctionCall(result, Runtime::typeofContextObjectProperty, + generateRuntimeCall(result, typeofContextObjectProperty, Assembler::EngineRegister, Assembler::PointerToValue(base), Assembler::TrustedImm32(propertyIndex)); } else { @@ -425,46 +425,46 @@ void InstructionSelection::callBuiltinTypeofQmlContextProperty(IR::Expr *base, void InstructionSelection::callBuiltinTypeofMember(IR::Expr *base, const QString &name, IR::Expr *result) { - generateFunctionCall(result, Runtime::typeofMember, Assembler::EngineRegister, + generateRuntimeCall(result, typeofMember, Assembler::EngineRegister, Assembler::PointerToValue(base), Assembler::StringToIndex(name)); } void InstructionSelection::callBuiltinTypeofSubscript(IR::Expr *base, IR::Expr *index, IR::Expr *result) { - generateFunctionCall(result, Runtime::typeofElement, + generateRuntimeCall(result, typeofElement, Assembler::EngineRegister, Assembler::PointerToValue(base), Assembler::PointerToValue(index)); } void InstructionSelection::callBuiltinTypeofName(const QString &name, IR::Expr *result) { - generateFunctionCall(result, Runtime::typeofName, Assembler::EngineRegister, + generateRuntimeCall(result, typeofName, Assembler::EngineRegister, Assembler::StringToIndex(name)); } void InstructionSelection::callBuiltinTypeofValue(IR::Expr *value, IR::Expr *result) { - generateFunctionCall(result, Runtime::typeofValue, Assembler::EngineRegister, + generateRuntimeCall(result, typeofValue, Assembler::EngineRegister, Assembler::PointerToValue(value)); } void InstructionSelection::callBuiltinDeleteMember(IR::Expr *base, const QString &name, IR::Expr *result) { - generateFunctionCall(result, Runtime::deleteMember, Assembler::EngineRegister, + generateRuntimeCall(result, deleteMember, Assembler::EngineRegister, Assembler::Reference(base), Assembler::StringToIndex(name)); } void InstructionSelection::callBuiltinDeleteSubscript(IR::Expr *base, IR::Expr *index, IR::Expr *result) { - generateFunctionCall(result, Runtime::deleteElement, Assembler::EngineRegister, + generateRuntimeCall(result, deleteElement, Assembler::EngineRegister, Assembler::Reference(base), Assembler::PointerToValue(index)); } void InstructionSelection::callBuiltinDeleteName(const QString &name, IR::Expr *result) { - generateFunctionCall(result, Runtime::deleteName, Assembler::EngineRegister, + generateRuntimeCall(result, deleteName, Assembler::EngineRegister, Assembler::StringToIndex(name)); } @@ -475,7 +475,7 @@ void InstructionSelection::callBuiltinDeleteValue(IR::Expr *result) void InstructionSelection::callBuiltinThrow(IR::Expr *arg) { - generateFunctionCall(Assembler::ReturnValueRegister, Runtime::throwException, Assembler::EngineRegister, + generateRuntimeCall(Assembler::ReturnValueRegister, throwException, Assembler::EngineRegister, Assembler::PointerToValue(arg)); } @@ -486,13 +486,13 @@ void InstructionSelection::callBuiltinReThrow() void InstructionSelection::callBuiltinUnwindException(IR::Expr *result) { - generateFunctionCall(result, Runtime::unwindException, Assembler::EngineRegister); + generateRuntimeCall(result, unwindException, Assembler::EngineRegister); } void InstructionSelection::callBuiltinPushCatchScope(const QString &exceptionName) { - generateFunctionCall(Assembler::Void, Runtime::pushCatchScope, Assembler::EngineRegister, Assembler::StringToIndex(exceptionName)); + generateRuntimeCall(Assembler::Void, pushCatchScope, Assembler::EngineRegister, Assembler::StringToIndex(exceptionName)); } void InstructionSelection::callBuiltinForeachIteratorObject(IR::Expr *arg, IR::Expr *result) @@ -500,7 +500,7 @@ void InstructionSelection::callBuiltinForeachIteratorObject(IR::Expr *arg, IR::E Q_ASSERT(arg); Q_ASSERT(result); - generateFunctionCall(result, Runtime::foreachIterator, Assembler::EngineRegister, Assembler::PointerToValue(arg)); + generateRuntimeCall(result, foreachIterator, Assembler::EngineRegister, Assembler::PointerToValue(arg)); } void InstructionSelection::callBuiltinForeachNextPropertyname(IR::Expr *arg, IR::Expr *result) @@ -508,24 +508,24 @@ void InstructionSelection::callBuiltinForeachNextPropertyname(IR::Expr *arg, IR: Q_ASSERT(arg); Q_ASSERT(result); - generateFunctionCall(result, Runtime::foreachNextPropertyName, Assembler::Reference(arg)); + generateRuntimeCall(result, foreachNextPropertyName, Assembler::Reference(arg)); } void InstructionSelection::callBuiltinPushWithScope(IR::Expr *arg) { Q_ASSERT(arg); - generateFunctionCall(Assembler::Void, Runtime::pushWithScope, Assembler::Reference(arg), Assembler::EngineRegister); + generateRuntimeCall(Assembler::Void, pushWithScope, Assembler::Reference(arg), Assembler::EngineRegister); } void InstructionSelection::callBuiltinPopScope() { - generateFunctionCall(Assembler::Void, Runtime::popScope, Assembler::EngineRegister); + generateRuntimeCall(Assembler::Void, popScope, Assembler::EngineRegister); } void InstructionSelection::callBuiltinDeclareVar(bool deletable, const QString &name) { - generateFunctionCall(Assembler::Void, Runtime::declareVar, Assembler::EngineRegister, + generateRuntimeCall(Assembler::Void, declareVar, Assembler::EngineRegister, Assembler::TrustedImm32(deletable), Assembler::StringToIndex(name)); } @@ -534,7 +534,7 @@ void InstructionSelection::callBuiltinDefineArray(IR::Expr *result, IR::ExprList Q_ASSERT(result); int length = prepareVariableArguments(args); - generateFunctionCall(result, Runtime::arrayLiteral, Assembler::EngineRegister, + generateRuntimeCall(result, arrayLiteral, Assembler::EngineRegister, baseAddressForCallArguments(), Assembler::TrustedImm32(length)); } @@ -614,19 +614,19 @@ void InstructionSelection::callBuiltinDefineObjectLiteral(IR::Expr *result, int it = it->next; } - generateFunctionCall(result, Runtime::objectLiteral, Assembler::EngineRegister, + generateRuntimeCall(result, objectLiteral, Assembler::EngineRegister, baseAddressForCallArguments(), Assembler::TrustedImm32(classId), Assembler::TrustedImm32(arrayValueCount), Assembler::TrustedImm32(arrayGetterSetterCount | (needSparseArray << 30))); } void InstructionSelection::callBuiltinSetupArgumentObject(IR::Expr *result) { - generateFunctionCall(result, Runtime::setupArgumentsObject, Assembler::EngineRegister); + generateRuntimeCall(result, setupArgumentsObject, Assembler::EngineRegister); } void InstructionSelection::callBuiltinConvertThisToObject() { - generateFunctionCall(Assembler::Void, Runtime::convertThisToObject, Assembler::EngineRegister); + generateRuntimeCall(Assembler::Void, convertThisToObject, Assembler::EngineRegister); } void InstructionSelection::callValue(IR::Expr *value, IR::ExprList *args, IR::Expr *result) @@ -635,11 +635,11 @@ void InstructionSelection::callValue(IR::Expr *value, IR::ExprList *args, IR::Ex prepareCallData(args, 0); if (value->asConst()) - generateFunctionCall(result, Runtime::callValue, Assembler::EngineRegister, + generateRuntimeCall(result, callValue, Assembler::EngineRegister, Assembler::PointerToValue(value), baseAddressForCallData()); else - generateFunctionCall(result, Runtime::callValue, Assembler::EngineRegister, + generateRuntimeCall(result, callValue, Assembler::EngineRegister, Assembler::Reference(value), baseAddressForCallData()); } @@ -659,17 +659,17 @@ void InstructionSelection::loadThisObject(IR::Expr *temp) void InstructionSelection::loadQmlContext(IR::Expr *temp) { - generateFunctionCall(temp, Runtime::getQmlContext, Assembler::EngineRegister); + generateRuntimeCall(temp, getQmlContext, Assembler::EngineRegister); } void InstructionSelection::loadQmlImportedScripts(IR::Expr *temp) { - generateFunctionCall(temp, Runtime::getQmlImportedScripts, Assembler::EngineRegister); + generateRuntimeCall(temp, getQmlImportedScripts, Assembler::EngineRegister); } void InstructionSelection::loadQmlSingleton(const QString &name, IR::Expr *temp) { - generateFunctionCall(temp, Runtime::getQmlSingleton, Assembler::EngineRegister, Assembler::StringToIndex(name)); + generateRuntimeCall(temp, getQmlSingleton, Assembler::EngineRegister, Assembler::StringToIndex(name)); } void InstructionSelection::loadConst(IR::Const *sourceConst, IR::Expr *target) @@ -716,7 +716,7 @@ void InstructionSelection::loadString(const QString &str, IR::Expr *target) void InstructionSelection::loadRegexp(IR::RegExp *sourceRegexp, IR::Expr *target) { int id = registerRegExp(sourceRegexp); - generateFunctionCall(target, Runtime::regexpLiteral, Assembler::EngineRegister, Assembler::TrustedImm32(id)); + generateRuntimeCall(target, regexpLiteral, Assembler::EngineRegister, Assembler::TrustedImm32(id)); } void InstructionSelection::getActivationProperty(const IR::Name *name, IR::Expr *target) @@ -726,20 +726,20 @@ void InstructionSelection::getActivationProperty(const IR::Name *name, IR::Expr generateLookupCall(target, index, qOffsetOf(QV4::Lookup, globalGetter), Assembler::EngineRegister, Assembler::Void); return; } - generateFunctionCall(target, Runtime::getActivationProperty, Assembler::EngineRegister, Assembler::StringToIndex(*name->id)); + generateRuntimeCall(target, getActivationProperty, Assembler::EngineRegister, Assembler::StringToIndex(*name->id)); } void InstructionSelection::setActivationProperty(IR::Expr *source, const QString &targetName) { // ### should use a lookup call here - generateFunctionCall(Assembler::Void, Runtime::setActivationProperty, + generateRuntimeCall(Assembler::Void, setActivationProperty, Assembler::EngineRegister, Assembler::StringToIndex(targetName), Assembler::PointerToValue(source)); } void InstructionSelection::initClosure(IR::Closure *closure, IR::Expr *target) { int id = closure->value; - generateFunctionCall(target, Runtime::closure, Assembler::EngineRegister, Assembler::TrustedImm32(id)); + generateRuntimeCall(target, closure, Assembler::EngineRegister, Assembler::TrustedImm32(id)); } void InstructionSelection::getProperty(IR::Expr *base, const QString &name, IR::Expr *target) @@ -748,7 +748,7 @@ void InstructionSelection::getProperty(IR::Expr *base, const QString &name, IR:: uint index = registerGetterLookup(name); generateLookupCall(target, index, qOffsetOf(QV4::Lookup, getter), Assembler::EngineRegister, Assembler::PointerToValue(base), Assembler::Void); } else { - generateFunctionCall(target, Runtime::getProperty, Assembler::EngineRegister, + generateRuntimeCall(target, getProperty, Assembler::EngineRegister, Assembler::PointerToValue(base), Assembler::StringToIndex(name)); } } @@ -756,11 +756,11 @@ void InstructionSelection::getProperty(IR::Expr *base, const QString &name, IR:: void InstructionSelection::getQmlContextProperty(IR::Expr *base, IR::Member::MemberKind kind, int index, IR::Expr *target) { if (kind == IR::Member::MemberOfQmlScopeObject) - generateFunctionCall(target, Runtime::getQmlScopeObjectProperty, Assembler::EngineRegister, Assembler::PointerToValue(base), Assembler::TrustedImm32(index)); + generateRuntimeCall(target, getQmlScopeObjectProperty, Assembler::EngineRegister, Assembler::PointerToValue(base), Assembler::TrustedImm32(index)); else if (kind == IR::Member::MemberOfQmlContextObject) - generateFunctionCall(target, Runtime::getQmlContextObjectProperty, Assembler::EngineRegister, Assembler::PointerToValue(base), Assembler::TrustedImm32(index)); + generateRuntimeCall(target, getQmlContextObjectProperty, Assembler::EngineRegister, Assembler::PointerToValue(base), Assembler::TrustedImm32(index)); else if (kind == IR::Member::MemberOfIdObjectsArray) - generateFunctionCall(target, Runtime::getQmlIdObject, Assembler::EngineRegister, Assembler::PointerToValue(base), Assembler::TrustedImm32(index)); + generateRuntimeCall(target, getQmlIdObject, Assembler::EngineRegister, Assembler::PointerToValue(base), Assembler::TrustedImm32(index)); else Q_ASSERT(false); } @@ -768,12 +768,12 @@ void InstructionSelection::getQmlContextProperty(IR::Expr *base, IR::Member::Mem void InstructionSelection::getQObjectProperty(IR::Expr *base, int propertyIndex, bool captureRequired, bool isSingleton, int attachedPropertiesId, IR::Expr *target) { if (attachedPropertiesId != 0) - generateFunctionCall(target, Runtime::getQmlAttachedProperty, Assembler::EngineRegister, Assembler::TrustedImm32(attachedPropertiesId), Assembler::TrustedImm32(propertyIndex)); + generateRuntimeCall(target, getQmlAttachedProperty, Assembler::EngineRegister, Assembler::TrustedImm32(attachedPropertiesId), Assembler::TrustedImm32(propertyIndex)); else if (isSingleton) - generateFunctionCall(target, Runtime::getQmlSingletonQObjectProperty, Assembler::EngineRegister, Assembler::PointerToValue(base), Assembler::TrustedImm32(propertyIndex), + generateRuntimeCall(target, getQmlSingletonQObjectProperty, Assembler::EngineRegister, Assembler::PointerToValue(base), Assembler::TrustedImm32(propertyIndex), Assembler::TrustedImm32(captureRequired)); else - generateFunctionCall(target, Runtime::getQmlQObjectProperty, Assembler::EngineRegister, Assembler::PointerToValue(base), Assembler::TrustedImm32(propertyIndex), + generateRuntimeCall(target, getQmlQObjectProperty, Assembler::EngineRegister, Assembler::PointerToValue(base), Assembler::TrustedImm32(propertyIndex), Assembler::TrustedImm32(captureRequired)); } @@ -787,7 +787,7 @@ void InstructionSelection::setProperty(IR::Expr *source, IR::Expr *targetBase, Assembler::PointerToValue(targetBase), Assembler::PointerToValue(source)); } else { - generateFunctionCall(Assembler::Void, Runtime::setProperty, Assembler::EngineRegister, + generateRuntimeCall(Assembler::Void, setProperty, Assembler::EngineRegister, Assembler::PointerToValue(targetBase), Assembler::StringToIndex(targetName), Assembler::PointerToValue(source)); } @@ -796,10 +796,10 @@ void InstructionSelection::setProperty(IR::Expr *source, IR::Expr *targetBase, void InstructionSelection::setQmlContextProperty(IR::Expr *source, IR::Expr *targetBase, IR::Member::MemberKind kind, int propertyIndex) { if (kind == IR::Member::MemberOfQmlScopeObject) - generateFunctionCall(Assembler::Void, Runtime::setQmlScopeObjectProperty, Assembler::EngineRegister, Assembler::PointerToValue(targetBase), + generateRuntimeCall(Assembler::Void, setQmlScopeObjectProperty, Assembler::EngineRegister, Assembler::PointerToValue(targetBase), Assembler::TrustedImm32(propertyIndex), Assembler::PointerToValue(source)); else if (kind == IR::Member::MemberOfQmlContextObject) - generateFunctionCall(Assembler::Void, Runtime::setQmlContextObjectProperty, Assembler::EngineRegister, Assembler::PointerToValue(targetBase), + generateRuntimeCall(Assembler::Void, setQmlContextObjectProperty, Assembler::EngineRegister, Assembler::PointerToValue(targetBase), Assembler::TrustedImm32(propertyIndex), Assembler::PointerToValue(source)); else Q_ASSERT(false); @@ -807,7 +807,7 @@ void InstructionSelection::setQmlContextProperty(IR::Expr *source, IR::Expr *tar void InstructionSelection::setQObjectProperty(IR::Expr *source, IR::Expr *targetBase, int propertyIndex) { - generateFunctionCall(Assembler::Void, Runtime::setQmlQObjectProperty, Assembler::EngineRegister, Assembler::PointerToValue(targetBase), + generateRuntimeCall(Assembler::Void, setQmlQObjectProperty, Assembler::EngineRegister, Assembler::PointerToValue(targetBase), Assembler::TrustedImm32(propertyIndex), Assembler::PointerToValue(source)); } @@ -821,7 +821,7 @@ void InstructionSelection::getElement(IR::Expr *base, IR::Expr *index, IR::Expr return; } - generateFunctionCall(target, Runtime::getElement, Assembler::EngineRegister, + generateRuntimeCall(target, getElement, Assembler::EngineRegister, Assembler::PointerToValue(base), Assembler::PointerToValue(index)); } @@ -834,7 +834,7 @@ void InstructionSelection::setElement(IR::Expr *source, IR::Expr *targetBase, IR Assembler::PointerToValue(source)); return; } - generateFunctionCall(Assembler::Void, Runtime::setElement, Assembler::EngineRegister, + generateRuntimeCall(Assembler::Void, setElement, Assembler::EngineRegister, Assembler::PointerToValue(targetBase), Assembler::PointerToValue(targetIndex), Assembler::PointerToValue(source)); } @@ -981,9 +981,9 @@ void InstructionSelection::swapValues(IR::Expr *source, IR::Expr *target) } #define setOp(op, opName, operation) \ - do { op = operation; opName = isel_stringIfy(operation); } while (0) + do { op = RuntimeCall(qOffsetOf(QV4::Runtime, operation)); opName = "Runtime::" isel_stringIfy(operation); } while (0) #define setOpContext(op, opName, operation) \ - do { opContext = operation; opName = isel_stringIfy(operation); } while (0) + do { opContext = RuntimeCall(qOffsetOf(QV4::Runtime, operation)); opName = "Runtime::" isel_stringIfy(operation); } while (0) void InstructionSelection::unop(IR::AluOp oper, IR::Expr *source, IR::Expr *target) { @@ -1003,12 +1003,12 @@ void InstructionSelection::callQmlContextProperty(IR::Expr *base, IR::Member::Me prepareCallData(args, base); if (kind == IR::Member::MemberOfQmlScopeObject) - generateFunctionCall(result, Runtime::callQmlScopeObjectProperty, + generateRuntimeCall(result, callQmlScopeObjectProperty, Assembler::EngineRegister, Assembler::TrustedImm32(propertyIndex), baseAddressForCallData()); else if (kind == IR::Member::MemberOfQmlContextObject) - generateFunctionCall(result, Runtime::callQmlContextObjectProperty, + generateRuntimeCall(result, callQmlContextObjectProperty, Assembler::EngineRegister, Assembler::TrustedImm32(propertyIndex), baseAddressForCallData()); @@ -1025,12 +1025,12 @@ void InstructionSelection::callProperty(IR::Expr *base, const QString &name, IR: if (useFastLookups) { uint index = registerGetterLookup(name); - generateFunctionCall(result, Runtime::callPropertyLookup, + generateRuntimeCall(result, callPropertyLookup, Assembler::EngineRegister, Assembler::TrustedImm32(index), baseAddressForCallData()); } else { - generateFunctionCall(result, Runtime::callProperty, Assembler::EngineRegister, + generateRuntimeCall(result, callProperty, Assembler::EngineRegister, Assembler::StringToIndex(name), baseAddressForCallData()); } @@ -1042,7 +1042,7 @@ void InstructionSelection::callSubscript(IR::Expr *base, IR::Expr *index, IR::Ex Q_ASSERT(base != 0); prepareCallData(args, base); - generateFunctionCall(result, Runtime::callElement, Assembler::EngineRegister, + generateRuntimeCall(result, callElement, Assembler::EngineRegister, Assembler::PointerToValue(index), baseAddressForCallData()); } @@ -1118,7 +1118,7 @@ void InstructionSelection::convertTypeToDouble(IR::Expr *source, IR::Expr *targe Assembler::TrustedImm32(Value::NotDouble_Mask)); #endif - generateFunctionCall(target, Runtime::toDouble, Assembler::PointerToValue(source)); + generateRuntimeCall(target, toDouble, Assembler::PointerToValue(source)); Assembler::Jump noDoubleDone = _as->jump(); // it is a double: @@ -1183,7 +1183,7 @@ void InstructionSelection::convertTypeToBool(IR::Expr *source, IR::Expr *target) case IR::StringType: case IR::VarType: default: - generateFunctionCall(Assembler::ReturnValueRegister, Runtime::toBoolean, + generateRuntimeCall(Assembler::ReturnValueRegister, toBoolean, Assembler::PointerToValue(source)); _as->storeBool(Assembler::ReturnValueRegister, target); break; @@ -1215,7 +1215,7 @@ void InstructionSelection::convertTypeToSInt32(IR::Expr *source, IR::Expr *targe // not an int: fallback.link(_as); - generateFunctionCall(Assembler::ReturnValueRegister, Runtime::toInt, + generateRuntimeCall(Assembler::ReturnValueRegister, toInt, _as->loadAddress(Assembler::ScratchRegister, source)); isInt.link(_as); @@ -1253,7 +1253,7 @@ void InstructionSelection::convertTypeToSInt32(IR::Expr *source, IR::Expr *targe // not an int: fallback.link(_as); - generateFunctionCall(Assembler::ReturnValueRegister, Runtime::toInt, + generateRuntimeCall(Assembler::ReturnValueRegister, toInt, _as->loadAddress(Assembler::ScratchRegister, source)); _as->storeInt32(Assembler::ReturnValueRegister, target); @@ -1266,7 +1266,7 @@ void InstructionSelection::convertTypeToSInt32(IR::Expr *source, IR::Expr *targe _as->branchTruncateDoubleToInt32(_as->toDoubleRegister(source), Assembler::ReturnValueRegister, Assembler::BranchIfTruncateSuccessful); - generateFunctionCall(Assembler::ReturnValueRegister, Runtime::doubleToInt, + generateRuntimeCall(Assembler::ReturnValueRegister, doubleToInt, Assembler::PointerToValue(source)); success.link(_as); _as->storeInt32(Assembler::ReturnValueRegister, target); @@ -1284,7 +1284,7 @@ void InstructionSelection::convertTypeToSInt32(IR::Expr *source, IR::Expr *targe break; case IR::StringType: default: - generateFunctionCall(Assembler::ReturnValueRegister, Runtime::toInt, + generateRuntimeCall(Assembler::ReturnValueRegister, toInt, _as->loadAddress(Assembler::ScratchRegister, source)); _as->storeInt32(Assembler::ReturnValueRegister, target); break; @@ -1309,7 +1309,7 @@ void InstructionSelection::convertTypeToUInt32(IR::Expr *source, IR::Expr *targe // not an int: isNoInt.link(_as); - generateFunctionCall(Assembler::ReturnValueRegister, Runtime::toUInt, + generateRuntimeCall(Assembler::ReturnValueRegister, toUInt, _as->loadAddress(Assembler::ScratchRegister, source)); _as->storeInt32(Assembler::ReturnValueRegister, target); @@ -1320,7 +1320,7 @@ void InstructionSelection::convertTypeToUInt32(IR::Expr *source, IR::Expr *targe Assembler::Jump success = _as->branchTruncateDoubleToUint32(reg, Assembler::ReturnValueRegister, Assembler::BranchIfTruncateSuccessful); - generateFunctionCall(Assembler::ReturnValueRegister, Runtime::doubleToUInt, + generateRuntimeCall(Assembler::ReturnValueRegister, doubleToUInt, Assembler::PointerToValue(source)); success.link(_as); _as->storeUInt32(Assembler::ReturnValueRegister, target); @@ -1331,7 +1331,7 @@ void InstructionSelection::convertTypeToUInt32(IR::Expr *source, IR::Expr *targe _as->storeUInt32(Assembler::ReturnValueRegister, target); break; case IR::StringType: - generateFunctionCall(Assembler::ReturnValueRegister, Runtime::toUInt, + generateRuntimeCall(Assembler::ReturnValueRegister, toUInt, Assembler::PointerToValue(source)); _as->storeUInt32(Assembler::ReturnValueRegister, target); break; @@ -1351,13 +1351,13 @@ void InstructionSelection::constructActivationProperty(IR::Name *func, IR::ExprL if (useFastLookups && func->global) { uint index = registerGlobalGetterLookup(*func->id); - generateFunctionCall(result, Runtime::constructGlobalLookup, + generateRuntimeCall(result, constructGlobalLookup, Assembler::EngineRegister, Assembler::TrustedImm32(index), baseAddressForCallData()); return; } - generateFunctionCall(result, Runtime::constructActivationProperty, + generateRuntimeCall(result, constructActivationProperty, Assembler::EngineRegister, Assembler::StringToIndex(*func->id), baseAddressForCallData()); @@ -1369,14 +1369,14 @@ void InstructionSelection::constructProperty(IR::Expr *base, const QString &name prepareCallData(args, base); if (useFastLookups) { uint index = registerGetterLookup(name); - generateFunctionCall(result, Runtime::constructPropertyLookup, + generateRuntimeCall(result, constructPropertyLookup, Assembler::EngineRegister, Assembler::TrustedImm32(index), baseAddressForCallData()); return; } - generateFunctionCall(result, Runtime::constructProperty, Assembler::EngineRegister, + generateRuntimeCall(result, constructProperty, Assembler::EngineRegister, Assembler::StringToIndex(name), baseAddressForCallData()); } @@ -1386,7 +1386,7 @@ void InstructionSelection::constructValue(IR::Expr *value, IR::ExprList *args, I Q_ASSERT(value != 0); prepareCallData(args, 0); - generateFunctionCall(result, Runtime::constructValue, + generateRuntimeCall(result, constructValue, Assembler::EngineRegister, Assembler::Reference(value), baseAddressForCallData()); @@ -1422,7 +1422,7 @@ void InstructionSelection::visitCJump(IR::CJump *s) booleanConversion.link(_as); reg = Assembler::ReturnValueRegister; - generateFunctionCall(reg, Runtime::toBoolean, Assembler::Reference(s->cond)); + generateRuntimeCall(reg, toBoolean, Assembler::Reference(s->cond)); testBoolean.link(_as); } @@ -1432,7 +1432,7 @@ void InstructionSelection::visitCJump(IR::CJump *s) } else if (IR::Const *c = s->cond->asConst()) { // TODO: SSA optimization for constant condition evaluation should remove this. // See also visitCJump() in RegAllocInfo. - generateFunctionCall(Assembler::ReturnValueRegister, Runtime::toBoolean, + generateRuntimeCall(Assembler::ReturnValueRegister, toBoolean, Assembler::PointerToValue(c)); _as->generateCJumpOnNonZero(Assembler::ReturnValueRegister, _block, s->iftrue, s->iffalse); return; @@ -1454,8 +1454,8 @@ void InstructionSelection::visitCJump(IR::CJump *s) return; } - Runtime::CompareOperation op = 0; - Runtime::CompareOperationContext opContext = 0; + RuntimeCall op; + RuntimeCall opContext; const char *opName = 0; switch (b->op) { default: Q_UNREACHABLE(); Q_ASSERT(!"todo"); break; @@ -1476,7 +1476,7 @@ void InstructionSelection::visitCJump(IR::CJump *s) // if (true === true) ..... // Of course, after folding the CJUMP to a JUMP, dead-code (dead-basic-block) // elimination (which isn't there either) would remove the whole else block. - if (opContext) + if (opContext.isValid()) _as->generateFunctionCallImp(Assembler::ReturnValueRegister, opName, opContext, Assembler::EngineRegister, Assembler::PointerToValue(b->left), @@ -1800,7 +1800,7 @@ void InstructionSelection::visitCJumpStrict(IR::Binop *binop, IR::BasicBlock *tr IR::Expr *left = binop->left; IR::Expr *right = binop->right; - _as->generateFunctionCallImp(Assembler::ReturnValueRegister, "Runtime::compareStrictEqual", Runtime::compareStrictEqual, + generateRuntimeCall(Assembler::ReturnValueRegister, compareStrictEqual, Assembler::PointerToValue(left), Assembler::PointerToValue(right)); _as->generateCJumpOnCompare(binop->op == IR::OpStrictEqual ? Assembler::NotEqual : Assembler::Equal, Assembler::ReturnValueRegister, Assembler::TrustedImm32(0), @@ -1954,7 +1954,7 @@ void InstructionSelection::visitCJumpEqual(IR::Binop *binop, IR::BasicBlock *tru IR::Expr *left = binop->left; IR::Expr *right = binop->right; - _as->generateFunctionCallImp(Assembler::ReturnValueRegister, "Runtime::compareEqual", Runtime::compareEqual, + generateRuntimeCall(Assembler::ReturnValueRegister, compareEqual, Assembler::PointerToValue(left), Assembler::PointerToValue(right)); _as->generateCJumpOnCompare(binop->op == IR::OpEqual ? Assembler::NotEqual : Assembler::Equal, Assembler::ReturnValueRegister, Assembler::TrustedImm32(0), diff --git a/src/qml/jit/qv4isel_masm_p.h b/src/qml/jit/qv4isel_masm_p.h index 366d510072..a92196f5f7 100644 --- a/src/qml/jit/qv4isel_masm_p.h +++ b/src/qml/jit/qv4isel_masm_p.h @@ -244,8 +244,8 @@ private: #define isel_stringIfyx(s) #s #define isel_stringIfy(s) isel_stringIfyx(s) - #define generateFunctionCall(t, function, ...) \ - _as->generateFunctionCallImp(t, isel_stringIfy(function), function, __VA_ARGS__) + #define generateRuntimeCall(t, function, ...) \ + _as->generateFunctionCallImp(t, "Runtime::" isel_stringIfy(function), RuntimeCall(qOffsetOf(QV4::Runtime, function)), __VA_ARGS__) int prepareVariableArguments(IR::ExprList* args); int prepareCallData(IR::ExprList* args, IR::Expr *thisObject); diff --git a/src/qml/jit/qv4unop.cpp b/src/qml/jit/qv4unop.cpp index cb9131d731..6a32069ac4 100644 --- a/src/qml/jit/qv4unop.cpp +++ b/src/qml/jit/qv4unop.cpp @@ -47,11 +47,11 @@ using namespace JIT; #define stringIfyx(s) #s #define stringIfy(s) stringIfyx(s) #define setOp(operation) \ - do { call = operation; name = stringIfy(operation); } while (0) + do { call = RuntimeCall(qOffsetOf(QV4::Runtime, operation)); name = "Runtime::" stringIfy(operation); } while (0) void Unop::generate(IR::Expr *source, IR::Expr *target) { - Runtime::UnaryOperation call = 0; + RuntimeCall call; const char *name = 0; switch (op) { case IR::OpNot: @@ -60,19 +60,18 @@ void Unop::generate(IR::Expr *source, IR::Expr *target) case IR::OpUMinus: generateUMinus(source, target); return; - case IR::OpUPlus: setOp(Runtime::uPlus); break; + case IR::OpUPlus: setOp(uPlus); break; case IR::OpCompl: generateCompl(source, target); return; - case IR::OpIncrement: setOp(Runtime::increment); break; - case IR::OpDecrement: setOp(Runtime::decrement); break; + case IR::OpIncrement: setOp(increment); break; + case IR::OpDecrement: setOp(decrement); break; default: Q_UNREACHABLE(); } // switch - if (call) { - as->generateFunctionCallImp(target, name, call, Assembler::PointerToValue(source)); - } + Q_ASSERT(call.isValid()); + _as->generateFunctionCallImp(target, name, call, Assembler::PointerToValue(source)); } void Unop::generateUMinus(IR::Expr *source, IR::Expr *target) @@ -82,15 +81,15 @@ void Unop::generateUMinus(IR::Expr *source, IR::Expr *target) Assembler::RegisterID tReg = Assembler::ScratchRegister; if (targetTemp && targetTemp->kind == IR::Temp::PhysicalRegister) tReg = (Assembler::RegisterID) targetTemp->index; - Assembler::RegisterID sReg = as->toInt32Register(source, tReg); - as->move(sReg, tReg); - as->neg32(tReg); + Assembler::RegisterID sReg = _as->toInt32Register(source, tReg); + _as->move(sReg, tReg); + _as->neg32(tReg); if (!targetTemp || targetTemp->kind != IR::Temp::PhysicalRegister) - as->storeInt32(tReg, target); + _as->storeInt32(tReg, target); return; } - as->generateFunctionCallImp(target, "Runtime::uMinus", Runtime::uMinus, Assembler::PointerToValue(source)); + generateRuntimeCall(target, uMinus, Assembler::PointerToValue(source)); } void Unop::generateNot(IR::Expr *source, IR::Expr *target) @@ -100,26 +99,26 @@ void Unop::generateNot(IR::Expr *source, IR::Expr *target) Assembler::RegisterID tReg = Assembler::ScratchRegister; if (targetTemp && targetTemp->kind == IR::Temp::PhysicalRegister) tReg = (Assembler::RegisterID) targetTemp->index; - as->xor32(Assembler::TrustedImm32(0x1), as->toInt32Register(source, tReg), tReg); + _as->xor32(Assembler::TrustedImm32(0x1), _as->toInt32Register(source, tReg), tReg); if (!targetTemp || targetTemp->kind != IR::Temp::PhysicalRegister) - as->storeBool(tReg, target); + _as->storeBool(tReg, target); return; } else if (source->type == IR::SInt32Type) { Assembler::RegisterID tReg = Assembler::ScratchRegister; if (targetTemp && targetTemp->kind == IR::Temp::PhysicalRegister) tReg = (Assembler::RegisterID) targetTemp->index; - as->compare32(Assembler::Equal, - as->toInt32Register(source, Assembler::ScratchRegister), Assembler::TrustedImm32(0), + _as->compare32(Assembler::Equal, + _as->toInt32Register(source, Assembler::ScratchRegister), Assembler::TrustedImm32(0), tReg); if (!targetTemp || targetTemp->kind != IR::Temp::PhysicalRegister) - as->storeBool(tReg, target); + _as->storeBool(tReg, target); return; } else if (source->type == IR::DoubleType) { // ### } // ## generic implementation testing for int/bool - as->generateFunctionCallImp(target, "Runtime::uNot", Runtime::uNot, Assembler::PointerToValue(source)); + generateRuntimeCall(target, uNot, Assembler::PointerToValue(source)); } void Unop::generateCompl(IR::Expr *source, IR::Expr *target) @@ -129,12 +128,12 @@ void Unop::generateCompl(IR::Expr *source, IR::Expr *target) Assembler::RegisterID tReg = Assembler::ScratchRegister; if (targetTemp && targetTemp->kind == IR::Temp::PhysicalRegister) tReg = (Assembler::RegisterID) targetTemp->index; - as->xor32(Assembler::TrustedImm32(0xffffffff), as->toInt32Register(source, tReg), tReg); + _as->xor32(Assembler::TrustedImm32(0xffffffff), _as->toInt32Register(source, tReg), tReg); if (!targetTemp || targetTemp->kind != IR::Temp::PhysicalRegister) - as->storeInt32(tReg, target); + _as->storeInt32(tReg, target); return; } - as->generateFunctionCallImp(target, "Runtime::complement", Runtime::complement, Assembler::PointerToValue(source)); + generateRuntimeCall(target, complement, Assembler::PointerToValue(source)); } #endif diff --git a/src/qml/jit/qv4unop_p.h b/src/qml/jit/qv4unop_p.h index f0b5b9c223..1141a84913 100644 --- a/src/qml/jit/qv4unop_p.h +++ b/src/qml/jit/qv4unop_p.h @@ -64,7 +64,7 @@ class Assembler; struct Unop { Unop(Assembler *assembler, IR::AluOp operation) - : as(assembler) + : _as(assembler) , op(operation) {} @@ -74,7 +74,7 @@ struct Unop { void generateNot(IR::Expr *source, IR::Expr *target); void generateCompl(IR::Expr *source, IR::Expr *target); - Assembler *as; + Assembler *_as; IR::AluOp op; }; diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp index e369842252..edb23d94db 100644 --- a/src/qml/jsapi/qjsvalue.cpp +++ b/src/qml/jsapi/qjsvalue.cpp @@ -938,7 +938,7 @@ bool QJSValue::equals(const QJSValue& other) const if (!ov) return other.equals(*this); - return Runtime::compareEqual(*v, *ov); + return Runtime::method_compareEqual(*v, *ov); } /*! diff --git a/src/qml/jsruntime/jsruntime.pri b/src/qml/jsruntime/jsruntime.pri index c61e848bd7..6ef92511e2 100644 --- a/src/qml/jsruntime/jsruntime.pri +++ b/src/qml/jsruntime/jsruntime.pri @@ -49,6 +49,7 @@ HEADERS += \ $$PWD/qv4global_p.h \ $$PWD/qv4engine_p.h \ $$PWD/qv4context_p.h \ + $$PWD/qv4context_p_p.h \ $$PWD/qv4math_p.h \ $$PWD/qv4persistent_p.h \ $$PWD/qv4debugging_p.h \ @@ -98,6 +99,7 @@ HEADERS += \ HEADERS += \ $$PWD/qv4runtime_p.h \ + $$PWD/qv4runtimeapi_p.h \ $$PWD/qv4value_p.h \ $$PWD/qv4string_p.h \ $$PWD/qv4value_p.h diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp index 728ee38e76..73aa7047b8 100644 --- a/src/qml/jsruntime/qv4arraydata.cpp +++ b/src/qml/jsruntime/qv4arraydata.cpp @@ -676,7 +676,7 @@ bool ArrayElementLessThan::operator()(Value v1, Value v2) const callData->thisObject = Primitive::undefinedValue(); callData->args[0] = v1; callData->args[1] = v2; - result = Runtime::callValue(scope.engine, m_comparefn, callData); + result = scope.engine->runtime.callValue(scope.engine, m_comparefn, callData); return result->toNumber() < 0; } diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index 18983eb832..97b3e26a26 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -39,7 +39,7 @@ #include <QString> #include "qv4debugging_p.h" -#include <qv4context_p.h> +#include <qv4context_p_p.h> #include <qv4object_p.h> #include <qv4objectproto_p.h> #include <private/qv4mm_p.h> @@ -47,7 +47,6 @@ #include "qv4function_p.h" #include "qv4errorobject_p.h" #include "qv4string_p.h" -#include "private/qqmlcontextwrapper_p.h" using namespace QV4; @@ -574,19 +573,3 @@ Heap::FunctionObject *ExecutionContext::getFunctionObject() const return 0; } - - -QObject *QmlContext::qmlScope() const -{ - return d()->qml->scopeObject; -} - -QQmlContextData *QmlContext::qmlContext() const -{ - return d()->qml->context; -} - -void QmlContext::takeContextOwnership() { - d()->qml->ownsContext = true; -} - diff --git a/src/qml/qml/ftw/qhashfield_p.h b/src/qml/jsruntime/qv4context_p_p.h index 15114239eb..0da9f678ed 100644 --- a/src/qml/qml/ftw/qhashfield_p.h +++ b/src/qml/jsruntime/qv4context_p_p.h @@ -36,9 +36,8 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - -#ifndef QHASHFIELD_P_H -#define QHASHFIELD_P_H +#ifndef QV4CONTEXT_P_P_H +#define QV4CONTEXT_P_P_H // // W A R N I N G @@ -51,68 +50,34 @@ // We mean it. // +// This header defines a couple of inlinable methods. +// These implementation cannot be put in qv4context_p.h, because they rely on the +// QQmlContextWrapper, which in turn is a QV4::Object subclass (so it includes qv4object_p.h), +// which includes qv4engine_p.h, that needs to include qv4context_p.h -#include <QtCore/qglobal.h> +#include "qv4context_p.h" +#include "private/qqmlcontextwrapper_p.h" QT_BEGIN_NAMESPACE -// QHashField can be used for doing coarse grained set testing, in -// cases where you do not expect the set to contain the item. For -// example where you would write: -// QSet<QString> strings; -// for (int ii = 0; ii < mystrings.count(); ++ii) { -// if (strings.contains(mystrings.at(ii))) -// qFatal("Duplication!"); -// strings.insert(mystrings); -// } -// You may write: -// QHashField strings; -// for (int ii = 0; ii < mystrings.count(); ++ii) { -// if (strings.testAndSet(qHash(mystrings.at(ii)))) { -// // The string *might* be duplicated -// for (int jj = 0; jj < ii; ++jj) { -// if (mystrings.at(ii) == mystrings.at(jj)) -// qFatal("Duplication!"); -// } -// } -// } -// For small lists of things, where the hash is cheap to calculate -// and you don't expect duplication this will be much faster. -class QHashField { -public: - inline QHashField(); - - inline void clear(); - - inline bool test(quint32 hash); - inline bool testAndSet(quint32 hash); -private: - quint32 m_field; -}; +namespace QV4 { -QHashField::QHashField() -: m_field(0) +QObject *QmlContext::qmlScope() const { + return d()->qml->scopeObject; } -void QHashField::clear() +QQmlContextData *QmlContext::qmlContext() const { - m_field = 0; + return d()->qml->context; } -bool QHashField::test(quint32 hash) -{ - return m_field & (1 << (hash % 31)); +void QmlContext::takeContextOwnership() { + d()->qml->ownsContext = true; } -bool QHashField::testAndSet(quint32 hash) -{ - quint32 mask = 1 << (hash % 31); - bool rv = m_field & mask; - m_field |= mask; - return rv; -} +} // QV4 namespace QT_END_NAMESPACE -#endif // QHASHFIELD_P_H +#endif // QV4CONTEXT_P_P_H diff --git a/src/qml/jsruntime/qv4dataview.cpp b/src/qml/jsruntime/qv4dataview.cpp index b4422bcdc6..f296ffd71e 100644 --- a/src/qml/jsruntime/qv4dataview.cpp +++ b/src/qml/jsruntime/qv4dataview.cpp @@ -41,6 +41,7 @@ #include "qv4arraybuffer_p.h" #include "qv4string_p.h" +#include <QtCore/private/qnumeric_p.h> #include "qendian.h" using namespace QV4; @@ -291,7 +292,7 @@ ReturnedValue DataViewPrototype::method_setFloat(CallContext *ctx) return scope.engine->throwTypeError(); idx += v->d()->byteOffset; - double val = ctx->argc() >= 2 ? ctx->args()[1].toNumber() : qQNaN(); + double val = ctx->argc() >= 2 ? ctx->args()[1].toNumber() : qt_qnan(); bool littleEndian = ctx->argc() < 3 ? false : ctx->args()[2].toBoolean(); if (sizeof(T) == 4) { diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index 7051d5c3a5..5783e8fa2b 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -204,7 +204,7 @@ static inline double MonthFromTime(double t) else if (d < 365.0 + l) return 11; - return qQNaN(); // ### assert? + return qt_qnan(); // ### assert? } static inline double DateFromTime(double t) @@ -228,7 +228,7 @@ static inline double DateFromTime(double t) case 11: return d - 333.0 - l; } - return qQNaN(); // ### assert + return qt_qnan(); // ### assert } static inline double WeekDay(double t) @@ -260,7 +260,7 @@ static inline double DayFromMonth(double month, double leap) case 11: return 334.0 + leap; } - return qQNaN(); // ### assert? + return qt_qnan(); // ### assert? } static double MakeDay(double year, double month, double day) @@ -339,7 +339,7 @@ static inline double currentTime() static inline double TimeClip(double t) { if (! qIsFinite(t) || fabs(t) > 8.64e15) - return qQNaN(); + return qt_qnan(); return Primitive::toInteger(t); } @@ -466,7 +466,7 @@ static inline double ParseString(const QString &s) if (format < Minute || format >= TimezoneHour) error = true; format = TimezoneHour; - } else if (*ch == 'Z' || *ch == 0) { + } else if (*ch == 'Z' || ch->unicode() == 0) { format = Done; } current = 0; @@ -544,7 +544,7 @@ static inline double ParseString(const QString &s) } } if (!dt.isValid()) - return qQNaN(); + return qt_qnan(); return dt.toMSecsSinceEpoch(); } @@ -636,7 +636,7 @@ DEFINE_OBJECT_VTABLE(DateObject); Heap::DateObject::DateObject(const QDateTime &date) { - this->date = date.isValid() ? date.toMSecsSinceEpoch() : qQNaN(); + this->date = date.isValid() ? date.toMSecsSinceEpoch() : qt_qnan(); } QDateTime DateObject::toQDateTime() const @@ -770,7 +770,7 @@ double DatePrototype::getThisDate(ExecutionContext *ctx) ReturnedValue DatePrototype::method_parse(CallContext *ctx) { if (!ctx->argc()) - return Encode(qQNaN()); + return Encode(qt_qnan()); return Encode(ParseString(ctx->args()[0].toQString())); } @@ -1000,7 +1000,7 @@ ReturnedValue DatePrototype::method_setTime(CallContext *ctx) if (!self) return ctx->engine()->throwTypeError(); - double t = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double t = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); self->setDate(TimeClip(t)); return Encode(self->date()); } @@ -1013,7 +1013,7 @@ ReturnedValue DatePrototype::method_setMilliseconds(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = LocalTime(self->date()); - double ms = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double ms = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); self->setDate(TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), ms))))); return Encode(self->date()); } @@ -1025,7 +1025,7 @@ ReturnedValue DatePrototype::method_setUTCMilliseconds(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = self->date(); - double ms = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double ms = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); self->setDate(TimeClip(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), ms)))); return Encode(self->date()); } @@ -1037,7 +1037,7 @@ ReturnedValue DatePrototype::method_setSeconds(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = LocalTime(self->date()); - double sec = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double sec = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double ms = (ctx->argc() < 2) ? msFromTime(t) : ctx->args()[1].toNumber(); t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), sec, ms)))); self->setDate(t); @@ -1051,7 +1051,7 @@ ReturnedValue DatePrototype::method_setUTCSeconds(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = self->date(); - double sec = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double sec = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double ms = (ctx->argc() < 2) ? msFromTime(t) : ctx->args()[1].toNumber(); t = TimeClip(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), sec, ms))); self->setDate(t); @@ -1065,7 +1065,7 @@ ReturnedValue DatePrototype::method_setMinutes(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = LocalTime(self->date()); - double min = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double min = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double sec = (ctx->argc() < 2) ? SecFromTime(t) : ctx->args()[1].toNumber(); double ms = (ctx->argc() < 3) ? msFromTime(t) : ctx->args()[2].toNumber(); t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), min, sec, ms)))); @@ -1080,7 +1080,7 @@ ReturnedValue DatePrototype::method_setUTCMinutes(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = self->date(); - double min = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double min = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double sec = (ctx->argc() < 2) ? SecFromTime(t) : ctx->args()[1].toNumber(); double ms = (ctx->argc() < 3) ? msFromTime(t) : ctx->args()[2].toNumber(); t = TimeClip(MakeDate(Day(t), MakeTime(HourFromTime(t), min, sec, ms))); @@ -1095,7 +1095,7 @@ ReturnedValue DatePrototype::method_setHours(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = LocalTime(self->date()); - double hour = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double hour = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double min = (ctx->argc() < 2) ? MinFromTime(t) : ctx->args()[1].toNumber(); double sec = (ctx->argc() < 3) ? SecFromTime(t) : ctx->args()[2].toNumber(); double ms = (ctx->argc() < 4) ? msFromTime(t) : ctx->args()[3].toNumber(); @@ -1111,7 +1111,7 @@ ReturnedValue DatePrototype::method_setUTCHours(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = self->date(); - double hour = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double hour = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double min = (ctx->argc() < 2) ? MinFromTime(t) : ctx->args()[1].toNumber(); double sec = (ctx->argc() < 3) ? SecFromTime(t) : ctx->args()[2].toNumber(); double ms = (ctx->argc() < 4) ? msFromTime(t) : ctx->args()[3].toNumber(); @@ -1127,7 +1127,7 @@ ReturnedValue DatePrototype::method_setDate(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = LocalTime(self->date()); - double date = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double date = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), date), TimeWithinDay(t)))); self->setDate(t); return Encode(self->date()); @@ -1140,7 +1140,7 @@ ReturnedValue DatePrototype::method_setUTCDate(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = self->date(); - double date = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double date = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); t = TimeClip(MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), date), TimeWithinDay(t))); self->setDate(t); return Encode(self->date()); @@ -1153,7 +1153,7 @@ ReturnedValue DatePrototype::method_setMonth(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = LocalTime(self->date()); - double month = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double month = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double date = (ctx->argc() < 2) ? DateFromTime(t) : ctx->args()[1].toNumber(); t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), month, date), TimeWithinDay(t)))); self->setDate(t); @@ -1167,7 +1167,7 @@ ReturnedValue DatePrototype::method_setUTCMonth(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = self->date(); - double month = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double month = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double date = (ctx->argc() < 2) ? DateFromTime(t) : ctx->args()[1].toNumber(); t = TimeClip(MakeDate(MakeDay(YearFromTime(t), month, date), TimeWithinDay(t))); self->setDate(t); @@ -1185,10 +1185,10 @@ ReturnedValue DatePrototype::method_setYear(CallContext *ctx) t = 0; else t = LocalTime(t); - double year = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double year = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double r; if (std::isnan(year)) { - r = qQNaN(); + r = qt_qnan(); } else { if ((Primitive::toInteger(year) >= 0) && (Primitive::toInteger(year) <= 99)) year += 1900; @@ -1207,7 +1207,7 @@ ReturnedValue DatePrototype::method_setUTCFullYear(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = self->date(); - double year = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double year = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double month = (ctx->argc() < 2) ? MonthFromTime(t) : ctx->args()[1].toNumber(); double date = (ctx->argc() < 3) ? DateFromTime(t) : ctx->args()[2].toNumber(); t = TimeClip(MakeDate(MakeDay(year, month, date), TimeWithinDay(t))); @@ -1224,7 +1224,7 @@ ReturnedValue DatePrototype::method_setFullYear(CallContext *ctx) double t = LocalTime(self->date()); if (std::isnan(t)) t = 0; - double year = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double year = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double month = (ctx->argc() < 2) ? MonthFromTime(t) : ctx->args()[1].toNumber(); double date = (ctx->argc() < 3) ? DateFromTime(t) : ctx->args()[2].toNumber(); t = TimeClip(UTC(MakeDate(MakeDay(year, month, date), TimeWithinDay(t)))); diff --git a/src/qml/jsruntime/qv4dateobject_p.h b/src/qml/jsruntime/qv4dateobject_p.h index edf5d625fd..e3615d76a7 100644 --- a/src/qml/jsruntime/qv4dateobject_p.h +++ b/src/qml/jsruntime/qv4dateobject_p.h @@ -52,7 +52,7 @@ #include "qv4object_p.h" #include "qv4functionobject_p.h" -#include <QtCore/qnumeric.h> +#include <QtCore/private/qnumeric_p.h> QT_BEGIN_NAMESPACE @@ -65,7 +65,7 @@ namespace Heap { struct DateObject : Object { DateObject() { - date = qQNaN(); + date = qt_qnan(); } DateObject(const Value &date) diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index 7da4a1c3c1..57a5952a6d 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -55,6 +55,7 @@ #include "qv4managed_p.h" #include "qv4context_p.h" #include "qv4internalclass_p.h" +#include "qv4runtimeapi_p.h" #include <private/qintrusivelist_p.h> namespace WTF { @@ -109,6 +110,8 @@ public: Value *jsStackLimit; quintptr cStackLimit; + Runtime runtime; + WTF::BumpPointerAllocator *bumperPointerAllocator; // Used by Yarr Regex engine. enum { JSStackLimit = 4*1024*1024 }; @@ -473,6 +476,13 @@ public: void assertObjectBelongsToEngine(const Heap::Base &baseObject); }; +// This is a trick to tell the code generators that functions taking a NoThrowContext won't +// throw exceptions and therefore don't need a check after the call. +struct NoThrowEngine : public ExecutionEngine +{ +}; + + inline void ExecutionEngine::pushContext(Heap::ExecutionContext *context) { Q_ASSERT(currentContext && context); diff --git a/src/qml/jsruntime/qv4mathobject.cpp b/src/qml/jsruntime/qv4mathobject.cpp index 8c5e7d8be1..4a304b6138 100644 --- a/src/qml/jsruntime/qv4mathobject.cpp +++ b/src/qml/jsruntime/qv4mathobject.cpp @@ -42,7 +42,7 @@ #include <QtCore/qdatetime.h> #include <QtCore/qmath.h> -#include <QtCore/qnumeric.h> +#include <QtCore/private/qnumeric_p.h> #include <QtCore/qthreadstorage.h> #include <cmath> @@ -100,7 +100,7 @@ static double copySign(double x, double y) ReturnedValue MathObject::method_abs(CallContext *context) { if (!context->argc()) - return Encode(qQNaN()); + return Encode(qt_qnan()); if (context->args()[0].isInteger()) { int i = context->args()[0].integerValue(); @@ -118,7 +118,7 @@ ReturnedValue MathObject::method_acos(CallContext *context) { double v = context->argc() ? context->args()[0].toNumber() : 2; if (v > 1) - return Encode(qQNaN()); + return Encode(qt_qnan()); return Encode(std::acos(v)); } @@ -127,14 +127,14 @@ ReturnedValue MathObject::method_asin(CallContext *context) { double v = context->argc() ? context->args()[0].toNumber() : 2; if (v > 1) - return Encode(qQNaN()); + return Encode(qt_qnan()); else return Encode(std::asin(v)); } ReturnedValue MathObject::method_atan(CallContext *context) { - double v = context->argc() ? context->args()[0].toNumber() : qQNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qt_qnan(); if (v == 0.0) return Encode(v); else @@ -143,10 +143,10 @@ ReturnedValue MathObject::method_atan(CallContext *context) ReturnedValue MathObject::method_atan2(CallContext *context) { - double v1 = context->argc() ? context->args()[0].toNumber() : qQNaN(); - double v2 = context->argc() > 1 ? context->args()[1].toNumber() : qQNaN(); + double v1 = context->argc() ? context->args()[0].toNumber() : qt_qnan(); + double v2 = context->argc() > 1 ? context->args()[1].toNumber() : qt_qnan(); - if ((v1 < 0) && qIsFinite(v1) && qIsInf(v2) && (copySign(1.0, v2) == 1.0)) + if ((v1 < 0) && qt_is_finite(v1) && qt_is_inf(v2) && (copySign(1.0, v2) == 1.0)) return Encode(copySign(0, -1.0)); if ((v1 == 0.0) && (v2 == 0.0)) { @@ -161,7 +161,7 @@ ReturnedValue MathObject::method_atan2(CallContext *context) ReturnedValue MathObject::method_ceil(CallContext *context) { - double v = context->argc() ? context->args()[0].toNumber() : qQNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qt_qnan(); if (v < 0.0 && v > -1.0) return Encode(copySign(0, -1.0)); else @@ -170,18 +170,18 @@ ReturnedValue MathObject::method_ceil(CallContext *context) ReturnedValue MathObject::method_cos(CallContext *context) { - double v = context->argc() ? context->args()[0].toNumber() : qQNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qt_qnan(); return Encode(std::cos(v)); } ReturnedValue MathObject::method_exp(CallContext *context) { - double v = context->argc() ? context->args()[0].toNumber() : qQNaN(); - if (qIsInf(v)) { + double v = context->argc() ? context->args()[0].toNumber() : qt_qnan(); + if (qt_is_inf(v)) { if (copySign(1.0, v) == -1.0) return Encode(0); else - return Encode(qInf()); + return Encode(qt_inf()); } else { return Encode(std::exp(v)); } @@ -189,22 +189,22 @@ ReturnedValue MathObject::method_exp(CallContext *context) ReturnedValue MathObject::method_floor(CallContext *context) { - double v = context->argc() ? context->args()[0].toNumber() : qQNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qt_qnan(); return Encode(std::floor(v)); } ReturnedValue MathObject::method_log(CallContext *context) { - double v = context->argc() ? context->args()[0].toNumber() : qQNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qt_qnan(); if (v < 0) - return Encode(qQNaN()); + return Encode(qt_qnan()); else return Encode(std::log(v)); } ReturnedValue MathObject::method_max(CallContext *context) { - double mx = -qInf(); + double mx = -qt_inf(); for (int i = 0; i < context->argc(); ++i) { double x = context->args()[i].toNumber(); if (x > mx || std::isnan(x)) @@ -215,7 +215,7 @@ ReturnedValue MathObject::method_max(CallContext *context) ReturnedValue MathObject::method_min(CallContext *context) { - double mx = qInf(); + double mx = qt_inf(); for (int i = 0; i < context->argc(); ++i) { double x = context->args()[i].toNumber(); if ((x == 0 && mx == x && copySign(1.0, x) == -1.0) @@ -228,24 +228,24 @@ ReturnedValue MathObject::method_min(CallContext *context) ReturnedValue MathObject::method_pow(CallContext *context) { - double x = context->argc() > 0 ? context->args()[0].toNumber() : qQNaN(); - double y = context->argc() > 1 ? context->args()[1].toNumber() : qQNaN(); + double x = context->argc() > 0 ? context->args()[0].toNumber() : qt_qnan(); + double y = context->argc() > 1 ? context->args()[1].toNumber() : qt_qnan(); if (std::isnan(y)) - return Encode(qQNaN()); + return Encode(qt_qnan()); if (y == 0) { return Encode(1); } else if (((x == 1) || (x == -1)) && std::isinf(y)) { - return Encode(qQNaN()); + return Encode(qt_qnan()); } else if (((x == 0) && copySign(1.0, x) == 1.0) && (y < 0)) { return Encode(qInf()); } else if ((x == 0) && copySign(1.0, x) == -1.0) { if (y < 0) { if (std::fmod(-y, 2.0) == 1.0) - return Encode(-qInf()); + return Encode(-qt_inf()); else - return Encode(qInf()); + return Encode(qt_inf()); } else if (y > 0) { if (std::fmod(y, 2.0) == 1.0) return Encode(copySign(0, -1.0)); @@ -255,12 +255,12 @@ ReturnedValue MathObject::method_pow(CallContext *context) } #ifdef Q_OS_AIX - else if (qIsInf(x) && copySign(1.0, x) == -1.0) { + else if (qt_is_inf(x) && copySign(1.0, x) == -1.0) { if (y > 0) { if (std::fmod(y, 2.0) == 1.0) - return Encode(-qInf()); + return Encode(-qt_inf()); else - return Encode(qInf()); + return Encode(qt_inf()); } else if (y < 0) { if (std::fmod(-y, 2.0) == 1.0) return Encode(copySign(0, -1.0)); @@ -273,7 +273,7 @@ ReturnedValue MathObject::method_pow(CallContext *context) return Encode(std::pow(x, y)); } // ### - return Encode(qQNaN()); + return Encode(qt_qnan()); } Q_GLOBAL_STATIC(QThreadStorage<bool *>, seedCreatedStorage); @@ -294,26 +294,26 @@ ReturnedValue MathObject::method_random(CallContext *context) ReturnedValue MathObject::method_round(CallContext *context) { - double v = context->argc() ? context->args()[0].toNumber() : qQNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qt_qnan(); v = copySign(std::floor(v + 0.5), v); return Encode(v); } ReturnedValue MathObject::method_sin(CallContext *context) { - double v = context->argc() ? context->args()[0].toNumber() : qQNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qt_qnan(); return Encode(std::sin(v)); } ReturnedValue MathObject::method_sqrt(CallContext *context) { - double v = context->argc() ? context->args()[0].toNumber() : qQNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qt_qnan(); return Encode(std::sqrt(v)); } ReturnedValue MathObject::method_tan(CallContext *context) { - double v = context->argc() ? context->args()[0].toNumber() : qQNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qt_qnan(); if (v == 0.0) return Encode(v); else diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp index 5cf7dbebd8..ab3e03b183 100644 --- a/src/qml/jsruntime/qv4numberobject.cpp +++ b/src/qml/jsruntime/qv4numberobject.cpp @@ -95,7 +95,7 @@ void NumberPrototype::init(ExecutionEngine *engine, Object *ctor) ctor->defineReadonlyProperty(engine->id_prototype(), (o = this)); ctor->defineReadonlyProperty(engine->id_length(), Primitive::fromInt32(1)); - ctor->defineReadonlyProperty(QStringLiteral("NaN"), Primitive::fromDouble(qQNaN())); + ctor->defineReadonlyProperty(QStringLiteral("NaN"), Primitive::fromDouble(qt_qnan())); ctor->defineReadonlyProperty(QStringLiteral("NEGATIVE_INFINITY"), Primitive::fromDouble(-qInf())); ctor->defineReadonlyProperty(QStringLiteral("POSITIVE_INFINITY"), Primitive::fromDouble(qInf())); ctor->defineReadonlyProperty(QStringLiteral("MAX_VALUE"), Primitive::fromDouble(1.7976931348623158e+308)); @@ -149,7 +149,7 @@ ReturnedValue NumberPrototype::method_toString(CallContext *ctx) if (std::isnan(num)) { return scope.engine->newString(QStringLiteral("NaN"))->asReturnedValue(); - } else if (qIsInf(num)) { + } else if (qt_is_inf(num)) { return scope.engine->newString(QLatin1String(num < 0 ? "-Infinity" : "Infinity"))->asReturnedValue(); } @@ -223,7 +223,7 @@ ReturnedValue NumberPrototype::method_toFixed(CallContext *ctx) QString str; if (std::isnan(v)) str = QStringLiteral("NaN"); - else if (qIsInf(v)) + else if (qt_is_inf(v)) str = QString::fromLatin1(v < 0 ? "-Infinity" : "Infinity"); else if (v < 1.e21) str = NumberLocale::instance()->toString(v, 'f', int(fdigits)); diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 470791fb00..fca218d9d0 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -1591,12 +1591,6 @@ void CallArgument::fromValue(int callType, QV4::ExecutionEngine *engine, const Q else qstringPtr = new (&allocData) QString(value.toQStringNoThrow()); type = callType; - } else if (callType == QMetaType::QByteArray) { - if (const ArrayBuffer *ab = value.as<ArrayBuffer>()) - qbyteArrayPtr = new (&allocData) QByteArray(ab->asByteArray()); - else - qbyteArrayPtr = new (&allocData) QByteArray(); - type = callType; } else if (callType == QMetaType::QObjectStar) { qobjectPtr = 0; if (const QV4::QObjectWrapper *qobjectWrapper = value.as<QV4::QObjectWrapper>()) diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 373e7fc8de..2abe6eeb06 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -225,7 +225,7 @@ void RuntimeHelpers::numberToString(QString *result, double num, int radix) if (std::isnan(num)) { *result = QStringLiteral("NaN"); return; - } else if (qIsInf(num)) { + } else if (qt_is_inf(num)) { *result = num < 0 ? QStringLiteral("-Infinity") : QStringLiteral("Infinity"); return; } @@ -297,14 +297,14 @@ void RuntimeHelpers::numberToString(QString *result, double num, int radix) result->prepend(QLatin1Char('-')); } -ReturnedValue Runtime::closure(ExecutionEngine *engine, int functionId) +ReturnedValue Runtime::method_closure(ExecutionEngine *engine, int functionId) { QV4::Function *clos = engine->current->compilationUnit->runtimeFunctions[functionId]; Q_ASSERT(clos); return FunctionObject::createScriptFunction(engine->currentContext, clos)->asReturnedValue(); } -ReturnedValue Runtime::deleteElement(ExecutionEngine *engine, const Value &base, const Value &index) +ReturnedValue Runtime::method_deleteElement(ExecutionEngine *engine, const Value &base, const Value &index) { Scope scope(engine); ScopedObject o(scope, base); @@ -316,17 +316,17 @@ ReturnedValue Runtime::deleteElement(ExecutionEngine *engine, const Value &base, } ScopedString name(scope, index.toString(engine)); - return Runtime::deleteMemberString(engine, base, name); + return method_deleteMemberString(engine, base, name); } -ReturnedValue Runtime::deleteMember(ExecutionEngine *engine, const Value &base, int nameIndex) +ReturnedValue Runtime::method_deleteMember(ExecutionEngine *engine, const Value &base, int nameIndex) { Scope scope(engine); ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]); - return deleteMemberString(engine, base, name); + return method_deleteMemberString(engine, base, name); } -ReturnedValue Runtime::deleteMemberString(ExecutionEngine *engine, const Value &base, String *name) +ReturnedValue Runtime::method_deleteMemberString(ExecutionEngine *engine, const Value &base, String *name) { Scope scope(engine); ScopedObject obj(scope, base.toObject(engine)); @@ -335,14 +335,14 @@ ReturnedValue Runtime::deleteMemberString(ExecutionEngine *engine, const Value & return Encode(obj->deleteProperty(name)); } -ReturnedValue Runtime::deleteName(ExecutionEngine *engine, int nameIndex) +ReturnedValue Runtime::method_deleteName(ExecutionEngine *engine, int nameIndex) { Scope scope(engine); ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]); return Encode(engine->currentContext->deleteProperty(name)); } -QV4::ReturnedValue Runtime::instanceof(ExecutionEngine *engine, const Value &left, const Value &right) +QV4::ReturnedValue Runtime::method_instanceof(ExecutionEngine *engine, const Value &left, const Value &right) { Scope scope(engine); ScopedFunctionObject f(scope, right.as<FunctionObject>()); @@ -372,7 +372,7 @@ QV4::ReturnedValue Runtime::instanceof(ExecutionEngine *engine, const Value &lef return Encode(false); } -QV4::ReturnedValue Runtime::in(ExecutionEngine *engine, const Value &left, const Value &right) +QV4::ReturnedValue Runtime::method_in(ExecutionEngine *engine, const Value &left, const Value &right) { if (!right.isObject()) return engine->throwTypeError(); @@ -561,7 +561,7 @@ QV4::ReturnedValue RuntimeHelpers::addHelper(ExecutionEngine *engine, const Valu return Encode(x + y); } -QV4::ReturnedValue Runtime::addString(ExecutionEngine *engine, const Value &left, const Value &right) +QV4::ReturnedValue Runtime::method_addString(ExecutionEngine *engine, const Value &left, const Value &right) { Q_ASSERT(left.isString() || right.isString()); @@ -592,7 +592,7 @@ QV4::ReturnedValue Runtime::addString(ExecutionEngine *engine, const Value &left return (mm->alloc<String>(mm, pleft->stringValue()->d(), pright->stringValue()->d()))->asReturnedValue(); } -void Runtime::setProperty(ExecutionEngine *engine, const Value &object, int nameIndex, const Value &value) +void Runtime::method_setProperty(ExecutionEngine *engine, const Value &object, int nameIndex, const Value &value) { Scope scope(engine); ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]); @@ -602,7 +602,7 @@ void Runtime::setProperty(ExecutionEngine *engine, const Value &object, int name o->put(name, value); } -ReturnedValue Runtime::getElement(ExecutionEngine *engine, const Value &object, const Value &index) +ReturnedValue Runtime::method_getElement(ExecutionEngine *engine, const Value &object, const Value &index) { Scope scope(engine); uint idx = index.asArrayIndex(); @@ -645,7 +645,7 @@ ReturnedValue Runtime::getElement(ExecutionEngine *engine, const Value &object, return o->get(name); } -void Runtime::setElement(ExecutionEngine *engine, const Value &object, const Value &index, const Value &value) +void Runtime::method_setElement(ExecutionEngine *engine, const Value &object, const Value &index, const Value &value) { Scope scope(engine); ScopedObject o(scope, object.toObject(engine)); @@ -669,7 +669,7 @@ void Runtime::setElement(ExecutionEngine *engine, const Value &object, const Val o->put(name, value); } -ReturnedValue Runtime::foreachIterator(ExecutionEngine *engine, const Value &in) +ReturnedValue Runtime::method_foreachIterator(ExecutionEngine *engine, const Value &in) { Scope scope(engine); ScopedObject o(scope, (Object *)0); @@ -678,7 +678,7 @@ ReturnedValue Runtime::foreachIterator(ExecutionEngine *engine, const Value &in) return engine->newForEachIteratorObject(o)->asReturnedValue(); } -ReturnedValue Runtime::foreachNextPropertyName(const Value &foreach_iterator) +ReturnedValue Runtime::method_foreachNextPropertyName(const Value &foreach_iterator) { Q_ASSERT(foreach_iterator.isObject()); @@ -689,14 +689,14 @@ ReturnedValue Runtime::foreachNextPropertyName(const Value &foreach_iterator) } -void Runtime::setActivationProperty(ExecutionEngine *engine, int nameIndex, const Value &value) +void Runtime::method_setActivationProperty(ExecutionEngine *engine, int nameIndex, const Value &value) { Scope scope(engine); ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]); engine->currentContext->setProperty(name, value); } -ReturnedValue Runtime::getProperty(ExecutionEngine *engine, const Value &object, int nameIndex) +ReturnedValue Runtime::method_getProperty(ExecutionEngine *engine, const Value &object, int nameIndex) { Scope scope(engine); ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]); @@ -716,7 +716,7 @@ ReturnedValue Runtime::getProperty(ExecutionEngine *engine, const Value &object, return o->get(name); } -ReturnedValue Runtime::getActivationProperty(ExecutionEngine *engine, int nameIndex) +ReturnedValue Runtime::method_getActivationProperty(ExecutionEngine *engine, int nameIndex) { Scope scope(engine); ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]); @@ -742,9 +742,9 @@ uint RuntimeHelpers::equalHelper(const Value &x, const Value &y) double dx = RuntimeHelpers::toNumber(x); return dx == y.asDouble(); } else if (x.isBoolean()) { - return Runtime::compareEqual(Primitive::fromDouble((double) x.booleanValue()), y); + return Runtime::method_compareEqual(Primitive::fromDouble((double) x.booleanValue()), y); } else if (y.isBoolean()) { - return Runtime::compareEqual(x, Primitive::fromDouble((double) y.booleanValue())); + return Runtime::method_compareEqual(x, Primitive::fromDouble((double) y.booleanValue())); } else { #ifdef V4_BOOTSTRAP Q_UNIMPLEMENTED(); @@ -752,11 +752,11 @@ uint RuntimeHelpers::equalHelper(const Value &x, const Value &y) if ((x.isNumber() || x.isString()) && y.isObject()) { Scope scope(y.objectValue()->engine()); ScopedValue py(scope, RuntimeHelpers::toPrimitive(y, PREFERREDTYPE_HINT)); - return Runtime::compareEqual(x, py); + return Runtime::method_compareEqual(x, py); } else if (x.isObject() && (y.isNumber() || y.isString())) { Scope scope(x.objectValue()->engine()); ScopedValue px(scope, RuntimeHelpers::toPrimitive(x, PREFERREDTYPE_HINT)); - return Runtime::compareEqual(px, y); + return Runtime::method_compareEqual(px, y); } #endif } @@ -779,7 +779,7 @@ Bool RuntimeHelpers::strictEqual(const Value &x, const Value &y) return false; } -QV4::Bool Runtime::compareGreaterThan(const Value &l, const Value &r) +QV4::Bool Runtime::method_compareGreaterThan(const Value &l, const Value &r) { TRACE2(l, r); if (l.isInteger() && r.isInteger()) @@ -803,7 +803,7 @@ QV4::Bool Runtime::compareGreaterThan(const Value &l, const Value &r) QV4::Scope scope(e); QV4::ScopedValue pl(scope, RuntimeHelpers::toPrimitive(l, QV4::NUMBER_HINT)); QV4::ScopedValue pr(scope, RuntimeHelpers::toPrimitive(r, QV4::NUMBER_HINT)); - return Runtime::compareGreaterThan(pl, pr); + return Runtime::method_compareGreaterThan(pl, pr); #endif } @@ -812,7 +812,7 @@ QV4::Bool Runtime::compareGreaterThan(const Value &l, const Value &r) return dl > dr; } -QV4::Bool Runtime::compareLessThan(const Value &l, const Value &r) +QV4::Bool Runtime::method_compareLessThan(const Value &l, const Value &r) { TRACE2(l, r); if (l.isInteger() && r.isInteger()) @@ -836,7 +836,7 @@ QV4::Bool Runtime::compareLessThan(const Value &l, const Value &r) QV4::Scope scope(e); QV4::ScopedValue pl(scope, RuntimeHelpers::toPrimitive(l, QV4::NUMBER_HINT)); QV4::ScopedValue pr(scope, RuntimeHelpers::toPrimitive(r, QV4::NUMBER_HINT)); - return Runtime::compareLessThan(pl, pr); + return Runtime::method_compareLessThan(pl, pr); #endif } @@ -845,7 +845,7 @@ QV4::Bool Runtime::compareLessThan(const Value &l, const Value &r) return dl < dr; } -QV4::Bool Runtime::compareGreaterEqual(const Value &l, const Value &r) +QV4::Bool Runtime::method_compareGreaterEqual(const Value &l, const Value &r) { TRACE2(l, r); if (l.isInteger() && r.isInteger()) @@ -869,7 +869,7 @@ QV4::Bool Runtime::compareGreaterEqual(const Value &l, const Value &r) QV4::Scope scope(e); QV4::ScopedValue pl(scope, RuntimeHelpers::toPrimitive(l, QV4::NUMBER_HINT)); QV4::ScopedValue pr(scope, RuntimeHelpers::toPrimitive(r, QV4::NUMBER_HINT)); - return Runtime::compareGreaterEqual(pl, pr); + return Runtime::method_compareGreaterEqual(pl, pr); #endif } @@ -878,7 +878,7 @@ QV4::Bool Runtime::compareGreaterEqual(const Value &l, const Value &r) return dl >= dr; } -QV4::Bool Runtime::compareLessEqual(const Value &l, const Value &r) +QV4::Bool Runtime::method_compareLessEqual(const Value &l, const Value &r) { TRACE2(l, r); if (l.isInteger() && r.isInteger()) @@ -902,7 +902,7 @@ QV4::Bool Runtime::compareLessEqual(const Value &l, const Value &r) QV4::Scope scope(e); QV4::ScopedValue pl(scope, RuntimeHelpers::toPrimitive(l, QV4::NUMBER_HINT)); QV4::ScopedValue pr(scope, RuntimeHelpers::toPrimitive(r, QV4::NUMBER_HINT)); - return Runtime::compareLessEqual(pl, pr); + return Runtime::method_compareLessEqual(pl, pr); #endif } @@ -912,26 +912,26 @@ QV4::Bool Runtime::compareLessEqual(const Value &l, const Value &r) } #ifndef V4_BOOTSTRAP -Bool Runtime::compareInstanceof(ExecutionEngine *engine, const Value &left, const Value &right) +Bool Runtime::method_compareInstanceof(ExecutionEngine *engine, const Value &left, const Value &right) { TRACE2(left, right); Scope scope(engine); - ScopedValue v(scope, Runtime::instanceof(engine, left, right)); + ScopedValue v(scope, method_instanceof(engine, left, right)); return v->booleanValue(); } -uint Runtime::compareIn(ExecutionEngine *engine, const Value &left, const Value &right) +uint Runtime::method_compareIn(ExecutionEngine *engine, const Value &left, const Value &right) { TRACE2(left, right); Scope scope(engine); - ScopedValue v(scope, Runtime::in(engine, left, right)); + ScopedValue v(scope, method_in(engine, left, right)); return v->booleanValue(); } -ReturnedValue Runtime::callGlobalLookup(ExecutionEngine *engine, uint index, CallData *callData) +ReturnedValue Runtime::method_callGlobalLookup(ExecutionEngine *engine, uint index, CallData *callData) { Scope scope(engine); Q_ASSERT(callData->thisObject.isUndefined()); @@ -949,7 +949,7 @@ ReturnedValue Runtime::callGlobalLookup(ExecutionEngine *engine, uint index, Cal } -ReturnedValue Runtime::callActivationProperty(ExecutionEngine *engine, int nameIndex, CallData *callData) +ReturnedValue Runtime::method_callActivationProperty(ExecutionEngine *engine, int nameIndex, CallData *callData) { Q_ASSERT(callData->thisObject.isUndefined()); Scope scope(engine); @@ -979,10 +979,10 @@ ReturnedValue Runtime::callActivationProperty(ExecutionEngine *engine, int nameI return o->call(callData); } -ReturnedValue Runtime::callQmlScopeObjectProperty(ExecutionEngine *engine, int propertyIndex, CallData *callData) +ReturnedValue Runtime::method_callQmlScopeObjectProperty(ExecutionEngine *engine, int propertyIndex, CallData *callData) { Scope scope(engine); - ScopedFunctionObject o(scope, getQmlScopeObjectProperty(engine, callData->thisObject, propertyIndex)); + ScopedFunctionObject o(scope, method_getQmlScopeObjectProperty(engine, callData->thisObject, propertyIndex)); if (!o) { QString error = QStringLiteral("Property '%1' of object %2 is not a function").arg(propertyIndex).arg(callData->thisObject.toQStringNoThrow()); return engine->throwTypeError(error); @@ -991,10 +991,10 @@ ReturnedValue Runtime::callQmlScopeObjectProperty(ExecutionEngine *engine, int p return o->call(callData); } -ReturnedValue Runtime::callQmlContextObjectProperty(ExecutionEngine *engine, int propertyIndex, CallData *callData) +ReturnedValue Runtime::method_callQmlContextObjectProperty(ExecutionEngine *engine, int propertyIndex, CallData *callData) { Scope scope(engine); - ScopedFunctionObject o(scope, getQmlContextObjectProperty(engine, callData->thisObject, propertyIndex)); + ScopedFunctionObject o(scope, method_getQmlContextObjectProperty(engine, callData->thisObject, propertyIndex)); if (!o) { QString error = QStringLiteral("Property '%1' of object %2 is not a function").arg(propertyIndex).arg(callData->thisObject.toQStringNoThrow()); return engine->throwTypeError(error); @@ -1003,7 +1003,7 @@ ReturnedValue Runtime::callQmlContextObjectProperty(ExecutionEngine *engine, int return o->call(callData); } -ReturnedValue Runtime::callProperty(ExecutionEngine *engine, int nameIndex, CallData *callData) +ReturnedValue Runtime::method_callProperty(ExecutionEngine *engine, int nameIndex, CallData *callData) { Scope scope(engine); ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]); @@ -1030,7 +1030,7 @@ ReturnedValue Runtime::callProperty(ExecutionEngine *engine, int nameIndex, Call return o->call(callData); } -ReturnedValue Runtime::callPropertyLookup(ExecutionEngine *engine, uint index, CallData *callData) +ReturnedValue Runtime::method_callPropertyLookup(ExecutionEngine *engine, uint index, CallData *callData) { Lookup *l = engine->current->lookups + index; Value v; @@ -1041,7 +1041,7 @@ ReturnedValue Runtime::callPropertyLookup(ExecutionEngine *engine, uint index, C return v.objectValue()->call(callData); } -ReturnedValue Runtime::callElement(ExecutionEngine *engine, const Value &index, CallData *callData) +ReturnedValue Runtime::method_callElement(ExecutionEngine *engine, const Value &index, CallData *callData) { Scope scope(engine); ScopedObject baseObject(scope, callData->thisObject.toObject(engine)); @@ -1058,7 +1058,7 @@ ReturnedValue Runtime::callElement(ExecutionEngine *engine, const Value &index, return o->call(callData); } -ReturnedValue Runtime::callValue(ExecutionEngine *engine, const Value &func, CallData *callData) +ReturnedValue Runtime::method_callValue(ExecutionEngine *engine, const Value &func, CallData *callData) { if (!func.isObject()) return engine->throwTypeError(QStringLiteral("%1 is not a function").arg(func.toQStringNoThrow())); @@ -1067,7 +1067,7 @@ ReturnedValue Runtime::callValue(ExecutionEngine *engine, const Value &func, Cal } -ReturnedValue Runtime::constructGlobalLookup(ExecutionEngine *engine, uint index, CallData *callData) +ReturnedValue Runtime::method_constructGlobalLookup(ExecutionEngine *engine, uint index, CallData *callData) { Scope scope(engine); Q_ASSERT(callData->thisObject.isUndefined()); @@ -1081,7 +1081,7 @@ ReturnedValue Runtime::constructGlobalLookup(ExecutionEngine *engine, uint index } -ReturnedValue Runtime::constructActivationProperty(ExecutionEngine *engine, int nameIndex, CallData *callData) +ReturnedValue Runtime::method_constructActivationProperty(ExecutionEngine *engine, int nameIndex, CallData *callData) { Scope scope(engine); ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]); @@ -1096,7 +1096,7 @@ ReturnedValue Runtime::constructActivationProperty(ExecutionEngine *engine, int return f->construct(callData); } -ReturnedValue Runtime::constructValue(ExecutionEngine *engine, const Value &func, CallData *callData) +ReturnedValue Runtime::method_constructValue(ExecutionEngine *engine, const Value &func, CallData *callData) { const Object *f = func.as<Object>(); if (!f) @@ -1105,7 +1105,7 @@ ReturnedValue Runtime::constructValue(ExecutionEngine *engine, const Value &func return f->construct(callData); } -ReturnedValue Runtime::constructProperty(ExecutionEngine *engine, int nameIndex, CallData *callData) +ReturnedValue Runtime::method_constructProperty(ExecutionEngine *engine, int nameIndex, CallData *callData) { Scope scope(engine); ScopedObject thisObject(scope, callData->thisObject.toObject(engine)); @@ -1120,7 +1120,7 @@ ReturnedValue Runtime::constructProperty(ExecutionEngine *engine, int nameIndex, return f->construct(callData); } -ReturnedValue Runtime::constructPropertyLookup(ExecutionEngine *engine, uint index, CallData *callData) +ReturnedValue Runtime::method_constructPropertyLookup(ExecutionEngine *engine, uint index, CallData *callData) { Lookup *l = engine->current->lookups + index; Value v; @@ -1132,13 +1132,13 @@ ReturnedValue Runtime::constructPropertyLookup(ExecutionEngine *engine, uint ind } -void Runtime::throwException(ExecutionEngine *engine, const Value &value) +void Runtime::method_throwException(ExecutionEngine *engine, const Value &value) { if (!value.isEmpty()) engine->throwError(value); } -ReturnedValue Runtime::typeofValue(ExecutionEngine *engine, const Value &value) +ReturnedValue Runtime::method_typeofValue(ExecutionEngine *engine, const Value &value) { Scope scope(engine); ScopedString res(scope); @@ -1167,39 +1167,37 @@ ReturnedValue Runtime::typeofValue(ExecutionEngine *engine, const Value &value) return res.asReturnedValue(); } -QV4::ReturnedValue Runtime::typeofName(ExecutionEngine *engine, int nameIndex) +QV4::ReturnedValue Runtime::method_typeofName(ExecutionEngine *engine, int nameIndex) { Scope scope(engine); ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]); ScopedValue prop(scope, engine->currentContext->getProperty(name)); // typeof doesn't throw. clear any possible exception scope.engine->hasException = false; - return Runtime::typeofValue(engine, prop); + return method_typeofValue(engine, prop); } #ifndef V4_BOOTSTRAP -ReturnedValue Runtime::typeofScopeObjectProperty(ExecutionEngine *engine, const Value &context, - int propertyIndex) +ReturnedValue Runtime::method_typeofScopeObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex) { Scope scope(engine); - ScopedValue prop(scope, getQmlScopeObjectProperty(engine, context, propertyIndex)); + ScopedValue prop(scope, method_getQmlScopeObjectProperty(engine, context, propertyIndex)); if (scope.engine->hasException) return Encode::undefined(); - return Runtime::typeofValue(engine, prop); + return method_typeofValue(engine, prop); } -ReturnedValue Runtime::typeofContextObjectProperty(ExecutionEngine *engine, const Value &context, - int propertyIndex) +ReturnedValue Runtime::method_typeofContextObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex) { Scope scope(engine); - ScopedValue prop(scope, getQmlContextObjectProperty(engine, context, propertyIndex)); + ScopedValue prop(scope, method_getQmlContextObjectProperty(engine, context, propertyIndex)); if (scope.engine->hasException) return Encode::undefined(); - return Runtime::typeofValue(engine, prop); + return method_typeofValue(engine, prop); } #endif // V4_BOOTSTRAP -QV4::ReturnedValue Runtime::typeofMember(ExecutionEngine *engine, const Value &base, int nameIndex) +QV4::ReturnedValue Runtime::method_typeofMember(ExecutionEngine *engine, const Value &base, int nameIndex) { Scope scope(engine); ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]); @@ -1207,10 +1205,10 @@ QV4::ReturnedValue Runtime::typeofMember(ExecutionEngine *engine, const Value &b if (scope.engine->hasException) return Encode::undefined(); ScopedValue prop(scope, obj->get(name)); - return Runtime::typeofValue(engine, prop); + return method_typeofValue(engine, prop); } -QV4::ReturnedValue Runtime::typeofElement(ExecutionEngine *engine, const Value &base, const Value &index) +QV4::ReturnedValue Runtime::method_typeofElement(ExecutionEngine *engine, const Value &base, const Value &index) { Scope scope(engine); ScopedString name(scope, index.toString(engine)); @@ -1218,10 +1216,10 @@ QV4::ReturnedValue Runtime::typeofElement(ExecutionEngine *engine, const Value & if (scope.engine->hasException) return Encode::undefined(); ScopedValue prop(scope, obj->get(name)); - return Runtime::typeofValue(engine, prop); + return method_typeofValue(engine, prop); } -ReturnedValue Runtime::unwindException(ExecutionEngine *engine) +ReturnedValue Runtime::method_unwindException(ExecutionEngine *engine) { if (!engine->hasException) return Primitive::emptyValue().asReturnedValue(); @@ -1233,39 +1231,39 @@ ReturnedValue Runtime::unwindException(ExecutionEngine *engine) * * Instead the push/pop pair acts as a non local scope. */ -void Runtime::pushWithScope(const Value &o, ExecutionEngine *engine) +void Runtime::method_pushWithScope(const Value &o, ExecutionEngine *engine) { engine->pushContext(engine->currentContext->newWithContext(o.toObject(engine))); Q_ASSERT(engine->jsStackTop = engine->currentContext + 2); } -void Runtime::pushCatchScope(NoThrowEngine *engine, int exceptionVarNameIndex) +void Runtime::method_pushCatchScope(NoThrowEngine *engine, int exceptionVarNameIndex) { ExecutionContext *c = engine->currentContext; engine->pushContext(c->newCatchContext(c->d()->compilationUnit->runtimeStrings[exceptionVarNameIndex], engine->catchException(0))); Q_ASSERT(engine->jsStackTop = engine->currentContext + 2); } -void Runtime::popScope(ExecutionEngine *engine) +void Runtime::method_popScope(ExecutionEngine *engine) { Q_ASSERT(engine->jsStackTop = engine->currentContext + 2); engine->popContext(); engine->jsStackTop -= 2; } -void Runtime::declareVar(ExecutionEngine *engine, bool deletable, int nameIndex) +void Runtime::method_declareVar(ExecutionEngine *engine, bool deletable, int nameIndex) { Scope scope(engine); ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]); engine->currentContext->createMutableBinding(name, deletable); } -ReturnedValue Runtime::arrayLiteral(ExecutionEngine *engine, Value *values, uint length) +ReturnedValue Runtime::method_arrayLiteral(ExecutionEngine *engine, Value *values, uint length) { return engine->newArrayObject(values, length)->asReturnedValue(); } -ReturnedValue Runtime::objectLiteral(ExecutionEngine *engine, const QV4::Value *args, int classId, int arrayValueCount, int arrayGetterSetterCountAndFlags) +ReturnedValue Runtime::method_objectLiteral(ExecutionEngine *engine, const QV4::Value *args, int classId, int arrayValueCount, int arrayGetterSetterCountAndFlags) { Scope scope(engine); QV4::InternalClass *klass = engine->current->compilationUnit->runtimeClasses[classId]; @@ -1307,7 +1305,7 @@ ReturnedValue Runtime::objectLiteral(ExecutionEngine *engine, const QV4::Value * return o.asReturnedValue(); } -QV4::ReturnedValue Runtime::setupArgumentsObject(ExecutionEngine *engine) +QV4::ReturnedValue Runtime::method_setupArgumentsObject(ExecutionEngine *engine) { Q_ASSERT(engine->current->type == Heap::ExecutionContext::Type_CallContext); QV4::CallContext *c = static_cast<QV4::CallContext *>(engine->currentContext); @@ -1317,7 +1315,7 @@ QV4::ReturnedValue Runtime::setupArgumentsObject(ExecutionEngine *engine) #endif // V4_BOOTSTRAP -QV4::ReturnedValue Runtime::increment(const Value &value) +QV4::ReturnedValue Runtime::method_increment(const Value &value) { TRACE1(value); @@ -1329,7 +1327,7 @@ QV4::ReturnedValue Runtime::increment(const Value &value) } } -QV4::ReturnedValue Runtime::decrement(const Value &value) +QV4::ReturnedValue Runtime::method_decrement(const Value &value) { TRACE1(value); @@ -1364,31 +1362,31 @@ QV4::ReturnedValue RuntimeHelpers::toObject(ExecutionEngine *engine, const Value #endif // V4_BOOTSTRAP -ReturnedValue Runtime::toDouble(const Value &value) +ReturnedValue Runtime::method_toDouble(const Value &value) { TRACE1(value); return Encode(value.toNumber()); } -int Runtime::toInt(const Value &value) +int Runtime::method_toInt(const Value &value) { TRACE1(value); return value.toInt32(); } -int Runtime::doubleToInt(const double &d) +int Runtime::method_doubleToInt(const double &d) { TRACE0(); return Primitive::toInt32(d); } -unsigned Runtime::toUInt(const Value &value) +unsigned Runtime::method_toUInt(const Value &value) { TRACE1(value); return value.toUInt32(); } -unsigned Runtime::doubleToUInt(const double &d) +unsigned Runtime::method_doubleToUInt(const double &d) { TRACE0(); return Primitive::toUInt32(d); @@ -1396,17 +1394,17 @@ unsigned Runtime::doubleToUInt(const double &d) #ifndef V4_BOOTSTRAP -ReturnedValue Runtime::getQmlContext(NoThrowEngine *engine) +ReturnedValue Runtime::method_getQmlContext(NoThrowEngine *engine) { return engine->qmlContext()->asReturnedValue(); } -ReturnedValue Runtime::regexpLiteral(ExecutionEngine *engine, int id) +ReturnedValue Runtime::method_regexpLiteral(ExecutionEngine *engine, int id) { return engine->current->compilationUnit->runtimeRegularExpressions[id].asReturnedValue(); } -ReturnedValue Runtime::getQmlQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, bool captureRequired) +ReturnedValue Runtime::method_getQmlQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, bool captureRequired) { Scope scope(engine); QV4::Scoped<QObjectWrapper> wrapper(scope, object); @@ -1417,7 +1415,7 @@ ReturnedValue Runtime::getQmlQObjectProperty(ExecutionEngine *engine, const Valu return QV4::QObjectWrapper::getProperty(scope.engine, wrapper->object(), propertyIndex, captureRequired); } -QV4::ReturnedValue Runtime::getQmlAttachedProperty(ExecutionEngine *engine, int attachedPropertiesId, int propertyIndex) +QV4::ReturnedValue Runtime::method_getQmlAttachedProperty(ExecutionEngine *engine, int attachedPropertiesId, int propertyIndex) { QObject *scopeObject = engine->qmlScopeObject(); QObject *attachedObject = qmlAttachedPropertiesObjectById(attachedPropertiesId, scopeObject); @@ -1427,19 +1425,19 @@ QV4::ReturnedValue Runtime::getQmlAttachedProperty(ExecutionEngine *engine, int return QV4::QObjectWrapper::getProperty(engine, attachedObject, propertyIndex, /*captureRequired*/true); } -ReturnedValue Runtime::getQmlScopeObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex) +ReturnedValue Runtime::method_getQmlScopeObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex) { const QmlContext &c = static_cast<const QmlContext &>(context); return QV4::QObjectWrapper::getProperty(engine, c.d()->qml->scopeObject, propertyIndex, false); } -ReturnedValue Runtime::getQmlContextObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex) +ReturnedValue Runtime::method_getQmlContextObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex) { const QmlContext &c = static_cast<const QmlContext &>(context); return QV4::QObjectWrapper::getProperty(engine, c.d()->qml->context->contextObject, propertyIndex, false); } -ReturnedValue Runtime::getQmlSingletonQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, bool captureRequired) +ReturnedValue Runtime::method_getQmlSingletonQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, bool captureRequired) { Scope scope(engine); QV4::Scoped<QmlTypeWrapper> wrapper(scope, object); @@ -1450,7 +1448,7 @@ ReturnedValue Runtime::getQmlSingletonQObjectProperty(ExecutionEngine *engine, c return QV4::QObjectWrapper::getProperty(scope.engine, wrapper->singletonObject(), propertyIndex, captureRequired); } -ReturnedValue Runtime::getQmlIdObject(ExecutionEngine *engine, const Value &c, uint index) +ReturnedValue Runtime::method_getQmlIdObject(ExecutionEngine *engine, const Value &c, uint index) { Scope scope(engine); const QmlContext &qmlContext = static_cast<const QmlContext &>(c); @@ -1465,19 +1463,19 @@ ReturnedValue Runtime::getQmlIdObject(ExecutionEngine *engine, const Value &c, u return QObjectWrapper::wrap(engine, context->idValues[index].data()); } -void Runtime::setQmlScopeObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex, const Value &value) +void Runtime::method_setQmlScopeObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex, const Value &value) { const QmlContext &c = static_cast<const QmlContext &>(context); return QV4::QObjectWrapper::setProperty(engine, c.d()->qml->scopeObject, propertyIndex, value); } -void Runtime::setQmlContextObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex, const Value &value) +void Runtime::method_setQmlContextObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex, const Value &value) { const QmlContext &c = static_cast<const QmlContext &>(context); return QV4::QObjectWrapper::setProperty(engine, c.d()->qml->context->contextObject, propertyIndex, value); } -void Runtime::setQmlQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, const Value &value) +void Runtime::method_setQmlQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, const Value &value) { Scope scope(engine); QV4::Scoped<QObjectWrapper> wrapper(scope, object); @@ -1488,7 +1486,7 @@ void Runtime::setQmlQObjectProperty(ExecutionEngine *engine, const Value &object wrapper->setProperty(engine, propertyIndex, value); } -ReturnedValue Runtime::getQmlImportedScripts(NoThrowEngine *engine) +ReturnedValue Runtime::method_getQmlImportedScripts(NoThrowEngine *engine) { QQmlContextData *context = engine->callingQmlContext(); if (!context) @@ -1496,14 +1494,14 @@ ReturnedValue Runtime::getQmlImportedScripts(NoThrowEngine *engine) return context->importedScripts.value(); } -QV4::ReturnedValue Runtime::getQmlSingleton(QV4::NoThrowEngine *engine, int nameIndex) +QV4::ReturnedValue Runtime::method_getQmlSingleton(QV4::NoThrowEngine *engine, int nameIndex) { Scope scope(engine); ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]); return engine->qmlSingletonWrapper(name); } -void Runtime::convertThisToObject(ExecutionEngine *engine) +void Runtime::method_convertThisToObject(ExecutionEngine *engine) { Value *t = &engine->current->callData->thisObject; if (t->isObject()) diff --git a/src/qml/jsruntime/qv4runtime_p.h b/src/qml/jsruntime/qv4runtime_p.h index 51cc4f50b0..d9b46606c9 100644 --- a/src/qml/jsruntime/qv4runtime_p.h +++ b/src/qml/jsruntime/qv4runtime_p.h @@ -55,7 +55,7 @@ #include "qv4context_p.h" #include "qv4engine_p.h" #include "qv4math_p.h" - +#include "qv4runtimeapi_p.h" #include <QtCore/qnumeric.h> @@ -98,150 +98,6 @@ enum TypeHint { STRING_HINT }; -// This is a trick to tell the code generators that functions taking a NoThrowContext won't -// throw exceptions and therefore don't need a check after the call. -struct NoThrowEngine : public ExecutionEngine -{ -}; - -struct Q_QML_PRIVATE_EXPORT Runtime { - // call - static ReturnedValue callGlobalLookup(ExecutionEngine *engine, uint index, CallData *callData); - static ReturnedValue callActivationProperty(ExecutionEngine *engine, int nameIndex, CallData *callData); - static ReturnedValue callQmlScopeObjectProperty(ExecutionEngine *engine, int propertyIndex, CallData *callData); - static ReturnedValue callQmlContextObjectProperty(ExecutionEngine *engine, int propertyIndex, CallData *callData); - static ReturnedValue callProperty(ExecutionEngine *engine, int nameIndex, CallData *callData); - static ReturnedValue callPropertyLookup(ExecutionEngine *engine, uint index, CallData *callData); - static ReturnedValue callElement(ExecutionEngine *engine, const Value &index, CallData *callData); - static ReturnedValue callValue(ExecutionEngine *engine, const Value &func, CallData *callData); - - // construct - static ReturnedValue constructGlobalLookup(ExecutionEngine *engine, uint index, CallData *callData); - static ReturnedValue constructActivationProperty(ExecutionEngine *engine, int nameIndex, CallData *callData); - static ReturnedValue constructProperty(ExecutionEngine *engine, int nameIndex, CallData *callData); - static ReturnedValue constructPropertyLookup(ExecutionEngine *engine, uint index, CallData *callData); - static ReturnedValue constructValue(ExecutionEngine *engine, const Value &func, CallData *callData); - - // set & get - static void setActivationProperty(ExecutionEngine *engine, int nameIndex, const Value &value); - static void setProperty(ExecutionEngine *engine, const Value &object, int nameIndex, const Value &value); - static void setElement(ExecutionEngine *engine, const Value &object, const Value &index, const Value &value); - static ReturnedValue getProperty(ExecutionEngine *engine, const Value &object, int nameIndex); - static ReturnedValue getActivationProperty(ExecutionEngine *engine, int nameIndex); - static ReturnedValue getElement(ExecutionEngine *engine, const Value &object, const Value &index); - - // typeof - static ReturnedValue typeofValue(ExecutionEngine *engine, const Value &val); - static ReturnedValue typeofName(ExecutionEngine *engine, int nameIndex); - static ReturnedValue typeofScopeObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex); - static ReturnedValue typeofContextObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex); - static ReturnedValue typeofMember(ExecutionEngine *engine, const Value &base, int nameIndex); - static ReturnedValue typeofElement(ExecutionEngine *engine, const Value &base, const Value &index); - - // delete - static ReturnedValue deleteElement(ExecutionEngine *engine, const Value &base, const Value &index); - static ReturnedValue deleteMember(ExecutionEngine *engine, const Value &base, int nameIndex); - static ReturnedValue deleteMemberString(ExecutionEngine *engine, const Value &base, String *name); - static ReturnedValue deleteName(ExecutionEngine *engine, int nameIndex); - - // exceptions & scopes - static void throwException(ExecutionEngine *engine, const Value &value); - static ReturnedValue unwindException(ExecutionEngine *engine); - static void pushWithScope(const Value &o, ExecutionEngine *engine); - static void pushCatchScope(NoThrowEngine *engine, int exceptionVarNameIndex); - static void popScope(ExecutionEngine *engine); - - // closures - static ReturnedValue closure(ExecutionEngine *engine, int functionId); - - // function header - static void declareVar(ExecutionEngine *engine, bool deletable, int nameIndex); - static ReturnedValue setupArgumentsObject(ExecutionEngine *engine); - static void convertThisToObject(ExecutionEngine *engine); - - // literals - static ReturnedValue arrayLiteral(ExecutionEngine *engine, Value *values, uint length); - static ReturnedValue objectLiteral(ExecutionEngine *engine, const Value *args, int classId, int arrayValueCount, int arrayGetterSetterCountAndFlags); - static ReturnedValue regexpLiteral(ExecutionEngine *engine, int id); - - // foreach - static ReturnedValue foreachIterator(ExecutionEngine *engine, const Value &in); - static ReturnedValue foreachNextPropertyName(const Value &foreach_iterator); - - // unary operators - typedef ReturnedValue (*UnaryOperation)(const Value &value); - static ReturnedValue uPlus(const Value &value); - static ReturnedValue uMinus(const Value &value); - static ReturnedValue uNot(const Value &value); - static ReturnedValue complement(const Value &value); - static ReturnedValue increment(const Value &value); - static ReturnedValue decrement(const Value &value); - - // binary operators - typedef ReturnedValue (*BinaryOperation)(const Value &left, const Value &right); - typedef ReturnedValue (*BinaryOperationContext)(ExecutionEngine *engine, const Value &left, const Value &right); - - static ReturnedValue instanceof(ExecutionEngine *engine, const Value &left, const Value &right); - static ReturnedValue in(ExecutionEngine *engine, const Value &left, const Value &right); - static ReturnedValue add(ExecutionEngine *engine, const Value &left, const Value &right); - static ReturnedValue addString(ExecutionEngine *engine, const Value &left, const Value &right); - static ReturnedValue bitOr(const Value &left, const Value &right); - static ReturnedValue bitXor(const Value &left, const Value &right); - static ReturnedValue bitAnd(const Value &left, const Value &right); - static ReturnedValue sub(const Value &left, const Value &right); - static ReturnedValue mul(const Value &left, const Value &right); - static ReturnedValue div(const Value &left, const Value &right); - static ReturnedValue mod(const Value &left, const Value &right); - static ReturnedValue shl(const Value &left, const Value &right); - static ReturnedValue shr(const Value &left, const Value &right); - static ReturnedValue ushr(const Value &left, const Value &right); - static ReturnedValue greaterThan(const Value &left, const Value &right); - static ReturnedValue lessThan(const Value &left, const Value &right); - static ReturnedValue greaterEqual(const Value &left, const Value &right); - static ReturnedValue lessEqual(const Value &left, const Value &right); - static ReturnedValue equal(const Value &left, const Value &right); - static ReturnedValue notEqual(const Value &left, const Value &right); - static ReturnedValue strictEqual(const Value &left, const Value &right); - static ReturnedValue strictNotEqual(const Value &left, const Value &right); - - // comparisons - typedef Bool (*CompareOperation)(const Value &left, const Value &right); - static Bool compareGreaterThan(const Value &l, const Value &r); - static Bool compareLessThan(const Value &l, const Value &r); - static Bool compareGreaterEqual(const Value &l, const Value &r); - static Bool compareLessEqual(const Value &l, const Value &r); - static Bool compareEqual(const Value &left, const Value &right); - static Bool compareNotEqual(const Value &left, const Value &right); - static Bool compareStrictEqual(const Value &left, const Value &right); - static Bool compareStrictNotEqual(const Value &left, const Value &right); - - typedef Bool (*CompareOperationContext)(ExecutionEngine *engine, const Value &left, const Value &right); - static Bool compareInstanceof(ExecutionEngine *engine, const Value &left, const Value &right); - static Bool compareIn(ExecutionEngine *engine, const Value &left, const Value &right); - - // conversions - static Bool toBoolean(const Value &value); - static ReturnedValue toDouble(const Value &value); - static int toInt(const Value &value); - static int doubleToInt(const double &d); - static unsigned toUInt(const Value &value); - static unsigned doubleToUInt(const double &d); - - // qml - static ReturnedValue getQmlContext(NoThrowEngine *engine); - static ReturnedValue getQmlImportedScripts(NoThrowEngine *engine); - static ReturnedValue getQmlSingleton(NoThrowEngine *engine, int nameIndex); - static ReturnedValue getQmlAttachedProperty(ExecutionEngine *engine, int attachedPropertiesId, int propertyIndex); - static ReturnedValue getQmlScopeObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex); - static ReturnedValue getQmlContextObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex); - static ReturnedValue getQmlQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, bool captureRequired); - static ReturnedValue getQmlSingletonQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, bool captureRequired); - static ReturnedValue getQmlIdObject(ExecutionEngine *engine, const Value &context, uint index); - - static void setQmlScopeObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex, const Value &value); - static void setQmlContextObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex, const Value &value); - static void setQmlQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, const Value &value); -}; struct Q_QML_PRIVATE_EXPORT RuntimeHelpers { static ReturnedValue objectDefaultValue(const Object *object, int typeHint); @@ -281,7 +137,7 @@ inline double RuntimeHelpers::toNumber(const Value &value) return value.toNumber(); } -inline ReturnedValue Runtime::uPlus(const Value &value) +inline ReturnedValue Runtime::method_uPlus(const Value &value) { TRACE1(value); @@ -294,7 +150,7 @@ inline ReturnedValue Runtime::uPlus(const Value &value) return Encode(n); } -inline ReturnedValue Runtime::uMinus(const Value &value) +inline ReturnedValue Runtime::method_uMinus(const Value &value) { TRACE1(value); @@ -307,7 +163,7 @@ inline ReturnedValue Runtime::uMinus(const Value &value) } } -inline ReturnedValue Runtime::complement(const Value &value) +inline ReturnedValue Runtime::method_complement(const Value &value) { TRACE1(value); @@ -315,7 +171,7 @@ inline ReturnedValue Runtime::complement(const Value &value) return Encode((int)~n); } -inline ReturnedValue Runtime::uNot(const Value &value) +inline ReturnedValue Runtime::method_uNot(const Value &value) { TRACE1(value); @@ -324,7 +180,7 @@ inline ReturnedValue Runtime::uNot(const Value &value) } // binary operators -inline ReturnedValue Runtime::bitOr(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_bitOr(const Value &left, const Value &right) { TRACE2(left, right); @@ -333,7 +189,7 @@ inline ReturnedValue Runtime::bitOr(const Value &left, const Value &right) return Encode(lval | rval); } -inline ReturnedValue Runtime::bitXor(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_bitXor(const Value &left, const Value &right) { TRACE2(left, right); @@ -342,7 +198,7 @@ inline ReturnedValue Runtime::bitXor(const Value &left, const Value &right) return Encode(lval ^ rval); } -inline ReturnedValue Runtime::bitAnd(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_bitAnd(const Value &left, const Value &right) { TRACE2(left, right); @@ -352,7 +208,7 @@ inline ReturnedValue Runtime::bitAnd(const Value &left, const Value &right) } #ifndef V4_BOOTSTRAP -inline ReturnedValue Runtime::add(ExecutionEngine *engine, const Value &left, const Value &right) +inline ReturnedValue Runtime::method_add(ExecutionEngine *engine, const Value &left, const Value &right) { TRACE2(left, right); @@ -365,7 +221,7 @@ inline ReturnedValue Runtime::add(ExecutionEngine *engine, const Value &left, co } #endif // V4_BOOTSTRAP -inline ReturnedValue Runtime::sub(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_sub(const Value &left, const Value &right) { TRACE2(left, right); @@ -378,7 +234,7 @@ inline ReturnedValue Runtime::sub(const Value &left, const Value &right) return Primitive::fromDouble(lval - rval).asReturnedValue(); } -inline ReturnedValue Runtime::mul(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_mul(const Value &left, const Value &right) { TRACE2(left, right); @@ -391,7 +247,7 @@ inline ReturnedValue Runtime::mul(const Value &left, const Value &right) return Primitive::fromDouble(lval * rval).asReturnedValue(); } -inline ReturnedValue Runtime::div(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_div(const Value &left, const Value &right) { TRACE2(left, right); @@ -409,7 +265,7 @@ inline ReturnedValue Runtime::div(const Value &left, const Value &right) return Primitive::fromDouble(lval / rval).asReturnedValue(); } -inline ReturnedValue Runtime::mod(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_mod(const Value &left, const Value &right) { TRACE2(left, right); @@ -424,7 +280,7 @@ inline ReturnedValue Runtime::mod(const Value &left, const Value &right) return Primitive::fromDouble(std::fmod(lval, rval)).asReturnedValue(); } -inline ReturnedValue Runtime::shl(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_shl(const Value &left, const Value &right) { TRACE2(left, right); @@ -433,7 +289,7 @@ inline ReturnedValue Runtime::shl(const Value &left, const Value &right) return Encode((int)(lval << rval)); } -inline ReturnedValue Runtime::shr(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_shr(const Value &left, const Value &right) { TRACE2(left, right); @@ -442,7 +298,7 @@ inline ReturnedValue Runtime::shr(const Value &left, const Value &right) return Encode((int)(lval >> rval)); } -inline ReturnedValue Runtime::ushr(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_ushr(const Value &left, const Value &right) { TRACE2(left, right); @@ -453,39 +309,39 @@ inline ReturnedValue Runtime::ushr(const Value &left, const Value &right) return Encode(res); } -inline ReturnedValue Runtime::greaterThan(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_greaterThan(const Value &left, const Value &right) { TRACE2(left, right); - bool r = Runtime::compareGreaterThan(left, right); + bool r = method_compareGreaterThan(left, right); return Encode(r); } -inline ReturnedValue Runtime::lessThan(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_lessThan(const Value &left, const Value &right) { TRACE2(left, right); - bool r = Runtime::compareLessThan(left, right); + bool r = method_compareLessThan(left, right); return Encode(r); } -inline ReturnedValue Runtime::greaterEqual(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_greaterEqual(const Value &left, const Value &right) { TRACE2(left, right); - bool r = Runtime::compareGreaterEqual(left, right); + bool r = method_compareGreaterEqual(left, right); return Encode(r); } -inline ReturnedValue Runtime::lessEqual(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_lessEqual(const Value &left, const Value &right) { TRACE2(left, right); - bool r = Runtime::compareLessEqual(left, right); + bool r = method_compareLessEqual(left, right); return Encode(r); } -inline Bool Runtime::compareEqual(const Value &left, const Value &right) +inline Bool Runtime::method_compareEqual(const Value &left, const Value &right) { TRACE2(left, right); @@ -503,23 +359,23 @@ inline Bool Runtime::compareEqual(const Value &left, const Value &right) return RuntimeHelpers::equalHelper(left, right); } -inline ReturnedValue Runtime::equal(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_equal(const Value &left, const Value &right) { TRACE2(left, right); - bool r = Runtime::compareEqual(left, right); + bool r = method_compareEqual(left, right); return Encode(r); } -inline ReturnedValue Runtime::notEqual(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_notEqual(const Value &left, const Value &right) { TRACE2(left, right); - bool r = !Runtime::compareEqual(left, right); + bool r = !method_compareEqual(left, right); return Encode(r); } -inline ReturnedValue Runtime::strictEqual(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_strictEqual(const Value &left, const Value &right) { TRACE2(left, right); @@ -527,7 +383,7 @@ inline ReturnedValue Runtime::strictEqual(const Value &left, const Value &right) return Encode(r); } -inline ReturnedValue Runtime::strictNotEqual(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_strictNotEqual(const Value &left, const Value &right) { TRACE2(left, right); @@ -535,28 +391,28 @@ inline ReturnedValue Runtime::strictNotEqual(const Value &left, const Value &rig return Encode(r); } -inline Bool Runtime::compareNotEqual(const Value &left, const Value &right) +inline Bool Runtime::method_compareNotEqual(const Value &left, const Value &right) { TRACE2(left, right); - return !Runtime::compareEqual(left, right); + return !Runtime::method_compareEqual(left, right); } -inline Bool Runtime::compareStrictEqual(const Value &left, const Value &right) +inline Bool Runtime::method_compareStrictEqual(const Value &left, const Value &right) { TRACE2(left, right); return RuntimeHelpers::strictEqual(left, right); } -inline Bool Runtime::compareStrictNotEqual(const Value &left, const Value &right) +inline Bool Runtime::method_compareStrictNotEqual(const Value &left, const Value &right) { TRACE2(left, right); return ! RuntimeHelpers::strictEqual(left, right); } -inline Bool Runtime::toBoolean(const Value &value) +inline Bool Runtime::method_toBoolean(const Value &value) { return value.toBoolean(); } diff --git a/src/qml/jsruntime/qv4runtimeapi_p.h b/src/qml/jsruntime/qv4runtimeapi_p.h new file mode 100644 index 0000000000..9eb6a124b4 --- /dev/null +++ b/src/qml/jsruntime/qv4runtimeapi_p.h @@ -0,0 +1,304 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QV4RUNTIMEAPI_P_H +#define QV4RUNTIMEAPI_P_H + +#include <private/qv4global_p.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +struct NoThrowEngine; + +#define RUNTIME_METHOD(returnvalue, name, args) \ + typedef returnvalue (*Method_##name)args; \ + static returnvalue method_##name args; \ + const Method_##name name + +#define INIT_RUNTIME_METHOD(name) \ + name(method_##name) + +struct Q_QML_PRIVATE_EXPORT Runtime { + Runtime() + : INIT_RUNTIME_METHOD(callGlobalLookup) + , INIT_RUNTIME_METHOD(callActivationProperty) + , INIT_RUNTIME_METHOD(callQmlScopeObjectProperty) + , INIT_RUNTIME_METHOD(callQmlContextObjectProperty) + , INIT_RUNTIME_METHOD(callProperty) + , INIT_RUNTIME_METHOD(callPropertyLookup) + , INIT_RUNTIME_METHOD(callElement) + , INIT_RUNTIME_METHOD(callValue) + , INIT_RUNTIME_METHOD(constructGlobalLookup) + , INIT_RUNTIME_METHOD(constructActivationProperty) + , INIT_RUNTIME_METHOD(constructProperty) + , INIT_RUNTIME_METHOD(constructPropertyLookup) + , INIT_RUNTIME_METHOD(constructValue) + , INIT_RUNTIME_METHOD(setActivationProperty) + , INIT_RUNTIME_METHOD(setProperty) + , INIT_RUNTIME_METHOD(setElement) + , INIT_RUNTIME_METHOD(getProperty) + , INIT_RUNTIME_METHOD(getActivationProperty) + , INIT_RUNTIME_METHOD(getElement) + , INIT_RUNTIME_METHOD(typeofValue) + , INIT_RUNTIME_METHOD(typeofName) + , INIT_RUNTIME_METHOD(typeofScopeObjectProperty) + , INIT_RUNTIME_METHOD(typeofContextObjectProperty) + , INIT_RUNTIME_METHOD(typeofMember) + , INIT_RUNTIME_METHOD(typeofElement) + , INIT_RUNTIME_METHOD(deleteElement) + , INIT_RUNTIME_METHOD(deleteMember) + , INIT_RUNTIME_METHOD(deleteMemberString) + , INIT_RUNTIME_METHOD(deleteName) + , INIT_RUNTIME_METHOD(throwException) + , INIT_RUNTIME_METHOD(unwindException) + , INIT_RUNTIME_METHOD(pushWithScope) + , INIT_RUNTIME_METHOD(pushCatchScope) + , INIT_RUNTIME_METHOD(popScope) + , INIT_RUNTIME_METHOD(closure) + , INIT_RUNTIME_METHOD(declareVar) + , INIT_RUNTIME_METHOD(setupArgumentsObject) + , INIT_RUNTIME_METHOD(convertThisToObject) + , INIT_RUNTIME_METHOD(arrayLiteral) + , INIT_RUNTIME_METHOD(objectLiteral) + , INIT_RUNTIME_METHOD(regexpLiteral) + , INIT_RUNTIME_METHOD(foreachIterator) + , INIT_RUNTIME_METHOD(foreachNextPropertyName) + , INIT_RUNTIME_METHOD(uPlus) + , INIT_RUNTIME_METHOD(uMinus) + , INIT_RUNTIME_METHOD(uNot) + , INIT_RUNTIME_METHOD(complement) + , INIT_RUNTIME_METHOD(increment) + , INIT_RUNTIME_METHOD(decrement) + , INIT_RUNTIME_METHOD(instanceof) + , INIT_RUNTIME_METHOD(in) + , INIT_RUNTIME_METHOD(add) + , INIT_RUNTIME_METHOD(addString) + , INIT_RUNTIME_METHOD(bitOr) + , INIT_RUNTIME_METHOD(bitXor) + , INIT_RUNTIME_METHOD(bitAnd) + , INIT_RUNTIME_METHOD(sub) + , INIT_RUNTIME_METHOD(mul) + , INIT_RUNTIME_METHOD(div) + , INIT_RUNTIME_METHOD(mod) + , INIT_RUNTIME_METHOD(shl) + , INIT_RUNTIME_METHOD(shr) + , INIT_RUNTIME_METHOD(ushr) + , INIT_RUNTIME_METHOD(greaterThan) + , INIT_RUNTIME_METHOD(lessThan) + , INIT_RUNTIME_METHOD(greaterEqual) + , INIT_RUNTIME_METHOD(lessEqual) + , INIT_RUNTIME_METHOD(equal) + , INIT_RUNTIME_METHOD(notEqual) + , INIT_RUNTIME_METHOD(strictEqual) + , INIT_RUNTIME_METHOD(strictNotEqual) + , INIT_RUNTIME_METHOD(compareGreaterThan) + , INIT_RUNTIME_METHOD(compareLessThan) + , INIT_RUNTIME_METHOD(compareGreaterEqual) + , INIT_RUNTIME_METHOD(compareLessEqual) + , INIT_RUNTIME_METHOD(compareEqual) + , INIT_RUNTIME_METHOD(compareNotEqual) + , INIT_RUNTIME_METHOD(compareStrictEqual) + , INIT_RUNTIME_METHOD(compareStrictNotEqual) + , INIT_RUNTIME_METHOD(compareInstanceof) + , INIT_RUNTIME_METHOD(compareIn) + , INIT_RUNTIME_METHOD(toBoolean) + , INIT_RUNTIME_METHOD(toDouble) + , INIT_RUNTIME_METHOD(toInt) + , INIT_RUNTIME_METHOD(doubleToInt) + , INIT_RUNTIME_METHOD(toUInt) + , INIT_RUNTIME_METHOD(doubleToUInt) + , INIT_RUNTIME_METHOD(getQmlContext) + , INIT_RUNTIME_METHOD(getQmlImportedScripts) + , INIT_RUNTIME_METHOD(getQmlSingleton) + , INIT_RUNTIME_METHOD(getQmlAttachedProperty) + , INIT_RUNTIME_METHOD(getQmlScopeObjectProperty) + , INIT_RUNTIME_METHOD(getQmlContextObjectProperty) + , INIT_RUNTIME_METHOD(getQmlQObjectProperty) + , INIT_RUNTIME_METHOD(getQmlSingletonQObjectProperty) + , INIT_RUNTIME_METHOD(getQmlIdObject) + , INIT_RUNTIME_METHOD(setQmlScopeObjectProperty) + , INIT_RUNTIME_METHOD(setQmlContextObjectProperty) + , INIT_RUNTIME_METHOD(setQmlQObjectProperty) + { } + + // call + RUNTIME_METHOD(ReturnedValue, callGlobalLookup, (ExecutionEngine *engine, uint index, CallData *callData)); + RUNTIME_METHOD(ReturnedValue, callActivationProperty, (ExecutionEngine *engine, int nameIndex, CallData *callData)); + RUNTIME_METHOD(ReturnedValue, callQmlScopeObjectProperty, (ExecutionEngine *engine, int propertyIndex, CallData *callData)); + RUNTIME_METHOD(ReturnedValue, callQmlContextObjectProperty, (ExecutionEngine *engine, int propertyIndex, CallData *callData)); + RUNTIME_METHOD(ReturnedValue, callProperty, (ExecutionEngine *engine, int nameIndex, CallData *callData)); + RUNTIME_METHOD(ReturnedValue, callPropertyLookup, (ExecutionEngine *engine, uint index, CallData *callData)); + RUNTIME_METHOD(ReturnedValue, callElement, (ExecutionEngine *engine, const Value &index, CallData *callData)); + RUNTIME_METHOD(ReturnedValue, callValue, (ExecutionEngine *engine, const Value &func, CallData *callData)); + + // construct + RUNTIME_METHOD(ReturnedValue, constructGlobalLookup, (ExecutionEngine *engine, uint index, CallData *callData)); + RUNTIME_METHOD(ReturnedValue, constructActivationProperty, (ExecutionEngine *engine, int nameIndex, CallData *callData)); + RUNTIME_METHOD(ReturnedValue, constructProperty, (ExecutionEngine *engine, int nameIndex, CallData *callData)); + RUNTIME_METHOD(ReturnedValue, constructPropertyLookup, (ExecutionEngine *engine, uint index, CallData *callData)); + RUNTIME_METHOD(ReturnedValue, constructValue, (ExecutionEngine *engine, const Value &func, CallData *callData)); + + // set & get + RUNTIME_METHOD(void, setActivationProperty, (ExecutionEngine *engine, int nameIndex, const Value &value)); + RUNTIME_METHOD(void, setProperty, (ExecutionEngine *engine, const Value &object, int nameIndex, const Value &value)); + RUNTIME_METHOD(void, setElement, (ExecutionEngine *engine, const Value &object, const Value &index, const Value &value)); + RUNTIME_METHOD(ReturnedValue, getProperty, (ExecutionEngine *engine, const Value &object, int nameIndex)); + RUNTIME_METHOD(ReturnedValue, getActivationProperty, (ExecutionEngine *engine, int nameIndex)); + RUNTIME_METHOD(ReturnedValue, getElement, (ExecutionEngine *engine, const Value &object, const Value &index)); + + // typeof + RUNTIME_METHOD(ReturnedValue, typeofValue, (ExecutionEngine *engine, const Value &val)); + RUNTIME_METHOD(ReturnedValue, typeofName, (ExecutionEngine *engine, int nameIndex)); + RUNTIME_METHOD(ReturnedValue, typeofScopeObjectProperty, (ExecutionEngine *engine, const Value &context, int propertyIndex)); + RUNTIME_METHOD(ReturnedValue, typeofContextObjectProperty, (ExecutionEngine *engine, const Value &context, int propertyIndex)); + RUNTIME_METHOD(ReturnedValue, typeofMember, (ExecutionEngine *engine, const Value &base, int nameIndex)); + RUNTIME_METHOD(ReturnedValue, typeofElement, (ExecutionEngine *engine, const Value &base, const Value &index)); + + // delete + RUNTIME_METHOD(ReturnedValue, deleteElement, (ExecutionEngine *engine, const Value &base, const Value &index)); + RUNTIME_METHOD(ReturnedValue, deleteMember, (ExecutionEngine *engine, const Value &base, int nameIndex)); + RUNTIME_METHOD(ReturnedValue, deleteMemberString, (ExecutionEngine *engine, const Value &base, String *name)); + RUNTIME_METHOD(ReturnedValue, deleteName, (ExecutionEngine *engine, int nameIndex)); + + // exceptions & scopes + RUNTIME_METHOD(void, throwException, (ExecutionEngine *engine, const Value &value)); + RUNTIME_METHOD(ReturnedValue, unwindException, (ExecutionEngine *engine)); + RUNTIME_METHOD(void, pushWithScope, (const Value &o, ExecutionEngine *engine)); + RUNTIME_METHOD(void, pushCatchScope, (NoThrowEngine *engine, int exceptionVarNameIndex)); + RUNTIME_METHOD(void, popScope, (ExecutionEngine *engine)); + + // closures + RUNTIME_METHOD(ReturnedValue, closure, (ExecutionEngine *engine, int functionId)); + + // function header + RUNTIME_METHOD(void, declareVar, (ExecutionEngine *engine, bool deletable, int nameIndex)); + RUNTIME_METHOD(ReturnedValue, setupArgumentsObject, (ExecutionEngine *engine)); + RUNTIME_METHOD(void, convertThisToObject, (ExecutionEngine *engine)); + + // literals + RUNTIME_METHOD(ReturnedValue, arrayLiteral, (ExecutionEngine *engine, Value *values, uint length)); + RUNTIME_METHOD(ReturnedValue, objectLiteral, (ExecutionEngine *engine, const Value *args, int classId, int arrayValueCount, int arrayGetterSetterCountAndFlags)); + RUNTIME_METHOD(ReturnedValue, regexpLiteral, (ExecutionEngine *engine, int id)); + + // foreach + RUNTIME_METHOD(ReturnedValue, foreachIterator, (ExecutionEngine *engine, const Value &in)); + RUNTIME_METHOD(ReturnedValue, foreachNextPropertyName, (const Value &foreach_iterator)); + + // unary operators + typedef ReturnedValue (*UnaryOperation)(const Value &value); + RUNTIME_METHOD(ReturnedValue, uPlus, (const Value &value)); + RUNTIME_METHOD(ReturnedValue, uMinus, (const Value &value)); + RUNTIME_METHOD(ReturnedValue, uNot, (const Value &value)); + RUNTIME_METHOD(ReturnedValue, complement, (const Value &value)); + RUNTIME_METHOD(ReturnedValue, increment, (const Value &value)); + RUNTIME_METHOD(ReturnedValue, decrement, (const Value &value)); + + // binary operators + typedef ReturnedValue (*BinaryOperation)(const Value &left, const Value &right); + typedef ReturnedValue (*BinaryOperationContext)(ExecutionEngine *engine, const Value &left, const Value &right); + + RUNTIME_METHOD(ReturnedValue, instanceof, (ExecutionEngine *engine, const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, in, (ExecutionEngine *engine, const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, add, (ExecutionEngine *engine, const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, addString, (ExecutionEngine *engine, const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, bitOr, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, bitXor, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, bitAnd, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, sub, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, mul, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, div, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, mod, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, shl, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, shr, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, ushr, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, greaterThan, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, lessThan, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, greaterEqual, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, lessEqual, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, equal, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, notEqual, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, strictEqual, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, strictNotEqual, (const Value &left, const Value &right)); + + // comparisons + RUNTIME_METHOD(Bool, compareGreaterThan, (const Value &l, const Value &r)); + RUNTIME_METHOD(Bool, compareLessThan, (const Value &l, const Value &r)); + RUNTIME_METHOD(Bool, compareGreaterEqual, (const Value &l, const Value &r)); + RUNTIME_METHOD(Bool, compareLessEqual, (const Value &l, const Value &r)); + RUNTIME_METHOD(Bool, compareEqual, (const Value &left, const Value &right)); + RUNTIME_METHOD(Bool, compareNotEqual, (const Value &left, const Value &right)); + RUNTIME_METHOD(Bool, compareStrictEqual, (const Value &left, const Value &right)); + RUNTIME_METHOD(Bool, compareStrictNotEqual, (const Value &left, const Value &right)); + + RUNTIME_METHOD(Bool, compareInstanceof, (ExecutionEngine *engine, const Value &left, const Value &right)); + RUNTIME_METHOD(Bool, compareIn, (ExecutionEngine *engine, const Value &left, const Value &right)); + + // conversions + RUNTIME_METHOD(Bool, toBoolean, (const Value &value)); + RUNTIME_METHOD(ReturnedValue, toDouble, (const Value &value)); + RUNTIME_METHOD(int, toInt, (const Value &value)); + RUNTIME_METHOD(int, doubleToInt, (const double &d)); + RUNTIME_METHOD(unsigned, toUInt, (const Value &value)); + RUNTIME_METHOD(unsigned, doubleToUInt, (const double &d)); + + // qml + RUNTIME_METHOD(ReturnedValue, getQmlContext, (NoThrowEngine *engine)); + RUNTIME_METHOD(ReturnedValue, getQmlImportedScripts, (NoThrowEngine *engine)); + RUNTIME_METHOD(ReturnedValue, getQmlSingleton, (NoThrowEngine *engine, int nameIndex)); + RUNTIME_METHOD(ReturnedValue, getQmlAttachedProperty, (ExecutionEngine *engine, int attachedPropertiesId, int propertyIndex)); + RUNTIME_METHOD(ReturnedValue, getQmlScopeObjectProperty, (ExecutionEngine *engine, const Value &context, int propertyIndex)); + RUNTIME_METHOD(ReturnedValue, getQmlContextObjectProperty, (ExecutionEngine *engine, const Value &context, int propertyIndex)); + RUNTIME_METHOD(ReturnedValue, getQmlQObjectProperty, (ExecutionEngine *engine, const Value &object, int propertyIndex, bool captureRequired)); + RUNTIME_METHOD(ReturnedValue, getQmlSingletonQObjectProperty, (ExecutionEngine *engine, const Value &object, int propertyIndex, bool captureRequired)); + RUNTIME_METHOD(ReturnedValue, getQmlIdObject, (ExecutionEngine *engine, const Value &context, uint index)); + + RUNTIME_METHOD(void, setQmlScopeObjectProperty, (ExecutionEngine *engine, const Value &context, int propertyIndex, const Value &value)); + RUNTIME_METHOD(void, setQmlContextObjectProperty, (ExecutionEngine *engine, const Value &context, int propertyIndex, const Value &value)); + RUNTIME_METHOD(void, setQmlQObjectProperty, (ExecutionEngine *engine, const Value &object, int propertyIndex, const Value &value)); +}; + +#undef RUNTIME_METHOD +#undef INIT_RUNTIME_METHOD + +} // namespace QV4 + +QT_END_NAMESPACE + +#endif // QV4RUNTIMEAPI_P_H diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index 5adc5beea5..b874766655 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -270,7 +270,7 @@ ReturnedValue StringPrototype::method_charCodeAt(CallContext *context) if (pos >= 0 && pos < str.length()) return Encode(str.at(pos).unicode()); - return Encode(qQNaN()); + return Encode(qt_qnan()); } ReturnedValue StringPrototype::method_concat(CallContext *context) diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index ecbc243baa..ec4509a5cc 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -451,12 +451,12 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(LoadRegExp) MOTH_BEGIN_INSTR(LoadClosure) - STOREVALUE(instr.result, Runtime::closure(engine, instr.value)); + STOREVALUE(instr.result, engine->runtime.closure(engine, instr.value)); MOTH_END_INSTR(LoadClosure) MOTH_BEGIN_INSTR(LoadName) TRACE(inline, "property name = %s", runtimeStrings[instr.name]->toQString().toUtf8().constData()); - STOREVALUE(instr.result, Runtime::getActivationProperty(engine, instr.name)); + STOREVALUE(instr.result, engine->runtime.getActivationProperty(engine, instr.name)); MOTH_END_INSTR(LoadName) MOTH_BEGIN_INSTR(GetGlobalLookup) @@ -466,12 +466,12 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_BEGIN_INSTR(StoreName) TRACE(inline, "property name = %s", runtimeStrings[instr.name]->toQString().toUtf8().constData()); - Runtime::setActivationProperty(engine, instr.name, VALUE(instr.source)); + engine->runtime.setActivationProperty(engine, instr.name, VALUE(instr.source)); CHECK_EXCEPTION; MOTH_END_INSTR(StoreName) MOTH_BEGIN_INSTR(LoadElement) - STOREVALUE(instr.result, Runtime::getElement(engine, VALUE(instr.base), VALUE(instr.index))); + STOREVALUE(instr.result, engine->runtime.getElement(engine, VALUE(instr.base), VALUE(instr.index))); MOTH_END_INSTR(LoadElement) MOTH_BEGIN_INSTR(LoadElementLookup) @@ -480,7 +480,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(LoadElementLookup) MOTH_BEGIN_INSTR(StoreElement) - Runtime::setElement(engine, VALUE(instr.base), VALUE(instr.index), VALUE(instr.source)); + engine->runtime.setElement(engine, VALUE(instr.base), VALUE(instr.index), VALUE(instr.source)); CHECK_EXCEPTION; MOTH_END_INSTR(StoreElement) @@ -491,7 +491,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(StoreElementLookup) MOTH_BEGIN_INSTR(LoadProperty) - STOREVALUE(instr.result, Runtime::getProperty(engine, VALUE(instr.base), instr.name)); + STOREVALUE(instr.result, engine->runtime.getProperty(engine, VALUE(instr.base), instr.name)); MOTH_END_INSTR(LoadProperty) MOTH_BEGIN_INSTR(GetLookup) @@ -500,7 +500,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(GetLookup) MOTH_BEGIN_INSTR(StoreProperty) - Runtime::setProperty(engine, VALUE(instr.base), instr.name, VALUE(instr.source)); + engine->runtime.setProperty(engine, VALUE(instr.base), instr.name, VALUE(instr.source)); CHECK_EXCEPTION; MOTH_END_INSTR(StoreProperty) @@ -511,42 +511,42 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(SetLookup) MOTH_BEGIN_INSTR(StoreQObjectProperty) - Runtime::setQmlQObjectProperty(engine, VALUE(instr.base), instr.propertyIndex, VALUE(instr.source)); + engine->runtime.setQmlQObjectProperty(engine, VALUE(instr.base), instr.propertyIndex, VALUE(instr.source)); CHECK_EXCEPTION; MOTH_END_INSTR(StoreQObjectProperty) MOTH_BEGIN_INSTR(LoadQObjectProperty) - STOREVALUE(instr.result, Runtime::getQmlQObjectProperty(engine, VALUE(instr.base), instr.propertyIndex, instr.captureRequired)); + STOREVALUE(instr.result, engine->runtime.getQmlQObjectProperty(engine, VALUE(instr.base), instr.propertyIndex, instr.captureRequired)); MOTH_END_INSTR(LoadQObjectProperty) MOTH_BEGIN_INSTR(StoreScopeObjectProperty) - Runtime::setQmlScopeObjectProperty(engine, VALUE(instr.base), instr.propertyIndex, VALUE(instr.source)); + engine->runtime.setQmlScopeObjectProperty(engine, VALUE(instr.base), instr.propertyIndex, VALUE(instr.source)); CHECK_EXCEPTION; MOTH_END_INSTR(StoreScopeObjectProperty) MOTH_BEGIN_INSTR(LoadScopeObjectProperty) - STOREVALUE(instr.result, Runtime::getQmlScopeObjectProperty(engine, VALUE(instr.base), instr.propertyIndex)); + STOREVALUE(instr.result, engine->runtime.getQmlScopeObjectProperty(engine, VALUE(instr.base), instr.propertyIndex)); MOTH_END_INSTR(LoadScopeObjectProperty) MOTH_BEGIN_INSTR(StoreContextObjectProperty) - Runtime::setQmlContextObjectProperty(engine, VALUE(instr.base), instr.propertyIndex, VALUE(instr.source)); + engine->runtime.setQmlContextObjectProperty(engine, VALUE(instr.base), instr.propertyIndex, VALUE(instr.source)); CHECK_EXCEPTION; MOTH_END_INSTR(StoreContextObjectProperty) MOTH_BEGIN_INSTR(LoadContextObjectProperty) - STOREVALUE(instr.result, Runtime::getQmlContextObjectProperty(engine, VALUE(instr.base), instr.propertyIndex)); + STOREVALUE(instr.result, engine->runtime.getQmlContextObjectProperty(engine, VALUE(instr.base), instr.propertyIndex)); MOTH_END_INSTR(LoadContextObjectProperty) MOTH_BEGIN_INSTR(LoadIdObject) - STOREVALUE(instr.result, Runtime::getQmlIdObject(engine, VALUE(instr.base), instr.index)); + STOREVALUE(instr.result, engine->runtime.getQmlIdObject(engine, VALUE(instr.base), instr.index)); MOTH_END_INSTR(LoadIdObject) MOTH_BEGIN_INSTR(LoadAttachedQObjectProperty) - STOREVALUE(instr.result, Runtime::getQmlAttachedProperty(engine, instr.attachedPropertiesId, instr.propertyIndex)); + STOREVALUE(instr.result, engine->runtime.getQmlAttachedProperty(engine, instr.attachedPropertiesId, instr.propertyIndex)); MOTH_END_INSTR(LoadAttachedQObjectProperty) MOTH_BEGIN_INSTR(LoadSingletonQObjectProperty) - STOREVALUE(instr.result, Runtime::getQmlSingletonQObjectProperty(engine, VALUE(instr.base), instr.propertyIndex, instr.captureRequired)); + STOREVALUE(instr.result, engine->runtime.getQmlSingletonQObjectProperty(engine, VALUE(instr.base), instr.propertyIndex, instr.captureRequired)); MOTH_END_INSTR(LoadSingletonQObjectProperty) MOTH_BEGIN_INSTR(Push) @@ -572,7 +572,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = QV4::Primitive::undefinedValue(); - STOREVALUE(instr.result, Runtime::callValue(engine, VALUE(instr.dest), callData)); + STOREVALUE(instr.result, engine->runtime.callValue(engine, VALUE(instr.dest), callData)); MOTH_END_INSTR(CallValue) MOTH_BEGIN_INSTR(CallProperty) @@ -582,7 +582,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = VALUE(instr.base); - STOREVALUE(instr.result, Runtime::callProperty(engine, instr.name, callData)); + STOREVALUE(instr.result, engine->runtime.callProperty(engine, instr.name, callData)); MOTH_END_INSTR(CallProperty) MOTH_BEGIN_INSTR(CallPropertyLookup) @@ -591,7 +591,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = VALUE(instr.base); - STOREVALUE(instr.result, Runtime::callPropertyLookup(engine, instr.lookupIndex, callData)); + STOREVALUE(instr.result, engine->runtime.callPropertyLookup(engine, instr.lookupIndex, callData)); MOTH_END_INSTR(CallPropertyLookup) MOTH_BEGIN_INSTR(CallScopeObjectProperty) @@ -601,7 +601,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = VALUE(instr.base); - STOREVALUE(instr.result, Runtime::callQmlScopeObjectProperty(engine, instr.index, callData)); + STOREVALUE(instr.result, engine->runtime.callQmlScopeObjectProperty(engine, instr.index, callData)); MOTH_END_INSTR(CallScopeObjectProperty) MOTH_BEGIN_INSTR(CallContextObjectProperty) @@ -611,7 +611,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = VALUE(instr.base); - STOREVALUE(instr.result, Runtime::callQmlContextObjectProperty(engine, instr.index, callData)); + STOREVALUE(instr.result, engine->runtime.callQmlContextObjectProperty(engine, instr.index, callData)); MOTH_END_INSTR(CallContextObjectProperty) MOTH_BEGIN_INSTR(CallElement) @@ -620,7 +620,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = VALUE(instr.base); - STOREVALUE(instr.result, Runtime::callElement(engine, VALUE(instr.index), callData)); + STOREVALUE(instr.result, engine->runtime.callElement(engine, VALUE(instr.index), callData)); MOTH_END_INSTR(CallElement) MOTH_BEGIN_INSTR(CallActivationProperty) @@ -629,7 +629,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = QV4::Primitive::undefinedValue(); - STOREVALUE(instr.result, Runtime::callActivationProperty(engine, instr.name, callData)); + STOREVALUE(instr.result, engine->runtime.callActivationProperty(engine, instr.name, callData)); MOTH_END_INSTR(CallActivationProperty) MOTH_BEGIN_INSTR(CallGlobalLookup) @@ -638,7 +638,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = QV4::Primitive::undefinedValue(); - STOREVALUE(instr.result, Runtime::callGlobalLookup(engine, instr.index, callData)); + STOREVALUE(instr.result, Runtime::method_callGlobalLookup(engine, instr.index, callData)); MOTH_END_INSTR(CallGlobalLookup) MOTH_BEGIN_INSTR(SetExceptionHandler) @@ -646,95 +646,95 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(SetExceptionHandler) MOTH_BEGIN_INSTR(CallBuiltinThrow) - Runtime::throwException(engine, VALUE(instr.arg)); + engine->runtime.throwException(engine, VALUE(instr.arg)); CHECK_EXCEPTION; MOTH_END_INSTR(CallBuiltinThrow) MOTH_BEGIN_INSTR(CallBuiltinUnwindException) - STOREVALUE(instr.result, Runtime::unwindException(engine)); + STOREVALUE(instr.result, engine->runtime.unwindException(engine)); MOTH_END_INSTR(CallBuiltinUnwindException) MOTH_BEGIN_INSTR(CallBuiltinPushCatchScope) - Runtime::pushCatchScope(static_cast<QV4::NoThrowEngine*>(engine), instr.name); + engine->runtime.pushCatchScope(static_cast<QV4::NoThrowEngine*>(engine), instr.name); context = engine->currentContext; MOTH_END_INSTR(CallBuiltinPushCatchScope) MOTH_BEGIN_INSTR(CallBuiltinPushScope) - Runtime::pushWithScope(VALUE(instr.arg), engine); + engine->runtime.pushWithScope(VALUE(instr.arg), engine); context = engine->currentContext; CHECK_EXCEPTION; MOTH_END_INSTR(CallBuiltinPushScope) MOTH_BEGIN_INSTR(CallBuiltinPopScope) - Runtime::popScope(engine); + engine->runtime.popScope(engine); context = engine->currentContext; MOTH_END_INSTR(CallBuiltinPopScope) MOTH_BEGIN_INSTR(CallBuiltinForeachIteratorObject) - STOREVALUE(instr.result, Runtime::foreachIterator(engine, VALUE(instr.arg))); + STOREVALUE(instr.result, engine->runtime.foreachIterator(engine, VALUE(instr.arg))); MOTH_END_INSTR(CallBuiltinForeachIteratorObject) MOTH_BEGIN_INSTR(CallBuiltinForeachNextPropertyName) - STOREVALUE(instr.result, Runtime::foreachNextPropertyName(VALUE(instr.arg))); + STOREVALUE(instr.result, engine->runtime.foreachNextPropertyName(VALUE(instr.arg))); MOTH_END_INSTR(CallBuiltinForeachNextPropertyName) MOTH_BEGIN_INSTR(CallBuiltinDeleteMember) - STOREVALUE(instr.result, Runtime::deleteMember(engine, VALUE(instr.base), instr.member)); + STOREVALUE(instr.result, engine->runtime.deleteMember(engine, VALUE(instr.base), instr.member)); MOTH_END_INSTR(CallBuiltinDeleteMember) MOTH_BEGIN_INSTR(CallBuiltinDeleteSubscript) - STOREVALUE(instr.result, Runtime::deleteElement(engine, VALUE(instr.base), VALUE(instr.index))); + STOREVALUE(instr.result, engine->runtime.deleteElement(engine, VALUE(instr.base), VALUE(instr.index))); MOTH_END_INSTR(CallBuiltinDeleteSubscript) MOTH_BEGIN_INSTR(CallBuiltinDeleteName) - STOREVALUE(instr.result, Runtime::deleteName(engine, instr.name)); + STOREVALUE(instr.result, engine->runtime.deleteName(engine, instr.name)); MOTH_END_INSTR(CallBuiltinDeleteName) MOTH_BEGIN_INSTR(CallBuiltinTypeofScopeObjectProperty) - STOREVALUE(instr.result, Runtime::typeofScopeObjectProperty(engine, VALUE(instr.base), instr.index)); + STOREVALUE(instr.result, engine->runtime.typeofScopeObjectProperty(engine, VALUE(instr.base), instr.index)); MOTH_END_INSTR(CallBuiltinTypeofMember) MOTH_BEGIN_INSTR(CallBuiltinTypeofContextObjectProperty) - STOREVALUE(instr.result, Runtime::typeofContextObjectProperty(engine, VALUE(instr.base), instr.index)); + STOREVALUE(instr.result, engine->runtime.typeofContextObjectProperty(engine, VALUE(instr.base), instr.index)); MOTH_END_INSTR(CallBuiltinTypeofMember) MOTH_BEGIN_INSTR(CallBuiltinTypeofMember) - STOREVALUE(instr.result, Runtime::typeofMember(engine, VALUE(instr.base), instr.member)); + STOREVALUE(instr.result, engine->runtime.typeofMember(engine, VALUE(instr.base), instr.member)); MOTH_END_INSTR(CallBuiltinTypeofMember) MOTH_BEGIN_INSTR(CallBuiltinTypeofSubscript) - STOREVALUE(instr.result, Runtime::typeofElement(engine, VALUE(instr.base), VALUE(instr.index))); + STOREVALUE(instr.result, engine->runtime.typeofElement(engine, VALUE(instr.base), VALUE(instr.index))); MOTH_END_INSTR(CallBuiltinTypeofSubscript) MOTH_BEGIN_INSTR(CallBuiltinTypeofName) - STOREVALUE(instr.result, Runtime::typeofName(engine, instr.name)); + STOREVALUE(instr.result, engine->runtime.typeofName(engine, instr.name)); MOTH_END_INSTR(CallBuiltinTypeofName) MOTH_BEGIN_INSTR(CallBuiltinTypeofValue) - STOREVALUE(instr.result, Runtime::typeofValue(engine, VALUE(instr.value))); + STOREVALUE(instr.result, engine->runtime.typeofValue(engine, VALUE(instr.value))); MOTH_END_INSTR(CallBuiltinTypeofValue) MOTH_BEGIN_INSTR(CallBuiltinDeclareVar) - Runtime::declareVar(engine, instr.isDeletable, instr.varName); + engine->runtime.declareVar(engine, instr.isDeletable, instr.varName); MOTH_END_INSTR(CallBuiltinDeclareVar) MOTH_BEGIN_INSTR(CallBuiltinDefineArray) Q_ASSERT(instr.args + instr.argc <= stackSize); QV4::Value *args = stack + instr.args; - STOREVALUE(instr.result, Runtime::arrayLiteral(engine, args, instr.argc)); + STOREVALUE(instr.result, engine->runtime.arrayLiteral(engine, args, instr.argc)); MOTH_END_INSTR(CallBuiltinDefineArray) MOTH_BEGIN_INSTR(CallBuiltinDefineObjectLiteral) QV4::Value *args = stack + instr.args; - STOREVALUE(instr.result, Runtime::objectLiteral(engine, args, instr.internalClassId, instr.arrayValueCount, instr.arrayGetterSetterCountAndFlags)); + STOREVALUE(instr.result, engine->runtime.objectLiteral(engine, args, instr.internalClassId, instr.arrayValueCount, instr.arrayGetterSetterCountAndFlags)); MOTH_END_INSTR(CallBuiltinDefineObjectLiteral) MOTH_BEGIN_INSTR(CallBuiltinSetupArgumentsObject) - STOREVALUE(instr.result, Runtime::setupArgumentsObject(engine)); + STOREVALUE(instr.result, engine->runtime.setupArgumentsObject(engine)); MOTH_END_INSTR(CallBuiltinSetupArgumentsObject) MOTH_BEGIN_INSTR(CallBuiltinConvertThisToObject) - Runtime::convertThisToObject(engine); + engine->runtime.convertThisToObject(engine); CHECK_EXCEPTION; MOTH_END_INSTR(CallBuiltinConvertThisToObject) @@ -744,7 +744,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = QV4::Primitive::undefinedValue(); - STOREVALUE(instr.result, Runtime::constructValue(engine, VALUE(instr.func), callData)); + STOREVALUE(instr.result, engine->runtime.constructValue(engine, VALUE(instr.func), callData)); MOTH_END_INSTR(CreateValue) MOTH_BEGIN_INSTR(CreateProperty) @@ -753,7 +753,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = VALUE(instr.base); - STOREVALUE(instr.result, Runtime::constructProperty(engine, instr.name, callData)); + STOREVALUE(instr.result, engine->runtime.constructProperty(engine, instr.name, callData)); MOTH_END_INSTR(CreateProperty) MOTH_BEGIN_INSTR(ConstructPropertyLookup) @@ -762,7 +762,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = VALUE(instr.base); - STOREVALUE(instr.result, Runtime::constructPropertyLookup(engine, instr.index, callData)); + STOREVALUE(instr.result, engine->runtime.constructPropertyLookup(engine, instr.index, callData)); MOTH_END_INSTR(ConstructPropertyLookup) MOTH_BEGIN_INSTR(CreateActivationProperty) @@ -771,7 +771,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = QV4::Primitive::undefinedValue(); - STOREVALUE(instr.result, Runtime::constructActivationProperty(engine, instr.name, callData)); + STOREVALUE(instr.result, engine->runtime.constructActivationProperty(engine, instr.name, callData)); MOTH_END_INSTR(CreateActivationProperty) MOTH_BEGIN_INSTR(ConstructGlobalLookup) @@ -780,7 +780,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = QV4::Primitive::undefinedValue(); - STOREVALUE(instr.result, Runtime::constructGlobalLookup(engine, instr.index, callData)); + STOREVALUE(instr.result, engine->runtime.constructGlobalLookup(engine, instr.index, callData)); MOTH_END_INSTR(ConstructGlobalLookup) MOTH_BEGIN_INSTR(Jump) @@ -802,7 +802,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(JumpNe) MOTH_BEGIN_INSTR(UNot) - STOREVALUE(instr.result, Runtime::uNot(VALUE(instr.source))); + STOREVALUE(instr.result, engine->runtime.uNot(VALUE(instr.source))); MOTH_END_INSTR(UNot) MOTH_BEGIN_INSTR(UNotBool) @@ -811,15 +811,15 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(UNotBool) MOTH_BEGIN_INSTR(UPlus) - STOREVALUE(instr.result, Runtime::uPlus(VALUE(instr.source))); + STOREVALUE(instr.result, engine->runtime.uPlus(VALUE(instr.source))); MOTH_END_INSTR(UPlus) MOTH_BEGIN_INSTR(UMinus) - STOREVALUE(instr.result, Runtime::uMinus(VALUE(instr.source))); + STOREVALUE(instr.result, engine->runtime.uMinus(VALUE(instr.source))); MOTH_END_INSTR(UMinus) MOTH_BEGIN_INSTR(UCompl) - STOREVALUE(instr.result, Runtime::complement(VALUE(instr.source))); + STOREVALUE(instr.result, engine->runtime.complement(VALUE(instr.source))); MOTH_END_INSTR(UCompl) MOTH_BEGIN_INSTR(UComplInt) @@ -827,31 +827,32 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(UComplInt) MOTH_BEGIN_INSTR(Increment) - STOREVALUE(instr.result, Runtime::increment(VALUE(instr.source))); + STOREVALUE(instr.result, engine->runtime.increment(VALUE(instr.source))); MOTH_END_INSTR(Increment) MOTH_BEGIN_INSTR(Decrement) - STOREVALUE(instr.result, Runtime::decrement(VALUE(instr.source))); + STOREVALUE(instr.result, engine->runtime.decrement(VALUE(instr.source))); MOTH_END_INSTR(Decrement) MOTH_BEGIN_INSTR(Binop) - STOREVALUE(instr.result, instr.alu(VALUE(instr.lhs), VALUE(instr.rhs))); + QV4::Runtime::BinaryOperation op = *reinterpret_cast<QV4::Runtime::BinaryOperation *>(reinterpret_cast<char *>(&engine->runtime) + instr.alu); + STOREVALUE(instr.result, op(VALUE(instr.lhs), VALUE(instr.rhs))); MOTH_END_INSTR(Binop) MOTH_BEGIN_INSTR(Add) - STOREVALUE(instr.result, Runtime::add(engine, VALUE(instr.lhs), VALUE(instr.rhs))); + STOREVALUE(instr.result, engine->runtime.add(engine, VALUE(instr.lhs), VALUE(instr.rhs))); MOTH_END_INSTR(Add) MOTH_BEGIN_INSTR(BitAnd) - STOREVALUE(instr.result, Runtime::bitAnd(VALUE(instr.lhs), VALUE(instr.rhs))); + STOREVALUE(instr.result, engine->runtime.bitAnd(VALUE(instr.lhs), VALUE(instr.rhs))); MOTH_END_INSTR(BitAnd) MOTH_BEGIN_INSTR(BitOr) - STOREVALUE(instr.result, Runtime::bitOr(VALUE(instr.lhs), VALUE(instr.rhs))); + STOREVALUE(instr.result, engine->runtime.bitOr(VALUE(instr.lhs), VALUE(instr.rhs))); MOTH_END_INSTR(BitOr) MOTH_BEGIN_INSTR(BitXor) - STOREVALUE(instr.result, Runtime::bitXor(VALUE(instr.lhs), VALUE(instr.rhs))); + STOREVALUE(instr.result, engine->runtime.bitXor(VALUE(instr.lhs), VALUE(instr.rhs))); MOTH_END_INSTR(BitXor) MOTH_BEGIN_INSTR(Shr) @@ -886,15 +887,16 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(ShlConst) MOTH_BEGIN_INSTR(Mul) - STOREVALUE(instr.result, Runtime::mul(VALUE(instr.lhs), VALUE(instr.rhs))); + STOREVALUE(instr.result, engine->runtime.mul(VALUE(instr.lhs), VALUE(instr.rhs))); MOTH_END_INSTR(Mul) MOTH_BEGIN_INSTR(Sub) - STOREVALUE(instr.result, Runtime::sub(VALUE(instr.lhs), VALUE(instr.rhs))); + STOREVALUE(instr.result, engine->runtime.sub(VALUE(instr.lhs), VALUE(instr.rhs))); MOTH_END_INSTR(Sub) MOTH_BEGIN_INSTR(BinopContext) - STOREVALUE(instr.result, instr.alu(engine, VALUE(instr.lhs), VALUE(instr.rhs))); + QV4::Runtime::BinaryOperationContext op = *reinterpret_cast<QV4::Runtime::BinaryOperationContext *>(reinterpret_cast<char *>(&engine->runtime) + instr.alu); + STOREVALUE(instr.result, op(engine, VALUE(instr.lhs), VALUE(instr.rhs))); MOTH_END_INSTR(BinopContext) MOTH_BEGIN_INSTR(Ret) @@ -922,15 +924,15 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(LoadThis) MOTH_BEGIN_INSTR(LoadQmlContext) - VALUE(instr.result) = Runtime::getQmlContext(static_cast<QV4::NoThrowEngine*>(engine)); + VALUE(instr.result) = engine->runtime.getQmlContext(static_cast<QV4::NoThrowEngine*>(engine)); MOTH_END_INSTR(LoadQmlContext) MOTH_BEGIN_INSTR(LoadQmlImportedScripts) - VALUE(instr.result) = Runtime::getQmlImportedScripts(static_cast<QV4::NoThrowEngine*>(engine)); + VALUE(instr.result) = engine->runtime.getQmlImportedScripts(static_cast<QV4::NoThrowEngine*>(engine)); MOTH_END_INSTR(LoadQmlImportedScripts) MOTH_BEGIN_INSTR(LoadQmlSingleton) - VALUE(instr.result) = Runtime::getQmlSingleton(static_cast<QV4::NoThrowEngine*>(engine), instr.name); + VALUE(instr.result) = engine->runtime.getQmlSingleton(static_cast<QV4::NoThrowEngine*>(engine), instr.name); MOTH_END_INSTR(LoadQmlSingleton) #ifdef MOTH_THREADED_INTERPRETER diff --git a/src/qml/parser/qqmljsengine_p.cpp b/src/qml/parser/qqmljsengine_p.cpp index d3b3af317c..07064a4889 100644 --- a/src/qml/parser/qqmljsengine_p.cpp +++ b/src/qml/parser/qqmljsengine_p.cpp @@ -40,7 +40,7 @@ #include "qqmljsengine_p.h" #include "qqmljsglobal_p.h" -#include <QtCore/qnumeric.h> +#include <QtCore/private/qnumeric_p.h> #include <QtCore/qhash.h> #include <QtCore/qdebug.h> @@ -62,7 +62,7 @@ static inline int toDigit(char c) double integerFromString(const char *buf, int size, int radix) { if (size == 0) - return qQNaN(); + return qt_qnan(); double sign = 1.0; int i = 0; @@ -101,7 +101,7 @@ double integerFromString(const char *buf, int size, int radix) if (!qstrcmp(buf, "Infinity")) result = qInf(); else - result = qQNaN(); + result = qt_qnan(); } else { result = 0; double multiplier = 1; diff --git a/src/qml/qml/ftw/ftw.pri b/src/qml/qml/ftw/ftw.pri index 51697b0aff..a671cfa12d 100644 --- a/src/qml/qml/ftw/ftw.pri +++ b/src/qml/qml/ftw/ftw.pri @@ -5,7 +5,6 @@ HEADERS += \ $$PWD/qhashedstring_p.h \ $$PWD/qqmlrefcount_p.h \ $$PWD/qfieldlist_p.h \ - $$PWD/qhashfield_p.h \ $$PWD/qqmlthread_p.h \ $$PWD/qfinitestack_p.h \ $$PWD/qrecursionwatcher_p.h \ diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index f91378b758..e8ddfecbe3 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -226,9 +226,6 @@ bool QQmlBinding::write(const QQmlPropertyData &core, Q_ASSERT(m_target.data()); Q_ASSERT(core.coreIndex != -1); - QQmlEngine *engine = context()->engine; - QV8Engine *v8engine = QQmlEnginePrivate::getV8Engine(engine); - #define QUICK_STORE(cpptype, conversion) \ { \ cpptype o = (conversion); \ @@ -239,7 +236,7 @@ bool QQmlBinding::write(const QQmlPropertyData &core, } \ - if (!isUndefined && !core.isValueTypeVirtual()) { + if (Q_LIKELY(!isUndefined && !core.isValueTypeVirtual())) { switch (core.propType) { case QMetaType::Int: if (result.isInteger()) @@ -270,6 +267,9 @@ bool QQmlBinding::write(const QQmlPropertyData &core, } #undef QUICK_STORE + QQmlEngine *engine = context()->engine; + QV8Engine *v8engine = QQmlEnginePrivate::getV8Engine(engine); + int type = core.isValueTypeVirtual() ? core.valueTypePropType : core.propType; QQmlJavaScriptExpression::DeleteWatcher watcher(this); @@ -497,7 +497,7 @@ QQmlPropertyData QQmlBinding::getPropertyData() const Q_ASSERT(propertyData); QQmlPropertyData d = *propertyData; - if (valueTypeIndex != -1) { + if (Q_UNLIKELY(valueTypeIndex != -1)) { const QMetaObject *valueTypeMetaObject = QQmlValueTypeFactory::metaObjectForMetaType(d.propType); Q_ASSERT(valueTypeMetaObject); QMetaProperty vtProp = valueTypeMetaObject->property(valueTypeIndex); diff --git a/src/qml/qml/qqmldata_p.h b/src/qml/qml/qqmldata_p.h index 1a8cd0ce09..ad2456a68d 100644 --- a/src/qml/qml/qqmldata_p.h +++ b/src/qml/qml/qqmldata_p.h @@ -149,7 +149,7 @@ public: inline QQmlNotifierEndpoint *notify(int index); void addNotify(int index, QQmlNotifierEndpoint *); int endpointCount(int index); - bool signalHasEndpoint(int index); + bool signalHasEndpoint(int index) const; void disconnectNotifiers(); // The context that created the C++ object @@ -264,6 +264,15 @@ QQmlNotifierEndpoint *QQmlData::notify(int index) } } +/* + The index MUST be in the range returned by QObjectPrivate::signalIndex() + This is different than the index returned by QMetaMethod::methodIndex() +*/ +inline bool QQmlData::signalHasEndpoint(int index) const +{ + return notifyList && (notifyList->connectionMask & (1ULL << quint64(index % 64))); +} + bool QQmlData::hasBindingBit(int coreIndex) const { int bit = coreIndex * 2; diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 68e06dfc31..63d3feee1e 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -179,6 +179,7 @@ void QQmlEnginePrivate::registerBaseTypes(const char *uri, int versionMajor, int qmlRegisterType<QQmlComponent>(uri,versionMajor,versionMinor,"Component"); qmlRegisterType<QObject>(uri,versionMajor,versionMinor,"QtObject"); qmlRegisterType<QQmlBind>(uri, versionMajor, versionMinor,"Binding"); + qmlRegisterType<QQmlBind,8>(uri, versionMajor, (versionMinor < 8 ? 8 : versionMinor), "Binding"); //Only available in >=2.8 qmlRegisterType<QQmlConnections,1>(uri, versionMajor, (versionMinor < 3 ? 3 : versionMinor), "Connections"); //Only available in >=2.3 qmlRegisterType<QQmlConnections>(uri, versionMajor, versionMinor,"Connections"); qmlRegisterType<QQmlTimer>(uri, versionMajor, versionMinor,"Timer"); @@ -1605,15 +1606,6 @@ void QQmlData::addNotify(int index, QQmlNotifierEndpoint *endpoint) } } -/* - index MUST in the range returned by QObjectPrivate::signalIndex() - This is different than the index returned by QMetaMethod::methodIndex() -*/ -bool QQmlData::signalHasEndpoint(int index) -{ - return notifyList && (notifyList->connectionMask & (1ULL << quint64(index % 64))); -} - void QQmlData::disconnectNotifiers() { if (notifyList) { @@ -1909,16 +1901,6 @@ void QQmlEnginePrivate::warning(QQmlEnginePrivate *engine, const QList<QQmlError } /* - This function should be called prior to evaluation of any js expression, - so that scarce resources are not freed prematurely (eg, if there is a - nested javascript expression). - */ -void QQmlEnginePrivate::referenceScarceResources() -{ - scarceResourcesRefCount += 1; -} - -/* This function should be called after evaluation of the js expression is complete, and so the scarce resources may be freed safely. */ @@ -1930,7 +1912,7 @@ void QQmlEnginePrivate::dereferenceScarceResources() // if the refcount is zero, then evaluation of the "top level" // expression must have completed. We can safely release the // scarce resources. - if (scarceResourcesRefCount == 0) { + if (Q_UNLIKELY(scarceResourcesRefCount == 0)) { // iterate through the list and release them all. // note that the actual SRD is owned by the JS engine, // so we cannot delete the SRD; but we can free the diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h index 795a505742..92eadb0540 100644 --- a/src/qml/qml/qqmlengine_p.h +++ b/src/qml/qml/qqmlengine_p.h @@ -269,6 +269,16 @@ private: void doDeleteInEngineThread(); }; +/* + This function should be called prior to evaluation of any js expression, + so that scarce resources are not freed prematurely (eg, if there is a + nested javascript expression). + */ +inline void QQmlEnginePrivate::referenceScarceResources() +{ + scarceResourcesRefCount += 1; +} + /*! Returns true if the calling thread is the QQmlEngine thread. */ diff --git a/src/qml/qml/qqmlincubator.cpp b/src/qml/qml/qqmlincubator.cpp index a046bfd922..235aa1bf44 100644 --- a/src/qml/qml/qqmlincubator.cpp +++ b/src/qml/qml/qqmlincubator.cpp @@ -687,7 +687,7 @@ void QQmlIncubator::statusChanged(Status status) Called after the \a object is first created, but before property bindings are evaluated and, if applicable, QQmlParserStatus::componentComplete() is called. This is equivalent to the point between QQmlComponent::beginCreate() -and QQmlComponent::endCreate(), and can be used to assign initial values +and QQmlComponent::completeCreate(), and can be used to assign initial values to the object's properties. The default implementation does nothing. diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index 15d0a571a5..069dadd1c9 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -40,7 +40,7 @@ #include "qqmljavascriptexpression_p.h" #include <private/qqmlexpression_p.h> -#include <private/qqmlcontextwrapper_p.h> +#include <private/qv4context_p.h> #include <private/qv4value_p.h> #include <private/qv4functionobject_p.h> #include <private/qv4script_p.h> @@ -336,14 +336,6 @@ void QQmlPropertyCapture::registerQmlDependencies(QV4::ExecutionEngine *engine, } - -void QQmlJavaScriptExpression::clearError() -{ - if (m_error) - delete m_error; - m_error = 0; -} - QQmlError QQmlJavaScriptExpression::error(QQmlEngine *engine) const { Q_UNUSED(engine); diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h index e8ca498ff4..64cb1bb242 100644 --- a/src/qml/qml/qqmljavascriptexpression_p.h +++ b/src/qml/qml/qqmljavascriptexpression_p.h @@ -243,6 +243,13 @@ bool QQmlJavaScriptExpression::hasDelayedError() const return m_error; } +inline void QQmlJavaScriptExpression::clearError() +{ + if (m_error) + delete m_error; + m_error = 0; +} + QQmlJavaScriptExpressionGuard::QQmlJavaScriptExpressionGuard(QQmlJavaScriptExpression *e) : QQmlNotifierEndpoint(QQmlNotifierEndpoint::QQmlJavaScriptExpressionGuard), expression(e), next(0) diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp index 3be52cf461..0522aa93ee 100644 --- a/src/qml/qml/qqmlpropertycache.cpp +++ b/src/qml/qml/qqmlpropertycache.cpp @@ -704,14 +704,6 @@ void QQmlPropertyCache::append(const QMetaObject *metaObject, } } -QQmlPropertyData *QQmlPropertyCache::ensureResolved(QQmlPropertyData *p) const -{ - if (p && p->notFullyResolved()) - resolve(p); - - return p; -} - void QQmlPropertyCache::resolve(QQmlPropertyData *data) const { Q_ASSERT(data->notFullyResolved()); @@ -840,19 +832,6 @@ int QQmlPropertyCache::methodIndexToSignalIndex(int index) const } QQmlPropertyData * -QQmlPropertyCache::property(int index) const -{ - if (index < 0 || index >= (propertyIndexCacheStart + propertyIndexCache.count())) - return 0; - - if (index < propertyIndexCacheStart) - return _parent->property(index); - - QQmlPropertyData *rv = const_cast<QQmlPropertyData *>(&propertyIndexCache.at(index - propertyIndexCacheStart)); - return ensureResolved(rv); -} - -QQmlPropertyData * QQmlPropertyCache::method(int index) const { if (index < 0 || index >= (methodIndexCacheStart + methodIndexCache.count())) diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h index 4ff5ee89f9..bb39a5e371 100644 --- a/src/qml/qml/qqmlpropertycache_p.h +++ b/src/qml/qml/qqmlpropertycache_p.h @@ -494,6 +494,18 @@ int QQmlPropertyRawData::encodedIndex() const return isValueTypeVirtual()?QQmlPropertyData::encodeValueTypePropertyIndex(coreIndex, valueTypeCoreIndex):coreIndex; } +inline QQmlPropertyData *QQmlPropertyCache::property(int index) const +{ + if (index < 0 || index >= (propertyIndexCacheStart + propertyIndexCache.count())) + return 0; + + if (index < propertyIndexCacheStart) + return _parent->property(index); + + QQmlPropertyData *rv = const_cast<QQmlPropertyData *>(&propertyIndexCache.at(index - propertyIndexCacheStart)); + return ensureResolved(rv); +} + QQmlPropertyData * QQmlPropertyCache::overrideData(QQmlPropertyData *data) const { @@ -542,6 +554,14 @@ int QQmlPropertyCache::signalOffset() const return signalHandlerIndexCacheStart; } +inline QQmlPropertyData *QQmlPropertyCache::ensureResolved(QQmlPropertyData *p) const +{ + if (p && p->notFullyResolved()) + resolve(p); + + return p; +} + QQmlMetaObject::QQmlMetaObject() { } diff --git a/src/qml/qml/qqmlvmemetaobject_p.h b/src/qml/qml/qqmlvmemetaobject_p.h index c95cb7e070..fcdac3cc53 100644 --- a/src/qml/qml/qqmlvmemetaobject_p.h +++ b/src/qml/qml/qqmlvmemetaobject_p.h @@ -171,7 +171,7 @@ public: QQmlPropertyCache *propertyCache() const { return cache; } protected: - virtual int metaCall(QObject *o, QMetaObject::Call c, int id, void **a); + int metaCall(QObject *o, QMetaObject::Call c, int id, void **a) Q_DECL_OVERRIDE; bool intercept(QMetaObject::Call c, int id, void **a); public: diff --git a/src/qml/types/qqmlbind.cpp b/src/qml/types/qqmlbind.cpp index ed9a8533c0..3102da3f20 100644 --- a/src/qml/types/qqmlbind.cpp +++ b/src/qml/types/qqmlbind.cpp @@ -51,6 +51,7 @@ #include <QtCore/qfile.h> #include <QtCore/qdebug.h> +#include <QtCore/qtimer.h> #include <private/qobject_p.h> @@ -59,16 +60,18 @@ QT_BEGIN_NAMESPACE class QQmlBindPrivate : public QObjectPrivate { public: - QQmlBindPrivate() : componentComplete(true), obj(0) {} + QQmlBindPrivate() : obj(0), componentComplete(true), delayed(false), pendingEval(false) {} ~QQmlBindPrivate() { } QQmlNullableValue<bool> when; - bool componentComplete; QPointer<QObject> obj; QString propName; QQmlNullableValue<QVariant> value; QQmlProperty prop; QQmlAbstractBinding::Ptr prevBind; + bool componentComplete:1; + bool delayed:1; + bool pendingEval:1; void validate(QObject *binding) const; }; @@ -281,7 +284,42 @@ void QQmlBind::setValue(const QVariant &v) { Q_D(QQmlBind); d->value = v; - eval(); + prepareEval(); +} + +/*! + \qmlproperty bool QtQml::Binding::delayed + + This property holds whether the binding should be delayed. + + A delayed binding will not immediately update the target, but rather wait + until the event queue has been cleared. This can be used as an optimization, + or to prevent intermediary values from being assigned. + + \code + Binding { + target: contactName; property: 'text' + value: givenName + " " + familyName; when: list.ListView.isCurrentItem + delayed: true + } + \endcode +*/ +bool QQmlBind::delayed() const +{ + Q_D(const QQmlBind); + return d->delayed; +} + +void QQmlBind::setDelayed(bool delayed) +{ + Q_D(QQmlBind); + if (d->delayed == delayed) + return; + + d->delayed = delayed; + + if (!d->delayed) + eval(); } void QQmlBind::setTarget(const QQmlProperty &p) @@ -307,9 +345,22 @@ void QQmlBind::componentComplete() eval(); } +void QQmlBind::prepareEval() +{ + Q_D(QQmlBind); + if (d->delayed) { + if (!d->pendingEval) + QTimer::singleShot(0, this, &QQmlBind::eval); + d->pendingEval = true; + } else { + eval(); + } +} + void QQmlBind::eval() { Q_D(QQmlBind); + d->pendingEval = false; if (!d->prop.isValid() || d->value.isNull || !d->componentComplete) return; diff --git a/src/qml/types/qqmlbind_p.h b/src/qml/types/qqmlbind_p.h index 581995af56..77939a40bc 100644 --- a/src/qml/types/qqmlbind_p.h +++ b/src/qml/types/qqmlbind_p.h @@ -68,6 +68,7 @@ class Q_AUTOTEST_EXPORT QQmlBind : public QObject, public QQmlPropertyValueSourc Q_PROPERTY(QString property READ property WRITE setProperty) Q_PROPERTY(QVariant value READ value WRITE setValue) Q_PROPERTY(bool when READ when WRITE setWhen) + Q_PROPERTY(bool delayed READ delayed WRITE setDelayed REVISION 8) public: QQmlBind(QObject *parent=0); @@ -85,12 +86,16 @@ public: QVariant value() const; void setValue(const QVariant &); + bool delayed() const; + void setDelayed(bool); + protected: virtual void setTarget(const QQmlProperty &); virtual void classBegin(); virtual void componentComplete(); private: + void prepareEval(); void eval(); }; diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp index 91eef2d982..60175ef310 100644 --- a/src/qml/types/qqmllistmodel.cpp +++ b/src/qml/types/qqmllistmodel.cpp @@ -169,9 +169,7 @@ ListLayout::ListLayout(const ListLayout *other) : currentBlock(0), currentBlockO ListLayout::~ListLayout() { - for (int i=0 ; i < roles.count() ; ++i) { - delete roles[i]; - } + qDeleteAll(roles); } void ListLayout::sync(ListLayout *src, ListLayout *target) @@ -1440,8 +1438,7 @@ void DynamicRoleModelNode::updateValues(const QVariantMap &object, QVector<int> const QByteArray &keyUtf8 = key.toUtf8(); QQmlListModel *existingModel = qobject_cast<QQmlListModel *>(m_meta->value(keyUtf8).value<QObject *>()); - if (existingModel) - delete existingModel; + delete existingModel; if (m_meta->setValue(keyUtf8, value)) roles << roleIndex; @@ -1457,8 +1454,7 @@ DynamicRoleModelNodeMetaObject::~DynamicRoleModelNodeMetaObject() { for (int i=0 ; i < count() ; ++i) { QQmlListModel *subModel = qobject_cast<QQmlListModel *>(value(i).value<QObject *>()); - if (subModel) - delete subModel; + delete subModel; } } @@ -1469,8 +1465,7 @@ void DynamicRoleModelNodeMetaObject::propertyWrite(int index) QVariant v = value(index); QQmlListModel *model = qobject_cast<QQmlListModel *>(v.value<QObject *>()); - if (model) - delete model; + delete model; } void DynamicRoleModelNodeMetaObject::propertyWritten(int index) @@ -1662,8 +1657,7 @@ QQmlListModel::QQmlListModel(QQmlListModel *orig, QQmlListModelWorkerAgent *agen QQmlListModel::~QQmlListModel() { - for (int i=0 ; i < m_modelObjects.count() ; ++i) - delete m_modelObjects[i]; + qDeleteAll(m_modelObjects); if (m_primary) { m_listModel->destroy(); @@ -1982,15 +1976,7 @@ void QQmlListModel::setDynamicRoles(bool enableDynamicRoles) */ int QQmlListModel::count() const { - int count; - - if (m_dynamicRoles) - count = m_modelObjects.count(); - else { - count = m_listModel->elementCount(); - } - - return count; + return m_dynamicRoles ? m_modelObjects.count() : m_listModel->elementCount(); } /*! @@ -2002,13 +1988,12 @@ int QQmlListModel::count() const */ void QQmlListModel::clear() { - int cleared = count(); + const int cleared = count(); emitItemsAboutToBeRemoved(0, cleared); if (m_dynamicRoles) { - for (int i=0 ; i < m_modelObjects.count() ; ++i) - delete m_modelObjects[i]; + qDeleteAll(m_modelObjects); m_modelObjects.clear(); } else { m_listModel->clear(); diff --git a/src/qml/types/qqmllistmodel_p.h b/src/qml/types/qqmllistmodel_p.h index b35a5a1224..e71b1e24b8 100644 --- a/src/qml/types/qqmllistmodel_p.h +++ b/src/qml/types/qqmllistmodel_p.h @@ -187,8 +187,8 @@ public: QQmlListModelParser() : QQmlCustomParser(QQmlCustomParser::AcceptsSignalHandlers) {} - virtual void verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &bindings); - virtual void applyBindings(QObject *obj, QQmlCompiledData *cdata, const QList<const QV4::CompiledData::Binding *> &bindings); + void verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &bindings) Q_DECL_OVERRIDE; + void applyBindings(QObject *obj, QQmlCompiledData *cdata, const QList<const QV4::CompiledData::Binding *> &bindings) Q_DECL_OVERRIDE; private: bool verifyProperty(const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding); diff --git a/src/qml/types/qqmllistmodel_p_p.h b/src/qml/types/qqmllistmodel_p_p.h index a59b8de525..431e6aca9f 100644 --- a/src/qml/types/qqmllistmodel_p_p.h +++ b/src/qml/types/qqmllistmodel_p_p.h @@ -198,7 +198,7 @@ public: explicit Role(const Role *other); ~Role(); - // This enum must be kept in sync with the roleTypeNames variable in qdeclarativelistmodel.cpp + // This enum must be kept in sync with the roleTypeNames variable in qqmllistmodel.cpp enum DataType { Invalid = -1, diff --git a/src/qmltest/quicktestresult.cpp b/src/qmltest/quicktestresult.cpp index 7a26027e11..235b532dbb 100644 --- a/src/qmltest/quicktestresult.cpp +++ b/src/qmltest/quicktestresult.cpp @@ -111,9 +111,7 @@ public Q_SLOTS: || x * y >= m_image.width() * m_image.height()) return QVariant(); - const QRgb* pixel = reinterpret_cast<const QRgb*>(m_image.constScanLine(y)); - pixel += x; - return QColor::fromRgba(*pixel); + return QColor::fromRgba(m_image.pixel(QPoint(x, y))); } bool equals(QuickTestImageObject *other) const diff --git a/src/quick/designer/qqmldesignermetaobject.cpp b/src/quick/designer/qqmldesignermetaobject.cpp index f238740504..46808f978b 100644 --- a/src/quick/designer/qqmldesignermetaobject.cpp +++ b/src/quick/designer/qqmldesignermetaobject.cpp @@ -41,7 +41,7 @@ #include <QSharedPointer> #include <QMetaProperty> -#include <qnumeric.h> +#include <QtCore/private/qnumeric_p.h> #include <QDebug> #include <private/qqmlengine_p.h> @@ -271,19 +271,19 @@ int QQmlDesignerMetaObject::metaCall(QObject *o, QMetaObject::Call call, int id, if (call == QMetaObject::WriteProperty && propertyById.userType() == QMetaType::QVariant && reinterpret_cast<QVariant *>(a[0])->type() == QVariant::Double - && qIsNaN(reinterpret_cast<QVariant *>(a[0])->toDouble())) { + && qt_is_nan(reinterpret_cast<QVariant *>(a[0])->toDouble())) { return -1; } if (call == QMetaObject::WriteProperty && propertyById.userType() == QMetaType::Double - && qIsNaN(*reinterpret_cast<double*>(a[0]))) { + && qt_is_nan(*reinterpret_cast<double*>(a[0]))) { return -1; } if (call == QMetaObject::WriteProperty && propertyById.userType() == QMetaType::Float - && qIsNaN(*reinterpret_cast<float*>(a[0]))) { + && qt_is_nan(*reinterpret_cast<float*>(a[0]))) { return -1; } diff --git a/src/quick/doc/images/anchorchanges.png b/src/quick/doc/images/anchorchanges.png Binary files differindex 4973e4e9aa..12d99393b6 100644 --- a/src/quick/doc/images/anchorchanges.png +++ b/src/quick/doc/images/anchorchanges.png diff --git a/src/quick/doc/images/parentchange.png b/src/quick/doc/images/parentchange.png Binary files differindex 93206fbbb2..05f78eac34 100644 --- a/src/quick/doc/images/parentchange.png +++ b/src/quick/doc/images/parentchange.png diff --git a/src/quick/doc/images/qml-borderimage-normal-image.png b/src/quick/doc/images/qml-borderimage-normal-image.png Binary files differindex ae7460a7d7..fd0dd37c82 100644 --- a/src/quick/doc/images/qml-borderimage-normal-image.png +++ b/src/quick/doc/images/qml-borderimage-normal-image.png diff --git a/src/quick/doc/images/qml-borderimage-scaled.png b/src/quick/doc/images/qml-borderimage-scaled.png Binary files differindex 8035c79f37..e42891ecc7 100644 --- a/src/quick/doc/images/qml-borderimage-scaled.png +++ b/src/quick/doc/images/qml-borderimage-scaled.png diff --git a/src/quick/doc/images/qml-borderimage-tiled.png b/src/quick/doc/images/qml-borderimage-tiled.png Binary files differindex 14883d0dd6..e27d9601c4 100644 --- a/src/quick/doc/images/qml-borderimage-tiled.png +++ b/src/quick/doc/images/qml-borderimage-tiled.png diff --git a/src/quick/doc/images/qml-item-canvas-clip-complex.png b/src/quick/doc/images/qml-item-canvas-clip-complex.png Binary files differindex cb582bad41..92730ff2e0 100644 --- a/src/quick/doc/images/qml-item-canvas-clip-complex.png +++ b/src/quick/doc/images/qml-item-canvas-clip-complex.png diff --git a/src/quick/doc/images/qml-item-canvas-startAngle.png b/src/quick/doc/images/qml-item-canvas-startAngle.png Binary files differindex f81562e5e4..bf82c3aa4b 100644 --- a/src/quick/doc/images/qml-item-canvas-startAngle.png +++ b/src/quick/doc/images/qml-item-canvas-startAngle.png diff --git a/src/quick/doc/images/qml-mousearea-snippet.png b/src/quick/doc/images/qml-mousearea-snippet.png Binary files differindex 15229446c7..d1ddd8d2f5 100644 --- a/src/quick/doc/images/qml-mousearea-snippet.png +++ b/src/quick/doc/images/qml-mousearea-snippet.png diff --git a/src/quick/doc/images/qml-photoviewer-demo-small.png b/src/quick/doc/images/qml-photoviewer-demo-small.png Binary files differindex b16fb4e53a..ada37794ae 100644 --- a/src/quick/doc/images/qml-photoviewer-demo-small.png +++ b/src/quick/doc/images/qml-photoviewer-demo-small.png diff --git a/src/quick/doc/images/qml-rssnews-demo-small.png b/src/quick/doc/images/qml-rssnews-demo-small.png Binary files differindex 451a420623..299f72adc5 100644 --- a/src/quick/doc/images/qml-rssnews-demo-small.png +++ b/src/quick/doc/images/qml-rssnews-demo-small.png diff --git a/src/quick/doc/images/qmldesigner-visual-editor.png b/src/quick/doc/images/qmldesigner-visual-editor.png Binary files differindex 9cd4b8b2dc..94f8239ed4 100644 --- a/src/quick/doc/images/qmldesigner-visual-editor.png +++ b/src/quick/doc/images/qmldesigner-visual-editor.png diff --git a/src/quick/doc/qtquick.qdocconf b/src/quick/doc/qtquick.qdocconf index 4f141a733a..131cd758a5 100644 --- a/src/quick/doc/qtquick.qdocconf +++ b/src/quick/doc/qtquick.qdocconf @@ -65,6 +65,7 @@ sourcedirs += ../../plugins excludedirs += ../../imports/models \ ../../imports/statemachine +excludefiles += ../util/qquickpropertychanges_p.h examples.fileextensions += "*.qm" manifestmeta.thumbnail.names += "QtQuick/Threaded ListModel Example" \ diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index 3e84a79445..74666fb8b6 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -65,7 +65,7 @@ #include <private/qv4scopedvalue_p.h> #include <QtCore/qmath.h> -#include <QtCore/qnumeric.h> +#include <QtCore/private/qnumeric_p.h> #include <QtCore/QRunnable> #include <QtGui/qguiapplication.h> #include <QtGui/qopenglframebufferobject.h> @@ -1260,7 +1260,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_globalAlpha(QV4::CallContext *c QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>()); CHECK_CONTEXT_SETTER(r) - double globalAlpha = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double globalAlpha = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); if (!qIsFinite(globalAlpha)) return QV4::Encode::undefined(); @@ -2010,7 +2010,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_shadowOffsetX(QV4::CallContext QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject()); CHECK_CONTEXT_SETTER(r) - qreal offsetX = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + qreal offsetX = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); if (qIsFinite(offsetX) && offsetX != r->d()->context->state.shadowOffsetX) { r->d()->context->state.shadowOffsetX = offsetX; r->d()->context->buffer()->setShadowOffsetX(offsetX); @@ -2038,7 +2038,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_shadowOffsetY(QV4::CallContext QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject()); CHECK_CONTEXT_SETTER(r) - qreal offsetY = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + qreal offsetY = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); if (qIsFinite(offsetY) && offsetY != r->d()->context->state.shadowOffsetY) { r->d()->context->state.shadowOffsetY = offsetY; r->d()->context->buffer()->setShadowOffsetY(offsetY); diff --git a/src/quick/items/items.qrc b/src/quick/items/items.qrc index 671d8acdbb..99f9b5224f 100644 --- a/src/quick/items/items.qrc +++ b/src/quick/items/items.qrc @@ -1,5 +1,5 @@ <RCC> - <qresource prefix="/items"> + <qresource prefix="/qt-project.org/items"> <file>shaders/sprite.frag</file> <file>shaders/sprite.vert</file> <file>shaders/shadereffect.vert</file> diff --git a/src/quick/items/qquickanimatedsprite.cpp b/src/quick/items/qquickanimatedsprite.cpp index c32e9546a5..77c7ae106b 100644 --- a/src/quick/items/qquickanimatedsprite.cpp +++ b/src/quick/items/qquickanimatedsprite.cpp @@ -102,8 +102,8 @@ public: AnimatedSpriteMaterialData() : QSGMaterialShader() { - setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/items/shaders/sprite.vert")); - setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/items/shaders/sprite.frag")); + setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/items/shaders/sprite.vert")); + setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/items/shaders/sprite.frag")); } void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *) Q_DECL_OVERRIDE diff --git a/src/quick/items/qquickimage.cpp b/src/quick/items/qquickimage.cpp index 8162eeb1bc..34b8f0ac49 100644 --- a/src/quick/items/qquickimage.cpp +++ b/src/quick/items/qquickimage.cpp @@ -697,17 +697,17 @@ QSGNode *QQuickImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) break; case Pad: - qreal w = qMin(qreal(d->pix.width()), width()); - qreal h = qMin(qreal(d->pix.height()), height()); - qreal x = (d->pix.width() > width()) ? -xOffset : 0; - qreal y = (d->pix.height() > height()) ? -yOffset : 0; + qreal w = qMin(qreal(pixWidth), width()); + qreal h = qMin(qreal(pixHeight), height()); + qreal x = (pixWidth > width()) ? -xOffset : 0; + qreal y = (pixHeight > height()) ? -yOffset : 0; targetRect = QRectF(x + xOffset, y + yOffset, w, h); sourceRect = QRectF(x, y, w, h); break; }; - qreal nsWidth = (hWrap == QSGTexture::Repeat) ? d->pix.width() / d->devicePixelRatio : d->pix.width(); - qreal nsHeight = (vWrap == QSGTexture::Repeat) ? d->pix.height() / d->devicePixelRatio : d->pix.height(); + qreal nsWidth = (hWrap == QSGTexture::Repeat || d->fillMode == Pad) ? d->pix.width() / d->devicePixelRatio : d->pix.width(); + qreal nsHeight = (vWrap == QSGTexture::Repeat || d->fillMode == Pad) ? d->pix.height() / d->devicePixelRatio : d->pix.height(); QRectF nsrect(sourceRect.x() / nsWidth, sourceRect.y() / nsHeight, sourceRect.width() / nsWidth, diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index da89a51f24..ea2cb5aa5f 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -56,7 +56,7 @@ #include <QtGui/private/qguiapplication_p.h> #include <QtGui/qinputmethod.h> #include <QtCore/qcoreevent.h> -#include <QtCore/qnumeric.h> +#include <QtCore/private/qnumeric_p.h> #include <QtGui/qpa/qplatformtheme.h> #include <QtCore/qloggingcategory.h> @@ -6260,8 +6260,8 @@ void QQuickItem::setX(qreal v) d->dirty(QQuickItemPrivate::Position); - geometryChanged(QRectF(x(), y(), width(), height()), - QRectF(oldx, y(), width(), height())); + geometryChanged(QRectF(d->x, d->y, d->width, d->height), + QRectF(oldx, d->y, d->width, d->height)); } void QQuickItem::setY(qreal v) @@ -6275,8 +6275,8 @@ void QQuickItem::setY(qreal v) d->dirty(QQuickItemPrivate::Position); - geometryChanged(QRectF(x(), y(), width(), height()), - QRectF(x(), oldy, width(), height())); + geometryChanged(QRectF(d->x, d->y, d->width, d->height), + QRectF(d->x, oldy, d->width, d->height)); } /*! @@ -6296,8 +6296,8 @@ void QQuickItem::setPosition(const QPointF &pos) d->dirty(QQuickItemPrivate::Position); - geometryChanged(QRectF(x(), y(), width(), height()), - QRectF(oldx, oldy, width(), height())); + geometryChanged(QRectF(d->x, d->y, d->width, d->height), + QRectF(oldx, oldy, d->width, d->height)); } /*! @@ -6314,7 +6314,7 @@ qreal QQuickItem::width() const void QQuickItem::setWidth(qreal w) { Q_D(QQuickItem); - if (qIsNaN(w)) + if (qt_is_nan(w)) return; d->widthValid = true; @@ -6326,8 +6326,8 @@ void QQuickItem::setWidth(qreal w) d->dirty(QQuickItemPrivate::Size); - geometryChanged(QRectF(x(), y(), width(), height()), - QRectF(x(), y(), oldWidth, height())); + geometryChanged(QRectF(d->x, d->y, d->width, d->height), + QRectF(d->x, d->y, oldWidth, d->height)); } void QQuickItem::resetWidth() @@ -6448,8 +6448,8 @@ void QQuickItem::setImplicitWidth(qreal w) d->dirty(QQuickItemPrivate::Size); - geometryChanged(QRectF(x(), y(), width(), height()), - QRectF(x(), y(), oldWidth, height())); + geometryChanged(QRectF(d->x, d->y, d->width, d->height), + QRectF(d->x, d->y, oldWidth, d->height)); if (changed) d->implicitWidthChanged(); @@ -6478,7 +6478,7 @@ qreal QQuickItem::height() const void QQuickItem::setHeight(qreal h) { Q_D(QQuickItem); - if (qIsNaN(h)) + if (qt_is_nan(h)) return; d->heightValid = true; @@ -6490,8 +6490,8 @@ void QQuickItem::setHeight(qreal h) d->dirty(QQuickItemPrivate::Size); - geometryChanged(QRectF(x(), y(), width(), height()), - QRectF(x(), y(), width(), oldHeight)); + geometryChanged(QRectF(d->x, d->y, d->width, d->height), + QRectF(d->x, d->y, d->width, oldHeight)); } void QQuickItem::resetHeight() @@ -6542,8 +6542,8 @@ void QQuickItem::setImplicitHeight(qreal h) d->dirty(QQuickItemPrivate::Size); - geometryChanged(QRectF(x(), y(), width(), height()), - QRectF(x(), y(), width(), oldHeight)); + geometryChanged(QRectF(d->x, d->y, d->width, d->height), + QRectF(d->x, d->y, d->width, oldHeight)); if (changed) d->implicitHeightChanged(); @@ -6587,8 +6587,8 @@ void QQuickItem::setImplicitSize(qreal w, qreal h) d->dirty(QQuickItemPrivate::Size); - geometryChanged(QRectF(x(), y(), width(), height()), - QRectF(x(), y(), oldWidth, oldHeight)); + geometryChanged(QRectF(d->x, d->y, d->width, d->height), + QRectF(d->x, d->y, oldWidth, oldHeight)); if (!wDone && wChanged) d->implicitWidthChanged(); @@ -6624,8 +6624,8 @@ void QQuickItem::setSize(const QSizeF &size) d->dirty(QQuickItemPrivate::Size); - geometryChanged(QRectF(x(), y(), width(), height()), - QRectF(x(), y(), oldWidth, oldHeight)); + geometryChanged(QRectF(d->x, d->y, d->width, d->height), + QRectF(d->x, d->y, oldWidth, oldHeight)); } /*! diff --git a/src/quick/items/qquickshadereffect.cpp b/src/quick/items/qquickshadereffect.cpp index 0cfb85db97..41b7ea3896 100644 --- a/src/quick/items/qquickshadereffect.cpp +++ b/src/quick/items/qquickshadereffect.cpp @@ -1033,12 +1033,12 @@ QSGNode *QQuickShaderEffect::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDa Key s = m_common.source; QSGShaderSourceBuilder builder; if (s.sourceCode[Key::FragmentShader].isEmpty()) { - builder.appendSourceFile(QStringLiteral(":/items/shaders/shadereffect.frag")); + builder.appendSourceFile(QStringLiteral(":/qt-project.org/items/shaders/shadereffect.frag")); s.sourceCode[Key::FragmentShader] = builder.source(); builder.clear(); } if (s.sourceCode[Key::VertexShader].isEmpty()) { - builder.appendSourceFile(QStringLiteral(":/items/shaders/shadereffect.vert")); + builder.appendSourceFile(QStringLiteral(":/qt-project.org/items/shaders/shadereffect.vert")); s.sourceCode[Key::VertexShader] = builder.source(); } s.className = metaObject()->className(); diff --git a/src/quick/items/qquickshadereffectnode.cpp b/src/quick/items/qquickshadereffectnode.cpp index 66154fac6d..a06fe26a9c 100644 --- a/src/quick/items/qquickshadereffectnode.cpp +++ b/src/quick/items/qquickshadereffectnode.cpp @@ -52,7 +52,7 @@ static bool hasAtlasTexture(const QVector<QSGTextureProvider *> &textureProvider { for (int i = 0; i < textureProviders.size(); ++i) { QSGTextureProvider *t = textureProviders.at(i); - if (t->texture() && t->texture()->isAtlasTexture()) + if (t && t->texture() && t->texture()->isAtlasTexture()) return true; } return false; @@ -305,8 +305,8 @@ void QQuickCustomMaterialShader::compile() QSGShaderSourceBuilder::initializeProgramFromFiles( program(), - QStringLiteral(":/items/shaders/shadereffectfallback.vert"), - QStringLiteral(":/items/shaders/shadereffectfallback.frag")); + QStringLiteral(":/qt-project.org/items/shaders/shadereffectfallback.vert"), + QStringLiteral(":/qt-project.org/items/shaders/shadereffectfallback.frag")); #ifndef QT_NO_DEBUG for (int i = 0; i < attrCount; ++i) { diff --git a/src/quick/items/qquickspritesequence.cpp b/src/quick/items/qquickspritesequence.cpp index 029beba1ff..f32e1afd50 100644 --- a/src/quick/items/qquickspritesequence.cpp +++ b/src/quick/items/qquickspritesequence.cpp @@ -101,8 +101,8 @@ public: SpriteSequenceMaterialData() : QSGMaterialShader() { - setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/items/shaders/sprite.vert")); - setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/items/shaders/sprite.frag")); + setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/items/shaders/sprite.vert")); + setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/items/shaders/sprite.frag")); } void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *) Q_DECL_OVERRIDE diff --git a/src/quick/items/qquickview_p.h b/src/quick/items/qquickview_p.h index 6306066134..1bbff0de0e 100644 --- a/src/quick/items/qquickview_p.h +++ b/src/quick/items/qquickview_p.h @@ -76,7 +76,7 @@ class QQmlError; class QQuickItem; class QQmlComponent; -class QQuickViewPrivate : public QQuickWindowPrivate, +class Q_QUICK_PRIVATE_EXPORT QQuickViewPrivate : public QQuickWindowPrivate, public QQuickItemChangeListener { Q_DECLARE_PUBLIC(QQuickView) diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index 8f08020374..a89dbc0ea2 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -2105,8 +2105,8 @@ Renderer::ClipType Renderer::updateStencilClip(const QSGClipNode *clip) if (!m_clipProgram.isLinked()) { QSGShaderSourceBuilder::initializeProgramFromFiles( &m_clipProgram, - QStringLiteral(":/scenegraph/shaders/stencilclip.vert"), - QStringLiteral(":/scenegraph/shaders/stencilclip.frag")); + QStringLiteral(":/qt-project.org/scenegraph/shaders/stencilclip.vert"), + QStringLiteral(":/qt-project.org/scenegraph/shaders/stencilclip.frag")); m_clipProgram.bindAttributeLocation("vCoord", 0); m_clipProgram.link(); m_clipMatrixId = m_clipProgram.uniformLocation("matrix"); @@ -3116,8 +3116,8 @@ void Renderer::visualize() VisualizeShader *prog = new VisualizeShader(); QSGShaderSourceBuilder::initializeProgramFromFiles( prog, - QStringLiteral(":/scenegraph/shaders/visualization.vert"), - QStringLiteral(":/scenegraph/shaders/visualization.frag")); + QStringLiteral(":/qt-project.org/scenegraph/shaders/visualization.vert"), + QStringLiteral(":/qt-project.org/scenegraph/shaders/visualization.frag")); prog->bindAttributeLocation("v", 0); prog->link(); prog->bind(); diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h index 1c62b69769..a84ac6d177 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h @@ -104,7 +104,11 @@ public: : available(PageSize) , allocated(PageSize) { - for (int i=0; i<PageSize; ++i) blocks[i] = i; + for (int i=0; i<PageSize; ++i) + blocks[i] = i; + + // Zero out all new pages. + memset(data, 0, sizeof(data)); } const Type *at(uint index) const @@ -156,7 +160,7 @@ public: void *mem = p->at(pos); p->available--; p->allocated.setBit(pos); - Type *t = new (mem) Type(); + Type *t = (Type*)mem; return t; } @@ -166,8 +170,9 @@ public: if (!page->allocated.testBit(index)) qFatal("Double delete in allocator: page=%d, index=%d", pageIndex , index); - // Call the destructor - page->at(index)->~Type(); + // Zero this instance as we're done with it. + void *mem = page->at(index); + memset(mem, 0, sizeof(Type)); page->allocated[index] = false; page->available++; @@ -443,21 +448,9 @@ struct Batch QDataBuffer<DrawSet> drawSets; }; +// NOTE: Node is zero-allocated by the Allocator. struct Node { - Node() - : sgNode(0) - , parent(0) - , data(0) - , firstChild(0) - , nextSibling(0) - , lastChild(0) - , dirtyState(0) - , isOpaque(false) - , isBatchRoot(false) - { - } - QSGNode *sgNode; Node *parent; void *data; diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp index d8552e622d..7c2663d5a3 100644 --- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp +++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp @@ -117,8 +117,8 @@ QSGTextMaskShader::QSGTextMaskShader(QFontEngine::GlyphFormat glyphFormat) , m_textureScale_id(-1) , m_glyphFormat(glyphFormat) { - setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/scenegraph/shaders/textmask.vert")); - setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/scenegraph/shaders/textmask.frag")); + setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/textmask.vert")); + setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/textmask.frag")); } static inline qreal fontSmoothingGamma() @@ -177,7 +177,7 @@ public: QSG8BitTextMaskShader(QFontEngine::GlyphFormat glyphFormat) : QSGTextMaskShader(glyphFormat) { - setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/scenegraph/shaders/8bittextmask.frag")); + setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/8bittextmask.frag")); } virtual void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect); @@ -202,7 +202,7 @@ public: : QSGTextMaskShader(glyphFormat) , m_useSRGB(false) { - setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/scenegraph/shaders/24bittextmask.frag")); + setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/24bittextmask.frag")); } virtual void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect); @@ -280,7 +280,7 @@ public: QSG32BitColorTextShader(QFontEngine::GlyphFormat glyphFormat) : QSGTextMaskShader(glyphFormat) { - setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/scenegraph/shaders/32bitcolortext.frag")); + setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/32bitcolortext.frag")); } void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) Q_DECL_OVERRIDE; @@ -304,8 +304,8 @@ public: QSGStyledTextShader(QFontEngine::GlyphFormat glyphFormat) : QSG8BitTextMaskShader(glyphFormat) { - setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/scenegraph/shaders/styledtext.vert")); - setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/scenegraph/shaders/styledtext.frag")); + setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/styledtext.vert")); + setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/styledtext.frag")); } virtual void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect); @@ -376,8 +376,8 @@ public: QSGOutlinedTextShader(QFontEngine::GlyphFormat glyphFormat) : QSGStyledTextShader(glyphFormat) { - setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/scenegraph/shaders/outlinedtext.vert")); - setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/scenegraph/shaders/outlinedtext.frag")); + setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/outlinedtext.vert")); + setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/outlinedtext.frag")); } }; diff --git a/src/quick/scenegraph/qsgdefaultimagenode.cpp b/src/quick/scenegraph/qsgdefaultimagenode.cpp index 8ab5575b18..9fed70a7de 100644 --- a/src/quick/scenegraph/qsgdefaultimagenode.cpp +++ b/src/quick/scenegraph/qsgdefaultimagenode.cpp @@ -85,8 +85,8 @@ QSGMaterialShader *QSGSmoothTextureMaterial::createShader() const SmoothTextureMaterialShader::SmoothTextureMaterialShader() : QSGTextureMaterialShader() { - setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/scenegraph/shaders/smoothtexture.vert")); - setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/scenegraph/shaders/smoothtexture.frag")); + setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/smoothtexture.vert")); + setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/smoothtexture.frag")); } void SmoothTextureMaterialShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) diff --git a/src/quick/scenegraph/qsgdefaultrectanglenode.cpp b/src/quick/scenegraph/qsgdefaultrectanglenode.cpp index da1623e197..117a9272e5 100644 --- a/src/quick/scenegraph/qsgdefaultrectanglenode.cpp +++ b/src/quick/scenegraph/qsgdefaultrectanglenode.cpp @@ -69,8 +69,8 @@ private: SmoothColorMaterialShader::SmoothColorMaterialShader() : QSGMaterialShader() { - setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/scenegraph/shaders/smoothcolor.vert")); - setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/scenegraph/shaders/smoothcolor.frag")); + setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/smoothcolor.vert")); + setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/smoothcolor.frag")); } void SmoothColorMaterialShader::updateState(const RenderState &state, QSGMaterial *, QSGMaterial *oldEffect) diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp index 6a49c90cc5..ca91e5d85f 100644 --- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp +++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp @@ -94,8 +94,8 @@ QSGDistanceFieldTextMaterialShader::QSGDistanceFieldTextMaterialShader() , m_lastAlphaMin(-1) , m_lastAlphaMax(-1) { - setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/scenegraph/shaders/distancefieldtext.vert")); - setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/scenegraph/shaders/distancefieldtext.frag")); + setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/distancefieldtext.vert")); + setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/distancefieldtext.frag")); } void QSGDistanceFieldTextMaterialShader::updateAlphaRange(ThresholdFunc thresholdFunc, AntialiasingSpreadFunc spreadFunc) @@ -345,7 +345,7 @@ DistanceFieldOutlineTextMaterialShader::DistanceFieldOutlineTextMaterialShader() , m_outlineAlphaMax0_id(-1) , m_outlineAlphaMax1_id(-1) { - setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/scenegraph/shaders/distancefieldoutlinetext.frag")); + setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/distancefieldoutlinetext.frag")); } void DistanceFieldOutlineTextMaterialShader::initialize() @@ -427,8 +427,8 @@ DistanceFieldShiftedStyleTextMaterialShader::DistanceFieldShiftedStyleTextMateri : DistanceFieldStyledTextMaterialShader() , m_shift_id(-1) { - setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/scenegraph/shaders/distancefieldshiftedtext.vert")); - setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/scenegraph/shaders/distancefieldshiftedtext.frag")); + setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/distancefieldshiftedtext.vert")); + setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/distancefieldshiftedtext.frag")); } void DistanceFieldShiftedStyleTextMaterialShader::initialize() @@ -507,8 +507,8 @@ QSGHiQSubPixelDistanceFieldTextMaterialShader::QSGHiQSubPixelDistanceFieldTextMa , m_fontScale_id(-1) , m_vecDelta_id(-1) { - setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/scenegraph/shaders/hiqsubpixeldistancefieldtext.vert")); - setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/scenegraph/shaders/hiqsubpixeldistancefieldtext.frag")); + setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/hiqsubpixeldistancefieldtext.vert")); + setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/hiqsubpixeldistancefieldtext.frag")); } void QSGHiQSubPixelDistanceFieldTextMaterialShader::initialize() @@ -574,8 +574,8 @@ public: QSGLoQSubPixelDistanceFieldTextMaterialShader::QSGLoQSubPixelDistanceFieldTextMaterialShader() : QSGHiQSubPixelDistanceFieldTextMaterialShader() { - setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/scenegraph/shaders/loqsubpixeldistancefieldtext.vert")); - setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/scenegraph/shaders/loqsubpixeldistancefieldtext.frag")); + setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/loqsubpixeldistancefieldtext.vert")); + setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/loqsubpixeldistancefieldtext.frag")); } QSGMaterialType *QSGLoQSubPixelDistanceFieldTextMaterial::type() const diff --git a/src/quick/scenegraph/scenegraph.qrc b/src/quick/scenegraph/scenegraph.qrc index 5db242e46b..ef6da71334 100644 --- a/src/quick/scenegraph/scenegraph.qrc +++ b/src/quick/scenegraph/scenegraph.qrc @@ -1,5 +1,5 @@ <RCC> - <qresource prefix="/scenegraph"> + <qresource prefix="/qt-project.org/scenegraph"> <file>shaders/flatcolor.frag</file> <file>shaders/flatcolor.vert</file> <file>shaders/8bittextmask.frag</file> diff --git a/src/quick/scenegraph/util/qsgflatcolormaterial.cpp b/src/quick/scenegraph/util/qsgflatcolormaterial.cpp index a3dfc555c4..b9986c3d11 100644 --- a/src/quick/scenegraph/util/qsgflatcolormaterial.cpp +++ b/src/quick/scenegraph/util/qsgflatcolormaterial.cpp @@ -68,8 +68,8 @@ FlatColorMaterialShader::FlatColorMaterialShader() : QSGMaterialShader(*new QSGMaterialShaderPrivate) { #ifndef QT_NO_OPENGL - setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/scenegraph/shaders/flatcolor.vert")); - setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/scenegraph/shaders/flatcolor.frag")); + setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/flatcolor.vert")); + setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/flatcolor.frag")); #endif } diff --git a/src/quick/scenegraph/util/qsgtexturematerial.cpp b/src/quick/scenegraph/util/qsgtexturematerial.cpp index 35c5ace889..12a1b474e3 100644 --- a/src/quick/scenegraph/util/qsgtexturematerial.cpp +++ b/src/quick/scenegraph/util/qsgtexturematerial.cpp @@ -58,8 +58,8 @@ QSGOpaqueTextureMaterialShader::QSGOpaqueTextureMaterialShader() : QSGMaterialShader() { #ifndef QT_NO_OPENGL - setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/scenegraph/shaders/opaquetexture.vert")); - setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/scenegraph/shaders/opaquetexture.frag")); + setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/opaquetexture.vert")); + setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/opaquetexture.frag")); #endif } @@ -370,7 +370,7 @@ QSGTextureMaterialShader::QSGTextureMaterialShader() : QSGOpaqueTextureMaterialShader() { #ifndef QT_NO_OPENGL - setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/scenegraph/shaders/texture.frag")); + setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/texture.frag")); #endif } diff --git a/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp b/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp index 3897dfe4b2..18de19b04e 100644 --- a/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp +++ b/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp @@ -66,8 +66,8 @@ QSGVertexColorMaterialShader::QSGVertexColorMaterialShader() : QSGMaterialShader() { #ifndef QT_NO_OPENGL - setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/scenegraph/shaders/vertexcolor.vert")); - setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/scenegraph/shaders/vertexcolor.frag")); + setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/vertexcolor.vert")); + setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/vertexcolor.frag")); #endif } diff --git a/src/quick/util/qquickanimation.cpp b/src/quick/util/qquickanimation.cpp index 51212661c9..adf8f600a0 100644 --- a/src/quick/util/qquickanimation.cpp +++ b/src/quick/util/qquickanimation.cpp @@ -1441,7 +1441,7 @@ QQuickVector3dAnimation::~QQuickVector3dAnimation() } /*! - \qmlproperty real QtQuick::Vector3dAnimation::from + \qmlproperty vector3d QtQuick::Vector3dAnimation::from This property holds the starting value for the animation. If the Vector3dAnimation is defined within a \l Transition or \l Behavior, @@ -1463,7 +1463,7 @@ void QQuickVector3dAnimation::setFrom(QVector3D f) } /*! - \qmlproperty real QtQuick::Vector3dAnimation::to + \qmlproperty vector3d QtQuick::Vector3dAnimation::to This property holds the end value for the animation. If the Vector3dAnimation is defined within a \l Transition or \l Behavior, diff --git a/src/quick/util/qquickanimatorjob.cpp b/src/quick/util/qquickanimatorjob.cpp index 3502a28301..f0ecb8150a 100644 --- a/src/quick/util/qquickanimatorjob.cpp +++ b/src/quick/util/qquickanimatorjob.cpp @@ -239,6 +239,10 @@ void QQuickAnimatorJob::debugAnimation(QDebug d) const << "target:" << m_target << "value:" << m_value; } +qreal QQuickAnimatorJob::progress(int time) const +{ + return m_easing.valueForProgress((m_duration == 0) ? qreal(1) : qreal(time) / qreal(m_duration)); +} qreal QQuickAnimatorJob::value() const { qreal v; @@ -388,7 +392,7 @@ void QQuickXAnimatorJob::updateCurrentTime(int time) if (!m_controller) return; - m_value = m_from + (m_to - m_from) * m_easing.valueForProgress(time / (qreal) m_duration); + m_value = m_from + (m_to - m_from) * progress(time); m_helper->dx = m_value; m_helper->wasChanged = true; } @@ -404,7 +408,7 @@ void QQuickYAnimatorJob::updateCurrentTime(int time) if (!m_controller) return; - m_value = m_from + (m_to - m_from) * m_easing.valueForProgress(time / (qreal) m_duration); + m_value = m_from + (m_to - m_from) * progress(time); m_helper->dy = m_value; m_helper->wasChanged = true; } @@ -473,7 +477,7 @@ void QQuickOpacityAnimatorJob::updateCurrentTime(int time) if (!m_controller || !m_opacityNode) return; - m_value = m_from + (m_to - m_from) * m_easing.valueForProgress(time / (qreal) m_duration); + m_value = m_from + (m_to - m_from) * progress(time); m_opacityNode->setOpacity(m_value); } @@ -488,7 +492,7 @@ void QQuickScaleAnimatorJob::updateCurrentTime(int time) if (!m_controller) return; - m_value = m_from + (m_to - m_from) * m_easing.valueForProgress(time / (qreal) m_duration); + m_value = m_from + (m_to - m_from) * progress(time); m_helper->scale = m_value; m_helper->wasChanged = true; } @@ -507,7 +511,8 @@ void QQuickRotationAnimatorJob::updateCurrentTime(int time) if (!m_controller) return; - float t = m_easing.valueForProgress(time / (qreal) m_duration); + float t = progress(time); + switch (m_direction) { case QQuickRotationAnimator::Clockwise: m_value = _q_interpolateClockwiseRotation(m_from, m_to, t).toFloat(); @@ -590,7 +595,7 @@ void QQuickUniformAnimatorJob::updateCurrentTime(int time) if (!m_node || m_uniformIndex == -1 || m_uniformType == -1) return; - m_value = m_from + (m_to - m_from) * m_easing.valueForProgress(time / (qreal) m_duration); + m_value = m_from + (m_to - m_from) * progress(time); QQuickShaderEffectMaterial *material = static_cast<QQuickShaderEffectMaterial *>(m_node->material()); diff --git a/src/quick/util/qquickanimatorjob_p.h b/src/quick/util/qquickanimatorjob_p.h index 75d2b962a5..118487f937 100644 --- a/src/quick/util/qquickanimatorjob_p.h +++ b/src/quick/util/qquickanimatorjob_p.h @@ -158,6 +158,8 @@ protected: QQuickAnimatorJob(); void debugAnimation(QDebug d) const Q_DECL_OVERRIDE; + qreal progress(int time) const; + QPointer<QQuickItem> m_target; QQuickAnimatorController *m_controller; diff --git a/src/quick/util/qquickpath.cpp b/src/quick/util/qquickpath.cpp index 062411e0a9..6b491a433c 100644 --- a/src/quick/util/qquickpath.cpp +++ b/src/quick/util/qquickpath.cpp @@ -46,7 +46,7 @@ #include <private/qbezier_p.h> #include <QtCore/qmath.h> -#include <QtCore/qnumeric.h> +#include <QtCore/private/qnumeric_p.h> QT_BEGIN_NAMESPACE @@ -560,7 +560,7 @@ void QQuickPath::createPointCache() const { Q_D(const QQuickPath); qreal pathLength = d->pathLength; - if (pathLength <= 0 || qIsNaN(pathLength)) + if (pathLength <= 0 || qt_is_nan(pathLength)) return; const int segments = segmentCount(d->_path, pathLength); @@ -633,7 +633,7 @@ QPointF QQuickPath::sequentialPointAt(const QPainterPath &path, const qreal &pat QPointF QQuickPath::forwardsPointAt(const QPainterPath &path, const qreal &pathLength, const QList<AttributePoint> &attributePoints, QQuickCachedBezier &prevBez, qreal p, qreal *angle) { - if (pathLength <= 0 || qIsNaN(pathLength)) + if (pathLength <= 0 || qt_is_nan(pathLength)) return path.pointAtPercent(0); //expensive? const int lastElement = path.elementCount() - 1; @@ -689,7 +689,7 @@ QPointF QQuickPath::forwardsPointAt(const QPainterPath &path, const qreal &pathL //ideally this should be merged with forwardsPointAt QPointF QQuickPath::backwardsPointAt(const QPainterPath &path, const qreal &pathLength, const QList<AttributePoint> &attributePoints, QQuickCachedBezier &prevBez, qreal p, qreal *angle) { - if (pathLength <= 0 || qIsNaN(pathLength)) + if (pathLength <= 0 || qt_is_nan(pathLength)) return path.pointAtPercent(0); const int firstElement = 1; //element 0 is always a MoveTo, which we ignore diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp index 23b2887fac..2b6e8f68c3 100644 --- a/src/quick/util/qquickpixmapcache.cpp +++ b/src/quick/util/qquickpixmapcache.cpp @@ -530,7 +530,6 @@ void QQuickPixmapReader::asyncResponseFinished(QQuickImageResponse *response) QQuickTextureFactory *t = 0; QQuickPixmapReply::ReadError error = QQuickPixmapReply::NoError; QString errorString; - QSize readSize; if (!response->errorString().isEmpty()) { error = QQuickPixmapReply::Loading; errorString = response->errorString(); diff --git a/src/quick/util/qquicktimeline.cpp b/src/quick/util/qquicktimeline.cpp index d8226a08f3..74baa3bfda 100644 --- a/src/quick/util/qquicktimeline.cpp +++ b/src/quick/util/qquicktimeline.cpp @@ -47,7 +47,7 @@ #include <QCoreApplication> #include <QEasingCurve> #include <QTime> -#include <QtNumeric> +#include <QtCore/private/qnumeric_p.h> #include <algorithm> @@ -387,7 +387,7 @@ void QQuickTimeLine::set(QQuickTimeLineValue &timeLineValue, qreal value) */ int QQuickTimeLine::accel(QQuickTimeLineValue &timeLineValue, qreal velocity, qreal acceleration) { - if (qFuzzyIsNull(acceleration) || qIsNaN(acceleration)) + if (qFuzzyIsNull(acceleration) || qt_is_nan(acceleration)) return -1; if ((velocity > 0.0f) == (acceleration > 0.0f)) @@ -414,7 +414,7 @@ int QQuickTimeLine::accel(QQuickTimeLineValue &timeLineValue, qreal velocity, qr */ int QQuickTimeLine::accel(QQuickTimeLineValue &timeLineValue, qreal velocity, qreal acceleration, qreal maxDistance) { - if (qFuzzyIsNull(maxDistance) || qIsNaN(maxDistance) || qFuzzyIsNull(acceleration) || qIsNaN(acceleration)) + if (qFuzzyIsNull(maxDistance) || qt_is_nan(maxDistance) || qFuzzyIsNull(acceleration) || qt_is_nan(acceleration)) return -1; Q_ASSERT(acceleration > 0.0f && maxDistance > 0.0f); @@ -444,7 +444,7 @@ int QQuickTimeLine::accel(QQuickTimeLineValue &timeLineValue, qreal velocity, qr */ int QQuickTimeLine::accelDistance(QQuickTimeLineValue &timeLineValue, qreal velocity, qreal distance) { - if (qFuzzyIsNull(distance) || qIsNaN(distance) || qFuzzyIsNull(velocity) || qIsNaN(velocity)) + if (qFuzzyIsNull(distance) || qt_is_nan(distance) || qFuzzyIsNull(velocity) || qt_is_nan(velocity)) return -1; Q_ASSERT((distance >= 0.0f) == (velocity >= 0.0f)); |