| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 | 4 |
| 5 var myString; | 5 var myString; |
| 6 | 6 |
| 7 void ifBailout(test) { | 7 void ifBailout(test) { |
| 8 if (test) { | 8 if (test) { |
| 9 // Share the same variable for the type inference. | 9 // Share the same variable for the type inference. |
| 10 var o = myString; | 10 var o = myString; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 var n = myString.length; | 35 var n = myString.length; |
| 36 var res = ''; | 36 var res = ''; |
| 37 for (int i = 0; i < n; i++) { | 37 for (int i = 0; i < n; i++) { |
| 38 var o = myString; | 38 var o = myString; |
| 39 if (false) o[1] = 2; | 39 if (false) o[1] = 2; |
| 40 res += o[i]; | 40 res += o[i]; |
| 41 } | 41 } |
| 42 return res; | 42 return res; |
| 43 } | 43 } |
| 44 | 44 |
| 45 void forInBailout() { |
| 46 var n = myString.length; |
| 47 var res = ''; |
| 48 for (int i in myString.charCodes()) { |
| 49 var o = myString; |
| 50 if (false) o[1] = 2; |
| 51 res += new String.fromCharCodes([i]); |
| 52 } |
| 53 return res; |
| 54 } |
| 55 |
| 45 void innerForBailout() { | 56 void innerForBailout() { |
| 46 var n = myString.length; | 57 var n = myString.length; |
| 47 var res = ''; | 58 var res = ''; |
| 48 for (int i = 0; i < 2; i++) { | 59 for (int i = 0; i < 2; i++) { |
| 49 for (int j = 0; j < n; j++) { | 60 for (int j = 0; j < n; j++) { |
| 50 var o = myString; | 61 var o = myString; |
| 51 if (false) o[1] = 2; | 62 if (false) o[1] = 2; |
| 52 res += o[j]; | 63 res += o[j]; |
| 53 } | 64 } |
| 54 } | 65 } |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 main() { | 196 main() { |
| 186 myString = '1'; | 197 myString = '1'; |
| 187 Expect.equals('1 no bailout', ifBailout(false)); | 198 Expect.equals('1 no bailout', ifBailout(false)); |
| 188 Expect.equals('1 bailout', ifBailout(true)); | 199 Expect.equals('1 bailout', ifBailout(true)); |
| 189 | 200 |
| 190 Expect.equals('1 else bailout', ifElseBailout(false)); | 201 Expect.equals('1 else bailout', ifElseBailout(false)); |
| 191 Expect.equals('1 if bailout', ifElseBailout(true)); | 202 Expect.equals('1 if bailout', ifElseBailout(true)); |
| 192 | 203 |
| 193 myString = '1234'; | 204 myString = '1234'; |
| 194 Expect.equals('1234', forBailout()); | 205 Expect.equals('1234', forBailout()); |
| 206 Expect.equals('1234', forInBailout()); |
| 195 Expect.equals('12341234', innerForBailout()); | 207 Expect.equals('12341234', innerForBailout()); |
| 196 | 208 |
| 197 Expect.equals('1234', whileBailout()); | 209 Expect.equals('1234', whileBailout()); |
| 198 Expect.equals('1234', doWhileBailout()); | 210 Expect.equals('1234', doWhileBailout()); |
| 199 | 211 |
| 200 Expect.equals(102334155, fibonacci(40)); | 212 Expect.equals(102334155, fibonacci(40)); |
| 201 | 213 |
| 202 phiBailout(); | 214 phiBailout(); |
| 203 ifPhiBailout1(1); | 215 ifPhiBailout1(1); |
| 204 ifPhiBailout1(2); | 216 ifPhiBailout1(2); |
| 205 ifPhiBailout2(1); | 217 ifPhiBailout2(1); |
| 206 ifPhiBailout2(2); | 218 ifPhiBailout2(2); |
| 207 } | 219 } |
| OLD | NEW |