| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 program to test cid guessing optimizations. | 4 // Dart test program to test cid guessing optimizations. |
| 5 // VMOptions=--optimization-counter-threshold=10 | 5 // VMOptions=--optimization-counter-threshold=10 --no-background-compilation |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 | 8 |
| 9 main() { | 9 main() { |
| 10 // Warmup optimizes methods. | 10 // Warmup optimizes methods. |
| 11 for (int i = 0; i < 100; i++) { | 11 for (int i = 0; i < 100; i++) { |
| 12 Expect.equals(i, compareInt(i)); | 12 Expect.equals(i, compareInt(i)); |
| 13 Expect.equals(i.toDouble(), compareDouble(i.toDouble())); | 13 Expect.equals(i.toDouble(), compareDouble(i.toDouble())); |
| 14 Expect.equals(i, binOpInt(i, i)); | 14 Expect.equals(i, binOpInt(i, i)); |
| 15 Expect.equals(i.toDouble(), binOpDouble(i.toDouble(), i.toDouble())); | 15 Expect.equals(i.toDouble(), binOpDouble(i.toDouble(), i.toDouble())); |
| 16 } | 16 } |
| 17 Expect.equals(3, compareInt(3)); | 17 Expect.equals(3, compareInt(3)); |
| 18 Expect.equals(-2, compareInt(-2)); | 18 Expect.equals(-2, compareInt(-2)); |
| 19 Expect.equals(0, compareInt(-1)); | 19 Expect.equals(0, compareInt(-1)); |
| 20 | 20 |
| 21 Expect.equals(3, binOpInt(3, 3)); | 21 Expect.equals(3, binOpInt(3, 3)); |
| 22 Expect.equals(0, binOpInt(-2, -2)); | 22 Expect.equals(0, binOpInt(-2, -2)); |
| 23 | 23 |
| 24 Expect.equals(3.0, binOpDouble(3.0, 3.0)); | 24 Expect.equals(3.0, binOpDouble(3.0, 3.0)); |
| 25 Expect.equals(0.0, binOpDouble(-2.0, -2.0)); | 25 Expect.equals(0.0, binOpDouble(-2.0, -2.0)); |
| 26 | 26 |
| 27 Expect.equals(3.0, compareDouble(3.0)); | 27 Expect.equals(3.0, compareDouble(3.0)); |
| 28 Expect.equals(-2.0, compareDouble(-2.0)); | 28 Expect.equals(-2.0, compareDouble(-2.0)); |
| 29 Expect.equals(0.0, compareDouble(-1.0)); | 29 Expect.equals(0.0, compareDouble(-1.0)); |
| 30 | 30 |
| 31 testOSR(); | 31 testOSR(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 int compareInt(int i) { | 34 int compareInt(int i) { |
| 35 if (i < 0) { | 35 if (i < 0) { |
| 36 // Not visited in before optimization. | 36 // Not visited in before optimization. |
| 37 // Guess cid of comparison below. | 37 // Guess cid of comparison below. |
| 38 if (i == -1) return 0; | 38 if (i == -1) return 0; |
| 39 } | 39 } |
| 40 return i; | 40 return i; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 for (int i = 0; i < N; ++i) { | 79 for (int i = 0; i < N; ++i) { |
| 80 // Will trigger OSR. Operation in loop below will use guessed cids. | 80 // Will trigger OSR. Operation in loop below will use guessed cids. |
| 81 } | 81 } |
| 82 int sum = 0; | 82 int sum = 0; |
| 83 for (int i = 0; i < N; ++i) { | 83 for (int i = 0; i < N; ++i) { |
| 84 // Guess 'x' is Smi, but is actually Bigint: deoptimize. | 84 // Guess 'x' is Smi, but is actually Bigint: deoptimize. |
| 85 sum += x + 2; | 85 sum += x + 2; |
| 86 } | 86 } |
| 87 return sum; | 87 return sum; |
| 88 } | 88 } |
| OLD | NEW |