| 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 var r = ShiftRight(10, 2); | 175 var r = ShiftRight(10, 2); |
| 176 Expect.equals(2, r); | 176 Expect.equals(2, r); |
| 177 } | 177 } |
| 178 // ShiftRight is optimized. | 178 // ShiftRight is optimized. |
| 179 Expect.equals(0, ShiftRight(10, 64)); | 179 Expect.equals(0, ShiftRight(10, 64)); |
| 180 // Deoptimize ShiftRight because 'a' is a Mint. | 180 // Deoptimize ShiftRight because 'a' is a Mint. |
| 181 var mint = 1 << 63; | 181 var mint = 1 << 63; |
| 182 Expect.equals(1 << 3, ShiftRight(mint, 60)); | 182 Expect.equals(1 << 3, ShiftRight(mint, 60)); |
| 183 } | 183 } |
| 184 | 184 |
| 185 static doubleUnary() { |
| 186 num unary(num a) { return -a; } |
| 187 |
| 188 for (int i = 0; i < 2000; i++) { |
| 189 var r = unary(2.0); |
| 190 Expect.equals(-2.0, r); |
| 191 } |
| 192 var r = unary(5); |
| 193 Expect.equals(-5, r); |
| 194 } |
| 195 |
| 185 static void testMain() { | 196 static void testMain() { |
| 186 test1(); | 197 test1(); |
| 187 test2(); | 198 test2(); |
| 188 test3(); | 199 test3(); |
| 189 test4(); | 200 test4(); |
| 190 SmiCompares.smiComparesTest(); | 201 SmiCompares.smiComparesTest(); |
| 191 SmiBinop.smiBinopTest(); | 202 SmiBinop.smiBinopTest(); |
| 192 SmiBinop.smiBinopOverflowTest(); | 203 SmiBinop.smiBinopOverflowTest(); |
| 193 ObjectsEquality.objectsEqualityTest(); | 204 ObjectsEquality.objectsEqualityTest(); |
| 194 smiRightShift(); | 205 smiRightShift(); |
| 206 doubleUnary(); |
| 195 } | 207 } |
| 196 } | 208 } |
| 197 | 209 |
| 198 main() { | 210 main() { |
| 199 DeoptimizationTest.testMain(); | 211 DeoptimizationTest.testMain(); |
| 200 } | 212 } |
| OLD | NEW |