| 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 // Test deoptimization. | 4 // Test deoptimization. |
| 5 | 5 |
| 6 class SmiCompares { | 6 class SmiCompares { |
| 7 // Test deoptimization when one argument is known to be Smi. | 7 // Test deoptimization when one argument is known to be Smi. |
| 8 static bool smiCompareLessThan2(a) { | 8 static bool smiCompareLessThan2(a) { |
| 9 return a < 2; | 9 return a < 2; |
| 10 } | 10 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 return a - 1; | 47 return a - 1; |
| 48 } | 48 } |
| 49 | 49 |
| 50 static void smiBinopTest() { | 50 static void smiBinopTest() { |
| 51 for (int i = 0; i < 2000; i++) { | 51 for (int i = 0; i < 2000; i++) { |
| 52 Expect.equals(2, subWithLiteral(3)); | 52 Expect.equals(2, subWithLiteral(3)); |
| 53 } | 53 } |
| 54 // Deoptimize. | 54 // Deoptimize. |
| 55 Expect.equals(2.0, subWithLiteral(3.0)); | 55 Expect.equals(2.0, subWithLiteral(3.0)); |
| 56 } | 56 } |
| 57 |
| 58 static mul(x) { |
| 59 return x * 1024; |
| 60 } |
| 61 |
| 62 static void smiBinopOverflowTest() { |
| 63 final int big = 536870912; |
| 64 for (int i = 0; i < 2000; i++) { |
| 65 Expect.equals(1024, mul(1)); |
| 66 } |
| 67 // Deoptimize by overflow. |
| 68 Expect.equals(1024 * big, mul(big)); |
| 69 } |
| 57 } | 70 } |
| 58 | 71 |
| 59 | 72 |
| 60 class ObjectsEquality { | 73 class ObjectsEquality { |
| 61 static bool compareEqual(a, b) { | 74 static bool compareEqual(a, b) { |
| 62 return a == b; | 75 return a == b; |
| 63 } | 76 } |
| 64 | 77 |
| 65 static bool compareNotEqual(a, b) { | 78 static bool compareNotEqual(a, b) { |
| 66 return a != b; | 79 return a != b; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 170 |
| 158 | 171 |
| 159 | 172 |
| 160 static void testMain() { | 173 static void testMain() { |
| 161 test1(); | 174 test1(); |
| 162 test2(); | 175 test2(); |
| 163 test3(); | 176 test3(); |
| 164 test4(); | 177 test4(); |
| 165 SmiCompares.smiComparesTest(); | 178 SmiCompares.smiComparesTest(); |
| 166 SmiBinop.smiBinopTest(); | 179 SmiBinop.smiBinopTest(); |
| 180 SmiBinop.smiBinopOverflowTest(); |
| 167 ObjectsEquality.objectsEqualityTest(); | 181 ObjectsEquality.objectsEqualityTest(); |
| 168 } | 182 } |
| 169 } | 183 } |
| 170 | 184 |
| 171 main() { | 185 main() { |
| 172 DeoptimizationTest.testMain(); | 186 DeoptimizationTest.testMain(); |
| 173 } | 187 } |
| OLD | NEW |