diff options
author | Lars Knoll <lars.knoll@theqtcompany.com> | 2015-01-09 13:13:04 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2015-01-12 11:04:19 +0100 |
commit | 3840beb6c61023542a689c7f125a7b521d3b2551 (patch) | |
tree | b787c7383fd6ea631d81f6952f4687804e4c4e48 /src/qml/jsruntime | |
parent | 462496c2bbf9a35ce13762af8830cb2f87b0c27e (diff) |
Get rid of hasAccessorProperty in Heap::Base
This shouldn't affect performance as we can just as well
check for cases where we need to take the slow path
differently.
Change-Id: I4b9f69c39e9e64b437820ca3a6ea43e8877f2cf3
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4argumentsobject.cpp | 1 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4arraydata.cpp | 9 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4arrayobject.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4object.cpp | 16 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4object_p.h | 8 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4value_p.h | 2 |
7 files changed, 15 insertions, 27 deletions
diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp index f0898088e2..33529dbfab 100644 --- a/src/qml/jsruntime/qv4argumentsobject.cpp +++ b/src/qml/jsruntime/qv4argumentsobject.cpp @@ -64,7 +64,6 @@ Heap::ArgumentsObject::ArgumentsObject(QV4::CallContext *context) args->arrayPut(0, context->d()->callData->args, context->d()->callData->argc); args->d()->fullyCreated = true; } else { - args->setHasAccessorProperty(); Q_ASSERT(CalleePropertyIndex == args->internalClass()->find(context->d()->engine->id_callee)); args->memberData()->data[CalleePropertyIndex] = context->d()->function->asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp index f0277430ad..a4f67c7656 100644 --- a/src/qml/jsruntime/qv4arraydata.cpp +++ b/src/qml/jsruntime/qv4arraydata.cpp @@ -35,6 +35,7 @@ #include "qv4functionobject_p.h" #include "qv4mm_p.h" #include "qv4runtime_p.h" +#include "qv4argumentsobject_p.h" using namespace QV4; @@ -570,9 +571,13 @@ uint ArrayData::append(Object *obj, ArrayObject *otherObj, uint n) uint oldSize = obj->getLength(); - if (other && other->isSparse()) { + if (!other || ArgumentsObject::isNonStrictArgumentsObject(otherObj)) { + ScopedValue v(scope); + for (uint i = 0; i < n; ++i) + obj->arraySet(oldSize + i, (v = otherObj->getIndexed(i))); + } else if (other && other->isSparse()) { Heap::SparseArrayData *os = static_cast<Heap::SparseArrayData *>(other->d()); - if (otherObj->hasAccessorProperty() && other->hasAttributes()) { + if (other->hasAttributes()) { ScopedValue v(scope); for (const SparseArrayNode *it = os->sparse->begin(); it != os->sparse->end(); it = it->nextNode()) { diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp index 2d6955efc9..1186afb77c 100644 --- a/src/qml/jsruntime/qv4arrayobject.cpp +++ b/src/qml/jsruntime/qv4arrayobject.cpp @@ -35,6 +35,7 @@ #include "qv4sparsearray_p.h" #include "qv4objectproto_p.h" #include "qv4scopedvalue_p.h" +#include "qv4argumentsobject_p.h" #include "qv4runtime_p.h" using namespace QV4; @@ -605,7 +606,8 @@ ReturnedValue ArrayPrototype::method_indexOf(CallContext *ctx) ScopedValue value(scope); - if (instance->hasAccessorProperty() || (instance->arrayType() >= Heap::ArrayData::Sparse) || instance->protoHasArray()) { + if (ArgumentsObject::isNonStrictArgumentsObject(instance) || + (instance->arrayType() >= Heap::ArrayData::Sparse) || instance->protoHasArray()) { // lets be safe and slow for (uint i = fromIndex; i < len; ++i) { bool exists; diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 200d9550b9..3b0d723988 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -326,7 +326,7 @@ ReturnedValue FunctionPrototype::method_apply(CallContext *ctx) ScopedCallData callData(scope, len); if (len) { - if (arr->arrayType() != Heap::ArrayData::Simple || arr->protoHasArray() || arr->hasAccessorProperty()) { + if (arr->arrayType() != Heap::ArrayData::Simple || arr->protoHasArray()) { for (quint32 i = 0; i < len; ++i) callData->args[i] = arr->getIndexed(i); } else { diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index cc7171de72..d30c113c32 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -210,7 +210,6 @@ void Object::insertMember(String *s, const Property *p, PropertyAttributes attri ensureMemberIndex(internalClass()->size); if (attributes.isAccessor()) { - setHasAccessorProperty(); Property *pp = propertyAt(idx); pp->value = p->value; pp->set = p->set; @@ -882,8 +881,6 @@ bool Object::__defineOwnProperty__(ExecutionEngine *engine, String *name, const cattrs->setWritable(false); if (!succeeded) goto reject; - if (attrs.isAccessor()) - setHasAccessorProperty(); return true; } @@ -1047,8 +1044,6 @@ bool Object::__defineOwnProperty__(ExecutionEngine *engine, uint index, String * } else { setArrayAttributes(index, cattrs); } - if (cattrs.isAccessor()) - setHasAccessorProperty(); return true; reject: if (engine->currentContext()->strictMode) @@ -1070,7 +1065,8 @@ void Object::copyArrayData(Object *other) Q_ASSERT(isArrayObject()); Scope scope(engine()); - if (other->protoHasArray() || other->hasAccessorProperty()) { + if (other->protoHasArray() || ArgumentsObject::isNonStrictArgumentsObject(other) || + (other->arrayType() == Heap::ArrayData::Sparse && other->arrayData()->attrs)) { uint len = other->getLength(); Q_ASSERT(len); @@ -1080,14 +1076,6 @@ void Object::copyArrayData(Object *other) } } else if (!other->arrayData()) { ; - } else if (other->hasAccessorProperty() && other->d()->arrayData->attrs && other->d()->arrayData->isSparse()){ - // do it the slow way - ScopedValue v(scope); - Heap::ArrayData *osa = other->d()->arrayData; - for (const SparseArrayNode *it = osa->sparse->begin(); it != osa->sparse->end(); it = it->nextNode()) { - v = other->getValue(reinterpret_cast<Property *>(osa->arrayData + it->value), osa->attrs[it->value]); - arraySet(it->key(), v); - } } else { Q_ASSERT(!arrayData() && other->arrayData()); ArrayData::realloc(this, other->d()->arrayData->type, other->d()->arrayData->alloc, false); diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index c256b1f34b..a38750dd07 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -140,9 +140,6 @@ struct Q_QML_EXPORT Object: Managed { inline ExecutionEngine *engine() const { return internalClass()->engine; } - inline bool hasAccessorProperty() const { return d()->hasAccessorProperty; } - inline void setHasAccessorProperty() { d()->hasAccessorProperty = true; } - bool isExtensible() const { return d()->extensible; } void setExtensible(bool b) { d()->extensible = b; } @@ -367,10 +364,7 @@ inline void Object::arraySet(uint index, const Property *p, PropertyAttributes a { // ### Clean up arrayCreate(); - if (attributes.isAccessor()) { - setHasAccessorProperty(); - initSparseArray(); - } else if (index > 0x1000 && index > 2*d()->arrayData->alloc) { + if (attributes.isAccessor() || (index > 0x1000 && index > 2*d()->arrayData->alloc)) { initSparseArray(); } else { arrayData()->vtable()->reallocate(this, index + 1, false); diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index 1a5ccb8e29..f7855b0e91 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -64,7 +64,7 @@ struct Q_QML_EXPORT Base { uchar _needsActivation : 1; // used by FunctionObject uchar _strictMode : 1; // used by FunctionObject uchar _bindingKeyFlag : 1; - uchar hasAccessorProperty : 1; + uchar _hasAccessorProperty : 1; uchar _unused : 1; mutable uchar subtype; uchar _unused2; |