diff options
author | Holger Hans Peter Freyther <[email protected]> | 2014-06-15 08:12:17 +0200 |
---|---|---|
committer | Holger Freyther <[email protected]> | 2014-07-20 09:51:50 +0200 |
commit | a62955472b2acd644db46ea194d4fb0bc119150f (patch) | |
tree | 7f3d45a32b9e515666c42882d389cf526a2422ca /src/qml/jsruntime | |
parent | 8ea3b20b141a93da5ca6e2ef4e623249ab46d91b (diff) |
v4: Delay creating the ScopedValue/ScopedProperty in objectLiteral
Creating a ScopedValue/ScopedProperty is not free. It will use the
ExecutionEngine directly to reserve memory from the JS Stack. In
tests/manual/v4/v8-bench.js and bench-allocate-nonretained.js a lot
of objects are created and the arrayValueCount and the
arrayGetterSetterCount are 0. We can delay the creation for a small
gain.
When generating the code we already know the various sizes and
could already call specialized versions of the creation code. The
gain is not so clear though.
Change-Id: Ic99b241f5506457e57611ad4eba143c56be1f657
Reviewed-by: Simon Hausmann <[email protected]>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index e44d1a07a6..bd52f0e678 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -1162,24 +1162,28 @@ ReturnedValue Runtime::objectLiteral(QV4::ExecutionContext *ctx, const QV4::Valu for (uint i = 0; i < klass->size; ++i) o->memberData[i] = *args++; - ScopedValue entry(scope); - for (int i = 0; i < arrayValueCount; ++i) { - uint idx = args->toUInt32(); - ++args; - entry = *args++; - o->arraySet(idx, entry); + if (arrayValueCount > 0) { + ScopedValue entry(scope); + for (int i = 0; i < arrayValueCount; ++i) { + uint idx = args->toUInt32(); + ++args; + entry = *args++; + o->arraySet(idx, entry); + } } - ScopedProperty pd(scope); uint arrayGetterSetterCount = arrayGetterSetterCountAndFlags & ((1 << 30) - 1); - for (uint i = 0; i < arrayGetterSetterCount; ++i) { - uint idx = args->toUInt32(); - ++args; - pd->value = *args; - ++args; - pd->set = *args; - ++args; - o->arraySet(idx, pd, Attr_Accessor); + if (arrayGetterSetterCount > 0) { + ScopedProperty pd(scope); + for (uint i = 0; i < arrayGetterSetterCount; ++i) { + uint idx = args->toUInt32(); + ++args; + pd->value = *args; + ++args; + pd->set = *args; + ++args; + o->arraySet(idx, pd, Attr_Accessor); + } } return o.asReturnedValue(); |