OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 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 | 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 // VMOptions=--optimization_counter_threshold=100 --no-use-osr --no-background_c
ompilation | 4 // VMOptions=--optimization_counter_threshold=100 --no-use-osr --no-background_c
ompilation |
5 | 5 |
6 // Test CHA-based optimizations in presence of try-catch. | 6 // Test CHA-based optimizations in presence of try-catch. |
7 | 7 |
8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
9 | 9 |
10 bar(i) { | 10 bar(i) { |
11 if (i == 11) throw 123; | 11 if (i == 11) throw 123; |
12 } | 12 } |
13 | 13 |
14 class A { | 14 class A { |
15 var f = 42; | 15 var f = 42; |
16 | 16 |
17 foo(i) { | 17 foo(i) { |
18 do { | 18 do { |
19 try { | 19 try { |
20 bar(i); | 20 bar(i); |
21 } catch (e, s) { | 21 } catch (e, s) { |
22 Expect.equals(123, e); | 22 Expect.equals(123, e); |
23 } | 23 } |
24 } while (i < 0); | 24 } while (i < 0); |
25 return f; | 25 return f; |
26 } | 26 } |
27 } | 27 } |
28 | 28 |
29 class B extends A { | 29 class B extends A {} |
30 | |
31 } | |
32 | 30 |
33 main() { | 31 main() { |
34 var result; | 32 var result; |
35 for (var i = 0; i < 200; i++) { | 33 for (var i = 0; i < 200; i++) { |
36 try { | 34 try { |
37 result = new B().foo(i); | 35 result = new B().foo(i); |
38 } catch (e) { } | 36 } catch (e) {} |
39 } | 37 } |
40 Expect.equals(42, result); | 38 Expect.equals(42, result); |
41 } | 39 } |
OLD | NEW |