From 10c1e4053366085080a39ea84ebbd189c8d827ec Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 27 Jan 2017 09:57:00 +0100 Subject: Unify mark handling for MemberData and ArrayData Introduce a ValueArray class, that defines an array of Values at the end of a Heap Object. Change-Id: I00efbf6f5839a6687dd5bc5fc037ec8f06e0936e Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4lookup.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/qml/jsruntime/qv4lookup.cpp') diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp index 52ed449664..f85ead1852 100644 --- a/src/qml/jsruntime/qv4lookup.cpp +++ b/src/qml/jsruntime/qv4lookup.cpp @@ -182,7 +182,7 @@ ReturnedValue Lookup::indexedGetterObjectInt(Lookup *l, const Value &object, con Heap::Object *o = static_cast(b); if (o->arrayData && o->arrayData->type == Heap::ArrayData::Simple) { Heap::SimpleArrayData *s = o->arrayData.cast(); - if (idx < s->len) + if (idx < s->values.size) if (!s->data(idx).isEmpty()) return s->data(idx).asReturnedValue(); } @@ -217,7 +217,7 @@ void Lookup::indexedSetterFallback(Lookup *l, const Value &object, const Value & if (index.asArrayIndex(idx)) { if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple) { Heap::SimpleArrayData *s = o->d()->arrayData.cast(); - if (idx < s->len) { + if (idx < s->values.size) { s->data(idx) = value; return; } @@ -239,7 +239,7 @@ void Lookup::indexedSetterObjectInt(Lookup *l, const Value &object, const Value Heap::Object *o = static_cast(b); if (o->arrayData && o->arrayData->type == Heap::ArrayData::Simple) { Heap::SimpleArrayData *s = o->arrayData.cast(); - if (idx < s->len) { + if (idx < s->values.size) { s->data(idx) = v; return; } -- cgit v1.2.3 From 2fbb5c93c765ea53c3bd5f30b8bf769ccc88874a Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 30 Jan 2017 14:04:33 +0100 Subject: Always pass the ExecutionEngine into lookup calls This is required in preparation for proper write barriers, where we'll need to check the engine whether the barrier is enabled. It also makes the lookup calls more consistent, and doesn't affect performance in any measurable way. Change-Id: Ia838237a44ba809d4643e2626bc81560388276e2 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4lookup.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/qml/jsruntime/qv4lookup.cpp') diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp index f85ead1852..bd677483b5 100644 --- a/src/qml/jsruntime/qv4lookup.cpp +++ b/src/qml/jsruntime/qv4lookup.cpp @@ -116,20 +116,20 @@ ReturnedValue Lookup::lookup(const Object *thisObject, PropertyAttributes *attrs return Primitive::emptyValue().asReturnedValue(); } -ReturnedValue Lookup::indexedGetterGeneric(Lookup *l, const Value &object, const Value &index) +ReturnedValue Lookup::indexedGetterGeneric(Lookup *l, ExecutionEngine *engine, const Value &object, const Value &index) { uint idx; if (object.isObject() && index.asArrayIndex(idx)) { l->indexedGetter = indexedGetterObjectInt; - return indexedGetterObjectInt(l, object, index); + return indexedGetterObjectInt(l, engine, object, index); } - return indexedGetterFallback(l, object, index); + return indexedGetterFallback(l, engine, object, index); } -ReturnedValue Lookup::indexedGetterFallback(Lookup *l, const Value &object, const Value &index) +ReturnedValue Lookup::indexedGetterFallback(Lookup *l, ExecutionEngine *engine, const Value &object, const Value &index) { Q_UNUSED(l); - Scope scope(l->engine); + Scope scope(engine); uint idx = 0; bool isInt = index.asArrayIndex(idx); @@ -147,7 +147,7 @@ ReturnedValue Lookup::indexedGetterFallback(Lookup *l, const Value &object, cons if (object.isNullOrUndefined()) { QString message = QStringLiteral("Cannot read property '%1' of %2").arg(index.toQStringNoThrow()).arg(object.toQStringNoThrow()); - return l->engine->throwTypeError(message); + return engine->throwTypeError(message); } o = RuntimeHelpers::convertToObject(scope.engine, object); @@ -173,7 +173,7 @@ ReturnedValue Lookup::indexedGetterFallback(Lookup *l, const Value &object, cons } -ReturnedValue Lookup::indexedGetterObjectInt(Lookup *l, const Value &object, const Value &index) +ReturnedValue Lookup::indexedGetterObjectInt(Lookup *l, ExecutionEngine *engine, const Value &object, const Value &index) { uint idx; if (index.asArrayIndex(idx)) { @@ -190,25 +190,25 @@ ReturnedValue Lookup::indexedGetterObjectInt(Lookup *l, const Value &object, con } } - return indexedGetterFallback(l, object, index); + return indexedGetterFallback(l, engine, object, index); } -void Lookup::indexedSetterGeneric(Lookup *l, const Value &object, const Value &index, const Value &v) +void Lookup::indexedSetterGeneric(Lookup *l, ExecutionEngine *engine, const Value &object, const Value &index, const Value &v) { if (Object *o = object.objectValue()) { uint idx; if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple && index.asArrayIndex(idx)) { l->indexedSetter = indexedSetterObjectInt; - indexedSetterObjectInt(l, object, index, v); + indexedSetterObjectInt(l, engine, object, index, v); return; } } - indexedSetterFallback(l, object, index, v); + indexedSetterFallback(l, engine, object, index, v); } -void Lookup::indexedSetterFallback(Lookup *l, const Value &object, const Value &index, const Value &value) +void Lookup::indexedSetterFallback(Lookup *, ExecutionEngine *engine, const Value &object, const Value &index, const Value &value) { - Scope scope(l->engine); + Scope scope(engine); ScopedObject o(scope, object.toObject(scope.engine)); if (scope.engine->hasException) return; @@ -230,7 +230,7 @@ void Lookup::indexedSetterFallback(Lookup *l, const Value &object, const Value & o->put(name, value); } -void Lookup::indexedSetterObjectInt(Lookup *l, const Value &object, const Value &index, const Value &v) +void Lookup::indexedSetterObjectInt(Lookup *l, ExecutionEngine *engine, const Value &object, const Value &index, const Value &v) { uint idx; if (index.asArrayIndex(idx)) { @@ -247,7 +247,7 @@ void Lookup::indexedSetterObjectInt(Lookup *l, const Value &object, const Value } } } - indexedSetterFallback(l, object, index, v); + indexedSetterFallback(l, engine, object, index, v); } ReturnedValue Lookup::getterGeneric(Lookup *l, ExecutionEngine *engine, const Value &object) -- cgit v1.2.3 From df3256b1f1eaa3ff9137ad1da36508365d978a8a Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 3 Feb 2017 16:28:17 +0100 Subject: Go through proper set() functions when writing to MemberData This is required, so we only have to add the write barrier in one place. Change-Id: I4e8bde823b30ad18f043312ac3f1ed46597b91a7 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4lookup.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/qml/jsruntime/qv4lookup.cpp') diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp index bd677483b5..f322d5a001 100644 --- a/src/qml/jsruntime/qv4lookup.cpp +++ b/src/qml/jsruntime/qv4lookup.cpp @@ -59,7 +59,7 @@ ReturnedValue Lookup::lookup(const Value &thisObject, Object *o, PropertyAttribu if (index != UINT_MAX) { level = i; *attrs = obj->internalClass->propertyData.at(index); - Value *v = obj->propertyData(index); + const Value *v = obj->propertyData(index); return !attrs->isAccessor() ? v->asReturnedValue() : Object::getValue(thisObject, *v, *attrs); } @@ -72,7 +72,7 @@ ReturnedValue Lookup::lookup(const Value &thisObject, Object *o, PropertyAttribu index = obj->internalClass->find(name); if (index != UINT_MAX) { *attrs = obj->internalClass->propertyData.at(index); - Value *v = obj->propertyData(index); + const Value *v = obj->propertyData(index); return !attrs->isAccessor() ? v->asReturnedValue() : Object::getValue(thisObject, *v, *attrs); } @@ -94,7 +94,7 @@ ReturnedValue Lookup::lookup(const Object *thisObject, PropertyAttributes *attrs if (index != UINT_MAX) { level = i; *attrs = obj->internalClass->propertyData.at(index); - Value *v = obj->propertyData(index); + const Value *v = obj->propertyData(index); return !attrs->isAccessor() ? v->asReturnedValue() : thisObject->getValue(*v, *attrs); } @@ -107,7 +107,7 @@ ReturnedValue Lookup::lookup(const Object *thisObject, PropertyAttributes *attrs index = obj->internalClass->find(name); if (index != UINT_MAX) { *attrs = obj->internalClass->propertyData.at(index); - Value *v = obj->propertyData(index); + const Value *v = obj->propertyData(index); return !attrs->isAccessor() ? v->asReturnedValue() : thisObject->getValue(*v, *attrs); } @@ -772,7 +772,7 @@ void Lookup::setter0(Lookup *l, ExecutionEngine *engine, Value &object, const Va { Object *o = object.as(); if (o && o->internalClass() == l->classList[0]) { - *o->propertyData(l->index) = value; + o->setProperty(l->index, value); return; } @@ -785,7 +785,7 @@ void Lookup::setterInsert0(Lookup *l, ExecutionEngine *engine, Value &object, co if (o && o->internalClass() == l->classList[0]) { if (!o->prototype()) { o->setInternalClass(l->classList[3]); - *o->propertyData(l->index) = value; + o->setProperty(l->index, value); return; } } @@ -801,7 +801,7 @@ void Lookup::setterInsert1(Lookup *l, ExecutionEngine *engine, Value &object, co Heap::Object *p = o->prototype(); if (p && p->internalClass == l->classList[1]) { o->setInternalClass(l->classList[3]); - *o->propertyData(l->index) = value; + o->setProperty(l->index, value); return; } } @@ -819,7 +819,7 @@ void Lookup::setterInsert2(Lookup *l, ExecutionEngine *engine, Value &object, co p = p->prototype; if (p && p->internalClass == l->classList[2]) { o->setInternalClass(l->classList[3]); - *o->propertyData(l->index) = value; + o->setProperty(l->index, value); return; } } @@ -834,11 +834,11 @@ void Lookup::setter0setter0(Lookup *l, ExecutionEngine *engine, Value &object, c Object *o = object.as(); if (o) { if (o->internalClass() == l->classList[0]) { - *o->propertyData(l->index) = value; + o->setProperty(l->index, value); return; } if (o->internalClass() == l->classList[1]) { - *o->propertyData(l->index2) = value; + o->setProperty(l->index2, value); return; } } -- cgit v1.2.3 From d7aa952e143accc18d54707d956d019272197078 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 3 Feb 2017 20:58:22 +0100 Subject: Make writes to ArrayData write-barrier safe Change-Id: I2e46100fe72fd83b36b3195130eefce5289d1627 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4lookup.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/qml/jsruntime/qv4lookup.cpp') diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp index f322d5a001..9fc11a2d2d 100644 --- a/src/qml/jsruntime/qv4lookup.cpp +++ b/src/qml/jsruntime/qv4lookup.cpp @@ -218,7 +218,7 @@ void Lookup::indexedSetterFallback(Lookup *, ExecutionEngine *engine, const Valu if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple) { Heap::SimpleArrayData *s = o->d()->arrayData.cast(); if (idx < s->values.size) { - s->data(idx) = value; + s->setData(engine, idx, value); return; } } @@ -240,7 +240,7 @@ void Lookup::indexedSetterObjectInt(Lookup *l, ExecutionEngine *engine, const Va if (o->arrayData && o->arrayData->type == Heap::ArrayData::Simple) { Heap::SimpleArrayData *s = o->arrayData.cast(); if (idx < s->values.size) { - s->data(idx) = v; + s->setData(engine, idx, v); return; } } -- cgit v1.2.3 From 2a554434a571dcefd26cf10ef8c5ae8b3b7d66db Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 8 Feb 2017 16:21:02 +0100 Subject: Implement a real write barrier Implement a Steel write barrier for our objects. The barrier is interesting as it can also be used for incremental GC runs by simply turning the barrier on and leaving old objects marked as black. Change-Id: I0b273974d94a990dee3cd9298089b8b202c75bf2 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4lookup.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/qml/jsruntime/qv4lookup.cpp') diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp index 9fc11a2d2d..11d7767e05 100644 --- a/src/qml/jsruntime/qv4lookup.cpp +++ b/src/qml/jsruntime/qv4lookup.cpp @@ -772,7 +772,7 @@ void Lookup::setter0(Lookup *l, ExecutionEngine *engine, Value &object, const Va { Object *o = object.as(); if (o && o->internalClass() == l->classList[0]) { - o->setProperty(l->index, value); + o->setProperty(engine, l->index, value); return; } -- cgit v1.2.3