diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-05-03 08:45:28 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-05-08 06:42:11 +0000 |
commit | 99594f518a5fb657b75f68bba73537c4e9208e46 (patch) | |
tree | 3593f524105582aa6777ef406d4ce5696d378dbf /src/qml/jsruntime/qv4internalclass.cpp | |
parent | 720a88be5ba98a71a085ec5977d87ecb22c20008 (diff) |
Re-add some inline property storage
It turns out that not using any inline property storage
comes at a relatively high price in terms of memory
consumption, as we always need to also create a
memberData for any object.
This avoids the memberData creation in quite a few
cases, as we use the additional padding we have up
to the 32 byte boundary given by the memory manager
to store some property data.
This complicates property access somewhat. To avoid
performance regressions because of this, add specialized
QV4::Lookup functions that optimize for properties that
are inline or in the memberData struct.
Change seems to be performance neutral on v8-bench on
x86_64, but reduces peak memory usage when running the
benchmark by around 20%.
Change-Id: I0127d31a2d6038aaa540c4c4a1156f45ca3b7464
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
Diffstat (limited to 'src/qml/jsruntime/qv4internalclass.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4internalclass.cpp | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4internalclass.cpp b/src/qml/jsruntime/qv4internalclass.cpp index bac71b4537..7e3fd7dc12 100644 --- a/src/qml/jsruntime/qv4internalclass.cpp +++ b/src/qml/jsruntime/qv4internalclass.cpp @@ -43,6 +43,7 @@ #include <qv4identifier_p.h> #include "qv4object_p.h" #include "qv4identifiertable_p.h" +#include "qv4value_p.h" QT_BEGIN_NAMESPACE @@ -128,22 +129,48 @@ InternalClass::InternalClass(const QV4::InternalClass &other) static void insertHoleIntoPropertyData(Object *object, int idx) { + int inlineSize = object->d()->vt->nInlineProperties; int icSize = object->internalClass()->size; - int from = idx; + int from = qMax(idx, inlineSize); int to = from + 1; - if (from < icSize) + if (from < icSize) { memmove(object->propertyData(to), object->propertyData(from), (icSize - from - 1) * sizeof(Value)); + } + if (from == idx) + return; + if (inlineSize < icSize) + *object->propertyData(inlineSize) = *object->propertyData(inlineSize - 1); + from = idx; + to = from + 1; + if (from < inlineSize - 1) { + memmove(object->propertyData(to), object->propertyData(from), + (inlineSize - from - 1) * sizeof(Value)); + } } static void removeFromPropertyData(Object *object, int idx, bool accessor = false) { + int inlineSize = object->d()->vt->nInlineProperties; int delta = (accessor ? 2 : 1); int oldSize = object->internalClass()->size + delta; int to = idx; int from = to + delta; - if (from < oldSize) + if (from < inlineSize) { + memmove(object->propertyData(to), object->d()->propertyData(from), (inlineSize - from)*sizeof(Value)); + to = inlineSize - delta; + from = inlineSize; + } + if (to < inlineSize && from < oldSize) { + Q_ASSERT(from >= inlineSize); + memcpy(object->propertyData(to), object->d()->propertyData(from), (inlineSize - to)*sizeof(Value)); + to = inlineSize; + from = inlineSize + delta; + } + if (from < oldSize) { + Q_ASSERT(to >= inlineSize && from > to); memmove(object->propertyData(to), object->d()->propertyData(from), (oldSize - to)*sizeof(Value)); + } } void InternalClass::changeMember(Object *object, String *string, PropertyAttributes data, uint *index) |