diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-11-03 22:08:02 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-11-14 21:45:54 +0000 |
commit | 353164263c55825a0ec72d30128c50560c626334 (patch) | |
tree | e44b831652a84fc75237ce628a06438f620a0599 | |
parent | 5c0481c1934ef4b39437eef06ddfa15170473bcb (diff) |
Avoid marking on simple array data's
Speeds up things by 2-3%.
Change-Id: Ib17ab126cf91ce48a0ced7dd7b06c4f7f0a70a3b
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
-rw-r--r-- | src/qml/jsruntime/qv4arraydata.cpp | 11 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4arraydata_p.h | 7 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4object.cpp | 7 |
4 files changed, 27 insertions, 4 deletions
diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp index 0130dc0077..390840fb1e 100644 --- a/src/qml/jsruntime/qv4arraydata.cpp +++ b/src/qml/jsruntime/qv4arraydata.cpp @@ -111,6 +111,13 @@ static Q_ALWAYS_INLINE void storeValue(ReturnedValue *target, uint value) *target = v.asReturnedValue(); } +void Heap::ArrayData::markObjects(Heap::Base *base, MarkStack *stack) +{ + ArrayData *a = static_cast<ArrayData *>(base); + a->values.mark(stack); +} + + void ArrayData::realloc(Object *o, Type newType, uint requested, bool enforceAttributes) { Scope scope(o->engine()); @@ -161,6 +168,8 @@ void ArrayData::realloc(Object *o, Type newType, uint requested, bool enforceAtt } newData->setAlloc(alloc); newData->setType(newType); + if (d) + newData->d()->needsMark = d->d()->needsMark; newData->setAttrs(enforceAttributes ? reinterpret_cast<PropertyAttributes *>(newData->d()->values.values + alloc) : 0); o->setArrayData(newData); @@ -183,6 +192,8 @@ void ArrayData::realloc(Object *o, Type newType, uint requested, bool enforceAtt memcpy(newData->d()->values.values, d->d()->values.values + offset, sizeof(Value)*toCopy); } + if (newType != Heap::ArrayData::Simple) + newData->d()->needsMark = true; if (newType != Heap::ArrayData::Sparse) return; diff --git a/src/qml/jsruntime/qv4arraydata_p.h b/src/qml/jsruntime/qv4arraydata_p.h index 154fe5d150..db9db5a220 100644 --- a/src/qml/jsruntime/qv4arraydata_p.h +++ b/src/qml/jsruntime/qv4arraydata_p.h @@ -91,7 +91,8 @@ struct ArrayVTable namespace Heap { #define ArrayDataMembers(class, Member) \ - Member(class, NoMark, uint, type) \ + Member(class, NoMark, ushort, type) \ + Member(class, NoMark, ushort, needsMark) \ Member(class, NoMark, uint, offset) \ Member(class, NoMark, PropertyAttributes *, attrs) \ Member(class, NoMark, ReturnedValue, freeList) \ @@ -99,7 +100,7 @@ namespace Heap { Member(class, ValueArray, ValueArray, values) DECLARE_HEAP_OBJECT(ArrayData, Base) { - DECLARE_MARKOBJECTS(ArrayData); + static void markObjects(Heap::Base *base, MarkStack *stack); enum Type { Simple = 0, Complex = 1, Sparse = 2, Custom = 3 }; @@ -147,6 +148,8 @@ struct SimpleArrayData : public ArrayData { uint mappedIndex(uint index) const { index += offset; if (index >= values.alloc) index -= values.alloc; return index; } const Value &data(uint index) const { return values[mappedIndex(index)]; } void setData(EngineBase *e, uint index, Value newVal) { + if (newVal.isManaged()) + needsMark = true; values.set(e, mappedIndex(index), newVal); } diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 049e4a117d..78c10eacc7 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -585,6 +585,12 @@ Heap::ArrayObject *ExecutionEngine::newArrayObject(const Value *values, int leng // this doesn't require a write barrier, things will be ok, when the new array data gets inserted into // the parent object memcpy(&d->values.values, values, length*sizeof(Value)); + for (int i = 0; i < length; ++i) { + if (values[i].isManaged()) { + d->needsMark = true; + break; + } + } a->d()->arrayData.set(this, d); a->setArrayLengthUnchecked(length); } diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index 8fbcadfd4a..70f6341ac9 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -271,8 +271,11 @@ void Heap::Object::markObjects(Heap::Base *b, MarkStack *stack) Object *o = static_cast<Object *>(b); if (o->memberData) o->memberData->mark(stack); - if (o->arrayData) - o->arrayData->mark(stack); + if (o->arrayData) { + o->arrayData->setMarkBit(); + if (o->arrayData->needsMark) + ArrayData::markObjects(o->arrayData, stack); + } uint nInline = o->vtable()->nInlineProperties; Value *v = reinterpret_cast<Value *>(o) + o->vtable()->inlinePropertyOffset; const Value *end = v + nInline; |