| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // |
| 5 // Dart test program for testing left shifts of a constant. |
| 6 |
| 7 shiftLeft0(c) => 0 << c; |
| 8 shiftLeft1(c) => 1 << c; |
| 9 shiftLeft8448(c) => 8448 << c; |
| 10 |
| 11 shiftLeftNeg1(c) => -1 << c; |
| 12 shiftLeftNeg8448(c) => -8448 << c; |
| 13 |
| 14 main() { |
| 15 // Optimize shifts. |
| 16 for (int i = 0; i < 6000; i++) { |
| 17 shiftLeft1(2); |
| 18 shiftLeft0(2); |
| 19 shiftLeft8448(2); |
| 20 shiftLeftNeg1(2); |
| 21 shiftLeftNeg8448(2); |
| 22 } |
| 23 for (int i = 0; i < 80; i++) { |
| 24 Expect.equals(0, shiftLeft0(i)); |
| 25 } |
| 26 // Exceptions. |
| 27 Expect.throws(() => shiftLeft0(-1)); |
| 28 |
| 29 return; |
| 30 Expect.equals(1, shiftLeft1(0)); |
| 31 Expect.equals(128, shiftLeft1(7)); |
| 32 Expect.equals(536870912, shiftLeft1(29)); |
| 33 // Deoptimize on 32-bit. |
| 34 Expect.equals(1073741824, shiftLeft1(30)); |
| 35 Expect.equals(2147483648, shiftLeft1(31)); |
| 36 Expect.equals(1152921504606846976, shiftLeft1(60)); |
| 37 Expect.equals(2305843009213693952, shiftLeft1(61)); |
| 38 // Deoptimize on 64 bits. |
| 39 Expect.equals(4611686018427387904, shiftLeft1(62)); |
| 40 Expect.equals(9223372036854775808, shiftLeft1(63)); |
| 41 |
| 42 Expect.equals(8448, shiftLeft8448(0)); |
| 43 Expect.equals(1081344, shiftLeft8448(7)); |
| 44 Expect.equals(553648128, shiftLeft8448(16)); |
| 45 // Deoptimize on 32-bit. |
| 46 Expect.equals(1107296256, shiftLeft8448(17)); |
| 47 Expect.equals(2214592512, shiftLeft8448(18)); |
| 48 Expect.equals(1188950301625810944, shiftLeft8448(47)); |
| 49 Expect.equals(2377900603251621888, shiftLeft8448(48)); |
| 50 // Deoptimize on 64 bits. |
| 51 Expect.equals(4755801206503243776, shiftLeft8448(49)); |
| 52 Expect.equals(9511602413006487552, shiftLeft8448(50)); |
| 53 |
| 54 Expect.equals(-1, shiftLeftNeg1(0)); |
| 55 Expect.equals(-128, shiftLeftNeg1(7)); |
| 56 Expect.equals(-536870912, shiftLeftNeg1(29)); |
| 57 // Deoptimize on 32-bit. |
| 58 Expect.equals(-1073741824, shiftLeftNeg1(30)); |
| 59 Expect.equals(-2147483648, shiftLeftNeg1(31)); |
| 60 Expect.equals(-1152921504606846976, shiftLeftNeg1(60)); |
| 61 Expect.equals(-2305843009213693952, shiftLeftNeg1(61)); |
| 62 // Deoptimize on 64 bits. |
| 63 Expect.equals(-4611686018427387904, shiftLeftNeg1(62)); |
| 64 Expect.equals(-9223372036854775808, shiftLeftNeg1(63)); |
| 65 |
| 66 Expect.equals(-8448, shiftLeftNeg8448(0)); |
| 67 Expect.equals(-1081344, shiftLeftNeg8448(7)); |
| 68 Expect.equals(-553648128, shiftLeftNeg8448(16)); |
| 69 // Deoptimize on 32-bit. |
| 70 Expect.equals(-1107296256, shiftLeftNeg8448(17)); |
| 71 Expect.equals(-2214592512, shiftLeftNeg8448(18)); |
| 72 Expect.equals(-1188950301625810944, shiftLeftNeg8448(47)); |
| 73 Expect.equals(-2377900603251621888, shiftLeftNeg8448(48)); |
| 74 // Deoptimize on 64 bits. |
| 75 Expect.equals(-4755801206503243776, shiftLeftNeg8448(49)); |
| 76 Expect.equals(-9511602413006487552, shiftLeftNeg8448(50)); |
| 77 } |
| 78 |
| OLD | NEW |