js/src/jit-test/tests/parallel/ic-getelement.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 load(libdir + "parallelarray-helpers.js");
     3 function f(a) {
     4   assertArraySeqParResultsEq(
     5     range(0, minItemsTestingThreshold),
     6     "map",
     7     function(i) { return a[i]; });
     8 }
    10 function g(a, x) {
    11   assertArraySeqParResultsEq(
    12     range(0, minItemsTestingThreshold),
    13     "map",
    14     function(i) { return a[x]; });
    15 }
    17 function testICDenseElement() {
    18   var a1 = [];
    19   var a2 = [];
    20   var a3 = [];
    21   var a4 = [];
    22   var len = minItemsTestingThreshold;
    23   for (var i = 0; i < len; i++) {
    24     a1[i] = Math.random() * 100 | 0;
    25     a2[i] = Math.random() * 100 | 0;
    26     a3[i] = Math.random() * 100 | 0;
    27     a4[i] = Math.random() * 100 | 0;
    28   }
    29   f(a1); f({}); f(a2); f(a3); f(a4); f(a3); f(a1);
    30 }
    32 function testICTypedArrayElement() {
    33   var specs = [Int8Array,
    34                Uint8Array,
    35                Int16Array,
    36                Uint16Array,
    37                Int32Array,
    38                Uint32Array,
    39                Float32Array,
    40                Float64Array,
    41                Uint8ClampedArray];
    42   var len = minItemsTestingThreshold;
    43   f({});
    44   for (var i = 0; i < specs.length; i++) {
    45     var ta = new specs[i](len);
    46     for (var j = 0; j < len; j++)
    47       ta[j] = Math.random() * 100;
    48     f(ta);
    49   }
    50 }
    52 function testICSlotElement() {
    53   var o1 = { foo: 0 };
    54   var o2 = { foo: 0, bar: '' };
    55   var o3 = { foo: 0, bar: '', baz: function () { } };
    56   var o4 = { foo: { } };
    57   g(o1, "foo"); g(o2, "foo"); g(o3, "foo"); g(o2, "foo"); g(o1, "foo"); g(o4, "foo");
    58 }
    60 if (getBuildConfiguration().parallelJS) {
    61   testICDenseElement();
    62   testICTypedArrayElement();
    63   testICSlotElement();
    64 }

mercurial