From 2ad0e1978347dd7c1782a9edb5047351c3fb6706 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Thu, 10 Nov 2011 10:39:56 +0100 Subject: [PATCH] Use the property cache when compiling the V4 instructions. Change-Id: Ifca6166328e7c20707fef153fa2b960da3a00a98 Reviewed-by: Aaron Kennedy --- src/declarative/qml/v4/qv4compiler.cpp | 17 ++++++++++------- src/declarative/qml/v4/qv4ir.cpp | 16 ++++++++-------- src/declarative/qml/v4/qv4ir_p.h | 8 ++++---- src/declarative/qml/v4/qv4irbuilder.cpp | 17 ++++++----------- 4 files changed, 28 insertions(+), 30 deletions(-) diff --git a/src/declarative/qml/v4/qv4compiler.cpp b/src/declarative/qml/v4/qv4compiler.cpp index 31a0a1e..8fdfa74 100644 --- a/src/declarative/qml/v4/qv4compiler.cpp +++ b/src/declarative/qml/v4/qv4compiler.cpp @@ -277,7 +277,7 @@ void QV4CompilerPrivate::visitName(IR::Name *e) Instr::LoadId instr; instr.reg = currentReg; - instr.index = e->index; + instr.index = e->idObject->idIndex; gen(instr); _subscribeName << QLatin1String("$$$ID_") + *e->id; @@ -320,10 +320,13 @@ void QV4CompilerPrivate::visitName(IR::Name *e) case IR::Name::Property: { _subscribeName << *e->id; - QMetaProperty prop = e->meta->property(e->index); - int fastFetchIndex = QDeclarativeFastProperties::instance()->accessorIndexForProperty(e->meta, e->index); + if (e->property->coreIndex == -1) { + QMetaProperty prop; + e->property->load(prop, QDeclarativeEnginePrivate::get(engine)); + } + int fastFetchIndex = QDeclarativeFastProperties::instance()->accessorIndexForProperty(e->meta, e->property->coreIndex); - const int propTy = prop.userType(); + const int propTy = e->property->propType; QDeclarativeRegisterType regType; switch (propTy) { @@ -366,17 +369,17 @@ void QV4CompilerPrivate::visitName(IR::Name *e) fetch.valueType = regType; gen(fetch); } else { - if (blockNeedsSubscription(_subscribeName) && prop.hasNotifySignal() && prop.notifySignalIndex() != -1) { + if (blockNeedsSubscription(_subscribeName) && e->property->notifyIndex != -1) { Instr::Subscribe sub; sub.reg = currentReg; sub.offset = subscriptionIndex(_subscribeName); - sub.index = prop.notifySignalIndex(); + sub.index = e->property->notifyIndex; gen(sub); } Instr::Fetch fetch; fetch.reg = currentReg; - fetch.index = e->index; + fetch.index = e->property->coreIndex; fetch.exceptionId = exceptionId(e->line, e->column); fetch.valueType = regType; gen(fetch); diff --git a/src/declarative/qml/v4/qv4ir.cpp b/src/declarative/qml/v4/qv4ir.cpp index ec3ffc9..48d6c9b 100644 --- a/src/declarative/qml/v4/qv4ir.cpp +++ b/src/declarative/qml/v4/qv4ir.cpp @@ -193,7 +193,7 @@ void Name::init(Name *base, Type type, const QString *id, Symbol symbol, quint32 this->id = id; this->symbol = symbol; this->ptr = 0; - this->index = -1; + this->property = 0; this->storage = MemberStorage; this->builtin = NoBuiltinSymbol; this->line = line; @@ -465,34 +465,34 @@ Name *BasicBlock::NAME(Name *base, const QString &id, quint32 line, quint32 colu return e; } -Name *BasicBlock::SYMBOL(Type type, const QString &id, const QMetaObject *meta, int index, Name::Storage storage, +Name *BasicBlock::SYMBOL(Type type, const QString &id, const QMetaObject *meta, QDeclarativePropertyData *property, Name::Storage storage, quint32 line, quint32 column) { - Name *name = SYMBOL(/*base = */ 0, type, id, meta, index, line, column); + Name *name = SYMBOL(/*base = */ 0, type, id, meta, property, line, column); name->storage = storage; return name; } -Name *BasicBlock::SYMBOL(Name *base, Type type, const QString &id, const QMetaObject *meta, int index, Name::Storage storage, +Name *BasicBlock::SYMBOL(Name *base, Type type, const QString &id, const QMetaObject *meta, QDeclarativePropertyData *property, Name::Storage storage, quint32 line, quint32 column) { Name *name = function->pool->New(); name->init(base, type, function->newString(id), Name::Property, line, column); name->meta = meta; - name->index = index; + name->property = property; name->storage = storage; return name; } -Name *BasicBlock::SYMBOL(Name *base, Type type, const QString &id, const QMetaObject *meta, int index, +Name *BasicBlock::SYMBOL(Name *base, Type type, const QString &id, const QMetaObject *meta, QDeclarativePropertyData *property, quint32 line, quint32 column) { Name *name = function->pool->New(); name->init(base, type, function->newString(id), Name::Property, line, column); name->meta = meta; - name->index = index; + name->property = property; return name; } @@ -503,7 +503,7 @@ Name *BasicBlock::ID_OBJECT(const QString &id, const QDeclarativeScript::Object function->newString(id), Name::IdObject, line, column); name->idObject = object; - name->index = object->idIndex; + name->property = 0; name->storage = Name::IdStorage; return name; } diff --git a/src/declarative/qml/v4/qv4ir_p.h b/src/declarative/qml/v4/qv4ir_p.h index 9dbd220..0786472 100644 --- a/src/declarative/qml/v4/qv4ir_p.h +++ b/src/declarative/qml/v4/qv4ir_p.h @@ -269,7 +269,7 @@ struct Name: Expr { const QDeclarativeType *declarativeType; const QDeclarativeScript::Object *idObject; }; - int index; + QDeclarativePropertyData *property; Storage storage; BuiltinSymbol builtin; quint32 line; @@ -531,9 +531,9 @@ struct BasicBlock { Name *NAME(const QString &id, quint32 line, quint32 column); Name *NAME(Name *base, const QString &id, quint32 line, quint32 column); - Name *SYMBOL(Type type, const QString &id, const QMetaObject *meta, int index, Name::Storage storage, quint32 line, quint32 column); - Name *SYMBOL(Name *base, Type type, const QString &id, const QMetaObject *meta, int index, quint32 line, quint32 column); - Name *SYMBOL(Name *base, Type type, const QString &id, const QMetaObject *meta, int index, Name::Storage storage, quint32 line, quint32 column); + Name *SYMBOL(Type type, const QString &id, const QMetaObject *meta, QDeclarativePropertyData *property, Name::Storage storage, quint32 line, quint32 column); + Name *SYMBOL(Name *base, Type type, const QString &id, const QMetaObject *meta, QDeclarativePropertyData *property, quint32 line, quint32 column); + Name *SYMBOL(Name *base, Type type, const QString &id, const QMetaObject *meta, QDeclarativePropertyData *property, Name::Storage storage, quint32 line, quint32 column); Name *ID_OBJECT(const QString &id, const QDeclarativeScript::Object *object, quint32 line, quint32 column); Name *ATTACH_TYPE(const QString &id, const QDeclarativeType *attachType, Name::Storage storage, quint32 line, quint32 column); diff --git a/src/declarative/qml/v4/qv4irbuilder.cpp b/src/declarative/qml/v4/qv4irbuilder.cpp index 258627a..125e1d0 100644 --- a/src/declarative/qml/v4/qv4irbuilder.cpp +++ b/src/declarative/qml/v4/qv4irbuilder.cpp @@ -466,7 +466,7 @@ bool QV4IRBuilder::visit(AST::IdentifierExpression *ast) if (data && !data->isFunction()) { IR::Type irType = irTypeFromVariantType(data->propType, m_engine, metaObject); - _expr.code = _block->SYMBOL(irType, name, metaObject, data->coreIndex, IR::Name::ScopeStorage, line, column); + _expr.code = _block->SYMBOL(irType, name, metaObject, data, IR::Name::ScopeStorage, line, column); found = true; } } @@ -487,7 +487,7 @@ bool QV4IRBuilder::visit(AST::IdentifierExpression *ast) if (data && !data->isFunction()) { IR::Type irType = irTypeFromVariantType(data->propType, m_engine, metaObject); - _expr.code = _block->SYMBOL(irType, name, metaObject, data->coreIndex, IR::Name::RootStorage, line, column); + _expr.code = _block->SYMBOL(irType, name, metaObject, data, IR::Name::RootStorage, line, column); found = true; } } @@ -615,7 +615,7 @@ bool QV4IRBuilder::visit(AST::FieldMemberExpression *ast) } IR::Type irType = irTypeFromVariantType(data->propType, m_engine, attachedMeta); - _expr.code = _block->SYMBOL(baseName, irType, name, attachedMeta, data->coreIndex, line, column); + _expr.code = _block->SYMBOL(baseName, irType, name, attachedMeta, data, line, column); } break; @@ -638,18 +638,13 @@ bool QV4IRBuilder::visit(AST::FieldMemberExpression *ast) IR::Type irType = irTypeFromVariantType(data->propType, m_engine, idObject->metaObject()); _expr.code = _block->SYMBOL(baseName, irType, name, - idObject->metaObject(), data->coreIndex, line, column); + idObject->metaObject(), data, line, column); } break; case IR::Name::Property: if (baseName->type == IR::ObjectType) { - const QMetaObject *m = - m_engine->metaObjectForType(baseName->meta->property(baseName->index).userType()); - QDeclarativePropertyCache *cache = m_engine->cache(m); - - QDeclarativePropertyData *data = cache->property(name); - + QDeclarativePropertyData *data = baseName->property; if (!data || data->isFunction()) return false; // Don't support methods (or non-existing properties ;) @@ -662,7 +657,7 @@ bool QV4IRBuilder::visit(AST::FieldMemberExpression *ast) IR::Type irType = irTypeFromVariantType(data->propType, m_engine, baseName->meta); _expr.code = _block->SYMBOL(baseName, irType, name, - baseName->meta, data->coreIndex, line, column); + baseName->meta, data, line, column); } break; -- 1.7.2.5