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

Side by Side Diff: pkg/compiler/lib/src/inferrer/inferrer_engine.dart

Issue 2767103003: Fix #29130: only consider classes allocated with generative constructors as potential closures (Closed)
Patch Set: Created 3 years, 9 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 | « no previous file | tests/compiler/dart2js_extra/29130_test.dart » ('j') | 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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:kernel/ast.dart' as ir; 5 import 'package:kernel/ast.dart' as ir;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/names.dart'; 8 import '../common/names.dart';
9 import '../compiler.dart'; 9 import '../compiler.dart';
10 import '../constants/expressions.dart'; 10 import '../constants/expressions.dart';
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 375
376 if (info is ClosureTypeInformation) { 376 if (info is ClosureTypeInformation) {
377 Iterable<FunctionElement> elements = [info.element]; 377 Iterable<FunctionElement> elements = [info.element];
378 trace(elements, new ClosureTracerVisitor(elements, info, this)); 378 trace(elements, new ClosureTracerVisitor(elements, info, this));
379 } else if (info is CallSiteTypeInformation) { 379 } else if (info is CallSiteTypeInformation) {
380 if (info is StaticCallSiteTypeInformation && 380 if (info is StaticCallSiteTypeInformation &&
381 info.selector != null && 381 info.selector != null &&
382 info.selector.isCall) { 382 info.selector.isCall) {
383 // This is a constructor call to a class with a call method. So we 383 // This is a constructor call to a class with a call method. So we
384 // need to trace the call method here. 384 // need to trace the call method here.
385 assert(info.calledElement.isConstructor); 385 assert(info.calledElement.isGenerativeConstructor);
386 ClassElement cls = info.calledElement.enclosingClass; 386 ClassElement cls = info.calledElement.enclosingClass;
387 FunctionElement callMethod = cls.lookupMember(Identifiers.call); 387 FunctionElement callMethod = cls.lookupMember(Identifiers.call);
388 assert(invariant(cls, callMethod != null)); 388 assert(invariant(cls, callMethod != null));
389 Iterable<FunctionElement> elements = [callMethod]; 389 Iterable<FunctionElement> elements = [callMethod];
390 trace(elements, new ClosureTracerVisitor(elements, info, this)); 390 trace(elements, new ClosureTracerVisitor(elements, info, this));
391 } else { 391 } else {
392 // We only are interested in functions here, as other targets 392 // We only are interested in functions here, as other targets
393 // of this closure call are not a root to trace but an intermediate 393 // of this closure call are not a root to trace but an intermediate
394 // for some other function. 394 // for some other function.
395 Iterable<FunctionElement> elements = new List<FunctionElement>.from( 395 Iterable<FunctionElement> elements = new List<FunctionElement>.from(
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 types.currentMember, 837 types.currentMember,
838 node, 838 node,
839 caller, 839 caller,
840 callee, 840 callee,
841 selector, 841 selector,
842 mask, 842 mask,
843 arguments, 843 arguments,
844 inLoop); 844 inLoop);
845 // If this class has a 'call' method then we have essentially created a 845 // If this class has a 'call' method then we have essentially created a
846 // closure here. Register it as such so that it is traced. 846 // closure here. Register it as such so that it is traced.
847 if (selector != null && selector.isCall && callee.isConstructor) { 847 // Note: we exclude factory constructors because they don't always create an
848 // instance of the type. They are static methods that delegate to some other
849 // generative constructor to do the actual creation of the object.
850 if (selector != null && selector.isCall && callee.isGenerativeConstructor) {
848 ClassElement cls = callee.enclosingClass; 851 ClassElement cls = callee.enclosingClass;
849 if (cls.callType != null) { 852 if (cls.callType != null) {
850 types.allocatedClosures.add(info); 853 types.allocatedClosures.add(info);
851 } 854 }
852 } 855 }
853 info.addToGraph(this); 856 info.addToGraph(this);
854 types.allocatedCalls.add(info); 857 types.allocatedCalls.add(info);
855 updateSideEffects(sideEffects, selector, callee); 858 updateSideEffects(sideEffects, selector, callee);
856 return info; 859 return info;
857 } 860 }
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 /** 1056 /**
1054 * Records that the captured variable [local] is read. 1057 * Records that the captured variable [local] is read.
1055 */ 1058 */
1056 void recordCapturedLocalRead(Local local) {} 1059 void recordCapturedLocalRead(Local local) {}
1057 1060
1058 /** 1061 /**
1059 * Records that the variable [local] is being updated. 1062 * Records that the variable [local] is being updated.
1060 */ 1063 */
1061 void recordLocalUpdate(Local local, TypeInformation type) {} 1064 void recordLocalUpdate(Local local, TypeInformation type) {}
1062 } 1065 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js_extra/29130_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698