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/jsruntime/qv4qobjectwrapper_p.h | |
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/jsruntime/qv4qobjectwrapper_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper_p.h | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h index 37397db55b..727af6c9c6 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper_p.h +++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h @@ -78,7 +78,7 @@ namespace Heap { struct QQmlValueTypeWrapper; struct QObjectWrapper : Object { - QObjectWrapper(QObject *object); + void init(QObject *object); void destroy() { qObj.destroy(); } QObject *object() const { return qObj.data(); } @@ -88,16 +88,22 @@ private: }; struct QObjectMethod : FunctionObject { - QObjectMethod(QV4::ExecutionContext *scope); + void init(QV4::ExecutionContext *scope); void destroy() { - propertyCache = nullptr; + setPropertyCache(nullptr); qObj.destroy(); FunctionObject::destroy(); } - QQmlRefPointer<QQmlPropertyCache> propertyCache; - int index; + QQmlPropertyCache *propertyCache() const { return _propertyCache; } + void setPropertyCache(QQmlPropertyCache *c) { + if (c) + c->addref(); + if (_propertyCache) + _propertyCache->release(); + _propertyCache = c; + } Pointer<QQmlValueTypeWrapper> valueTypeWrapper; @@ -107,6 +113,10 @@ struct QObjectMethod : FunctionObject { private: QQmlQPointer<QObject> qObj; + QQmlPropertyCache *_propertyCache; + +public: + int index; }; struct QMetaObjectWrapper : FunctionObject { @@ -114,13 +124,13 @@ struct QMetaObjectWrapper : FunctionObject { QQmlPropertyData *constructors; int constructorCount; - QMetaObjectWrapper(const QMetaObject* metaObject); + void init(const QMetaObject* metaObject); void destroy(); void ensureConstructorsCache(); }; struct QmlSignalHandler : Object { - QmlSignalHandler(QObject *object, int signalIndex); + void init(QObject *object, int signalIndex); void destroy() { qObj.destroy(); } int signalIndex; |