aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4jsir_p.h
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-11-02 20:35:33 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-12 18:20:30 +0100
commit7a092000169a8e9d537f3d341ef48277397f997d (patch)
treef29f189d57e4923dff2decfd073b8e04f4a211a8 /src/qml/compiler/qv4jsir_p.h
parent7c6d2d78fe0997dfebba5569f097bdacbba5a861 (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/compiler/qv4jsir_p.h')
-rw-r--r--src/qml/compiler/qv4jsir_p.h81
1 files changed, 8 insertions, 73 deletions
diff --git a/src/qml/compiler/qv4jsir_p.h b/src/qml/compiler/qv4jsir_p.h
index a7bed6419b..f4b8b15984 100644
--- a/src/qml/compiler/qv4jsir_p.h
+++ b/src/qml/compiler/qv4jsir_p.h
@@ -739,13 +739,19 @@ struct Function {
uint isNamedExpression : 1;
uint hasTry: 1;
uint hasWith: 1;
- uint hasQmlDependencies : 1;
- uint unused : 24;
+ uint unused : 25;
// Location of declaration in source code (-1 if not specified)
int line;
int column;
+ // Qml extension:
+ QSet<int> idObjectDependencies;
+ QSet<QQmlPropertyData*> contextObjectDependencies;
+ QSet<QQmlPropertyData*> scopeObjectDependencies;
+
+ bool hasQmlDependencies() const { return !idObjectDependencies.isEmpty() || !contextObjectDependencies.isEmpty() || !scopeObjectDependencies.isEmpty(); }
+
template <typename _Tp> _Tp *New() { return new (pool->allocate(sizeof(_Tp))) _Tp(); }
Function(Module *module, Function *outer, const QString &name)
@@ -761,7 +767,6 @@ struct Function {
, isNamedExpression(false)
, hasTry(false)
, hasWith(false)
- , hasQmlDependencies(false)
, unused(0)
, line(-1)
, column(-1)
@@ -957,76 +962,6 @@ private:
V4IR::Expr *cloned;
};
-struct QmlDependenciesCollector : public V4IR::StmtVisitor, V4IR::ExprVisitor
-{
- void run(Function *function, QSet<int> *idObjectDependencies, QSet<QQmlPropertyData*> *contextPropertyDependencies, QSet<QQmlPropertyData*> *scopePropertyDependencies)
- {
- QSet<int> idProperties;
- QSet<QQmlPropertyData*> contextProperties;
- QSet<QQmlPropertyData*> scopeProperties;
- qSwap(_usedIdObjects, idProperties);
- qSwap(_usedContextProperties, contextProperties);
- qSwap(_usedScopeProperties, scopeProperties);
- for (int i = 0; i < function->basicBlocks.count(); ++i) {
- BasicBlock *bb = function->basicBlocks.at(i);
- for (int j = 0; j < bb->statements.count(); ++j) {
- Stmt *s = bb->statements.at(j);
- s->accept(this);
- }
- }
- qSwap(_usedScopeProperties, scopeProperties);
- qSwap(_usedContextProperties, contextProperties);
- qSwap(_usedIdObjects, idProperties);
-
- *idObjectDependencies = idProperties;
- *contextPropertyDependencies = contextProperties;
- *scopePropertyDependencies = scopeProperties;
- }
-
-protected:
- QSet<int> _usedIdObjects;
- QSet<QQmlPropertyData*> _usedContextProperties;
- QSet<QQmlPropertyData*> _usedScopeProperties;
-
- virtual void visitConst(Const *) {}
- virtual void visitString(String *) {}
- virtual void visitRegExp(RegExp *) {}
- virtual void visitName(Name *) {}
- virtual void visitTemp(Temp *) {}
- virtual void visitClosure(Closure *) {}
- virtual void visitConvert(Convert *e) { e->expr->accept(this); }
- virtual void visitUnop(Unop *e) { e->expr->accept(this); }
- virtual void visitBinop(Binop *e) { e->left->accept(this); e->right->accept(this); }
-
- virtual void visitCall(Call *e) {
- e->base->accept(this);
- for (ExprList *it = e->args; it; it = it->next)
- it->expr->accept(this);
- }
- virtual void visitNew(New *e) {
- e->base->accept(this);
- for (ExprList *it = e->args; it; it = it->next)
- it->expr->accept(this);
- }
- virtual void visitSubscript(Subscript *e) {
- e->base->accept(this);
- e->index->accept(this);
- }
-
- virtual void visitMember(Member *e);
-
- virtual void visitExp(Exp *s) {s->expr->accept(this);}
- virtual void visitMove(Move *s) {
- s->source->accept(this);
- s->target->accept(this);
- }
-
- virtual void visitJump(Jump *) {}
- virtual void visitCJump(CJump *s) { s->cond->accept(this); }
- virtual void visitRet(Ret *s) { s->expr->accept(this); }
- virtual void visitPhi(Phi *s);
-};
-
} // end of namespace IR
} // end of namespace QQmlJS