js/src/jit-test/tests/ion/bug861165.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/ion/bug861165.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,83 @@
     1.4 +// IM has the following fastpaths:
     1.5 +// - constant index (constant)
     1.6 +// - need negative int check (neg)
     1.7 +// - needs hole check (hole)
     1.8 +// So to test everything we have to do:
     1.9 +//            constant | neg | hole
    1.10 +//  test 1:     0         0      0
    1.11 +//  test 2:     1         0      0
    1.12 +//  test 3:     0         1      0
    1.13 +//  test 4:     1         1      0
    1.14 +//  test 5:     0         0      1
    1.15 +//  test 6:     1         0      1
    1.16 +//  test 7:     0         1      1
    1.17 +//  test 8:     1         1      1
    1.18 +
    1.19 +function test1(index, a) {
    1.20 +  if (index < 0)
    1.21 +    index = -index
    1.22 +  return index in a;
    1.23 +}
    1.24 +assertEq(test1(1, [1,2]), true);
    1.25 +
    1.26 +function test2(a) {
    1.27 +  return 0 in a;
    1.28 +}
    1.29 +assertEq(test2([1,2]), true);
    1.30 +
    1.31 +function test3(index, a) {
    1.32 +  return index in a;
    1.33 +}
    1.34 +
    1.35 +var arr3 = [];
    1.36 +arr3["-1073741828"] = 17;
    1.37 +assertEq(test3(-1073741828, arr3), true);
    1.38 +
    1.39 +function test4(a) {
    1.40 +  return -1073741828 in a;
    1.41 +}
    1.42 +assertEq(test4(arr3), true);
    1.43 +
    1.44 +
    1.45 +function test5(index, a) {
    1.46 +  if (index < 0)
    1.47 +    index = -index
    1.48 +  return index in a;
    1.49 +}
    1.50 +var arr5 = [];
    1.51 +arr5[0] = 1
    1.52 +arr5[1] = 1
    1.53 +arr5[2] = 1
    1.54 +arr5[4] = 1
    1.55 +assertEq(test5(1, arr5), true);
    1.56 +assertEq(test5(3, arr5), false);
    1.57 +
    1.58 +function test7a(a) {
    1.59 +  return 3 in a;
    1.60 +}
    1.61 +function test7b(a) {
    1.62 +  return 4 in a;
    1.63 +}
    1.64 +assertEq(test7a(arr5), false);
    1.65 +assertEq(test7b(arr5), true);
    1.66 +
    1.67 +function test8(index, a) {
    1.68 +  return index in a;
    1.69 +}
    1.70 +arr5["-1073741828"] = 17;
    1.71 +assertEq(test8(-1073741828, arr5), true);
    1.72 +assertEq(test8(3, arr5), false);
    1.73 +assertEq(test8(0, arr5), true);
    1.74 +
    1.75 +function test9a(a) {
    1.76 +  return 0 in a;
    1.77 +}
    1.78 +function test9b(a) {
    1.79 +  return 3 in a;
    1.80 +}
    1.81 +function test9c(a) {
    1.82 +  return -1073741828 in a;
    1.83 +}
    1.84 +assertEq(test9a(arr5), true);
    1.85 +assertEq(test9b(arr5), false);
    1.86 +assertEq(test9c(arr5), true);

mercurial