aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4jsir.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-10-23 16:24:58 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-29 21:56:07 +0100
commitba6fc15d729304c136447242de2410fbf4f020cd (patch)
tree3ad8a9575de295c9102eae125f64246bec854852 /src/qml/compiler/qv4jsir.cpp
parentc32265bfc562db23b7c894306ec61fd22111a7b1 (diff)
Speed up id object lookups
We can resolve lookups for objects referenced by id at QML compile time and use a run-time helper to extract the id object out of the QML context data by index instead of name. Dependencies to id objects are also tracked at compile time and registered separately before entering the generated function code. The lookup of id objects is encoded in the IR as special member lookups. Members will also then in the future be used to for property lookups in context and scope properties, as well as any other property lookups in QObjects where we can determine the meta-object. Change-Id: I36cf3ceb11b51a983da6cad5b61c3bf574acc20a Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler/qv4jsir.cpp')
-rw-r--r--src/qml/compiler/qv4jsir.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/qml/compiler/qv4jsir.cpp b/src/qml/compiler/qv4jsir.cpp
index 1c9620e1f5..86a13cfe99 100644
--- a/src/qml/compiler/qv4jsir.cpp
+++ b/src/qml/compiler/qv4jsir.cpp
@@ -421,6 +421,8 @@ static const char *builtin_to_string(Name::Builtin b)
return "builtin_define_object_literal";
case V4IR::Name::builtin_setup_argument_object:
return "builtin_setup_argument_object";
+ case V4IR::Name::builtin_qml_id_scope:
+ return "builtin_qml_id_scope";
}
return "builtin_(###FIXME)";
};
@@ -817,6 +819,14 @@ Expr *BasicBlock::MEMBER(Expr *base, const QString *name)
return e;
}
+Expr *BasicBlock::QML_CONTEXT_ID_MEMBER(const QString &id, int objectId, quint32 line, quint32 column)
+{
+ Member*e = function->New<Member>();
+ Name *base = NAME(Name::builtin_qml_id_scope, line, column);
+ e->initQmlIdObject(base, function->newString(id), objectId);
+ return e;
+}
+
Stmt *BasicBlock::EXP(Expr *expr)
{
if (isTerminated())
@@ -1003,7 +1013,18 @@ void CloneExpr::visitSubscript(Subscript *e)
void CloneExpr::visitMember(Member *e)
{
- cloned = block->MEMBER(clone(e->base), e->name);
+ Member *m = static_cast<Member*>(block->MEMBER(clone(e->base), e->name));
+ if (e->type == Member::MemberByObjectId) {
+ m->type = e->type;
+ m->objectId = e->objectId;
+ }
+ cloned = m;
+}
+
+void QmlDependenciesCollector::visitPhi(Phi *s) {
+ s->targetTemp->accept(this);
+ foreach (Expr *e, s->d->incoming)
+ e->accept(this);
}
} // end of namespace IR