| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // Test various optimizations and deoptimizations of optimizing compiler.. |
| 5 |
| 6 addThem(a, b) { |
| 7 return a + b; |
| 8 } |
| 9 |
| 10 isItInt(a) { |
| 11 return a is int; |
| 12 } |
| 13 |
| 14 doNeg(a) { |
| 15 return -a; |
| 16 } |
| 17 |
| 18 doNot(a) { |
| 19 return !a; |
| 20 } |
| 21 |
| 22 doBitNot(a) { |
| 23 return ~a; |
| 24 } |
| 25 |
| 26 main() { |
| 27 for (int i = 0; i < 2000; i++) { |
| 28 Expect.stringEquals("HI 5", addThem("HI ", 5)); |
| 29 Expect.equals(true, isItInt(5)); |
| 30 } |
| 31 Expect.equals(8, addThem(3, 5)); |
| 32 for (int i = 0; i < 2000; i++) { |
| 33 Expect.stringEquals("HI 5", addThem("HI ", 5)); |
| 34 Expect.equals(8, addThem(3, 5)); |
| 35 } |
| 36 for (int i = -500; i < 500; i++) { |
| 37 var r = doNeg(i); |
| 38 var p = doNeg(r); |
| 39 Expect.equals(i, p); |
| 40 } |
| 41 var maxSmi = (1 << 30) - 1; |
| 42 Expect.equals(maxSmi, doNeg(doNeg(maxSmi))); |
| 43 // Deoptimize because of overflow. |
| 44 var minInt = -(1 << 30); |
| 45 Expect.equals(minInt, doNeg(doNeg(minInt))); |
| 46 |
| 47 for (int i = 0; i < 1000; i++) { |
| 48 Expect.equals(false, doNot(true)); |
| 49 Expect.equals(true, doNot(doNot(true))); |
| 50 } |
| 51 for (int i = 0; i < 1000; i++) { |
| 52 Expect.equals(-57, doBitNot(56)); |
| 53 Expect.equals(55, doBitNot(-56)); |
| 54 } |
| 55 } |
| OLD | NEW |