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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart

Issue 1416723008: dart2js cps: Propagate container types for lists. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove unreachable handling of list constructor in type propagation Created 5 years, 1 month 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
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 library dart2js.ir_builder_task; 5 library dart2js.ir_builder_task;
6 6
7 import '../closure.dart' as closurelib; 7 import '../closure.dart' as closurelib;
8 import '../closure.dart' hide ClosureScope; 8 import '../closure.dart' hide ClosureScope;
9 import '../common.dart'; 9 import '../common.dart';
10 import '../common/names.dart' show 10 import '../common/names.dart' show
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } 228 }
229 229
230 irBuilder.buildFunctionHeader(parameters, 230 irBuilder.buildFunctionHeader(parameters,
231 closureScope: getClosureScopeForNode(node), 231 closureScope: getClosureScopeForNode(node),
232 env: getClosureEnvironment()); 232 env: getClosureEnvironment());
233 233
234 visit(node.body); 234 visit(node.body);
235 return irBuilder.makeFunctionDefinition(); 235 return irBuilder.makeFunctionDefinition();
236 } 236 }
237 237
238 /// Returns the allocation site-specific type for a given allocation.
239 ///
240 /// Currently, it is an error to call this with anything that is not the
241 /// allocation site for a List object (a literal list or a call to one
242 /// of the List constructors).
243 TypeMask getAllocationSiteType(ast.Node node) {
244 return compiler.typesTask.getGuaranteedTypeOfNode(
245 elements.analyzedElement, node);
246 }
247
238 ir.Primitive visit(ast.Node node) => node.accept(this); 248 ir.Primitive visit(ast.Node node) => node.accept(this);
239 249
240 // ## Statements ## 250 // ## Statements ##
241 visitBlock(ast.Block node) { 251 visitBlock(ast.Block node) {
242 irBuilder.buildBlock(node.statements.nodes, build); 252 irBuilder.buildBlock(node.statements.nodes, build);
243 } 253 }
244 254
245 ir.Primitive visitBreakStatement(ast.BreakStatement node) { 255 ir.Primitive visitBreakStatement(ast.BreakStatement node) {
246 if (!irBuilder.buildBreak(elements.getTargetOf(node))) { 256 if (!irBuilder.buildBreak(elements.getTargetOf(node))) {
247 reporter.internalError(node, "'break' target not found"); 257 reporter.internalError(node, "'break' target not found");
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 irBuilder.state.constants.getConstantValue(expression), 637 irBuilder.state.constants.getConstantValue(expression),
628 sourceInformation: sourceInformation); 638 sourceInformation: sourceInformation);
629 } 639 }
630 640
631 ir.Primitive visitLiteralList(ast.LiteralList node) { 641 ir.Primitive visitLiteralList(ast.LiteralList node) {
632 if (node.isConst) { 642 if (node.isConst) {
633 return translateConstant(node); 643 return translateConstant(node);
634 } 644 }
635 List<ir.Primitive> values = node.elements.nodes.mapToList(visit); 645 List<ir.Primitive> values = node.elements.nodes.mapToList(visit);
636 InterfaceType type = elements.getType(node); 646 InterfaceType type = elements.getType(node);
637 return irBuilder.buildListLiteral(type, values); 647 return irBuilder.buildListLiteral(type, values,
648 allocationSiteType: getAllocationSiteType(node));
638 } 649 }
639 650
640 ir.Primitive visitLiteralMap(ast.LiteralMap node) { 651 ir.Primitive visitLiteralMap(ast.LiteralMap node) {
641 if (node.isConst) { 652 if (node.isConst) {
642 return translateConstant(node); 653 return translateConstant(node);
643 } 654 }
644 InterfaceType type = elements.getType(node); 655 InterfaceType type = elements.getType(node);
645 return irBuilder.buildMapLiteral( 656 return irBuilder.buildMapLiteral(
646 type, 657 type,
647 node.entries.nodes.map((e) => e.key), 658 node.entries.nodes.map((e) => e.key),
(...skipping 2623 matching lines...) Expand 10 before | Expand all | Expand 10 after
3271 ConstructorElement constructor, 3282 ConstructorElement constructor,
3272 DartType type, 3283 DartType type,
3273 ast.NodeList arguments, 3284 ast.NodeList arguments,
3274 CallStructure callStructure, 3285 CallStructure callStructure,
3275 _) { 3286 _) {
3276 List<ir.Primitive> arguments = 3287 List<ir.Primitive> arguments =
3277 node.send.arguments.mapToList(visit, growable:false); 3288 node.send.arguments.mapToList(visit, growable:false);
3278 // Use default values from the effective target, not the immediate target. 3289 // Use default values from the effective target, not the immediate target.
3279 ConstructorElement target = constructor.effectiveTarget; 3290 ConstructorElement target = constructor.effectiveTarget;
3280 arguments = normalizeStaticArguments(callStructure, target, arguments); 3291 arguments = normalizeStaticArguments(callStructure, target, arguments);
3292 TypeMask allocationSiteType;
3293 ast.Node send = node.send;
3294 if (Elements.isFixedListConstructorCall(constructor, send, compiler) ||
3295 Elements.isGrowableListConstructorCall(constructor, send, compiler) ||
3296 Elements.isFilledListConstructorCall(constructor, send, compiler) ||
3297 Elements.isConstructorOfTypedArraySubclass(constructor, compiler)) {
3298 allocationSiteType = getAllocationSiteType(send);
3299 }
3281 return irBuilder.buildConstructorInvocation( 3300 return irBuilder.buildConstructorInvocation(
3282 target, 3301 target,
3283 callStructure, 3302 callStructure,
3284 constructor.computeEffectiveTargetType(type), 3303 constructor.computeEffectiveTargetType(type),
3285 arguments, 3304 arguments,
3286 sourceInformationBuilder.buildNew(node)); 3305 sourceInformationBuilder.buildNew(node),
3306 allocationSiteType: allocationSiteType);
3287 } 3307 }
3288 3308
3289 @override 3309 @override
3290 ir.Primitive buildStaticNoSuchMethod(Selector selector, 3310 ir.Primitive buildStaticNoSuchMethod(Selector selector,
3291 List<ir.Primitive> arguments) { 3311 List<ir.Primitive> arguments) {
3292 Element thrower = backend.helpers.throwNoSuchMethod; 3312 Element thrower = backend.helpers.throwNoSuchMethod;
3293 ir.Primitive receiver = irBuilder.buildStringConstant(''); 3313 ir.Primitive receiver = irBuilder.buildStringConstant('');
3294 ir.Primitive name = irBuilder.buildStringConstant(selector.name); 3314 ir.Primitive name = irBuilder.buildStringConstant(selector.name);
3295 ir.Primitive argumentList = irBuilder.buildListLiteral(null, arguments); 3315 ir.Primitive argumentList = irBuilder.buildListLiteral(null, arguments);
3296 ir.Primitive expectedArgumentNames = irBuilder.buildNullConstant(); 3316 ir.Primitive expectedArgumentNames = irBuilder.buildNullConstant();
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
3579 if (compiler.backend.isForeign(function)) { 3599 if (compiler.backend.isForeign(function)) {
3580 return handleForeignCode(node, function, argumentList, callStructure); 3600 return handleForeignCode(node, function, argumentList, callStructure);
3581 } else { 3601 } else {
3582 return irBuilder.buildStaticFunctionInvocation(function, callStructure, 3602 return irBuilder.buildStaticFunctionInvocation(function, callStructure,
3583 translateStaticArguments(argumentList, function, callStructure), 3603 translateStaticArguments(argumentList, function, callStructure),
3584 sourceInformation: 3604 sourceInformation:
3585 sourceInformationBuilder.buildCall(node, node.selector)); 3605 sourceInformationBuilder.buildCall(node, node.selector));
3586 } 3606 }
3587 } 3607 }
3588 } 3608 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart ('k') | pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698