diff options
author | Lars Knoll <lars.knoll@theqtcompany.com> | 2015-09-08 14:58:16 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@theqtcompany.com> | 2015-09-25 08:38:56 +0000 |
commit | c72f973a35c0ba0a70a00f5c4d6bed8b0edbc21d (patch) | |
tree | 124f0a232e9389bc5a6320a03c8e2bac6b63ab9b /src/qml/jsruntime/qv4engine.cpp | |
parent | 3f12ee31a4dae822fd8e9d3a6791157d8503c653 (diff) |
Speed up creation of Array literals
Gives around 10% speedup on the v8 splay benchmark.
Change-Id: I47f64e7b73bde59ac3bdd2c94fc199ecfbbf290e
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/qml/jsruntime/qv4engine.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index e306106aea..d5a47273a9 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -618,6 +618,26 @@ Heap::ArrayObject *ExecutionEngine::newArrayObject(int count) return object->d(); } +Heap::ArrayObject *ExecutionEngine::newArrayObject(const Value *values, int length) +{ + Scope scope(this); + ScopedArrayObject a(scope, memoryManager->allocObject<ArrayObject>()); + + if (length) { + size_t size = sizeof(Heap::ArrayData) + (length-1)*sizeof(Value); + Heap::SimpleArrayData *d = scope.engine->memoryManager->allocManaged<SimpleArrayData>(size); + new (d) Heap::SimpleArrayData; + d->alloc = length; + d->type = Heap::ArrayData::Simple; + d->offset = 0; + d->len = length; + memcpy(&d->arrayData, values, length*sizeof(Value)); + a->d()->arrayData = d; + a->setArrayLengthUnchecked(length); + } + return a->d(); +} + Heap::ArrayObject *ExecutionEngine::newArrayObject(const QStringList &list) { Scope scope(this); |