michael@0: load(libdir + "parallelarray-helpers.js"); michael@0: michael@0: // The following tests test 2 paths in Ion. The 'ValueToInt32' paths test michael@0: // LValueToInt32, and the 'V' paths test the slow value-taking VM functions michael@0: // corresponding to the bit ops. michael@0: // michael@0: // At the time of writing the 'V' paths are triggered when any of the operands michael@0: // to the bit ops may be an object, thus the always-false branch which assign michael@0: // {} to one of the operands. michael@0: michael@0: var len = minItemsTestingThreshold; michael@0: var vals = [true, false, undefined, "1"]; michael@0: michael@0: function testBitNotValueToInt32() { michael@0: assertArraySeqParResultsEq(range(0, len), "map", function (i) { michael@0: return [~vals[0], ~vals[1], ~vals[2], ~vals[3]]; michael@0: }); michael@0: } michael@0: michael@0: function testBitNotV() { michael@0: assertArraySeqParResultsEq(range(0, len), "map", function (i) { michael@0: var a, b, c, d; michael@0: if (i < 0) { michael@0: a = {}; michael@0: b = {}; michael@0: c = {}; michael@0: d = {}; michael@0: } else { michael@0: a = vals[0]; michael@0: b = vals[1]; michael@0: c = vals[2]; michael@0: d = vals[3]; michael@0: } michael@0: return [~a, ~b, ~c, ~d]; michael@0: }); michael@0: } michael@0: michael@0: function testBitBinOpsValueToInt32() { michael@0: for (var n = 0; n < vals.length; n++) { michael@0: for (var m = n; m < vals.length; m++) { michael@0: assertArraySeqParResultsEq(range(0, len), "map", function (i) { michael@0: var a = vals[n]; michael@0: var b = vals[m]; michael@0: michael@0: return [a & b, michael@0: a | b, michael@0: a ^ b, michael@0: a << b, michael@0: a >> b]; michael@0: }); michael@0: } michael@0: } michael@0: } michael@0: michael@0: function testBitBinOpsV() { michael@0: for (var n = 0; n < vals.length; n++) { michael@0: for (var m = n; m < vals.length; m++) { michael@0: assertArraySeqParResultsEq(range(0, len), "map", function (i) { michael@0: var a, b; michael@0: michael@0: if (i < 0) { michael@0: a = {}; michael@0: b = {}; michael@0: } else { michael@0: a = vals[n]; michael@0: b = vals[m]; michael@0: } michael@0: michael@0: return [a & b, michael@0: a | b, michael@0: a ^ b, michael@0: a << b, michael@0: a >> b]; michael@0: }); michael@0: } michael@0: } michael@0: } michael@0: michael@0: if (getBuildConfiguration().parallelJS) { michael@0: testBitNotValueToInt32(); michael@0: testBitNotV(); michael@0: testBitBinOpsValueToInt32(); michael@0: testBitBinOpsV(); michael@0: }