Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: tests/language/try_catch_optimized5_test.dart

Issue 2388093003: VM: Make optimized try-catch work in DBC. (Closed)
Patch Set: address comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/corelib/corelib.status ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Dart test program for testing try/catch statement without any exceptions 4 // Dart test program for testing try/catch statement without any exceptions
5 // being thrown. 5 // being thrown.
6 // VMOptions=--optimization-counter-threshold=100 --no-background-compilation -- enable-inlining-annotations 6 // VMOptions=--optimization-counter-threshold=100 --no-background-compilation -- enable-inlining-annotations
7 7
8 // Test local variables updated inside try-catch. 8 // Test optional parameters updated inside try-catch
9 9
10 import "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
11 11
12 const noInline = "NeverInline"; 12 const noInline = "NeverInline";
13 13
14 @noInline 14 @noInline
15 m1(int b) { 15 m1(int b) {
16 if (b == 1) throw 123; 16 if (b == 1) throw 123;
17 } 17 }
18 18
19 19
20 @noInline 20 @noInline
21 m2(int b) { 21 m2(int b) {
22 if (b == 2) throw 456; 22 if (b == 2) throw 456;
23 } 23 }
24 24
25 25
26 @noInline 26 @noInline
27 test(b) { 27 test1(int b, [int state = 0]) {
28 var state = 0;
29 try { 28 try {
30 state++; 29 state++;
31 m1(b); 30 m1(b);
32 state++; 31 state++;
33 m2(b); 32 m2(b);
34 state++; 33 state++;
35 } on dynamic catch (e, s) { 34 } on dynamic catch (e, s) {
36 if (b == 1 && state != 1) throw "fail1"; 35 if (b == 1 && state != 1) throw "fail1";
37 if (b == 2 && state != 2) throw "fail2"; 36 if (b == 2 && state != 2) throw "fail2";
38 if (b == 3 && state != 3) throw "fail3"; 37 if (b == 3 && state != 3) throw "fail3";
38 if (s is! StackTrace) throw "fail4";
39 return e;
40 }
41 return "no throw";
42 }
43
44 @noInline
45 test2(int b, [int state]) {
46 state = 0;
47 try {
48 state++;
49 m1(b);
50 state++;
51 m2(b);
52 state++;
53 } on dynamic catch (e, s) {
54 if (b == 1 && state != 1) throw "fail1";
55 if (b == 2 && state != 2) throw "fail2";
56 if (b == 3 && state != 3) throw "fail3";
57 if (s is! StackTrace) throw "fail4";
39 return e; 58 return e;
40 } 59 }
41 return "no throw"; 60 return "no throw";
42 } 61 }
43 62
44 main() { 63 main() {
45 for (var i=0; i<300; i++) { 64 for (var i=0; i<300; i++) {
46 Expect.equals("no throw", test(0)); 65 Expect.equals("no throw", test1(0));
47 } 66 }
48 Expect.equals("no throw", test(0)); 67 Expect.equals("no throw", test1(0));
49 Expect.equals(123, test(1)); 68 Expect.equals(123, test1(1));
50 Expect.equals(456, test(2)); 69 Expect.equals(456, test1(2));
70
71 for (var i=0; i<300; i++) {
72 Expect.equals("no throw", test2(0));
73 }
74 Expect.equals("no throw", test2(0));
75 Expect.equals(123, test2(1));
76 Expect.equals(456, test2(2));
51 } 77 }
OLDNEW
« no previous file with comments | « tests/corelib/corelib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698