aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-11-17 18:07:06 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-28 15:12:06 +0100
commit4bf6969d8a1e17911a076ac470a38a464d7322a2 (patch)
tree5d2209c4d90cef64fac6f77bf3e86307de3f7f21 /src/qml/compiler
parentd72adccd2727d55a8f0adb87cfa9ef22db27ff9e (diff)
Slightly accelerate access to value type properties
We can't do a fast property index based access on them, due to the inability to read individual fields from the original object (i.e. the logic in QQmlValueTypeWrapper). However what we can determine and propagate is the type information of the individual properties, i.e. that the x and y properties of a QPointF are always doubles. Change-Id: Iee71ece2117294b7bc0b93deb0a77d7c51148b11 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler')
-rw-r--r--src/qml/compiler/qqmlcodegenerator.cpp17
-rw-r--r--src/qml/compiler/qv4jsir_p.h8
-rw-r--r--src/qml/compiler/qv4ssa.cpp6
3 files changed, 22 insertions, 9 deletions
diff --git a/src/qml/compiler/qqmlcodegenerator.cpp b/src/qml/compiler/qqmlcodegenerator.cpp
index 24755ee672..974de72858 100644
--- a/src/qml/compiler/qqmlcodegenerator.cpp
+++ b/src/qml/compiler/qqmlcodegenerator.cpp
@@ -1330,9 +1330,10 @@ QQmlPropertyData *JSCodeGen::lookupQmlCompliantProperty(QQmlPropertyCache *cache
static void initMetaObjectResolver(V4IR::MemberExpressionResolver *resolver, QQmlPropertyCache *metaObject);
enum MetaObjectResolverFlags {
- AllPropertiesAreFinal = 0x1,
- LookupsIncludeEnums = 0x2,
- LookupsExcludeProperties = 0x4
+ AllPropertiesAreFinal = 0x1,
+ LookupsIncludeEnums = 0x2,
+ LookupsExcludeProperties = 0x4,
+ ResolveTypeInformationOnly = 0x8
};
static void initMetaObjectResolver(V4IR::MemberExpressionResolver *resolver, QQmlPropertyCache *metaObject);
@@ -1464,7 +1465,9 @@ static V4IR::Type resolveMetaObjectProperty(QQmlEnginePrivate *qmlEngine, V4IR::
if (isFinalProperty && metaObject->isAllowedInRevision(candidate)) {
property = candidate;
- member->property = candidate; // Cache for next iteration and isel needs it.
+ member->inhibitTypeConversionOnWrite = true;
+ if (!(resolver->flags & ResolveTypeInformationOnly))
+ member->property = candidate; // Cache for next iteration and isel needs it.
}
}
}
@@ -1486,6 +1489,12 @@ static V4IR::Type resolveMetaObjectProperty(QQmlEnginePrivate *qmlEngine, V4IR::
initMetaObjectResolver(resolver, cache);
return V4IR::QObjectType;
}
+ } else if (QQmlValueType *valueType = QQmlValueTypeFactory::valueType(property->propType)) {
+ if (QQmlPropertyCache *cache = qmlEngine->cache(valueType->metaObject())) {
+ initMetaObjectResolver(resolver, cache);
+ resolver->flags |= ResolveTypeInformationOnly;
+ return V4IR::QObjectType;
+ }
}
break;
}
diff --git a/src/qml/compiler/qv4jsir_p.h b/src/qml/compiler/qv4jsir_p.h
index 9105a9137d..59e8d02bbc 100644
--- a/src/qml/compiler/qv4jsir_p.h
+++ b/src/qml/compiler/qv4jsir_p.h
@@ -562,6 +562,12 @@ struct Member: Expr {
bool memberIsEnum : 1;
bool freeOfSideEffects : 1;
+ // This is set for example for for QObject properties. All sorts of extra behavior
+ // is defined when writing to them, for example resettable properties are reset
+ // when writing undefined to them, and an exception is thrown when they're missing
+ // a reset function. And then there's also Qt.binding().
+ bool inhibitTypeConversionOnWrite: 1;
+
void init(Expr *base, const QString *name, QQmlPropertyData *property = 0, int attachedPropertiesId = 0)
{
this->base = base;
@@ -571,6 +577,7 @@ struct Member: Expr {
this->enumValue = 0;
this->memberIsEnum = false;
this->freeOfSideEffects = false;
+ this->inhibitTypeConversionOnWrite = property != 0;
}
void init(Expr *base, const QString *name, int enumValue)
@@ -582,6 +589,7 @@ struct Member: Expr {
this->enumValue = enumValue;
this->memberIsEnum = true;
this->freeOfSideEffects = false;
+ this->inhibitTypeConversionOnWrite = false;
}
virtual void accept(ExprVisitor *v) { v->visitMember(this); }
diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp
index 5e2c7ba722..249dfab660 100644
--- a/src/qml/compiler/qv4ssa.cpp
+++ b/src/qml/compiler/qv4ssa.cpp
@@ -1906,12 +1906,8 @@ protected:
}
}
- // Don't convert when writing to QObject properties. All sorts of extra behavior
- // is defined when writing to them, for example resettable properties are reset
- // when writing undefined to them, and an exception is thrown when they're missing
- // a reset function.
const Member *targetMember = s->target->asMember();
- const bool inhibitConversion = targetMember && targetMember->property;
+ const bool inhibitConversion = targetMember && targetMember->inhibitTypeConversionOnWrite;
run(s->source, s->target->type, !inhibitConversion);
}