| 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 various optimizations and deoptimizations of optimizing compiler.. | 4 // Test various optimizations and deoptimizations of optimizing compiler.. |
| 5 | 5 |
| 6 addThem(a, b) { | 6 addThem(a, b) { |
| 7 return a + b; | 7 return a + b; |
| 8 } | 8 } |
| 9 | 9 |
| 10 isItInt(a) { | 10 isItInt(a) { |
| 11 return a is int; | 11 return a is int; |
| 12 } | 12 } |
| 13 | 13 |
| 14 doNeg(a) { | 14 doNeg(a) { |
| 15 return -a; | 15 return -a; |
| 16 } | 16 } |
| 17 | 17 |
| 18 doNeg2(a) { |
| 19 return -a; |
| 20 } |
| 21 |
| 18 doNot(a) { | 22 doNot(a) { |
| 19 return !a; | 23 return !a; |
| 20 } | 24 } |
| 21 | 25 |
| 22 doBitNot(a) { | 26 doBitNot(a) { |
| 23 return ~a; | 27 return ~a; |
| 24 } | 28 } |
| 25 | 29 |
| 26 main() { | 30 main() { |
| 27 for (int i = 0; i < 2000; i++) { | 31 for (int i = 0; i < 2000; i++) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 45 Expect.equals(minInt, doNeg(doNeg(minInt))); | 49 Expect.equals(minInt, doNeg(doNeg(minInt))); |
| 46 | 50 |
| 47 for (int i = 0; i < 1000; i++) { | 51 for (int i = 0; i < 1000; i++) { |
| 48 Expect.equals(false, doNot(true)); | 52 Expect.equals(false, doNot(true)); |
| 49 Expect.equals(true, doNot(doNot(true))); | 53 Expect.equals(true, doNot(doNot(true))); |
| 50 } | 54 } |
| 51 for (int i = 0; i < 1000; i++) { | 55 for (int i = 0; i < 1000; i++) { |
| 52 Expect.equals(-57, doBitNot(56)); | 56 Expect.equals(-57, doBitNot(56)); |
| 53 Expect.equals(55, doBitNot(-56)); | 57 Expect.equals(55, doBitNot(-56)); |
| 54 } | 58 } |
| 59 |
| 60 for (int i = 0; i < 2000; i++) { |
| 61 Expect.equals(-2.2, doNeg2(2.2)); |
| 62 } |
| 63 // Deoptimize. |
| 64 Expect.equals(-5, doNeg2(5)); |
| 55 } | 65 } |
| OLD | NEW |