| 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 lazy deoptimization from within an inlined function. | 4 // Test lazy deoptimization from within an inlined function. |
| 5 // VMOptions=--deoptimize_alot | 5 // VMOptions=--deoptimize_alot |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | |
| 8 | |
| 9 call_native(x) { | 7 call_native(x) { |
| 10 // Wrap in try to avoid inlining. | 8 // Wrap in try to avoid inlining. |
| 11 // Use a large int so the intrinsifier does not fire. | 9 // Use a large int so the intrinsifier does not fire. |
| 12 try { return x + 12342353257893275483274832; } finally { } | 10 try { return x + 12342353257893275483274832; } finally { } |
| 13 } | 11 } |
| 14 | 12 |
| 15 bar(x) { | 13 bar(x) { |
| 16 if (x < 0) call_native(x); | 14 if (x < 0) call_native(x); |
| 17 x = 42; | 15 x = 42; |
| 18 return x; | 16 return x; |
| 19 } | 17 } |
| 20 | 18 |
| 21 foo(x) { | 19 foo(x) { |
| 22 x = bar(x); | 20 x = bar(x); |
| 23 return x; | 21 return x; |
| 24 } | 22 } |
| 25 | 23 |
| 26 main() { | 24 main() { |
| 27 Expect.equals(42, foo(1)); | 25 Expect.equals(42, foo(1)); |
| 28 for (var i = 0; i < 2000; i++) foo(7); | 26 for (var i = 0; i < 2000; i++) foo(7); |
| 29 Expect.equals(42, foo(2)); | 27 Expect.equals(42, foo(2)); |
| 30 // Call the runtime to trigger lazy deopt with foo/bar on the stack. | 28 // Call the runtime to trigger lazy deopt with foo/bar on the stack. |
| 31 Expect.equals(42, foo(-1)); | 29 Expect.equals(42, foo(-1)); |
| 32 } | 30 } |
| OLD | NEW |