| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |