diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-11-02 20:35:33 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-12 18:20:30 +0100 |
commit | 7a092000169a8e9d537f3d341ef48277397f997d (patch) | |
tree | f29f189d57e4923dff2decfd073b8e04f4a211a8 /src/qml/jsruntime | |
parent | 7c6d2d78fe0997dfebba5569f097bdacbba5a861 (diff) |
Fix property dependency generation for accelerated QML QObject properties
The previous approach of collecting the dependencies through an IR visitor
doesn't work, because it relies on a fixed structure - for example MEMBER(NAME,
prop) - which we can't guarantee (it's usually MEMBER(TEMP, prop)). But it
turns out that we can only pre-calculate dependencies for context, scope or id
properties, so we can do that right away in the QML specific JS codegen, store
that information in the IR function and use it from there in the data structure
generator as well as in the isel as a parameter to getQObjectProperty to tell
the run-time whether capture is required or not.
Change-Id: I33711c3420d6534c653c2a6a4284f0fc12e941cf
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper.cpp | 20 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper_p.h | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4runtime_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 2 |
5 files changed, 17 insertions, 15 deletions
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 578c7310f2..f9c7b5ac6c 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -334,7 +334,7 @@ ReturnedValue QObjectWrapper::getQmlProperty(ExecutionContext *ctx, QQmlContextD return getProperty(ctx, result); } -ReturnedValue QObjectWrapper::getProperty(ExecutionContext *ctx, QQmlPropertyData *property) +ReturnedValue QObjectWrapper::getProperty(ExecutionContext *ctx, QQmlPropertyData *property, bool captureRequired) { QV4::Scope scope(ctx); @@ -371,17 +371,19 @@ ReturnedValue QObjectWrapper::getProperty(ExecutionContext *ctx, QQmlPropertyDat QV4::ScopedValue rv(scope, LoadProperty<ReadAccessor::Accessor>(ctx->engine->v8Engine, m_object, *property, nptr)); - if (property->accessors->notifier) { - if (n) - ep->captureProperty(n); - } else { - ep->captureProperty(m_object, property->coreIndex, property->notifyIndex); + if (captureRequired) { + if (property->accessors->notifier) { + if (n) + ep->captureProperty(n); + } else { + ep->captureProperty(m_object, property->coreIndex, property->notifyIndex); + } } return rv.asReturnedValue(); } - if (ep && !property->isConstant()) + if (captureRequired && ep && !property->isConstant()) ep->captureProperty(m_object, property->coreIndex, property->notifyIndex); if (property->isVarProperty()) { @@ -614,7 +616,7 @@ ReturnedValue QObjectWrapper::wrap(ExecutionEngine *engine, QObject *object) } } -ReturnedValue QObjectWrapper::getProperty(ExecutionContext *ctx, int propertyIndex) +ReturnedValue QObjectWrapper::getProperty(ExecutionContext *ctx, int propertyIndex, bool captureRequired) { if (QQmlData::wasDeleted(m_object)) return QV4::Encode::null(); @@ -626,7 +628,7 @@ ReturnedValue QObjectWrapper::getProperty(ExecutionContext *ctx, int propertyInd Q_ASSERT(cache); QQmlPropertyData *property = cache->property(propertyIndex); Q_ASSERT(property); // We resolved this property earlier, so it better exist! - return getProperty(ctx, property); + return getProperty(ctx, property, captureRequired); } void QObjectWrapper::setProperty(ExecutionContext *ctx, int propertyIndex, const ValueRef value) diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h index f6c333f401..3a420abedb 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper_p.h +++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h @@ -94,11 +94,11 @@ struct Q_QML_EXPORT QObjectWrapper : public QV4::Object using Object::get; - ReturnedValue getProperty(ExecutionContext *ctx, int propertyIndex); + ReturnedValue getProperty(ExecutionContext *ctx, int propertyIndex, bool captureRequired); void setProperty(ExecutionContext *ctx, int propertyIndex, const ValueRef value); private: - ReturnedValue getProperty(ExecutionContext *ctx, QQmlPropertyData *property); + ReturnedValue getProperty(ExecutionContext *ctx, QQmlPropertyData *property, bool captureRequired = true); static void setProperty(QObject *object, ExecutionContext *ctx, QQmlPropertyData *property, const ValueRef value); static ReturnedValue create(ExecutionEngine *engine, QQmlData *ddata, QObject *object); diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 75af118090..7f70837eff 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -1247,7 +1247,7 @@ ReturnedValue __qmljs_get_scope_object(NoThrowContext *ctx) return QObjectWrapper::wrap(ctx->engine, c->getScopeObject()); } -ReturnedValue __qmljs_get_qobject_property(ExecutionContext *ctx, const ValueRef object, int propertyIndex) +ReturnedValue __qmljs_get_qobject_property(ExecutionContext *ctx, const ValueRef object, int propertyIndex, bool captureRequired) { Scope scope(ctx); QV4::Scoped<QObjectWrapper> wrapper(scope, object); @@ -1255,7 +1255,7 @@ ReturnedValue __qmljs_get_qobject_property(ExecutionContext *ctx, const ValueRef ctx->throwTypeError(QStringLiteral("Cannot read property of null")); return Encode::undefined(); } - return wrapper->getProperty(ctx, propertyIndex); + return wrapper->getProperty(ctx, propertyIndex, captureRequired); } void __qmljs_set_qobject_property(ExecutionContext *ctx, const ValueRef object, int propertyIndex, const ValueRef value) diff --git a/src/qml/jsruntime/qv4runtime_p.h b/src/qml/jsruntime/qv4runtime_p.h index b2d2d211eb..b5567693e5 100644 --- a/src/qml/jsruntime/qv4runtime_p.h +++ b/src/qml/jsruntime/qv4runtime_p.h @@ -174,7 +174,7 @@ QV4::ReturnedValue __qmljs_get_id_object(NoThrowContext *ctx, int id); QV4::ReturnedValue __qmljs_get_imported_scripts(NoThrowContext *ctx); QV4::ReturnedValue __qmljs_get_context_object(NoThrowContext *ctx); QV4::ReturnedValue __qmljs_get_scope_object(NoThrowContext *ctx); -QV4::ReturnedValue __qmljs_get_qobject_property(ExecutionContext *ctx, const ValueRef object, int propertyIndex); +QV4::ReturnedValue __qmljs_get_qobject_property(ExecutionContext *ctx, const ValueRef object, int propertyIndex, bool captureRequired); void __qmljs_set_qobject_property(ExecutionContext *ctx, const ValueRef object, int propertyIndex, const ValueRef value); // For each diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index 68f791c87d..72db469ee6 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -317,7 +317,7 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *code, MOTH_END_INSTR(StoreQObjectProperty) MOTH_BEGIN_INSTR(LoadQObjectProperty) - STOREVALUE(instr.result, __qmljs_get_qobject_property(context, VALUEPTR(instr.base), instr.propertyIndex)); + STOREVALUE(instr.result, __qmljs_get_qobject_property(context, VALUEPTR(instr.base), instr.propertyIndex, instr.captureRequired)); MOTH_END_INSTR(LoadQObjectProperty) MOTH_BEGIN_INSTR(Push) |