Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // |jit-test| slow; |
michael@0 | 2 | |
michael@0 | 3 | load(libdir + "parallelarray-helpers.js"); |
michael@0 | 4 | |
michael@0 | 5 | function mergeSorted(l1, l2) { |
michael@0 | 6 | var result = []; |
michael@0 | 7 | var i1 = 0, i2 = 0, j = 0; |
michael@0 | 8 | while (i1 < l1.length && i2 < l2.length) { |
michael@0 | 9 | if (l1[i1] < l2[i2]) |
michael@0 | 10 | result[j++] = l1[i1++]; |
michael@0 | 11 | else |
michael@0 | 12 | result[j++] = l2[i2++]; |
michael@0 | 13 | } |
michael@0 | 14 | while (i1 < l1.length) { |
michael@0 | 15 | result[j++] = l1[i1++]; |
michael@0 | 16 | } |
michael@0 | 17 | while (i2 < l2.length) { |
michael@0 | 18 | result[j++] = l2[i2++]; |
michael@0 | 19 | } |
michael@0 | 20 | return result; |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | function test() { |
michael@0 | 24 | var elts = []; |
michael@0 | 25 | var ints = range(1, 5), c = 0; |
michael@0 | 26 | |
michael@0 | 27 | // Using 2048 as the length of elts induces bailouts due to GC. |
michael@0 | 28 | // This exposed various bugs. |
michael@0 | 29 | for (var i = 0; i < 2048; i++) |
michael@0 | 30 | elts[i] = ints; |
michael@0 | 31 | |
michael@0 | 32 | var scanned1 = seq_scan(elts, mergeSorted); |
michael@0 | 33 | var scanned2 = elts.scanPar(mergeSorted); |
michael@0 | 34 | assertStructuralEq(scanned1, scanned2); |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | if (getBuildConfiguration().parallelJS) |
michael@0 | 38 | test(); |