| 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 // VMOptions=--optimization-counter-threshold=10 |
| 4 | 5 |
| 5 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 6 | 7 |
| 7 // This is a test for deoptimization infrastructure and to reproduce the | 8 // This is a test for deoptimization infrastructure and to reproduce the |
| 8 // failure from bug 5442338. | 9 // failure from bug 5442338. |
| 9 | 10 |
| 10 main() { | 11 main() { |
| 11 warmup(); | 12 warmup(); |
| 12 runTest(); | 13 runTest(); |
| 13 } | 14 } |
| 14 | 15 |
| 15 // Create a situation where method 'call' is optimized for using class A | 16 // Create a situation where method 'call' is optimized for using class A |
| 16 // when calling foo. | 17 // when calling foo. |
| 17 warmup() { | 18 warmup() { |
| 18 List a = [ new A(), new A(), new A(), new A()]; | 19 List a = [ new A(), new A(), new A(), new A()]; |
| 19 var res = 0; | 20 var res = 0; |
| 20 for (int i = 0; i < 2000; i++) { | 21 for (int i = 0; i < 20; i++) { |
| 21 res = call(a, 0); | 22 res = call(a, 0); |
| 22 } | 23 } |
| 23 Expect.equals(10, res); | 24 Expect.equals(10, res); |
| 24 } | 25 } |
| 25 | 26 |
| 26 | 27 |
| 27 // Create a situation where several optimized frames of 'call' are on stack | 28 // Create a situation where several optimized frames of 'call' are on stack |
| 28 // when deoptimization occurs because B.foo is called. After the first | 29 // when deoptimization occurs because B.foo is called. After the first |
| 29 // deoptimization, several optimized frames of 'call' are still on stack and | 30 // deoptimization, several optimized frames of 'call' are still on stack and |
| 30 // some of them will be deoptimized. | 31 // some of them will be deoptimized. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 49 | 50 |
| 50 | 51 |
| 51 class A { | 52 class A { |
| 52 foo() { return 1; } | 53 foo() { return 1; } |
| 53 } | 54 } |
| 54 | 55 |
| 55 | 56 |
| 56 class B { | 57 class B { |
| 57 foo() { return 2; } | 58 foo() { return 2; } |
| 58 } | 59 } |
| OLD | NEW |