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

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

Issue 17334003: Do not treat elements of lists allocated through new List() and new List.filled() as potentially nu… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 'package:expect/expect.dart'; 5 import 'package:expect/expect.dart';
6 import 6 import
7 '../../../sdk/lib/_internal/compiler/implementation/types/types.dart' 7 '../../../sdk/lib/_internal/compiler/implementation/types/types.dart'
8 show ContainerTypeMask, TypeMask; 8 show ContainerTypeMask, TypeMask;
9 9
10 import 'compiler_helper.dart'; 10 import 'compiler_helper.dart';
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 var listUsedInLocal = $listAllocation; 78 var listUsedInLocal = $listAllocation;
79 var listUnset = $listAllocation; 79 var listUnset = $listAllocation;
80 var listOnlySetWithConstraint = $listAllocation; 80 var listOnlySetWithConstraint = $listAllocation;
81 var listEscapingInSetterValue = $listAllocation; 81 var listEscapingInSetterValue = $listAllocation;
82 var listEscapingInIndex = $listAllocation; 82 var listEscapingInIndex = $listAllocation;
83 var listEscapingInIndexSet = $listAllocation; 83 var listEscapingInIndexSet = $listAllocation;
84 var listEscapingTwiceInIndexSet = $listAllocation; 84 var listEscapingTwiceInIndexSet = $listAllocation;
85 var listPassedAsOptionalParameter = $listAllocation; 85 var listPassedAsOptionalParameter = $listAllocation;
86 var listPassedAsNamedParameter = $listAllocation; 86 var listPassedAsNamedParameter = $listAllocation;
87 var listSetInNonFinalField = $listAllocation; 87 var listSetInNonFinalField = $listAllocation;
88 var listWithChangedLength = $listAllocation;
88 89
89 foo(list) { 90 foo(list) {
90 list[0] = aDouble; 91 list[0] = aDouble;
91 } 92 }
92 93
93 bar() { 94 bar() {
94 return listReturnedFromMethod; 95 return listReturnedFromMethod;
95 } 96 }
96 97
97 takeOptional([list]) { 98 takeOptional([list]) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 new A()[listEscapingTwiceInIndexSet] = listEscapingTwiceInIndexSet; 164 new A()[listEscapingTwiceInIndexSet] = listEscapingTwiceInIndexSet;
164 165
165 listPassedAsOptionalParameter[0] = anInt; 166 listPassedAsOptionalParameter[0] = anInt;
166 takeOptional(listPassedAsOptionalParameter); 167 takeOptional(listPassedAsOptionalParameter);
167 168
168 listPassedAsNamedParameter[0] = anInt; 169 listPassedAsNamedParameter[0] = anInt;
169 takeNamed(list: listPassedAsNamedParameter); 170 takeNamed(list: listPassedAsNamedParameter);
170 171
171 listSetInNonFinalField[0] = anInt; 172 listSetInNonFinalField[0] = anInt;
172 new B(listSetInNonFinalField); 173 new B(listSetInNonFinalField);
174
175 listWithChangedLength[0] = anInt;
176 listWithChangedLength.length = 54;
173 } 177 }
174 """; 178 """;
175 } 179 }
176 180
177 void main() { 181 void main() {
178 doTest('[]'); // Test literal list. 182 doTest('[]', nullify: false); // Test literal list.
179 doTest('new List()'); // Test growable list. 183 doTest('new List()', nullify: false); // Test growable list.
180 doTest('new List(1)'); // Test fixed list. 184 doTest('new List(1)', nullify: true); // Test fixed list.
185 doTest('new List.filled(1, 0)', nullify: false); // Test List.filled.
186 doTest('new List.filled(1, null)', nullify: true); // Test List.filled.
181 } 187 }
182 188
183 void doTest(String allocation) { 189 void doTest(String allocation, {bool nullify}) {
184 Uri uri = new Uri(scheme: 'source'); 190 Uri uri = new Uri(scheme: 'source');
185 var compiler = compilerFor(generateTest(allocation), uri); 191 var compiler = compilerFor(generateTest(allocation), uri);
186 compiler.runCompiler(uri); 192 compiler.runCompiler(uri);
187 var typesInferrer = compiler.typesTask.typesInferrer; 193 var typesInferrer = compiler.typesTask.typesInferrer;
188 194
189 checkType(String name, type) { 195 checkType(String name, type) {
190 var element = findElement(compiler, name); 196 var element = findElement(compiler, name);
191 ContainerTypeMask mask = typesInferrer.internal.typeOf[element]; 197 ContainerTypeMask mask = typesInferrer.internal.typeOf[element];
198 if (nullify) type = type.nullable();
192 Expect.equals(type, mask.elementType.simplify(compiler), name); 199 Expect.equals(type, mask.elementType.simplify(compiler), name);
193 } 200 }
194 201
195 checkType('listInField', typesInferrer.numType.nullable()); 202 checkType('listInField', typesInferrer.numType);
196 checkType('listPassedToMethod', typesInferrer.numType.nullable()); 203 checkType('listPassedToMethod', typesInferrer.numType);
197 checkType('listReturnedFromMethod', typesInferrer.numType.nullable()); 204 checkType('listReturnedFromMethod', typesInferrer.numType);
198 checkType('listUsedWithCascade', typesInferrer.numType.nullable()); 205 checkType('listUsedWithCascade', typesInferrer.numType);
199 checkType('listUsedInClosure', typesInferrer.numType.nullable()); 206 checkType('listUsedInClosure', typesInferrer.numType);
200 checkType('listPassedToSelector', typesInferrer.numType.nullable()); 207 checkType('listPassedToSelector', typesInferrer.numType);
201 checkType('listReturnedFromSelector', typesInferrer.numType.nullable()); 208 checkType('listReturnedFromSelector', typesInferrer.numType);
202 checkType('listUsedWithAddAndInsert', typesInferrer.numType.nullable()); 209 checkType('listUsedWithAddAndInsert', typesInferrer.numType);
203 checkType('listUsedWithConstraint', typesInferrer.numType.nullable()); 210 checkType('listUsedWithConstraint', typesInferrer.numType);
204 checkType('listEscapingFromSetter', typesInferrer.numType.nullable()); 211 checkType('listEscapingFromSetter', typesInferrer.numType);
205 checkType('listUsedInLocal', typesInferrer.numType.nullable()); 212 checkType('listUsedInLocal', typesInferrer.numType);
206 checkType('listEscapingInSetterValue', typesInferrer.numType.nullable()); 213 checkType('listEscapingInSetterValue', typesInferrer.numType);
207 checkType('listEscapingInIndex', typesInferrer.numType.nullable()); 214 checkType('listEscapingInIndex', typesInferrer.numType);
208 checkType('listEscapingInIndexSet', typesInferrer.intType.nullable()); 215 checkType('listEscapingInIndexSet', typesInferrer.intType);
209 checkType('listEscapingTwiceInIndexSet', typesInferrer.numType.nullable()); 216 checkType('listEscapingTwiceInIndexSet', typesInferrer.numType);
210 checkType('listSetInNonFinalField', typesInferrer.numType.nullable()); 217 checkType('listSetInNonFinalField', typesInferrer.numType);
218 checkType('listWithChangedLength', typesInferrer.intType.nullable());
211 219
212 checkType('listPassedToClosure', typesInferrer.dynamicType); 220 checkType('listPassedToClosure', typesInferrer.dynamicType);
213 checkType('listReturnedFromClosure', typesInferrer.dynamicType); 221 checkType('listReturnedFromClosure', typesInferrer.dynamicType);
214 checkType('listUsedWithNonOkSelector', typesInferrer.dynamicType); 222 checkType('listUsedWithNonOkSelector', typesInferrer.dynamicType);
215 checkType('listPassedAsOptionalParameter', typesInferrer.dynamicType); 223 checkType('listPassedAsOptionalParameter', typesInferrer.dynamicType);
216 checkType('listPassedAsNamedParameter', typesInferrer.dynamicType); 224 checkType('listPassedAsNamedParameter', typesInferrer.dynamicType);
217 225
218 checkType('listUnset', new TypeMask.empty()); 226 if (!allocation.contains('filled')) {
219 checkType('listOnlySetWithConstraint', new TypeMask.empty()); 227 checkType('listUnset', new TypeMask.empty());
228 checkType('listOnlySetWithConstraint', new TypeMask.empty());
229 }
220 } 230 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart ('k') | tests/compiler/dart2js/mock_compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698