| 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 // VMOptions=--optimization-counter-threshold=10 --no-use-osr | 4 // VMOptions=--optimization-counter-threshold=10 --no-use-osr --no-background-co
mpilation |
| 5 | 5 |
| 6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 | 7 |
| 8 // Test optimization of redundant array loads. | 8 // Test optimization of redundant array loads. |
| 9 | 9 |
| 10 var A = [0,2,3]; | 10 var A = [0,2,3]; |
| 11 | 11 |
| 12 test1(a) { | 12 test1(a) { |
| 13 int x = a[0]; | 13 int x = a[0]; |
| 14 int y = a[1]; | 14 int y = a[1]; |
| 15 ++a[0]; | 15 ++a[0]; |
| 16 return a[0] + y + a[2]; | 16 return a[0] + y + a[2]; |
| 17 } | 17 } |
| 18 | 18 |
| 19 | 19 |
| 20 int test2(a) { | 20 int test2(a) { |
| 21 return a[2] + a[2]; | 21 return a[2] + a[2]; |
| 22 } | 22 } |
| 23 | 23 |
| 24 | 24 |
| 25 main() { | 25 main() { |
| 26 for (int i = 0; i < 20; i++) { | 26 for (int i = 0; i < 20; i++) { |
| 27 test1(A); | 27 test1(A); |
| 28 test2(A); | 28 test2(A); |
| 29 } | 29 } |
| 30 Expect.equals(26, test1(A)); | 30 Expect.equals(26, test1(A)); |
| 31 Expect.equals(6, test2(A)); | 31 Expect.equals(6, test2(A)); |
| 32 } | 32 } |
| OLD | NEW |