diff options
author | Lars Knoll <lars.knoll@digia.com> | 2014-01-09 11:05:08 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-20 21:14:27 +0100 |
commit | 5c25379cd1889dc16187c0ec62f32d2b17a320cf (patch) | |
tree | 23bb7bef5b2378ffe0e4193bf753811f4bf843f4 /tests/manual | |
parent | e2d9917878968986a9df21c9cfafc32a2360aee7 (diff) |
Save memory on array data
Store a simple vector of Values in the array data,
instead of a Vector of Property's. This halfes the
memory consumption on 64bit and simplifies our code.
If an indexed property gets converted to an accessor
property, we simply convert the ArrayData into a
SparseArrayData.
Add support in SparseArrayData to allocate double slots
(two Value's) to hold a full Property in case someone
sets an accessor on an indexed property.
Some methods still return a Property*, but this is safe, as
only the first Value in the Property pointer will ever get
accessed if the Property doesn't contain an accessor.
Change-Id: Ic9b0f309b09a2772a328d947a10faaf3be9fe56f
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'tests/manual')
-rw-r--r-- | tests/manual/v4/sparsearraytest.js | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/tests/manual/v4/sparsearraytest.js b/tests/manual/v4/sparsearraytest.js index 921a750472..3d7adfe903 100644 --- a/tests/manual/v4/sparsearraytest.js +++ b/tests/manual/v4/sparsearraytest.js @@ -1,10 +1,16 @@ var max for (max = 2; max < 100; ++max) { var arr = []; - arr[10000000] = -1 + // force a sparse array + Object.defineProperty(arr, "0", { + get: function () { + return 0; + }, + configurable: true + }); var i; var j; - for (i = 0; i < max; ++i) + for (i = 1; i < max; ++i) arr[i] = i; for (i = 1; i < max; i += 2) { delete arr[i]; @@ -19,3 +25,31 @@ for (max = 2; max < 100; ++max) { } } } + +for (max = 2; max < 100; ++max) { + var arr = []; + // force a sparse array + Object.defineProperty(arr, "0", { + get: function () { + return 0; + }, + configurable: true + }); + + var i; + var j; + for (i = 1; i < max; ++i) + arr[i] = i; + for (i = 0; i < max; i += 2) { + delete arr[i]; + for (j = 0; j < max; ++j) { + if (j <= i && !(j %2)) { + if (arr[j] != undefined) + throw "err1 " + i + " " + j + " " + arr[j] + } else { + if (arr[j] != j) + throw "err2 " + j + } + } + } +} |