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

Side by Side Diff: tests/compiler/dart2js/js_backend_cps_ir_control_flow.dart

Issue 758953002: cps-ir: Optimize identical used with constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add an assert. Created 6 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 4
5 // Tests of control flow statements. 5 // Tests of control flow statements.
6 6
7 library control_flow_tests; 7 library control_flow_tests;
8 8
9 import 'js_backend_cps_ir_test.dart'; 9 import 'js_backend_cps_ir_test.dart';
10 10
11 const List<TestEntry> tests = const [ 11 const List<TestEntry> tests = const [
12 const TestEntry(""" 12 const TestEntry("""
13 main() { 13 main() {
14 while (true); 14 while (true);
15 } 15 }
16 """, """ 16 """, """
17 function() { 17 function() {
18 while (P.identical(true, true)) 18 while (true)
19 ; 19 ;
20 return null;
21 }"""), 20 }"""),
22 const TestEntry(""" 21 const TestEntry("""
23 foo(a) => a; 22 foo(a) => a;
24 23
25 main() { 24 main() {
26 while (true) { 25 while (true) {
27 l: while (true) { 26 l: while (true) {
28 while (foo(true)) { 27 while (foo(true)) {
29 if (foo(false)) break l; 28 if (foo(false)) break l;
30 } 29 }
31 print(1); 30 print(1);
32 } 31 }
33 print(2); 32 print(2);
34 } 33 }
35 } 34 }
36 """, """ 35 """, """
37 function() { 36 function() {
38 L2: 37 L0:
39 while (P.identical(true, true)) 38 while (true)
40 L1: 39 while (true) {
41 while (true) { 40 while (P.identical(V.foo(true), true))
42 L0: 41 if (P.identical(V.foo(false), true)) {
43 if (P.identical(true, true)) { 42 P.print(2);
44 while (P.identical(V.foo(true), true)) 43 continue L0;
45 if (!P.identical(V.foo(false), true)) 44 }
46 ; 45 P.print(1);
47 else 46 }
48 break L0;
49 P.print(1);
50 continue L1;
51 }
52 P.print(2);
53 continue L2;
54 }
55 return null;
56 }"""), 47 }"""),
57 const TestEntry(""" 48 const TestEntry("""
58 foo(a) => a; 49 foo(a) => a;
59 50
60 main() { 51 main() {
61 for (int i = 0; foo(true); i = foo(i)) { 52 for (int i = 0; foo(true); i = foo(i)) {
62 print(1); 53 print(1);
63 if (foo(false)) break; 54 if (foo(false)) break;
64 } 55 }
65 print(2); 56 print(2);
66 }""", """ 57 }""", """
67 function() { 58 function() {
68 var i; 59 var i;
69 i = 0; 60 i = 0;
70 L3: 61 L1:
71 while (true) { 62 while (true) {
72 if (P.identical(V.foo(true), true)) { 63 if (P.identical(V.foo(true), true)) {
73 P.print(1); 64 P.print(1);
74 if (!P.identical(V.foo(false), true)) { 65 if (!P.identical(V.foo(false), true)) {
75 i = V.foo(i); 66 i = V.foo(i);
76 continue L3; 67 continue L1;
77 } 68 }
78 } 69 }
79 P.print(2); 70 P.print(2);
80 return null; 71 return null;
81 } 72 }
82 }"""), 73 }"""),
83 const TestEntry(""" 74 const TestEntry("""
84 foo(a) => a; 75 foo(a) => a;
85 76
86 main() { 77 main() {
(...skipping 26 matching lines...) Expand all
113 if (P.identical(V.foo(true), true)) { 104 if (P.identical(V.foo(true), true)) {
114 P.print(1); 105 P.print(1);
115 P.print(1); 106 P.print(1);
116 } else { 107 } else {
117 P.print(2); 108 P.print(2);
118 P.print(2); 109 P.print(2);
119 } 110 }
120 P.print(3); 111 P.print(3);
121 return null; 112 return null;
122 }"""), 113 }"""),
114 const TestEntry("""
115 main() {
116 if (1) {
117 print('bad');
118 } else {
119 print('ok');
120 }
121 }""","""
122 function() {
123 P.print("bad");
124 return null;
125 }"""),
123 ]; 126 ];
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698