| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 static test4() { | 161 static test4() { |
| 162 for (int i = 0; i < 2000; i++) { | 162 for (int i = 0; i < 2000; i++) { |
| 163 Expect.equals(true, compareInt(1, 2)); | 163 Expect.equals(true, compareInt(1, 2)); |
| 164 Expect.equals(true, compareDouble(1.0, 2.0)); | 164 Expect.equals(true, compareDouble(1.0, 2.0)); |
| 165 } | 165 } |
| 166 // Trigger deoptimization in compareInt and compareDouble. | 166 // Trigger deoptimization in compareInt and compareDouble. |
| 167 Expect.equals(true, compareInt(1, 2.0)); | 167 Expect.equals(true, compareInt(1, 2.0)); |
| 168 Expect.equals(true, compareDouble(1.0, 2)); | 168 Expect.equals(true, compareDouble(1.0, 2)); |
| 169 } | 169 } |
| 170 | 170 |
| 171 | 171 static smiRightShift() { |
| 172 int ShiftRight(int a, int b) { return a >> b; } |
| 173 |
| 174 for (int i = 0; i < 2000; i++) { |
| 175 var r = ShiftRight(10, 2); |
| 176 Expect.equals(2, r); |
| 177 } |
| 178 // ShiftRight is optimized. |
| 179 Expect.equals(0, ShiftRight(10, 64)); |
| 180 // Deoptimize ShiftRight because 'a' is a Mint. |
| 181 var mint = 1 << 63; |
| 182 Expect.equals(1 << 3, ShiftRight(mint, 60)); |
| 183 } |
| 172 | 184 |
| 173 static void testMain() { | 185 static void testMain() { |
| 174 test1(); | 186 test1(); |
| 175 test2(); | 187 test2(); |
| 176 test3(); | 188 test3(); |
| 177 test4(); | 189 test4(); |
| 178 SmiCompares.smiComparesTest(); | 190 SmiCompares.smiComparesTest(); |
| 179 SmiBinop.smiBinopTest(); | 191 SmiBinop.smiBinopTest(); |
| 180 SmiBinop.smiBinopOverflowTest(); | 192 SmiBinop.smiBinopOverflowTest(); |
| 181 ObjectsEquality.objectsEqualityTest(); | 193 ObjectsEquality.objectsEqualityTest(); |
| 194 smiRightShift(); |
| 182 } | 195 } |
| 183 } | 196 } |
| 184 | 197 |
| 185 main() { | 198 main() { |
| 186 DeoptimizationTest.testMain(); | 199 DeoptimizationTest.testMain(); |
| 187 } | 200 } |
| OLD | NEW |