michael@0: // |jit-test| slow; michael@0: michael@0: load(libdir + "parallelarray-helpers.js"); michael@0: michael@0: function mergeSorted(l1, l2) { michael@0: var result = []; michael@0: var i1 = 0, i2 = 0, j = 0; michael@0: while (i1 < l1.length && i2 < l2.length) { michael@0: if (l1[i1] < l2[i2]) michael@0: result[j++] = l1[i1++]; michael@0: else michael@0: result[j++] = l2[i2++]; michael@0: } michael@0: while (i1 < l1.length) { michael@0: result[j++] = l1[i1++]; michael@0: } michael@0: while (i2 < l2.length) { michael@0: result[j++] = l2[i2++]; michael@0: } michael@0: return result; michael@0: } michael@0: michael@0: function test() { michael@0: var elts = []; michael@0: var ints = range(1, 5), c = 0; michael@0: michael@0: // Using 2048 as the length of elts induces bailouts due to GC. michael@0: // This exposed various bugs. michael@0: for (var i = 0; i < 2048; i++) michael@0: elts[i] = ints; michael@0: michael@0: var scanned1 = seq_scan(elts, mergeSorted); michael@0: var scanned2 = elts.scanPar(mergeSorted); michael@0: assertStructuralEq(scanned1, scanned2); michael@0: } michael@0: michael@0: if (getBuildConfiguration().parallelJS) michael@0: test();