| 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 // VMOptions=--optimization-counter-threshold=10 --no-background-compilation | |
| 5 | |
| 6 import "package:expect/expect.dart"; | |
| 7 | |
| 8 // Note: in --limit-ints-to-64-bits mode all integers are 64-bit already. | |
| 9 // Still, it is harmless to apply _uint64Mask because (1 << 64) is 0 (all bits | |
| 10 // are shifted out), so _uint64Mask is -1 (its bit pattern is 0xffffffffffffffff
). | |
| 11 const _uint64Mask = (1 << 64) - 1; | |
| 12 | |
| 13 constants() { | |
| 14 Expect.equals(0, 499 >> 33); | |
| 15 Expect.equals(0, (499 << 33) & 0xFFFFFFFF); | |
| 16 Expect.equals(0, (499 << 32) >> 65); | |
| 17 Expect.equals(0, ((499 << 32) << 65) & _uint64Mask); | |
| 18 } | |
| 19 | |
| 20 foo(i) { | |
| 21 if (i != 0) { | |
| 22 y--; | |
| 23 foo(i - 1); | |
| 24 y++; | |
| 25 } | |
| 26 } | |
| 27 | |
| 28 var y; | |
| 29 | |
| 30 // id returns [x] in a way that should be difficult to predict statically. | |
| 31 id(x) { | |
| 32 y = x; | |
| 33 foo(10); | |
| 34 return y; | |
| 35 } | |
| 36 | |
| 37 interceptors() { | |
| 38 Expect.equals(0, id(499) >> 33); | |
| 39 Expect.equals(0, (id(499) << 33) & 0xFFFFFFFF); | |
| 40 Expect.equals(0, id(499 << 32) >> 65); | |
| 41 Expect.equals(0, (id(499 << 32) << 65) & _uint64Mask); | |
| 42 } | |
| 43 | |
| 44 speculative() { | |
| 45 var a = id(499); | |
| 46 var b = id(499 << 32); | |
| 47 for (int i = 0; i < 1; i++) { | |
| 48 Expect.equals(0, a >> 33); | |
| 49 Expect.equals(0, (a << 33) & 0xFFFFFFFF); | |
| 50 Expect.equals(0, b >> 65); | |
| 51 Expect.equals(0, (b << 65) & _uint64Mask); | |
| 52 } | |
| 53 } | |
| 54 | |
| 55 // JavaScript shifts by the amount modulo 32. That is x << y is equivalent to | |
| 56 // x << (y & 0x1F). Dart does not. | |
| 57 main() { | |
| 58 for (var i = 0; i < 10; ++i) { | |
| 59 constants(); | |
| 60 interceptors(); | |
| 61 speculative(); | |
| 62 } | |
| 63 } | |
| OLD | NEW |