| 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) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 } | 28 } |
| 29 | 29 |
| 30 doStore1(a, v) { | 30 doStore1(a, v) { |
| 31 a[1] = v; | 31 a[1] = v; |
| 32 } | 32 } |
| 33 | 33 |
| 34 doStore2(a, v) { | 34 doStore2(a, v) { |
| 35 a[2] = v; | 35 a[2] = v; |
| 36 } | 36 } |
| 37 | 37 |
| 38 class StringPlus { |
| 39 const StringPlus(String this._val); |
| 40 operator + (right) => new StringPlus("${_val}${right}"); |
| 41 toString() => _val; |
| 42 |
| 43 final String _val; |
| 44 } |
| 45 |
| 38 main() { | 46 main() { |
| 39 for (int i = 0; i < 2000; i++) { | 47 for (int i = 0; i < 2000; i++) { |
| 40 Expect.stringEquals("HI 5", addThem("HI ", 5)); | 48 Expect.stringEquals("HI 5", addThem(const StringPlus("HI "), 5).toString()); |
| 41 Expect.equals(true, isItInt(5)); | 49 Expect.equals(true, isItInt(5)); |
| 42 } | 50 } |
| 43 Expect.equals(8, addThem(3, 5)); | 51 Expect.equals(8, addThem(3, 5)); |
| 44 for (int i = 0; i < 2000; i++) { | 52 for (int i = 0; i < 2000; i++) { |
| 45 Expect.stringEquals("HI 5", addThem("HI ", 5)); | 53 Expect.stringEquals("HI 5", addThem(const StringPlus("HI "), 5).toString()); |
| 46 Expect.equals(8, addThem(3, 5)); | 54 Expect.equals(8, addThem(3, 5)); |
| 47 } | 55 } |
| 48 for (int i = -500; i < 500; i++) { | 56 for (int i = -500; i < 500; i++) { |
| 49 var r = doNeg(i); | 57 var r = doNeg(i); |
| 50 var p = doNeg(r); | 58 var p = doNeg(r); |
| 51 Expect.equals(i, p); | 59 Expect.equals(i, p); |
| 52 } | 60 } |
| 53 var maxSmi = (1 << 30) - 1; | 61 var maxSmi = (1 << 30) - 1; |
| 54 Expect.equals(maxSmi, doNeg(doNeg(maxSmi))); | 62 Expect.equals(maxSmi, doNeg(doNeg(maxSmi))); |
| 55 // Deoptimize because of overflow. | 63 // Deoptimize because of overflow. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 79 Expect.equals(7, fixed[1]); | 87 Expect.equals(7, fixed[1]); |
| 80 doStore2(growable, 12); | 88 doStore2(growable, 12); |
| 81 Expect.equals(12, growable[2]); | 89 Expect.equals(12, growable[2]); |
| 82 } | 90 } |
| 83 | 91 |
| 84 // Deoptimize. | 92 // Deoptimize. |
| 85 doStore1(growable, 8); | 93 doStore1(growable, 8); |
| 86 Expect.equals(8, growable[1]); | 94 Expect.equals(8, growable[1]); |
| 87 doStore2(fixed, 101); | 95 doStore2(fixed, 101); |
| 88 Expect.equals(101, fixed[2]); | 96 Expect.equals(101, fixed[2]); |
| 89 } | 97 } |
| OLD | NEW |