| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // Dart test for testing bitwise operations. | 4 // Dart test for testing bitwise operations. |
| 5 // VMOptions=--optimization-counter-threshold=10 --no-use-osr --no-background-co
mpilation | 5 // VMOptions=--optimization-counter-threshold=10 --no-use-osr --no-background-co
mpilation --enable-inlining-annotations |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 | 8 |
| 9 const neverInline = "NeverInline"; |
| 10 |
| 9 void main() { | 11 void main() { |
| 10 for (int i = 0; i < 4; i++) { | 12 for (int i = 0; i < 4; i++) { |
| 11 test(); | 13 test(); |
| 12 } | 14 } |
| 13 } | 15 } |
| 14 | 16 |
| 15 void test() { | 17 void test() { |
| 16 Expect.equals(3, (3 & 7)); | 18 Expect.equals(3, (3 & 7)); |
| 17 Expect.equals(7, (3 | 7)); | 19 Expect.equals(7, (3 | 7)); |
| 18 Expect.equals(4, (3 ^ 7)); | 20 Expect.equals(4, (3 ^ 7)); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 testLeftShift64Bit(); | 65 testLeftShift64Bit(); |
| 64 testLeftShift64BitWithOverflow1(); | 66 testLeftShift64BitWithOverflow1(); |
| 65 testLeftShift64BitWithOverflow2(); | 67 testLeftShift64BitWithOverflow2(); |
| 66 testLeftShift64BitWithOverflow3(); | 68 testLeftShift64BitWithOverflow3(); |
| 67 } | 69 } |
| 68 | 70 |
| 69 // Test precedence. | 71 // Test precedence. |
| 70 testPrecedence(4, 5, 3, 1); | 72 testPrecedence(4, 5, 3, 1); |
| 71 testPrecedence(3, 4, 5, 9); | 73 testPrecedence(3, 4, 5, 9); |
| 72 testPrecedence(0x5c71, 0x6b92, 0x7654, 0x7d28); | 74 testPrecedence(0x5c71, 0x6b92, 0x7654, 0x7d28); |
| 75 |
| 76 // Test more special cases. |
| 77 testRightShift65(); |
| 73 } | 78 } |
| 74 | 79 |
| 75 void testCornerCasesRightShifts() { | 80 void testCornerCasesRightShifts() { |
| 76 var v32 = 0xFF000000; | 81 var v32 = 0xFF000000; |
| 77 var v64 = 0xFF00000000000000; | 82 var v64 = 0xFF00000000000000; |
| 78 Expect.equals(0x3, v32 >> 0x1E); | 83 Expect.equals(0x3, v32 >> 0x1E); |
| 79 Expect.equals(0x1, v32 >> 0x1F); | 84 Expect.equals(0x1, v32 >> 0x1F); |
| 80 Expect.equals(0x0, v32 >> 0x20); | 85 Expect.equals(0x0, v32 >> 0x20); |
| 81 Expect.equals(0x3, v64 >> 0x3E); | 86 Expect.equals(0x3, v64 >> 0x3E); |
| 82 Expect.equals(0x1, v64 >> 0x3F); | 87 Expect.equals(0x1, v64 >> 0x3F); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 Expect.notEquals((a & b) ^ (c | (d & b)) ^ c, result); // &|^ | 196 Expect.notEquals((a & b) ^ (c | (d & b)) ^ c, result); // &|^ |
| 192 Expect.notEquals((a & b) ^ ((c | d) & b) ^ c, result); // |&^ | 197 Expect.notEquals((a & b) ^ ((c | d) & b) ^ c, result); // |&^ |
| 193 Expect.notEquals(a & (b ^ (c | d)) & (b ^ c), result); // |^& | 198 Expect.notEquals(a & (b ^ (c | d)) & (b ^ c), result); // |^& |
| 194 Expect.notEquals(a & ((b ^ c) | d) & (b ^ c), result); // ^|& | 199 Expect.notEquals(a & ((b ^ c) | d) & (b ^ c), result); // ^|& |
| 195 // Binds stronger than relational operators. | 200 // Binds stronger than relational operators. |
| 196 Expect.equals((a & b) < (c & d), a & b < c & d); | 201 Expect.equals((a & b) < (c & d), a & b < c & d); |
| 197 // Binds weaker than shift operators. | 202 // Binds weaker than shift operators. |
| 198 Expect.equals((a & (b << c)) ^ d, a & b << c ^ d); | 203 Expect.equals((a & (b << c)) ^ d, a & b << c ^ d); |
| 199 Expect.notEquals((a & b) << (c ^ d), a & b << c ^ d); | 204 Expect.notEquals((a & b) << (c ^ d), a & b << c ^ d); |
| 200 } | 205 } |
| 206 |
| 207 @neverInline |
| 208 rightShift65Noinline(a) => a >> 65; |
| 209 |
| 210 testRightShift65() { |
| 211 var a = 0x5f22334455667788; |
| 212 var b = -0x5f22334455667788; |
| 213 |
| 214 for (var i = 0; i < 20; ++i) { |
| 215 Expect.equals(0, rightShift65Noinline(a)); |
| 216 Expect.equals(-1, rightShift65Noinline(b)); |
| 217 } |
| 218 } |
| OLD | NEW |