From 59c9993a6a0d25904d278aabafa9be767e977b77 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Tue, 15 Nov 2016 11:26:34 +0100 Subject: QML: Check for failing realloc/malloc in the QmlJS memory pool This should make (properly functioning) static code checkers stop complaining. Task-number: QTBUG-57025 Change-Id: Ic7e6f1b0b02f2e9324dbc891ab4620d53d9f9a18 Reviewed-by: Simon Hausmann --- src/qml/parser/qqmljsmemorypool_p.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/qml/parser/qqmljsmemorypool_p.h b/src/qml/parser/qqmljsmemorypool_p.h index ae9f1d8257..a08e91f2c3 100644 --- a/src/qml/parser/qqmljsmemorypool_p.h +++ b/src/qml/parser/qqmljsmemorypool_p.h @@ -116,6 +116,7 @@ private: _allocatedBlocks *= 2; _blocks = (char **) realloc(_blocks, sizeof(char *) * _allocatedBlocks); + Q_CHECK_PTR(_blocks); for (int index = _blockCount; index < _allocatedBlocks; ++index) _blocks[index] = 0; @@ -123,8 +124,10 @@ private: char *&block = _blocks[_blockCount]; - if (! block) + if (! block) { block = (char *) malloc(BLOCK_SIZE); + Q_CHECK_PTR(block); + } _ptr = block; _end = _ptr + BLOCK_SIZE; -- cgit v1.2.3 From 4ef8b7e7a8a93b2921560db8cf021f89409154e5 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 15 Nov 2016 13:48:43 +0100 Subject: Doc: improve FolderListModel::rootFolder documentation Change-Id: I33ca6140d89041f89f0e3db9db7206aca50361d7 Reviewed-by: Robin Burchell --- src/imports/folderlistmodel/qquickfolderlistmodel.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp index d01fc5e74e..df83d50325 100644 --- a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp +++ b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp @@ -440,9 +440,9 @@ void QQuickFolderListModel::setFolder(const QUrl &folder) /*! \qmlproperty url FolderListModel::rootFolder - When the rootFolder is set, then this folder will - be threated as the root in the file system, so that - you can only travers sub folders from this rootFolder. + When this property is set, the given folder will + be treated as the root in the file system, so that + you can only traverse subfolders within it. */ QUrl QQuickFolderListModel::rootFolder() const { -- cgit v1.2.3 From 12b7e6bfe5a8fb7666a929090483921c3f99ae8a Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 15 Nov 2016 14:44:21 +0100 Subject: Fix reading of enum properties from gadgets QMetaProperty::type() maps an un-registered enum to QMetaType::Int, and so if a property cache is created for a gadget with enum properties, then their type will be int and we'll correctly read enum properties as ints in JavaScript. However if the enum is registered at the time we create the cache, then the property type will be the specific type and not QMetaType::Int. The property reading code in QV4::QObjectWrapper can deal with that, but the property reading code in the gadget value type wrapper code did not. [ChangeLog][Qt][Qml] Fix reading of enum properties from gadgets / value types when the enum was registered with qRegisterMetaType(). Change-Id: I7812b216a276dcc95c36e313507e1a1142250d0b Reviewed-by: Erik Verbruggen --- src/qml/qml/qqmlvaluetypewrapper.cpp | 1 + .../auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp | 34 ++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index 5486c14c38..810a2bdf2c 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -353,6 +353,7 @@ ReturnedValue QQmlValueTypeWrapper::get(const Managed *m, String *name, bool *ha // These four types are the most common used by the value type wrappers VALUE_TYPE_LOAD(QMetaType::QReal, qreal, qreal); + VALUE_TYPE_LOAD(QMetaType::Int || result->isEnum(), int, int); VALUE_TYPE_LOAD(QMetaType::Int, int, int); VALUE_TYPE_LOAD(QMetaType::QString, QString, v4->newString); VALUE_TYPE_LOAD(QMetaType::Bool, bool, bool); diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp index 04abe0bfcb..e82df79acb 100644 --- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp +++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp @@ -94,6 +94,7 @@ private slots: void customValueTypeInQml(); void gadgetInheritance(); void toStringConversion(); + void enumProperties(); private: QQmlEngine engine; @@ -1652,6 +1653,39 @@ void tst_qqmlvaluetypes::toStringConversion() QCOMPARE(stringConversion.toString(), StringLessGadget_to_QString(g)); } +struct GadgetWithEnum +{ + Q_GADGET +public: + + enum MyEnum { FirstValue, SecondValue }; + + Q_ENUM(MyEnum) + Q_PROPERTY(MyEnum enumProperty READ enumProperty) + + MyEnum enumProperty() const { return SecondValue; } +}; + +void tst_qqmlvaluetypes::enumProperties() +{ + QJSEngine engine; + + // When creating the property cache for the gadget when MyEnum is _not_ a registered + // meta-type, then QMetaProperty::type() will return QMetaType::Int and consequently + // property-read meta-calls will return an int (as expected in this test). However if we + // explicitly register the gadget, then QMetaProperty::type() will return the user-type + // and QQmlValueTypeWrapper should still handle that and return an integer/number for the + // enum property when it is read. + qRegisterMetaType(); + + GadgetWithEnum g; + QJSValue value = engine.toScriptValue(g); + + QJSValue enumValue = value.property("enumProperty"); + QVERIFY(enumValue.isNumber()); + QCOMPARE(enumValue.toInt(), int(g.enumProperty())); +} + QTEST_MAIN(tst_qqmlvaluetypes) -- cgit v1.2.3 From 835eac4ea0ded27c16e319177ef3087058808b0f Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 16 Nov 2016 14:06:01 +0100 Subject: QML: Change C++ benchmark to reflect QML benchmark The QQmlListReference will build a property cache entry, but it won't assign it to an engine when none is available (meaning: it would create the entry every time a QQmlListReference is created). QML won't do that, because it (obviously) has an engine available. Change-Id: I46eeaf3dffcb690902dd3d78be48c8509be6e84d Reviewed-by: Simon Hausmann --- tests/benchmarks/qml/creation/tst_creation.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/benchmarks/qml/creation/tst_creation.cpp b/tests/benchmarks/qml/creation/tst_creation.cpp index dbda07be5a..6c8d1eb21a 100644 --- a/tests/benchmarks/qml/creation/tst_creation.cpp +++ b/tests/benchmarks/qml/creation/tst_creation.cpp @@ -256,12 +256,13 @@ void tst_creation::itemtree_cpp() void tst_creation::itemtree_data_cpp() { + QQmlEngine engine; QBENCHMARK { QQuickItem *item = new QQuickItem; for (int i = 0; i < 30; ++i) { QQuickItem *child = new QQuickItem; QQmlGraphics_setParent_noEvent(child,item); - QQmlListReference ref(item, "data"); + QQmlListReference ref(item, "data", &engine); ref.append(child); } delete item; -- cgit v1.2.3 From 5718dac919c16e9c6c7b98043e1ecb74117af268 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 16 Nov 2016 14:04:04 +0100 Subject: QML: Fix memory leak in a benchmark Change-Id: I64b671243a107c518da2000e2ffd964f441af037 Reviewed-by: Simon Hausmann Reviewed-by: Robin Burchell --- tests/benchmarks/qml/creation/tst_creation.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/benchmarks/qml/creation/tst_creation.cpp b/tests/benchmarks/qml/creation/tst_creation.cpp index 6c8d1eb21a..b9df0ca8b5 100644 --- a/tests/benchmarks/qml/creation/tst_creation.cpp +++ b/tests/benchmarks/qml/creation/tst_creation.cpp @@ -219,12 +219,15 @@ inline void QQmlGraphics_setParent_noEvent(QObject *object, QObject *parent) void tst_creation::itemtree_notree_cpp() { + std::vector kids; + kids.resize(30); QBENCHMARK { QQuickItem *item = new QQuickItem; for (int i = 0; i < 30; ++i) { QQuickItem *child = new QQuickItem; - Q_UNUSED(child); + kids[i] = child; } + qDeleteAll(kids); delete item; } } -- cgit v1.2.3 From a3fe91ba463fcd27d6e0a69b66bc389bd6470c46 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 17 Nov 2016 12:40:25 +0100 Subject: Doc: fix incorrect argument name for createQmlObject() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "string" is the argument type, not its name. Change-Id: Ia8f1afe01363eb6bfa69247aca5c0849c56000c4 Reviewed-by: Topi Reiniƶ --- src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index b90fd7eb17..8cddd95fda 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2016 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtQml module of the Qt Toolkit. @@ -932,7 +932,7 @@ ReturnedValue QtObject::method_quit(CallContext *ctx) /*! \qmlmethod object Qt::createQmlObject(string qml, object parent, string filepath) -Returns a new object created from the given \a string of QML which will have the specified \a parent, +Returns a new object created from the given \a qml string which will have the specified \a parent, or \c null if there was an error in creating the object. If \a filepath is specified, it will be used for error reporting for the created object. -- cgit v1.2.3 From 1969991c4a4bd39ee224b0fa3c8cffa51f061757 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 1 Sep 2016 16:46:29 +0200 Subject: Fix binding re-evaluation when list model properties change This is a regression from commit 4876ea6a18ccdfd72014582aa5d50ab9f6b6ec9e, which avoided returning an expensive QObject when calling get() but also lost the ability to perform binding captures when accessing the properties. This change restores the captures by performing them by hand in get() and also triggering the notifiers directly when the values change, without creating the QObject. Task-number: QTBUG-52356 Change-Id: Ia429ffafd4032b63d3e592aa63bb0864a24e0965 Reviewed-by: Michael Brasser Reviewed-by: Lars Knoll --- src/qml/qml/qqmlnotifier.cpp | 6 +++ src/qml/qml/qqmlnotifier_p.h | 2 + src/qml/types/qqmllistmodel.cpp | 44 ++++++++++++++++++++-- src/qml/types/qqmllistmodel_p_p.h | 2 + .../qml/qqmllistmodel/data/bindingsOnGetResult.qml | 27 +++++++++++++ tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp | 13 +++++++ 6 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 tests/auto/qml/qqmllistmodel/data/bindingsOnGetResult.qml diff --git a/src/qml/qml/qqmlnotifier.cpp b/src/qml/qml/qqmlnotifier.cpp index ea3f7a1530..e3f23b3e5d 100644 --- a/src/qml/qml/qqmlnotifier.cpp +++ b/src/qml/qml/qqmlnotifier.cpp @@ -65,6 +65,12 @@ namespace { }; } +void QQmlNotifier::notify(QQmlData *ddata, int notifierIndex) +{ + if (QQmlNotifierEndpoint *ep = ddata->notify(notifierIndex)) + emitNotify(ep, Q_NULLPTR); +} + void QQmlNotifier::emitNotify(QQmlNotifierEndpoint *endpoint, void **a) { QVarLengthArray stack; diff --git a/src/qml/qml/qqmlnotifier_p.h b/src/qml/qml/qqmlnotifier_p.h index ac0aab892f..60ba041b4a 100644 --- a/src/qml/qml/qqmlnotifier_p.h +++ b/src/qml/qml/qqmlnotifier_p.h @@ -59,6 +59,8 @@ public: inline ~QQmlNotifier(); inline void notify(); + static void notify(QQmlData *ddata, int notifierIndex); + private: friend class QQmlData; friend class QQmlNotifierEndpoint; diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp index 3d71621290..299097d0c0 100644 --- a/src/qml/types/qqmllistmodel.cpp +++ b/src/qml/types/qqmllistmodel.cpp @@ -40,10 +40,12 @@ #include #include +#include #include #include #include +#include #include #include @@ -52,6 +54,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -1259,9 +1262,14 @@ ModelNodeMetaObject *ModelNodeMetaObject::get(QObject *obj) void ModelNodeMetaObject::updateValues() { - if (!m_initialized) + const int roleCount = m_model->m_listModel->roleCount(); + if (!m_initialized) { + int *changedRoles = reinterpret_cast(alloca(roleCount * sizeof(int))); + for (int i = 0; i < roleCount; ++i) + changedRoles[i] = i; + emitDirectNotifies(changedRoles, roleCount); return; - int roleCount = m_model->m_listModel->roleCount(); + } for (int i=0 ; i < roleCount ; ++i) { const ListLayout::Role &role = m_model->m_listModel->getExistingRole(i); QByteArray name = role.name.toUtf8(); @@ -1272,8 +1280,10 @@ void ModelNodeMetaObject::updateValues() void ModelNodeMetaObject::updateValues(const QVector &roles) { - if (!m_initialized) + if (!m_initialized) { + emitDirectNotifies(roles.constData(), roles.count()); return; + } int roleCount = roles.count(); for (int i=0 ; i < roleCount ; ++i) { int roleIndex = roles.at(i); @@ -1303,6 +1313,22 @@ void ModelNodeMetaObject::propertyWritten(int index) } } +// Does the emission of the notifiers when we haven't created the meta-object yet +void ModelNodeMetaObject::emitDirectNotifies(const int *changedRoles, int roleCount) +{ + Q_ASSERT(!m_initialized); + QQmlData *ddata = QQmlData::get(object(), /*create*/false); + if (!ddata) + return; + QQmlEnginePrivate *ep = QQmlEnginePrivate::get(qmlEngine(m_model)); + if (!ep) + return; + for (int i = 0; i < roleCount; ++i) { + const int changedRole = changedRoles[i]; + QQmlNotifier::notify(ddata, changedRole); + } +} + namespace QV4 { void ModelObject::put(Managed *m, String *name, const Value &value) @@ -1332,6 +1358,18 @@ ReturnedValue ModelObject::get(const Managed *m, String *name, bool *hasProperty return QObjectWrapper::get(m, name, hasProperty); if (hasProperty) *hasProperty = true; + + if (QQmlEngine *qmlEngine = that->engine()->qmlEngine()) { + QQmlEnginePrivate *ep = QQmlEnginePrivate::get(qmlEngine); + if (ep && ep->propertyCapture) { + QObjectPrivate *op = QObjectPrivate::get(that->object()); + // Temporarily hide the dynamic meta-object, to prevent it from being created when the capture + // triggers a QObject::connectNotify() by calling obj->metaObject(). + QScopedValueRollback metaObjectBlocker(op->metaObject, 0); + ep->propertyCapture->captureProperty(that->object(), -1, role->index); + } + } + const int elementIndex = that->d()->m_elementIndex; QVariant value = that->d()->m_model->data(elementIndex, role->index); return that->engine()->fromVariant(value); diff --git a/src/qml/types/qqmllistmodel_p_p.h b/src/qml/types/qqmllistmodel_p_p.h index d7e0defaec..f23fec1e59 100644 --- a/src/qml/types/qqmllistmodel_p_p.h +++ b/src/qml/types/qqmllistmodel_p_p.h @@ -146,6 +146,8 @@ private: setValue(name, val); } + void emitDirectNotifies(const int *changedRoles, int roleCount); + void initialize(); bool m_initialized; }; diff --git a/tests/auto/qml/qqmllistmodel/data/bindingsOnGetResult.qml b/tests/auto/qml/qqmllistmodel/data/bindingsOnGetResult.qml new file mode 100644 index 0000000000..6bf750dcda --- /dev/null +++ b/tests/auto/qml/qqmllistmodel/data/bindingsOnGetResult.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +QtObject { + property ListModel model: ListModel { + ListElement { modified: false } + ListElement { modified: false } + ListElement { modified: false } + ListElement { modified: false } + ListElement { modified: false } + } + + property bool isModified: { + for (var i = 0; i < model.count; ++i) { + if (model.get(i).modified) + return true; + } + return false; + } + + property bool success: false + Component.onCompleted: { + // trigger read and setup of property captures + success = isModified + model.setProperty(0, "modified", true) + success = isModified + } +} diff --git a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp index 6b1deceaf2..8a90be601a 100644 --- a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp +++ b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp @@ -127,6 +127,7 @@ private slots: void datetime_data(); void about_to_be_signals(); void modify_through_delegate(); + void bindingsOnGetResult(); }; bool tst_qqmllistmodel::compareVariantList(const QVariantList &testList, QVariant object) @@ -1474,6 +1475,18 @@ void tst_qqmllistmodel::modify_through_delegate() QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("age")).toInt(), 18); } +void tst_qqmllistmodel::bindingsOnGetResult() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("bindingsOnGetResult.qml")); + QVERIFY2(!component.isError(), qPrintable(component.errorString())); + + QScopedPointer obj(component.create()); + QVERIFY(!obj.isNull()); + + QVERIFY(obj->property("success").toBool()); +} + QTEST_MAIN(tst_qqmllistmodel) #include "tst_qqmllistmodel.moc" -- cgit v1.2.3 From 5ffd0d8be35cea57acbf1e8d7a740d3fab5cbe43 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Fri, 11 Nov 2016 15:35:02 +0100 Subject: Text: Make use of the new cached isSmoothlyScaled attribute on QFontEngine Relies on qtbase/f2205c48c21a6b135f2f59d0cf46e72f90f9f0f4. Asking QFontDatabase whether or not the font can be smoothly scaled is expensive Now that the attribute is available on QFontEngine, we can bypass all that. Benchmark results from qmlbench on creation/delegates_text on a 2011 mbp. Before: Average: 173.2 ops/frame; using 5/5 samples; MedianAll=173; StdDev=1.94, CoV=0.0112 - StdDev (all samples included)=1.94 After: Average: 180.8 ops/frame; using 5/5 samples; MedianAll=182; StdDev=1.94, CoV=0.0107 - StdDev (all samples included)=1.94 Change-Id: I56efd903037a29ee014de0cbf482cfbef7fce494 Reviewed-by: Gunnar Sletta --- src/quick/items/qquicktextnode.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/quick/items/qquicktextnode.cpp b/src/quick/items/qquicktextnode.cpp index 2c7ab254f8..f91c8de634 100644 --- a/src/quick/items/qquicktextnode.cpp +++ b/src/quick/items/qquicktextnode.cpp @@ -93,10 +93,12 @@ QSGGlyphNode *QQuickTextNode::addGlyphs(const QPointF &position, const QGlyphRun bool preferNativeGlyphNode = m_useNativeRenderer; if (!preferNativeGlyphNode) { QRawFontPrivate *fontPriv = QRawFontPrivate::get(font); - if (fontPriv->fontEngine->hasUnreliableGlyphOutline()) + if (fontPriv->fontEngine->hasUnreliableGlyphOutline()) { preferNativeGlyphNode = true; - else - preferNativeGlyphNode = !QFontDatabase().isSmoothlyScalable(font.familyName(), font.styleName()); + } else { + QFontEngine *fe = QRawFontPrivate::get(font)->fontEngine; + preferNativeGlyphNode = !fe->isSmoothlyScalable; + } } QSGGlyphNode *node = sg->sceneGraphContext()->createGlyphNode(sg, preferNativeGlyphNode); -- cgit v1.2.3 From c4ebe96c34c2179d0ebdc555afdce179e3de52e8 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 22 Nov 2016 15:16:09 +0100 Subject: Improved robustness of the optimizer when removing expressions For example during dead code elimination we may invalidate statements, but at the same time there may still be instances left in the work list of optimizeSSA(). When we encounter then, we should not process them any further. Task-number: QTBUG-56255 Change-Id: I4c24b1a225ce1bde112172e9606f91c426c19f19 Reviewed-by: Erik Verbruggen --- src/qml/compiler/qv4ssa.cpp | 15 ++++++--------- tests/auto/qml/qjsengine/tst_qjsengine.cpp | 8 ++++++++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp index f20dbbf4fe..93692b3996 100644 --- a/src/qml/compiler/qv4ssa.cpp +++ b/src/qml/compiler/qv4ssa.cpp @@ -1968,14 +1968,9 @@ public: return *this; } - bool isEmpty() const - { - return worklistSize == 0; - } - Stmt *takeNext(Stmt *last) { - if (isEmpty()) + if (worklistSize == 0) return 0; const int startAt = last ? last->id() + 1 : 0; @@ -1991,6 +1986,10 @@ public: --worklistSize; Stmt *s = stmts.at(pos); Q_ASSERT(s); + + if (removed.at(s->id())) + return takeNext(s); + return s; } @@ -3960,9 +3959,7 @@ void optimizeSSA(StatementWorklist &W, DefUses &defUses, DominatorTree &df) ExprReplacer replaceUses(defUses, function); Stmt *s = 0; - while (!W.isEmpty()) { - s = W.takeNext(s); - Q_ASSERT(s); + while ((s = W.takeNext(s))) { if (Phi *phi = s->asPhi()) { // dead code elimination: diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 6cbafbf055..781f3f93e4 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -197,6 +197,8 @@ private slots: void withNoContext(); void holeInPropertyData(); + void malformedExpression(); + signals: void testSignal(); }; @@ -3872,6 +3874,12 @@ void tst_QJSEngine::holeInPropertyData() QVERIFY(ok.toBool()); } +void tst_QJSEngine::malformedExpression() +{ + QJSEngine engine; + engine.evaluate("5%55555&&5555555\n7-0"); +} + QTEST_MAIN(tst_QJSEngine) #include "tst_qjsengine.moc" -- cgit v1.2.3 From c712f638a0a3ad2a71a9a18601fd320dabd50f16 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 23 Nov 2016 13:56:34 +0100 Subject: V4: Fix JIT codegen for null/undefined conditional jumps When checking for undefined, both the tag and the value need to be checked. When loading the tag, it shouldn't end up in the same register that is used to hold the address of the QV4::Value. Change-Id: I380fce432ba489fdabe569dd2c9cac31e9905260 Reviewed-by: Simon Hausmann --- src/qml/jit/qv4isel_masm.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qml/jit/qv4isel_masm.cpp b/src/qml/jit/qv4isel_masm.cpp index 05afc1ee77..4a201200fa 100644 --- a/src/qml/jit/qv4isel_masm.cpp +++ b/src/qml/jit/qv4isel_masm.cpp @@ -1871,7 +1871,7 @@ bool InstructionSelection::visitCJumpStrictUndefined(IR::Binop *binop, Assembler::RelationalCondition cond = binop->op == IR::OpStrictEqual ? Assembler::Equal : Assembler::NotEqual; - const Assembler::RegisterID tagReg = Assembler::ScratchRegister; + const Assembler::RegisterID tagReg = Assembler::ReturnValueRegister; #ifdef QV4_USE_64_BIT_VALUE_ENCODING Assembler::Pointer addr = _as->loadAddress(Assembler::ScratchRegister, varSrc); _as->load64(addr, tagReg); @@ -1970,7 +1970,7 @@ bool InstructionSelection::visitCJumpNullUndefined(IR::Type nullOrUndef, IR::Bin Assembler::Pointer tagAddr = _as->loadAddress(Assembler::ScratchRegister, varSrc); tagAddr.offset += 4; - const Assembler::RegisterID tagReg = Assembler::ScratchRegister; + const Assembler::RegisterID tagReg = Assembler::ReturnValueRegister; _as->load32(tagAddr, tagReg); if (binop->op == IR::OpNotEqual) -- cgit v1.2.3 From 2837f1c868b92e7cc8293064ff7ec3f76cdf6c7b Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 24 Nov 2016 11:50:45 +0100 Subject: QmlProfiler: Explicitly specify the offsets for scene graph events The profiler can be switched on in the middle of a frame. In that case the last offset into the timing data would be some random number, which may lead to a crash when recording the sample. However, as we know all the data points we are going to record, we can as well specify where they are supposed to go. The timings themselves may still be random for frames of which we only recorded parts, but the clients can deal with this. Task-number: QTBUG-57304 Change-Id: I1d507f2591516e43d5b3cd25f7939716f2b64ed9 Reviewed-by: Simon Hausmann --- src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp | 6 +- src/quick/scenegraph/coreapi/qsgrenderer.cpp | 12 +- src/quick/scenegraph/qsgadaptationlayer.cpp | 4 +- src/quick/scenegraph/qsgrenderloop.cpp | 12 +- src/quick/scenegraph/qsgthreadedrenderloop.cpp | 24 ++-- src/quick/scenegraph/qsgwindowsrenderloop.cpp | 21 ++-- src/quick/scenegraph/util/qsgatlastexture.cpp | 17 ++- src/quick/scenegraph/util/qsgtexture.cpp | 18 ++- src/quick/util/qquickprofiler_p.h | 140 +++++++++++++++------- 9 files changed, 172 insertions(+), 82 deletions(-) diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index 525d702a76..45fb857fb3 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -163,7 +163,8 @@ ShaderManager::Shader *ShaderManager::prepareMaterial(QSGMaterial *material) qCDebug(QSG_LOG_TIME_COMPILATION, "shader compiled in %dms", (int) qsg_renderer_timer.elapsed()); - Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphContextFrame); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphContextFrame, + QQuickProfiler::SceneGraphContextMaterialCompile); rewrittenShaders[type] = shader; return shader; @@ -194,7 +195,8 @@ ShaderManager::Shader *ShaderManager::prepareMaterialNoRewrite(QSGMaterial *mate qCDebug(QSG_LOG_TIME_COMPILATION, "shader compiled in %dms (no rewrite)", (int) qsg_renderer_timer.elapsed()); - Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphContextFrame); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphContextFrame, + QQuickProfiler::SceneGraphContextMaterialCompile); return shader; } diff --git a/src/quick/scenegraph/coreapi/qsgrenderer.cpp b/src/quick/scenegraph/coreapi/qsgrenderer.cpp index 775277e588..bd60454a50 100644 --- a/src/quick/scenegraph/coreapi/qsgrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgrenderer.cpp @@ -199,7 +199,8 @@ void QSGRenderer::renderScene(const QSGBindable &bindable) bindable.bind(); if (profileFrames) bindTime = frameTimer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRendererFrame); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRendererFrame, + QQuickProfiler::SceneGraphRendererBinding); // Sanity check that attribute registers are disabled if (qsg_sanity_check) { @@ -217,7 +218,8 @@ void QSGRenderer::renderScene(const QSGBindable &bindable) render(); if (profileFrames) renderTime = frameTimer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRendererFrame); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRendererFrame, + QQuickProfiler::SceneGraphRendererRender); m_is_rendering = false; m_changed_emitted = false; @@ -281,13 +283,15 @@ void QSGRenderer::preprocess() bool profileFrames = QSG_LOG_TIME_RENDERER().isDebugEnabled(); if (profileFrames) preprocessTime = frameTimer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRendererFrame); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRendererFrame, + QQuickProfiler::SceneGraphRendererPreprocess); nodeUpdater()->updateStates(root); if (profileFrames) updatePassTime = frameTimer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRendererFrame); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRendererFrame, + QQuickProfiler::SceneGraphRendererUpdate); } void QSGRenderer::addNodesToPreprocess(QSGNode *node) diff --git a/src/quick/scenegraph/qsgadaptationlayer.cpp b/src/quick/scenegraph/qsgadaptationlayer.cpp index bf97133e97..f32829c2ea 100644 --- a/src/quick/scenegraph/qsgadaptationlayer.cpp +++ b/src/quick/scenegraph/qsgadaptationlayer.cpp @@ -179,7 +179,8 @@ void QSGDistanceFieldGlyphCache::update() int count = m_pendingGlyphs.size(); if (profileFrames) renderTime = qsg_render_timer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphAdaptationLayerFrame); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphAdaptationLayerFrame, + QQuickProfiler::SceneGraphAdaptationLayerGlyphRender); m_pendingGlyphs.reset(); @@ -200,6 +201,7 @@ void QSGDistanceFieldGlyphCache::update() int((now - (renderTime / 1000000)))); } Q_QUICK_SG_PROFILE_END_WITH_PAYLOAD(QQuickProfiler::SceneGraphAdaptationLayerFrame, + QQuickProfiler::SceneGraphAdaptationLayerGlyphStore, (qint64)count); } diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index 68947d3a3c..8fba301c4e 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -383,7 +383,8 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) if (profileFrames) polishTime = renderTimer.nsecsElapsed(); Q_QUICK_SG_PROFILE_SWITCH(QQuickProfiler::SceneGraphPolishFrame, - QQuickProfiler::SceneGraphRenderLoopFrame); + QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphPolishPolish); emit window->afterAnimating(); @@ -391,13 +392,15 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) if (profileFrames) syncTime = renderTimer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphRenderLoopSync); cd->renderSceneGraph(window->size()); if (profileFrames) renderTime = renderTimer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphRenderLoopRender); if (data.grabOnly) { bool alpha = window->format().alphaBufferSize() > 0 && window->color().alpha() != 255; @@ -414,7 +417,8 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) qint64 swapTime = 0; if (profileFrames) swapTime = renderTimer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphRenderLoopSwap); if (QSG_LOG_TIME_RENDERLOOP().isDebugEnabled()) { static QTime lastFrameTime = QTime::currentTime(); diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp index ceb3caa53f..c9cc3b9fa0 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp +++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp @@ -591,7 +591,8 @@ void QSGRenderThread::syncAndRender() if (profileFrames) syncTime = threadTimer.nsecsElapsed(); #endif - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphRenderLoopSync); if (!syncResultedInChanges && !repaintRequested && sgrc->isValid()) { qCDebug(QSG_LOG_RENDERLOOP) << QSG_RT_PAD << "- no changes, render aborted"; @@ -623,12 +624,14 @@ void QSGRenderThread::syncAndRender() d->renderSceneGraph(windowSize); if (profileFrames) renderTime = threadTimer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphRenderLoopRender); if (!d->customRenderStage || !d->customRenderStage->swap()) gl->swapBuffers(window); d->fireFrameSwapped(); } else { - Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphRenderLoopFrame, 1); + Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphRenderLoopSync, 1); qCDebug(QSG_LOG_RENDERLOOP) << QSG_RT_PAD << "- window not ready, skipping render"; } @@ -653,7 +656,8 @@ void QSGRenderThread::syncAndRender() int(threadTimer.elapsed() - renderTime / 1000000)); - Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphRenderLoopSwap); } @@ -1158,7 +1162,8 @@ void QSGThreadedRenderLoop::polishAndSync(Window *w, bool inExpose) if (profileFrames) polishTime = timer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync, + QQuickProfiler::SceneGraphPolishAndSyncPolish); w->updateDuringSync = false; @@ -1173,7 +1178,8 @@ void QSGThreadedRenderLoop::polishAndSync(Window *w, bool inExpose) qCDebug(QSG_LOG_RENDERLOOP) << "- wait for sync"; if (profileFrames) waitTime = timer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync, + QQuickProfiler::SceneGraphPolishAndSyncWait); w->thread->waitCondition.wait(&w->thread->mutex); m_lockedForSync = false; w->thread->mutex.unlock(); @@ -1181,7 +1187,8 @@ void QSGThreadedRenderLoop::polishAndSync(Window *w, bool inExpose) if (profileFrames) syncTime = timer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync, + QQuickProfiler::SceneGraphPolishAndSyncSync); if (m_animation_timer == 0 && m_animation_driver->isRunning()) { qCDebug(QSG_LOG_RENDERLOOP) << "- advancing animations"; @@ -1202,7 +1209,8 @@ void QSGThreadedRenderLoop::polishAndSync(Window *w, bool inExpose) << ", animations=" << (timer.nsecsElapsed() - syncTime) / 1000000 << " - (on Gui thread) " << window; - Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphPolishAndSync); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphPolishAndSync, + QQuickProfiler::SceneGraphPolishAndSyncAnimations); } bool QSGThreadedRenderLoop::event(QEvent *e) diff --git a/src/quick/scenegraph/qsgwindowsrenderloop.cpp b/src/quick/scenegraph/qsgwindowsrenderloop.cpp index 04a46bf929..510d65398d 100644 --- a/src/quick/scenegraph/qsgwindowsrenderloop.cpp +++ b/src/quick/scenegraph/qsgwindowsrenderloop.cpp @@ -61,9 +61,9 @@ static QElapsedTimer qsg_render_timer; if (QSG_LOG_TIME_RENDERLOOP().isDebugEnabled()) \ sampleName = qsg_render_timer.nsecsElapsed(); \ -#define QSG_RENDER_TIMING_SAMPLE(frameType, sampleName) \ +#define QSG_RENDER_TIMING_SAMPLE(frameType, sampleName, position) \ QSG_LOG_TIME_SAMPLE(sampleName) \ - Q_QUICK_SG_PROFILE_RECORD(frameType); + Q_QUICK_SG_PROFILE_RECORD(frameType, position); QSGWindowsRenderLoop::QSGWindowsRenderLoop() @@ -389,7 +389,7 @@ void QSGWindowsRenderLoop::render() "animations ticked in %dms", int((qsg_render_timer.nsecsElapsed() - time_start)/1000000)); - Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphWindowsAnimations); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphWindowsAnimations, 1); // It is not given that animations triggered another maybeUpdate() // and thus another render pass, so to keep things running, @@ -440,22 +440,26 @@ void QSGWindowsRenderLoop::renderWindow(QQuickWindow *window) d->polishItems(); QSG_LOG_TIME_SAMPLE(time_polished); Q_QUICK_SG_PROFILE_SWITCH(QQuickProfiler::SceneGraphPolishFrame, - QQuickProfiler::SceneGraphRenderLoopFrame); + QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphPolishPolish); emit window->afterAnimating(); RLDEBUG(" - syncing"); d->syncSceneGraph(); - QSG_RENDER_TIMING_SAMPLE(QQuickProfiler::SceneGraphRenderLoopFrame, time_synced); + QSG_RENDER_TIMING_SAMPLE(QQuickProfiler::SceneGraphRenderLoopFrame, time_synced, + QQuickProfiler::SceneGraphRenderLoopSync); RLDEBUG(" - rendering"); d->renderSceneGraph(window->size()); - QSG_RENDER_TIMING_SAMPLE(QQuickProfiler::SceneGraphRenderLoopFrame, time_rendered); + QSG_RENDER_TIMING_SAMPLE(QQuickProfiler::SceneGraphRenderLoopFrame, time_rendered, + QQuickProfiler::SceneGraphRenderLoopRender); RLDEBUG(" - swapping"); if (!d->customRenderStage || !d->customRenderStage->swap()) m_gl->swapBuffers(window); - QSG_RENDER_TIMING_SAMPLE(QQuickProfiler::SceneGraphRenderLoopFrame, time_swapped); + QSG_RENDER_TIMING_SAMPLE(QQuickProfiler::SceneGraphRenderLoopFrame, time_swapped, + QQuickProfiler::SceneGraphRenderLoopSwap); RLDEBUG(" - frameDone"); d->fireFrameSwapped(); @@ -468,7 +472,8 @@ void QSGWindowsRenderLoop::renderWindow(QQuickWindow *window) << ", swap=" << (time_swapped - time_rendered) / 1000000 << " - " << window; - Q_QUICK_SG_PROFILE_REPORT(QQuickProfiler::SceneGraphRenderLoopFrame); + Q_QUICK_SG_PROFILE_REPORT(QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphRenderLoopSwap); } QT_END_NAMESPACE diff --git a/src/quick/scenegraph/util/qsgatlastexture.cpp b/src/quick/scenegraph/util/qsgatlastexture.cpp index e163191c6e..d26629900f 100644 --- a/src/quick/scenegraph/util/qsgatlastexture.cpp +++ b/src/quick/scenegraph/util/qsgatlastexture.cpp @@ -388,9 +388,12 @@ void Atlas::bind(QSGTexture::Filtering filtering) bool profileFrames = QSG_LOG_TIME_TEXTURE().isDebugEnabled(); if (profileFrames) qsg_renderer_timer.start(); - // Skip bind, convert, swizzle; they're irrelevant + Q_QUICK_SG_PROFILE_START(QQuickProfiler::SceneGraphTexturePrepare); - Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphTexturePrepare, 3); + + // Skip bind, convert, swizzle; they're irrelevant + Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphTexturePrepare, + QQuickProfiler::SceneGraphTexturePrepareStart, 3); Texture *t = m_pending_uploads.at(i); if (m_externalFormat == GL_BGRA && @@ -408,10 +411,14 @@ void Atlas::bind(QSGTexture::Filtering filtering) << "ms (" << t->textureSize().width() << "x" << t->textureSize().height() << ")"; + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare, + QQuickProfiler::SceneGraphTexturePrepareUpload); + // Skip mipmap; unused - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare); - Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphTexturePrepare, 1); - Q_QUICK_SG_PROFILE_REPORT(QQuickProfiler::SceneGraphTexturePrepare); + Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphTexturePrepare, + QQuickProfiler::SceneGraphTexturePrepareUpload, 1); + Q_QUICK_SG_PROFILE_REPORT(QQuickProfiler::SceneGraphTexturePrepare, + QQuickProfiler::SceneGraphTexturePrepareMipmap); } GLenum f = filtering == QSGTexture::Nearest ? GL_NEAREST : GL_LINEAR; diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp index df9e569ca3..7625130dfe 100644 --- a/src/quick/scenegraph/util/qsgtexture.cpp +++ b/src/quick/scenegraph/util/qsgtexture.cpp @@ -646,7 +646,8 @@ void QSGPlainTexture::bind() (int) qsg_renderer_timer.elapsed(), m_texture_size.width(), m_texture_size.height()); - Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphTextureDeletion); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphTextureDeletion, + QQuickProfiler::SceneGraphTextureDeletionDelete); } m_texture_id = 0; m_texture_size = QSize(); @@ -662,7 +663,8 @@ void QSGPlainTexture::bind() qint64 bindTime = 0; if (profileFrames) bindTime = qsg_renderer_timer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare, + QQuickProfiler::SceneGraphTexturePrepareBind); // ### TODO: check for out-of-memory situations... @@ -703,7 +705,8 @@ void QSGPlainTexture::bind() qint64 convertTime = 0; if (profileFrames) convertTime = qsg_renderer_timer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare, + QQuickProfiler::SceneGraphTexturePrepareConvert); updateBindOptions(m_dirty_bind_options); @@ -746,14 +749,16 @@ void QSGPlainTexture::bind() qint64 swizzleTime = 0; if (profileFrames) swizzleTime = qsg_renderer_timer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare, + QQuickProfiler::SceneGraphTexturePrepareSwizzle); funcs->glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, m_texture_size.width(), m_texture_size.height(), 0, externalFormat, GL_UNSIGNED_BYTE, tmp.constBits()); qint64 uploadTime = 0; if (profileFrames) uploadTime = qsg_renderer_timer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare, + QQuickProfiler::SceneGraphTexturePrepareUpload); if (mipmapFiltering() != QSGTexture::None) { funcs->glGenerateMipmap(GL_TEXTURE_2D); @@ -776,7 +781,8 @@ void QSGPlainTexture::bind() int((mipmapTime - uploadTime)/1000000), m_texture_size != m_image.size() ? " (scaled to GL_MAX_TEXTURE_SIZE)" : ""); } - Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphTexturePrepare); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphTexturePrepare, + QQuickProfiler::SceneGraphTexturePrepareMipmap); m_texture_rect = QRectF(0, 0, 1, 1); diff --git a/src/quick/util/qquickprofiler_p.h b/src/quick/util/qquickprofiler_p.h index 6b6e7fa062..7aff1605c6 100644 --- a/src/quick/util/qquickprofiler_p.h +++ b/src/quick/util/qquickprofiler_p.h @@ -64,37 +64,52 @@ QT_BEGIN_NAMESPACE #define Q_QUICK_PROFILE(feature, Method)\ Q_QUICK_PROFILE_IF_ENABLED(feature, QQuickProfiler::Method) +// Record current timestamp for \a Type at position 0. #define Q_QUICK_SG_PROFILE_START(Type)\ Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ (QQuickProfiler::startSceneGraphFrame())) -#define Q_QUICK_SG_PROFILE_RECORD(Type)\ +// Record current timestamp for \a Type at \a position. +#define Q_QUICK_SG_PROFILE_RECORD(Type, position)\ Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ - (QQuickProfiler::recordSceneGraphTimestamp())) + (QQuickProfiler::recordSceneGraphTimestamp(position))) -#define Q_QUICK_SG_PROFILE_SKIP(Type, Skip)\ +// Use the timestamp for \a Type at position \a position and repeat it \a Skip times in subsequent +// positions. +#define Q_QUICK_SG_PROFILE_SKIP(Type, position, Skip)\ Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ - (QQuickProfiler::skipSceneGraphTimestamps())) + (QQuickProfiler::skipSceneGraphTimestamps(position))) +// Record current timestamp for both \a Type1 and \a Type2 at position 0. #define Q_QUICK_SG_PROFILE_START_SYNCHRONIZED(Type1, Type2)\ Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ (QQuickProfiler::startSceneGraphFrame())) -#define Q_QUICK_SG_PROFILE_SWITCH(Type1, Type2) \ +// report \a Type1, using the current timestamp at \a position, and switch to \a Typ2, using +// the current timestamp at position 0. +#define Q_QUICK_SG_PROFILE_SWITCH(Type1, Type2, position)\ Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ - (QQuickProfiler::reportSceneGraphFrame())) + (QQuickProfiler::reportSceneGraphFrame(\ + position))) -#define Q_QUICK_SG_PROFILE_REPORT(Type)\ +// report \a Type, using data points 0 to \a position, including \a position. +#define Q_QUICK_SG_PROFILE_REPORT(Type, position)\ Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ - (QQuickProfiler::reportSceneGraphFrame())) + (QQuickProfiler::reportSceneGraphFrame(position))) -#define Q_QUICK_SG_PROFILE_END(Type)\ +// report \a Type, using data points 0 to \a position, including \a position, and setting the +// timestamp at \a position to the current one. +#define Q_QUICK_SG_PROFILE_END(Type, position)\ Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ - (QQuickProfiler::reportSceneGraphFrame())) + (QQuickProfiler::reportSceneGraphFrame(position))) -#define Q_QUICK_SG_PROFILE_END_WITH_PAYLOAD(Type, Payload)\ +// report \a Type, using data points 0 to \a position, including \a position, and setting the +// timestamp at \a position to the current one. Remaining data points up to position 5 are filled +// with \a Payload. +#define Q_QUICK_SG_PROFILE_END_WITH_PAYLOAD(Type, position, Payload)\ Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ - (QQuickProfiler::reportSceneGraphFrame(Payload))) + (QQuickProfiler::reportSceneGraphFrame(position,\ + Payload))) #define Q_QUICK_INPUT_PROFILE(Method)\ @@ -173,7 +188,6 @@ private: template struct TimingData { qint64 values[size][s_numSceneGraphTimings + 1]; - int offsets[size]; }; QThreadStorage > renderThreadTimings; @@ -188,15 +202,6 @@ public: else return guiThreadTimings.values[type - NumRenderThreadFrameTypes]; } - - template - int &offset() - { - if (type < NumRenderThreadFrameTypes) - return renderThreadTimings.localData().offsets[type]; - else - return guiThreadTimings.offsets[type - NumRenderThreadFrameTypes]; - } }; class Q_QUICK_PRIVATE_EXPORT QQuickProfiler : public QQmlAbstractProfilerAdapter { @@ -208,6 +213,59 @@ public: RenderThread }; + enum SceneGraphContextStage { + SceneGraphContextStart, + SceneGraphContextMaterialCompile + }; + + enum SceneGraphRendererStage { + SceneGraphRendererStart, + SceneGraphRendererPreprocess, + SceneGraphRendererUpdate, + SceneGraphRendererBinding, + SceneGraphRendererRender + }; + + enum SceneGraphAdaptationLayerStage { + SceneGraphAdaptationLayerStart, + SceneGraphAdaptationLayerGlyphRender, + SceneGraphAdaptationLayerGlyphStore + }; + + enum SceneGraphRenderLoopStage { + SceneGraphRenderLoopStart, + SceneGraphRenderLoopSync, + SceneGraphRenderLoopRender, + SceneGraphRenderLoopSwap + }; + + enum SceneGraphPolishStage { + SceneGraphPolishStart, + SceneGraphPolishPolish + }; + + enum SceneGraphPolishAndSyncStage { + SceneGraphPolishAndSyncStart, + SceneGraphPolishAndSyncPolish, + SceneGraphPolishAndSyncWait, + SceneGraphPolishAndSyncSync, + SceneGraphPolishAndSyncAnimations + }; + + enum SceneGraphTexturePrepareStage { + SceneGraphTexturePrepareStart, + SceneGraphTexturePrepareBind, + SceneGraphTexturePrepareConvert, + SceneGraphTexturePrepareSwizzle, + SceneGraphTexturePrepareUpload, + SceneGraphTexturePrepareMipmap + }; + + enum SceneGraphTextureDeletionStage { + SceneGraphTextureDeletionStart, + SceneGraphTextureDeletionDelete + }; + template static void addEvent() { @@ -230,7 +288,6 @@ public: static void startSceneGraphFrame() { startSceneGraphFrame(); - s_instance->m_sceneGraphData.offset() = 0; s_instance->m_sceneGraphData.timings()[0] = s_instance->m_sceneGraphData.timings()[0]; } @@ -238,50 +295,45 @@ public: template static void startSceneGraphFrame() { - s_instance->m_sceneGraphData.offset() = 0; s_instance->m_sceneGraphData.timings()[0] = s_instance->timestamp(); } template - static void recordSceneGraphTimestamp() + static void recordSceneGraphTimestamp(uint position) { - s_instance->m_sceneGraphData.timings() - [++s_instance->m_sceneGraphData.offset()] = s_instance->timestamp(); + s_instance->m_sceneGraphData.timings()[position] = s_instance->timestamp(); } template - static void skipSceneGraphTimestamps() + static void skipSceneGraphTimestamps(uint position) { qint64 *timings = s_instance->m_sceneGraphData.timings(); - const qint64 last = timings[s_instance->m_sceneGraphData.offset()]; + const qint64 last = timings[position]; for (uint i = 0; i < Skip; ++i) - timings[++s_instance->m_sceneGraphData.offset()] = last; + timings[++position] = last; } template - static void reportSceneGraphFrame(quint64 payload = ~0) + static void reportSceneGraphFrame(uint position, quint64 payload = ~0) { qint64 *timings = s_instance->m_sceneGraphData.timings(); - int &offset = s_instance->m_sceneGraphData.offset(); if (Record) - timings[++offset] = s_instance->timestamp(); + timings[position] = s_instance->timestamp(); s_instance->processMessage(QQuickProfilerData( - timings[offset], 1 << SceneGraphFrame, 1 << FrameType, - offset > 0 ? timings[1] - timings[0] : payload, - offset > 1 ? timings[2] - timings[1] : payload, - offset > 2 ? timings[3] - timings[2] : payload, - offset > 3 ? timings[4] - timings[3] : payload, - offset > 4 ? timings[5] - timings[4] : payload)); + timings[position], 1 << SceneGraphFrame, 1 << FrameType, + position > 0 ? timings[1] - timings[0] : payload, + position > 1 ? timings[2] - timings[1] : payload, + position > 2 ? timings[3] - timings[2] : payload, + position > 3 ? timings[4] - timings[3] : payload, + position > 4 ? timings[5] - timings[4] : payload)); } template - static void reportSceneGraphFrame(quint64 payload = ~0) + static void reportSceneGraphFrame(uint position, quint64 payload = ~0) { - reportSceneGraphFrame(payload); - s_instance->m_sceneGraphData.offset() = 0; + reportSceneGraphFrame(position, payload); s_instance->m_sceneGraphData.timings()[0] = - s_instance->m_sceneGraphData.timings() - [s_instance->m_sceneGraphData.offset()]; + s_instance->m_sceneGraphData.timings()[position]; } template -- cgit v1.2.3 From 4fae8ff1e73eeb48734b28a9c846fbdff1c2ffe1 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 25 Nov 2016 11:17:12 +0100 Subject: Doc: fix incorrect syntax in "Code-Behind Implementation Resource" Change-Id: Ie86302f12d4ad65ff46335a1ea248bbb4c5559f3 Task-number: QTBUG-56008 Reviewed-by: J-P Nurmi --- src/qml/doc/src/javascript/resources.qdoc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qml/doc/src/javascript/resources.qdoc b/src/qml/doc/src/javascript/resources.qdoc index b831e2ba70..4f9b40f1d7 100644 --- a/src/qml/doc/src/javascript/resources.qdoc +++ b/src/qml/doc/src/javascript/resources.qdoc @@ -78,13 +78,13 @@ Rectangle { \code // my_button_impl.js -property var clickCount = 0; // this state is separate for each instance of MyButton -function onClicked(btn) { +var clickCount = 0; // this state is separate for each instance of MyButton +function onClicked(button) { clickCount += 1; if ((clickCount % 5) == 0) { - obj.color = Qt.rgba(1,0,0,1); + button.color = Qt.rgba(1,0,0,1); } else { - obj.color = Qt.rgba(0,1,0,1); + button.color = Qt.rgba(0,1,0,1); } } \endcode -- cgit v1.2.3