| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2016, 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 deoptimization on an optimistically hoisted smi check. | |
| 5 // VMOptions=--optimization-counter-threshold=10 --no-background-compilation --
enable-inlining-annotations | |
| 6 | |
| 7 // Test that lazy deoptimization works if the program returns to a function | |
| 8 // that is scheduled for lazy deoptimization via an exception. | |
| 9 | |
| 10 import 'package:expect/expect.dart'; | |
| 11 | |
| 12 class C { | |
| 13 var x = 42; | |
| 14 } | |
| 15 | |
| 16 | |
| 17 const NeverInline = "NeverInline"; | |
| 18 | |
| 19 @NeverInline | |
| 20 AA(C c, bool b) { | |
| 21 if (b) { | |
| 22 c.x = 2.5; | |
| 23 throw 123; | |
| 24 } | |
| 25 } | |
| 26 | |
| 27 @NeverInline | |
| 28 T1(C c, bool b) { | |
| 29 try { | |
| 30 AA(c, b); | |
| 31 } on dynamic catch (e, st) { | |
| 32 print(e); | |
| 33 print(st); | |
| 34 } | |
| 35 return c.x + 1; | |
| 36 } | |
| 37 | |
| 38 | |
| 39 @NeverInline | |
| 40 T2(C c, bool b) { | |
| 41 try { | |
| 42 AA(c, b); | |
| 43 } on String catch(e, st) { | |
| 44 print(e); | |
| 45 print(st); | |
| 46 Expect.isTrue(false); | |
| 47 } on int catch(e, st) { | |
| 48 Expect.equals(e, 123); | |
| 49 Expect.equals(b, true); | |
| 50 Expect.equals(c.x, 2.5); | |
| 51 print(st); | |
| 52 } | |
| 53 return c.x + 1; | |
| 54 } | |
| 55 | |
| 56 | |
| 57 main() { | |
| 58 var c = new C(); | |
| 59 for (var i = 0; i < 10000; ++i) { | |
| 60 T1(c, false); | |
| 61 T2(c, false); | |
| 62 } | |
| 63 Expect.equals(43, T1(c, false)); | |
| 64 Expect.equals(43, T2(c, false)); | |
| 65 Expect.equals(3.5, T1(c, true)); | |
| 66 Expect.equals(3.5, T2(c, true)); | |
| 67 } | |
| OLD | NEW |