Skip to content

Commit

Permalink
Use the property cache when compiling the V4 instructions.
Browse files Browse the repository at this point in the history
Change-Id: Ifca6166328e7c20707fef153fa2b960da3a00a98
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
  • Loading branch information
Roberto Raggi authored and Qt by Nokia committed Nov 14, 2011
1 parent 83029e5 commit 2ad0e19
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 30 deletions.
17 changes: 10 additions & 7 deletions src/declarative/qml/v4/qv4compiler.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
16 changes: 8 additions & 8 deletions src/declarative/qml/v4/qv4ir.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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>();
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>();
name->init(base, type, function->newString(id),
Name::Property, line, column);
name->meta = meta;
name->index = index;
name->property = property;
return name;
}

Expand All @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions src/declarative/qml/v4/qv4ir_p.h
Expand Up @@ -269,7 +269,7 @@ struct Name: Expr {
const QDeclarativeType *declarativeType;
const QDeclarativeScript::Object *idObject;
};
int index;
QDeclarativePropertyData *property;
Storage storage;
BuiltinSymbol builtin;
quint32 line;
Expand Down Expand Up @@ -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);

Expand Down
17 changes: 6 additions & 11 deletions src/declarative/qml/v4/qv4irbuilder.cpp
Expand Up @@ -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;
}
}
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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;

Expand All @@ -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 ;)

Expand All @@ -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;

Expand Down

0 comments on commit 2ad0e19

Please sign in to comment.