diff options
author | Erik Verbruggen <erik.verbruggen@digia.com> | 2016-09-09 15:37:57 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2016-10-06 11:44:08 +0000 |
commit | 3b14e2ffdd8eb4b7f7f4508768b75f2acc399370 (patch) | |
tree | 7943f293bf2d0d376d5dc620448bab1a2b58027d /src/qml/types | |
parent | 1b90dc4482d001512f09a5785d4cbd8030879d82 (diff) |
QML: Make Heap::Object and all subclasses trivial
GCC6 might dead-store-eliminate out our secret write to Base::mmdata,
because it expects all memory content to be "undefined" before
constructor calls. Clang might take the same approach if the constructor
of Heap::Object is removed.
By making these structs trivial, it also makes them memcpy-able.
Change-Id: I055b2ad28311b997fbe059849ebda4d5894eaa9b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/types')
-rw-r--r-- | src/qml/types/qqmldelegatemodel.cpp | 28 | ||||
-rw-r--r-- | src/qml/types/qqmldelegatemodel_p_p.h | 7 | ||||
-rw-r--r-- | src/qml/types/qqmllistmodel_p_p.h | 12 |
3 files changed, 27 insertions, 20 deletions
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index 02a5514275..395a3e5641 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -62,21 +62,24 @@ namespace QV4 { namespace Heap { struct DelegateModelGroupFunction : FunctionObject { - DelegateModelGroupFunction(QV4::ExecutionContext *scope, uint flag, QV4::ReturnedValue (*code)(QQmlDelegateModelItem *item, uint flag, const QV4::Value &arg)); + void init(QV4::ExecutionContext *scope, uint flag, QV4::ReturnedValue (*code)(QQmlDelegateModelItem *item, uint flag, const QV4::Value &arg)); - uint flag; QV4::ReturnedValue (*code)(QQmlDelegateModelItem *item, uint flag, const QV4::Value &arg); + uint flag; }; struct QQmlDelegateModelGroupChange : Object { - QQmlDelegateModelGroupChange() {} + void init() { Object::init(); } - QQmlChangeSet::Change change; + QQmlChangeSet::ChangeData change; }; struct QQmlDelegateModelGroupChangeArray : Object { - QQmlDelegateModelGroupChangeArray(const QVector<QQmlChangeSet::Change> &changes); - void destroy() { delete changes; } + void init(const QVector<QQmlChangeSet::Change> &changes); + void destroy() { + delete changes; + } + QVector<QQmlChangeSet::Change> *changes; }; @@ -106,11 +109,11 @@ struct DelegateModelGroupFunction : QV4::FunctionObject } }; -Heap::DelegateModelGroupFunction::DelegateModelGroupFunction(QV4::ExecutionContext *scope, uint flag, QV4::ReturnedValue (*code)(QQmlDelegateModelItem *item, uint flag, const QV4::Value &arg)) - : QV4::Heap::FunctionObject(scope, QStringLiteral("DelegateModelGroupFunction")) - , flag(flag) - , code(code) +void Heap::DelegateModelGroupFunction::init(QV4::ExecutionContext *scope, uint flag, QV4::ReturnedValue (*code)(QQmlDelegateModelItem *item, uint flag, const QV4::Value &arg)) { + QV4::Heap::FunctionObject::init(scope, QStringLiteral("DelegateModelGroupFunction")); + this->flag = flag; + this->code = code; } } @@ -3300,9 +3303,10 @@ public: } }; -QV4::Heap::QQmlDelegateModelGroupChangeArray::QQmlDelegateModelGroupChangeArray(const QVector<QQmlChangeSet::Change> &changes) - : changes(new QVector<QQmlChangeSet::Change>(changes)) +void QV4::Heap::QQmlDelegateModelGroupChangeArray::init(const QVector<QQmlChangeSet::Change> &changes) { + Object::init(); + this->changes = new QVector<QQmlChangeSet::Change>(changes); QV4::Scope scope(internalClass->engine); QV4::ScopedObject o(scope, this); o->setArrayType(QV4::Heap::ArrayData::Custom); diff --git a/src/qml/types/qqmldelegatemodel_p_p.h b/src/qml/types/qqmldelegatemodel_p_p.h index a34450ebd6..6cb82fddfc 100644 --- a/src/qml/types/qqmldelegatemodel_p_p.h +++ b/src/qml/types/qqmldelegatemodel_p_p.h @@ -160,7 +160,7 @@ protected: namespace QV4 { namespace Heap { struct QQmlDelegateModelItemObject : Object { - inline QQmlDelegateModelItemObject(QQmlDelegateModelItem *item); + inline void init(QQmlDelegateModelItem *item); void destroy(); QQmlDelegateModelItem *item; }; @@ -174,9 +174,10 @@ struct QQmlDelegateModelItemObject : QV4::Object V4_NEEDS_DESTROY }; -QV4::Heap::QQmlDelegateModelItemObject::QQmlDelegateModelItemObject(QQmlDelegateModelItem *item) - : item(item) +void QV4::Heap::QQmlDelegateModelItemObject::init(QQmlDelegateModelItem *item) { + Object::init(); + this->item = item; } diff --git a/src/qml/types/qqmllistmodel_p_p.h b/src/qml/types/qqmllistmodel_p_p.h index d3ff032ae9..bd2102679b 100644 --- a/src/qml/types/qqmllistmodel_p_p.h +++ b/src/qml/types/qqmllistmodel_p_p.h @@ -162,11 +162,12 @@ namespace QV4 { namespace Heap { struct ModelObject : public QObjectWrapper { - ModelObject(QObject *object, QQmlListModel *model, int elementIndex) - : QObjectWrapper(object) - , m_model(model) - , m_elementIndex(elementIndex) - {} + void init(QObject *object, QQmlListModel *model, int elementIndex) + { + QObjectWrapper::init(object); + m_model = model; + m_elementIndex = elementIndex; + } QQmlListModel *m_model; int m_elementIndex; }; @@ -180,6 +181,7 @@ struct ModelObject : public QObjectWrapper static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes); V4_OBJECT2(ModelObject, QObjectWrapper) + V4_NEEDS_DESTROY }; } // namespace QV4 |