diff options
author | Lars Knoll <lars.knoll@theqtcompany.com> | 2015-08-25 21:29:34 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@theqtcompany.com> | 2015-09-15 19:13:07 +0000 |
commit | e13b9624b09cf192f9af8cb2f24c5551478ed6d3 (patch) | |
tree | 689c129a84d30ca806169932ba8394bcadcca1d6 /src/qml/jsruntime | |
parent | 665f17782a984fa34934cb3fc6d8316a21da9862 (diff) |
Further reduce usage of Property
Using Property * as return value is something I wanted to get rid of for
a long time. As this interferes with storing properties inline in the
Object, now is a good time to finally do the work :)
Change-Id: I30594bad9a4cea5d9d606ebe02d7f3e707b4263a
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4argumentsobject.cpp | 8 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4lookup.cpp | 16 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4object.cpp | 37 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4object_p.h | 4 |
4 files changed, 35 insertions, 30 deletions
diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp index 9979c07b9d..ef2c362da9 100644 --- a/src/qml/jsruntime/qv4argumentsobject.cpp +++ b/src/qml/jsruntime/qv4argumentsobject.cpp @@ -56,10 +56,10 @@ Heap::ArgumentsObject::ArgumentsObject(QV4::CallContext *context) if (context->d()->strictMode) { Q_ASSERT(CalleePropertyIndex == args->internalClass()->find(context->d()->engine->id_callee())); Q_ASSERT(CallerPropertyIndex == args->internalClass()->find(context->d()->engine->id_caller())); - args->propertyAt(CalleePropertyIndex)->value = v4->thrower(); - args->propertyAt(CalleePropertyIndex)->set = v4->thrower(); - args->propertyAt(CallerPropertyIndex)->value = v4->thrower(); - args->propertyAt(CallerPropertyIndex)->set = v4->thrower(); + *args->propertyData(CalleePropertyIndex + QV4::Object::GetterOffset) = v4->thrower(); + *args->propertyData(CalleePropertyIndex + QV4::Object::SetterOffset) = v4->thrower(); + *args->propertyData(CallerPropertyIndex + QV4::Object::GetterOffset) = v4->thrower(); + *args->propertyData(CallerPropertyIndex + QV4::Object::SetterOffset) = v4->thrower(); args->arrayReserve(context->argc()); args->arrayPut(0, context->args(), context->argc()); diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp index 0130a64187..bce63d00e9 100644 --- a/src/qml/jsruntime/qv4lookup.cpp +++ b/src/qml/jsruntime/qv4lookup.cpp @@ -439,7 +439,7 @@ ReturnedValue Lookup::getterAccessor0(Lookup *l, ExecutionEngine *engine, const Object *o = object.objectValue(); if (l->classList[0] == o->internalClass()) { Scope scope(o->engine()); - ScopedFunctionObject getter(scope, o->propertyAt(l->index)->getter()); + ScopedFunctionObject getter(scope, o->propertyData(l->index + Object::GetterOffset)); if (!getter) return Encode::undefined(); @@ -461,7 +461,7 @@ ReturnedValue Lookup::getterAccessor1(Lookup *l, ExecutionEngine *engine, const if (l->classList[0] == o->internalClass && l->classList[1] == o->prototype->internalClass) { Scope scope(o->internalClass->engine); - ScopedFunctionObject getter(scope, o->prototype->propertyAt(l->index)->getter()); + ScopedFunctionObject getter(scope, o->prototype->propertyData(l->index + Object::GetterOffset)); if (!getter) return Encode::undefined(); @@ -486,7 +486,7 @@ ReturnedValue Lookup::getterAccessor2(Lookup *l, ExecutionEngine *engine, const o = o->prototype; if (l->classList[2] == o->internalClass) { Scope scope(o->internalClass->engine); - ScopedFunctionObject getter(scope, o->propertyAt(l->index)->getter()); + ScopedFunctionObject getter(scope, o->propertyData(l->index + Object::GetterOffset)); if (!getter) return Encode::undefined(); @@ -530,7 +530,7 @@ ReturnedValue Lookup::primitiveGetterAccessor0(Lookup *l, ExecutionEngine *engin Object *o = l->proto; if (l->classList[0] == o->internalClass()) { Scope scope(o->engine()); - ScopedFunctionObject getter(scope, o->propertyAt(l->index)->getter()); + ScopedFunctionObject getter(scope, o->propertyData(l->index + Object::GetterOffset)); if (!getter) return Encode::undefined(); @@ -550,7 +550,7 @@ ReturnedValue Lookup::primitiveGetterAccessor1(Lookup *l, ExecutionEngine *engin if (l->classList[0] == o->internalClass() && l->classList[1] == o->prototype()->internalClass) { Scope scope(o->engine()); - ScopedFunctionObject getter(scope, o->prototype()->propertyAt(l->index)->getter()); + ScopedFunctionObject getter(scope, o->prototype()->propertyData(l->index + Object::GetterOffset)); if (!getter) return Encode::undefined(); @@ -653,7 +653,7 @@ ReturnedValue Lookup::globalGetterAccessor0(Lookup *l, ExecutionEngine *engine) Object *o = engine->globalObject; if (l->classList[0] == o->internalClass()) { Scope scope(o->engine()); - ScopedFunctionObject getter(scope, o->propertyAt(l->index)->getter()); + ScopedFunctionObject getter(scope, o->propertyData(l->index + Object::GetterOffset)); if (!getter) return Encode::undefined(); @@ -671,7 +671,7 @@ ReturnedValue Lookup::globalGetterAccessor1(Lookup *l, ExecutionEngine *engine) if (l->classList[0] == o->internalClass() && l->classList[1] == o->prototype()->internalClass) { Scope scope(o->engine()); - ScopedFunctionObject getter(scope, o->prototype()->propertyAt(l->index)->getter()); + ScopedFunctionObject getter(scope, o->prototype()->propertyData(l->index + Object::GetterOffset)); if (!getter) return Encode::undefined(); @@ -692,7 +692,7 @@ ReturnedValue Lookup::globalGetterAccessor2(Lookup *l, ExecutionEngine *engine) o = o->prototype; if (l->classList[2] == o->internalClass) { Scope scope(o->internalClass->engine); - ScopedFunctionObject getter(scope, o->propertyAt(l->index)->getter()); + ScopedFunctionObject getter(scope, o->propertyData(l->index + Object::GetterOffset)); if (!getter) return Encode::undefined(); diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index 74e358b6a0..9724599977 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -102,15 +102,16 @@ ReturnedValue Object::getValue(const Value &thisObject, const Value &v, Property void Object::putValue(uint memberIndex, const Value &value) { - if (internalClass()->engine->hasException) + QV4::InternalClass *ic = internalClass(); + if (ic->engine->hasException) return; - Property *pd = propertyAt(memberIndex); - PropertyAttributes attrs = internalClass()->propertyData[memberIndex]; + PropertyAttributes attrs = ic->propertyData[memberIndex]; if (attrs.isAccessor()) { - if (Heap::FunctionObject *set = pd->setter()) { - Scope scope(set->internalClass->engine); + FunctionObject *set = propertyData(memberIndex + SetterOffset)->as<FunctionObject>(); + if (set) { + Scope scope(ic->engine); ScopedFunctionObject setter(scope, set); ScopedCallData callData(scope, 1); callData->args[0] = value; @@ -124,7 +125,7 @@ void Object::putValue(uint memberIndex, const Value &value) if (!attrs.isWritable()) goto reject; - pd->value = value; + *propertyData(memberIndex) = value; return; reject: @@ -217,11 +218,10 @@ void Object::insertMember(String *s, const Property *p, PropertyAttributes attri InternalClass::addMember(this, s, attributes, &idx); if (attributes.isAccessor()) { - Property *pp = propertyAt(idx); - pp->value = p->value; - pp->set = p->set; + *propertyData(idx + GetterOffset) = p->value; + *propertyData(idx + SetterOffset) = p->set; } else { - d()->memberData->data[idx] = p->value; + *propertyData(idx) = p->value; } } @@ -235,8 +235,11 @@ void Object::getOwnProperty(String *name, PropertyAttributes *attrs, Property *p uint member = internalClass()->find(name); if (member < UINT_MAX) { *attrs = internalClass()->propertyData[member]; - if (p) - p->copy(propertyAt(member), *attrs); + if (p) { + p->value = *propertyData(member); + if (attrs->isAccessor()) + p->set = *propertyData(member + SetterOffset); + } return; } @@ -574,13 +577,15 @@ void Object::advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint * continue; } - Property *p = o->propertyAt(it->memberIndex); + int idx = it->memberIndex; PropertyAttributes a = o->internalClass()->propertyData[it->memberIndex]; ++it->memberIndex; if (!(it->flags & ObjectIterator::EnumerableOnly) || a.isEnumerable()) { name->setM(o->engine()->newString(n->string)); *attrs = a; - pd->copy(p, a); + pd->value = *o->propertyData(idx); + if (a.isAccessor()) + pd->set = *o->propertyData(idx + SetterOffset); return; } } @@ -859,7 +864,6 @@ bool Object::__defineOwnProperty__(ExecutionEngine *engine, String *name, const Scope scope(engine); name->makeIdentifier(scope.engine); - Property *current; PropertyAttributes *cattrs; uint memberIndex; @@ -891,10 +895,9 @@ bool Object::__defineOwnProperty__(ExecutionEngine *engine, String *name, const // Clause 1 memberIndex = internalClass()->find(name); - current = (memberIndex < UINT_MAX) ? propertyAt(memberIndex) : 0; cattrs = internalClass()->propertyData.constData() + memberIndex; - if (!current) { + if (memberIndex == UINT_MAX) { // clause 3 if (!isExtensible()) goto reject; diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index 2527e7953c..f427b676d6 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -128,7 +128,9 @@ struct Q_QML_EXPORT Object: Managed { Q_MANAGED_TYPE(Object) enum { - IsObject = true + IsObject = true, + GetterOffset = 0, + SetterOffset = 1 }; InternalClass *internalClass() const { return d()->internalClass; } |