OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 // Test deoptimziation caused by lazy finalization. | |
5 // VMOptions=--optimization-counter-threshold=10 --no-use-osr | |
6 | |
7 import "package:expect/expect.dart"; | |
8 | |
9 main() { | |
10 Expect.equals(20000, part1()); | |
11 // Trigger lazy finalization of class B, which should invalidate | |
12 // optimized code for A.loop. | |
13 Expect.equals(-20000, part2()); | |
14 } | |
15 | |
16 part1() { | |
17 var a = new A(); | |
18 a.loop(); | |
19 return a.loop(); | |
regis
2013/11/21 21:48:18
If there is a reason to call a.loop() twice, you s
srdjan
2013/11/21 22:25:00
Added comments. The reason is that only second tim
| |
20 } | |
21 | |
22 part2() { | |
23 var b = new B(); | |
24 b.loop(); | |
25 return b.loop(); | |
regis
2013/11/21 21:48:18
ditto
srdjan
2013/11/21 22:25:00
Done.
| |
26 } | |
27 | |
28 class A { | |
29 foo() => 2; | |
30 | |
31 loop() { | |
32 var sum = 0; | |
33 for (int i = 0; i < 10000; i++) { | |
34 sum += foo(); | |
35 } | |
36 return sum; | |
37 } | |
38 } | |
39 | |
40 class B extends A { | |
41 foo() => -2; | |
42 } | |
OLD | NEW |