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

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

Issue 10986085: Deal with more conditional expressions in the value range analyzer. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « lib/compiler/implementation/ssa/value_range_analyzer.dart ('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) 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 4
5 #import("compiler_helper.dart"); 5 #import("compiler_helper.dart");
6 6
7 const int REMOVED = 0; 7 const int REMOVED = 0;
8 const int ABOVE_ZERO = 1; 8 const int ABOVE_ZERO = 1;
9 const int BELOW_LENGTH = 2; 9 const int BELOW_LENGTH = 2;
10 const int KEPT = 3; 10 const int KEPT = 3;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 121 }
122 """, 122 """,
123 ONE_ZERO_CHECK, 123 ONE_ZERO_CHECK,
124 124
125 """ 125 """
126 main(value) { 126 main(value) {
127 var a = new List(); 127 var a = new List();
128 return a[1] + a[0]; 128 return a[1] + a[0];
129 } 129 }
130 """, 130 """,
131 ONE_CHECK 131 ONE_CHECK,
132
133 """
134 main() {
135 var a = new List();
136 var sum = 0;
137 for (int i = 0; i <= a.length - 1; i++) {
138 sum += a[i];
139 }
140 return sum;
141 }
142 """,
143 REMOVED,
144
145 """
146 main() {
147 var a = new List();
148 var sum = 0;
149 for (int i = a.length - 1; i >=0; i--) {
150 sum += a[i];
151 }
152 return sum;
153 }
154 """,
155 REMOVED,
156
157 """
158 main(value) {
159 // Force [value] to be an int by having the speculative optimizer
160 // want an int.
161 int sum = 0;
162 for (int i = 0; i < 42; i++) sum += (value & 4);
163 var a = new List();
164 if (value > a.length - 1) return;
165 if (value < 0) return;
166 return a[value];
167 }
168 """,
169 REMOVED,
170
171 """
172 main(value) {
173 // Force [value] to be an int by having the speculative optimizer
174 // want an int.
175 int sum = 0;
176 for (int i = 0; i < 42; i++) sum += (value & 4);
177 var a = new List();
178 if (value <= a.length - 1) {
179 if (value >= 0) {
180 return a[value];
181 }
182 }
183 }
184 """,
185 REMOVED,
186 """
187 main(value) {
188 // Force [value] to be an int by having the speculative optimizer
189 // want an int.
190 int sum = 0;
191 for (int i = 0; i < 42; i++) sum += (value & 4);
192 var a = new List();
193 if (value >= a.length) return;
194 if (value <= -1) return;
195 return a[value];
196 }
197 """,
198 REMOVED,
132 ]; 199 ];
133 200
134 expect(String code, int kind) { 201 expect(String code, int kind) {
135 String generated = compile(code); 202 String generated = compile(code);
136 switch (kind) { 203 switch (kind) {
137 case REMOVED: 204 case REMOVED:
138 Expect.isTrue(!generated.contains('ioore')); 205 Expect.isTrue(!generated.contains('ioore'));
139 break; 206 break;
140 207
141 case ABOVE_ZERO: 208 case ABOVE_ZERO:
(...skipping 24 matching lines...) Expand all
166 break; 233 break;
167 } 234 }
168 } 235 }
169 236
170 237
171 main() { 238 main() {
172 for (int i = 0; i < TESTS.length; i += 2) { 239 for (int i = 0; i < TESTS.length; i += 2) {
173 expect(TESTS[i], TESTS[i + 1]); 240 expect(TESTS[i], TESTS[i + 1]);
174 } 241 }
175 } 242 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/ssa/value_range_analyzer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698