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