Chromium Code Reviews| 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 } | |
|
Florian Schneider
2013/02/14 17:41:07
Also add a test case for shiftLeft0(i) where i < 0
srdjan
2013/02/27 18:27:25
Done.
| |
| 26 Expect.equals(1, shiftLeft1(0)); | |
| 27 Expect.equals(128, shiftLeft1(7)); | |
| 28 Expect.equals(536870912, shiftLeft1(29)); | |
| 29 // Deoptimize on 32-bit. | |
| 30 Expect.equals(1073741824, shiftLeft1(30)); | |
| 31 Expect.equals(2147483648, shiftLeft1(31)); | |
| 32 Expect.equals(1152921504606846976, shiftLeft1(60)); | |
| 33 Expect.equals(2305843009213693952, shiftLeft1(61)); | |
| 34 // Deoptimize on 64 bits. | |
| 35 Expect.equals(4611686018427387904, shiftLeft1(62)); | |
| 36 Expect.equals(9223372036854775808, shiftLeft1(63)); | |
| 37 | |
| 38 Expect.equals(8448, shiftLeft8448(0)); | |
| 39 Expect.equals(1081344, shiftLeft8448(7)); | |
| 40 Expect.equals(553648128, shiftLeft8448(16)); | |
| 41 // Deoptimize on 32-bit. | |
| 42 Expect.equals(1107296256, shiftLeft8448(17)); | |
| 43 Expect.equals(2214592512, shiftLeft8448(18)); | |
| 44 Expect.equals(1188950301625810944, shiftLeft8448(47)); | |
| 45 Expect.equals(2377900603251621888, shiftLeft8448(48)); | |
| 46 // Deoptimize on 64 bits. | |
| 47 Expect.equals(4755801206503243776, shiftLeft8448(49)); | |
| 48 Expect.equals(9511602413006487552, shiftLeft8448(50)); | |
| 49 | |
| 50 Expect.equals(-1, shiftLeftNeg1(0)); | |
| 51 Expect.equals(-128, shiftLeftNeg1(7)); | |
| 52 Expect.equals(-536870912, shiftLeftNeg1(29)); | |
| 53 // Deoptimize on 32-bit. | |
| 54 Expect.equals(-1073741824, shiftLeftNeg1(30)); | |
| 55 Expect.equals(-2147483648, shiftLeftNeg1(31)); | |
| 56 Expect.equals(-1152921504606846976, shiftLeftNeg1(60)); | |
| 57 Expect.equals(-2305843009213693952, shiftLeftNeg1(61)); | |
| 58 // Deoptimize on 64 bits. | |
| 59 Expect.equals(-4611686018427387904, shiftLeftNeg1(62)); | |
| 60 Expect.equals(-9223372036854775808, shiftLeftNeg1(63)); | |
| 61 | |
| 62 Expect.equals(-8448, shiftLeftNeg8448(0)); | |
| 63 Expect.equals(-1081344, shiftLeftNeg8448(7)); | |
| 64 Expect.equals(-553648128, shiftLeftNeg8448(16)); | |
| 65 // Deoptimize on 32-bit. | |
| 66 Expect.equals(-1107296256, shiftLeftNeg8448(17)); | |
| 67 Expect.equals(-2214592512, shiftLeftNeg8448(18)); | |
| 68 Expect.equals(-1188950301625810944, shiftLeftNeg8448(47)); | |
| 69 Expect.equals(-2377900603251621888, shiftLeftNeg8448(48)); | |
| 70 // Deoptimize on 64 bits. | |
| 71 Expect.equals(-4755801206503243776, shiftLeftNeg8448(49)); | |
| 72 Expect.equals(-9511602413006487552, shiftLeftNeg8448(50)); | |
| 73 } | |
| 74 | |
| OLD | NEW |