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 // Test deoptimization from within an inlined function. | 4 // Test deoptimization from within an inlined function. |
5 | 5 |
6 import "package:expect/expect.dart"; | |
7 | |
8 class A { | 6 class A { |
9 deopt_here() => 1; | 7 deopt_here() => 1; |
10 } | 8 } |
11 | 9 |
12 class B { | 10 class B { |
13 deopt_here() => 2; | 11 deopt_here() => 2; |
14 } | 12 } |
15 | 13 |
16 var obj = new A(); | 14 var obj = new A(); |
17 | 15 |
18 bar(x) { | 16 bar(x) { |
19 x = 42; | 17 x = 42; |
20 obj.deopt_here(); | 18 obj.deopt_here(); |
21 return x; | 19 return x; |
22 } | 20 } |
23 | 21 |
24 foo(x) { | 22 foo(x) { |
25 x = bar(x); | 23 x = bar(x); |
26 return x; | 24 return x; |
27 } | 25 } |
28 | 26 |
29 main() { | 27 main() { |
30 Expect.equals(42, foo(1)); | 28 Expect.equals(42, foo(1)); |
31 for (var i = 0; i < 2000; i++) foo(7); | 29 for (var i = 0; i < 2000; i++) foo(7); |
32 Expect.equals(42, foo(2)); | 30 Expect.equals(42, foo(2)); |
33 obj = new B(); | 31 obj = new B(); |
34 Expect.equals(42, foo(3)); // <-- deoptimization via foo/bar/obj.deopt_here | 32 Expect.equals(42, foo(3)); // <-- deoptimization via foo/bar/obj.deopt_here |
35 } | 33 } |
OLD | NEW |