Debian Codegraph @

js/src/jit-test/tests/basic/testShiftRightArithmetic.js

raw
1 /* Test the proper operation of the arithmetic right shift operator. This is
2 * especially important on ARM as an explicit mask is required at the native
3 * instruction level. */
4
5 /* Test different combinations of literals/variables. */
6 var s = 4;
7 var t = 100;
8 assertEq(42 >> s, 2);
9 assertEq(s >> 1, 2);
10 assertEq(23 >> 3, 2);
11 assertEq(t >> s, 6);
12
13
14 function testShiftRightArithmetic()
15 {
16 var r = [];
17 var i = 0;
18 var j = 0;
19
20 var shifts = [0,1,7,8,15,16,23,24,31];
21
22 /* Samples from the simple shift range. */
23 for (i = 0; i < shifts.length; i++)
24 r[j++] = -2147483648 >> shifts[i];
25
26 /* Samples outside the normal shift range. */
27 for (i = 0; i < shifts.length; i++)
28 r[j++] = -2147483648 >> (shifts[i] + 32);
29
30 /* Samples far outside the normal shift range. */
31 for (i = 0; i < shifts.length; i++)
32 r[j++] = -2147483648 >> (shifts[i] + 224);
33 for (i = 0; i < shifts.length; i++)
34 r[j++] = -2147483648 >> (shifts[i] + 256);
35
36 return r.join(",");
37 }
38 assertEq(testShiftRightArithmetic(),
39 "-2147483648,-1073741824,-16777216,-8388608,-65536,-32768,-256,-128,-1,"+
40 "-2147483648,-1073741824,-16777216,-8388608,-65536,-32768,-256,-128,-1,"+
41 "-2147483648,-1073741824,-16777216,-8388608,-65536,-32768,-256,-128,-1,"+
42 "-2147483648,-1073741824,-16777216,-8388608,-65536,-32768,-256,-128,-1");