diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-05-03 15:11:55 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-05-08 06:42:16 +0000 |
commit | 799f4a526375701d2b68d2ca1c85648994468394 (patch) | |
tree | 90a2e02b5f922fab4dc973cb870dd41a355700ce /src/qml | |
parent | 99594f518a5fb657b75f68bba73537c4e9208e46 (diff) |
Optimize other lookups
Add some more optimized lookups for accessing
properties stored inline or in the memberData.
Change-Id: Id74901d1dd91fd60933bf164c2bf90fed86232e3
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/jsruntime/qv4lookup.cpp | 70 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4lookup_p.h | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4object.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4object_p.h | 4 |
4 files changed, 58 insertions, 24 deletions
diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp index 80a24cdde7..0d467098fe 100644 --- a/src/qml/jsruntime/qv4lookup.cpp +++ b/src/qml/jsruntime/qv4lookup.cpp @@ -284,11 +284,17 @@ ReturnedValue Lookup::getterGeneric(Lookup *l, ExecutionEngine *engine, const Va ReturnedValue v = l->lookup(object, proto, &attrs); if (v != Primitive::emptyValue().asReturnedValue()) { l->type = object.type(); - l->proto = proto; + l->proto = proto->d(); if (attrs.isData()) { - if (l->level == 0) - l->getter = Lookup::primitiveGetter0; - else if (l->level == 1) + if (l->level == 0) { + uint nInline = l->proto->vt->nInlineProperties; + if (l->index < nInline) + l->getter = Lookup::primitiveGetter0Inline; + else { + l->index -= nInline; + l->getter = Lookup::primitiveGetter0MemberData; + } + } else if (l->level == 1) l->getter = Lookup::primitiveGetter1; return v; } else { @@ -588,12 +594,23 @@ ReturnedValue Lookup::getterAccessor2(Lookup *l, ExecutionEngine *engine, const return getterFallback(l, engine, object); } -ReturnedValue Lookup::primitiveGetter0(Lookup *l, ExecutionEngine *engine, const Value &object) +ReturnedValue Lookup::primitiveGetter0Inline(Lookup *l, ExecutionEngine *engine, const Value &object) { if (object.type() == l->type) { - Object *o = l->proto; - if (l->classList[0] == o->internalClass()) - return o->propertyData(l->index)->asReturnedValue(); + Heap::Object *o = l->proto; + if (l->classList[0] == o->internalClass) + return o->inlinePropertyData(l->index)->asReturnedValue(); + } + l->getter = getterGeneric; + return getterGeneric(l, engine, object); +} + +ReturnedValue Lookup::primitiveGetter0MemberData(Lookup *l, ExecutionEngine *engine, const Value &object) +{ + if (object.type() == l->type) { + Heap::Object *o = l->proto; + if (l->classList[0] == o->internalClass) + return o->memberData->data[l->index].asReturnedValue(); } l->getter = getterGeneric; return getterGeneric(l, engine, object); @@ -602,10 +619,10 @@ ReturnedValue Lookup::primitiveGetter0(Lookup *l, ExecutionEngine *engine, const ReturnedValue Lookup::primitiveGetter1(Lookup *l, ExecutionEngine *engine, const Value &object) { if (object.type() == l->type) { - Object *o = l->proto; - if (l->classList[0] == o->internalClass() && - l->classList[1] == o->prototype()->internalClass) - return o->prototype()->propertyData(l->index)->asReturnedValue(); + Heap::Object *o = l->proto; + if (l->classList[0] == o->internalClass && + l->classList[1] == o->prototype->internalClass) + return o->prototype->propertyData(l->index)->asReturnedValue(); } l->getter = getterGeneric; return getterGeneric(l, engine, object); @@ -614,9 +631,9 @@ ReturnedValue Lookup::primitiveGetter1(Lookup *l, ExecutionEngine *engine, const ReturnedValue Lookup::primitiveGetterAccessor0(Lookup *l, ExecutionEngine *engine, const Value &object) { if (object.type() == l->type) { - Object *o = l->proto; - if (l->classList[0] == o->internalClass()) { - Scope scope(o->engine()); + Heap::Object *o = l->proto; + if (l->classList[0] == o->internalClass) { + Scope scope(o->internalClass->engine); ScopedFunctionObject getter(scope, o->propertyData(l->index + Object::GetterOffset)); if (!getter) return Encode::undefined(); @@ -634,11 +651,11 @@ ReturnedValue Lookup::primitiveGetterAccessor0(Lookup *l, ExecutionEngine *engin ReturnedValue Lookup::primitiveGetterAccessor1(Lookup *l, ExecutionEngine *engine, const Value &object) { if (object.type() == l->type) { - Object *o = l->proto; - if (l->classList[0] == o->internalClass() && - l->classList[1] == o->prototype()->internalClass) { - Scope scope(o->engine()); - ScopedFunctionObject getter(scope, o->prototype()->propertyData(l->index + Object::GetterOffset)); + Heap::Object *o = l->proto; + if (l->classList[0] == o->internalClass && + l->classList[1] == o->prototype->internalClass) { + Scope scope(o->internalClass->engine); + ScopedFunctionObject getter(scope, o->prototype->propertyData(l->index + Object::GetterOffset)); if (!getter) return Encode::undefined(); @@ -836,7 +853,7 @@ void Lookup::setterTwoClasses(Lookup *l, ExecutionEngine *engine, Value &object, if (Object *o = object.as<Object>()) { o->setLookup(l, value); - if (l->setter == Lookup::setter0) { + if (l->setter == Lookup::setter0 || l->setter == Lookup::setter0Inline) { l->setter = setter0setter0; l->classList[1] = l1.classList[0]; l->index2 = l1.index; @@ -869,6 +886,17 @@ void Lookup::setter0(Lookup *l, ExecutionEngine *engine, Value &object, const Va setterTwoClasses(l, engine, object, value); } +void Lookup::setter0Inline(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value) +{ + Object *o = object.as<Object>(); + if (o && o->internalClass() == l->classList[0]) { + *o->d()->inlinePropertyData(l->index) = value; + return; + } + + setterTwoClasses(l, engine, object, value); +} + void Lookup::setterInsert0(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value) { Object *o = object.as<Object>(); diff --git a/src/qml/jsruntime/qv4lookup_p.h b/src/qml/jsruntime/qv4lookup_p.h index 5a67c203ce..9e50235b73 100644 --- a/src/qml/jsruntime/qv4lookup_p.h +++ b/src/qml/jsruntime/qv4lookup_p.h @@ -79,7 +79,7 @@ struct Lookup { struct { void *dummy0; void *dummy1; - Object *proto; + Heap::Object *proto; unsigned type; }; }; @@ -116,7 +116,8 @@ struct Lookup { static ReturnedValue getterAccessor1(Lookup *l, ExecutionEngine *engine, const Value &object); static ReturnedValue getterAccessor2(Lookup *l, ExecutionEngine *engine, const Value &object); - static ReturnedValue primitiveGetter0(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue primitiveGetter0Inline(Lookup *l, ExecutionEngine *engine, const Value &object); + static ReturnedValue primitiveGetter0MemberData(Lookup *l, ExecutionEngine *engine, const Value &object); static ReturnedValue primitiveGetter1(Lookup *l, ExecutionEngine *engine, const Value &object); static ReturnedValue primitiveGetterAccessor0(Lookup *l, ExecutionEngine *engine, const Value &object); static ReturnedValue primitiveGetterAccessor1(Lookup *l, ExecutionEngine *engine, const Value &object); @@ -136,6 +137,7 @@ struct Lookup { static void setterTwoClasses(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value); static void setterFallback(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value); static void setter0(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value); + static void setter0Inline(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value); static void setterInsert0(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value); static void setterInsert1(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value); static void setterInsert2(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value); diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index 9595158ce9..3d8e8f3ddf 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -549,7 +549,7 @@ void Object::setLookup(Managed *m, Lookup *l, const Value &value) if (idx != UINT_MAX && o->internalClass()->propertyData[idx].isData() && o->internalClass()->propertyData[idx].isWritable()) { l->classList[0] = o->internalClass(); l->index = idx; - l->setter = Lookup::setter0; + l->setter = idx < o->d()->vt->nInlineProperties ? Lookup::setter0Inline : Lookup::setter0; *o->propertyData(idx) = value; return; } diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index c1d5fd66b2..45392c0486 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -75,6 +75,10 @@ struct Object : Base { Q_ASSERT(index < vt->nInlineProperties); return reinterpret_cast<const Value *>(this) + vt->inlinePropertyOffset + index; } + Value *inlinePropertyData(uint index) { + Q_ASSERT(index < vt->nInlineProperties); + return reinterpret_cast<Value *>(this) + vt->inlinePropertyOffset + index; + } const Value *propertyData(uint index) const { uint nInline = vt->nInlineProperties; |