diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-11-15 00:06:18 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-28 13:47:40 +0100 |
commit | f474eede801ed7bec712069e95bbe2f4ab5558ae (patch) | |
tree | 94470e17070c1ff1b9805c38ed2bec10cc9110ff /src/qml/qml | |
parent | 140400be0f8a8c91ce02ad5691d81d7604e5a4db (diff) |
Add support for accelerated property access to QML types and namespace support
* Resolve lookups in namespaces at compile time and instruct the SSA optimizer
to eliminate reads from the namespace (QQmlTypeWrapper) if possible. For example
access to attached properties of types (i.e. MyNameSpace.ListView.isCurrentItem)
requires neither reading the namespace nor the type.
* Add support for accelerated lookup of attached properties
Change-Id: Ib0b66404ed7e70e1d4a46a1ac8218743a4cc8608
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml')
-rw-r--r-- | src/qml/qml/qqmlcontextwrapper.cpp | 6 | ||||
-rw-r--r-- | src/qml/qml/qqmldata_p.h | 3 | ||||
-rw-r--r-- | src/qml/qml/qqmlengine.cpp | 10 |
3 files changed, 17 insertions, 2 deletions
diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp index 0b3b282061..54b540bb4c 100644 --- a/src/qml/qml/qqmlcontextwrapper.cpp +++ b/src/qml/qml/qqmlcontextwrapper.cpp @@ -53,6 +53,7 @@ #include <private/qv4compileddata_p.h> #include <private/qqmltypewrapper_p.h> #include <private/qqmllistwrapper_p.h> +#include <private/qjsvalue_p.h> QT_BEGIN_NAMESPACE @@ -427,8 +428,9 @@ ReturnedValue QmlContextWrapper::qmlSingletonWrapper(const StringRef &name) QQmlType::SingletonInstanceInfo *siinfo = r.type->singletonInstanceInfo(); siinfo->init(e); - QObject *qobjectSingleton = siinfo->qobjectApi(e); - return QV4::QObjectWrapper::wrap(engine(), qobjectSingleton); + if (QObject *qobjectSingleton = siinfo->qobjectApi(e)) + return QV4::QObjectWrapper::wrap(engine(), qobjectSingleton); + return QJSValuePrivate::get(siinfo->scriptApi(e))->getValue(engine()); } DEFINE_MANAGED_VTABLE(QQmlIdObjectsArray); diff --git a/src/qml/qml/qqmldata_p.h b/src/qml/qml/qqmldata_p.h index 621b3d3c2e..982156ea15 100644 --- a/src/qml/qml/qqmldata_p.h +++ b/src/qml/qml/qqmldata_p.h @@ -61,6 +61,7 @@ QT_BEGIN_NAMESPACE template <class Key, class T> class QHash; +class QQmlEngine; class QQmlGuardImpl; class QQmlCompiledData; class QQmlAbstractBinding; @@ -222,6 +223,8 @@ public: static inline void flushPendingBinding(QObject *, int coreIndex); + static void ensurePropertyCache(QQmlEngine *engine, QObject *object); + private: // For attachedProperties mutable QQmlDataExtended *extendedData; diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 1eec710c84..5b05576129 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -1734,6 +1734,16 @@ void QQmlData::setPendingBindingBit(QObject *obj, int coreIndex) QQmlData_setBit(this, obj, coreIndex * 2 + 1); } +void QQmlData::ensurePropertyCache(QQmlEngine *engine, QObject *object) +{ + Q_ASSERT(engine); + QQmlData *ddata = QQmlData::get(object, /*create*/true); + if (ddata->propertyCache) + return; + ddata->propertyCache = QQmlEnginePrivate::get(engine)->cache(object); + if (ddata->propertyCache) ddata->propertyCache->addref(); +} + void QQmlEnginePrivate::sendQuit() { Q_Q(QQmlEngine); |