OLD | NEW |
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 compiler.src.inferrer.closure_tracer; | 5 library compiler.src.inferrer.closure_tracer; |
6 | 6 |
7 import '../common/names.dart' show Names; | 7 import '../common/names.dart' show Names; |
8 import '../elements/elements.dart'; | 8 import '../elements/elements.dart'; |
9 import '../js_backend/backend.dart' show JavaScriptBackend; | 9 import '../js_backend/backend.dart' show JavaScriptBackend; |
10 import '../types/types.dart' show TypeMask; | 10 import '../types/types.dart' show TypeMask; |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 ApplyableTypeInformation get tracedType => super.tracedType; | 26 ApplyableTypeInformation get tracedType => super.tracedType; |
27 | 27 |
28 void run() { | 28 void run() { |
29 analyze(); | 29 analyze(); |
30 if (!continueAnalyzing) return; | 30 if (!continueAnalyzing) return; |
31 _callsToAnalyze.forEach(_analyzeCall); | 31 _callsToAnalyze.forEach(_analyzeCall); |
32 for (FunctionElement e in tracedElements) { | 32 for (FunctionElement e in tracedElements) { |
33 e.functionSignature.forEachParameter((Element parameter) { | 33 e.functionSignature.forEachParameter((Element parameter) { |
34 ElementTypeInformation info = | 34 ElementTypeInformation info = |
35 inferrer.types.getInferredTypeOf(parameter); | 35 inferrer.types.getInferredTypeOfParameter(parameter); |
36 info.disableInferenceForClosures = false; | 36 info.disableInferenceForClosures = false; |
37 }); | 37 }); |
38 } | 38 } |
39 } | 39 } |
40 | 40 |
41 void _tagAsFunctionApplyTarget([String reason]) { | 41 void _tagAsFunctionApplyTarget([String reason]) { |
42 tracedType.mightBePassedToFunctionApply = true; | 42 tracedType.mightBePassedToFunctionApply = true; |
43 if (debug.VERBOSE) { | 43 if (debug.VERBOSE) { |
44 print("Closure $tracedType might be passed to apply: $reason"); | 44 print("Closure $tracedType might be passed to apply: $reason"); |
45 } | 45 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 if (compiler.backend | 80 if (compiler.backend |
81 .isForeign(inferrer.closedWorld.commonElements, called)) { | 81 .isForeign(inferrer.closedWorld.commonElements, called)) { |
82 String name = called.name; | 82 String name = called.name; |
83 if (name == JavaScriptBackend.JS || name == 'DART_CLOSURE_TO_JS') { | 83 if (name == JavaScriptBackend.JS || name == 'DART_CLOSURE_TO_JS') { |
84 bailout('Used in JS ${info.call}'); | 84 bailout('Used in JS ${info.call}'); |
85 } | 85 } |
86 } | 86 } |
87 if (called.isGetter && | 87 if (called.isGetter && |
88 info.selector != null && | 88 info.selector != null && |
89 info.selector.isCall && | 89 info.selector.isCall && |
90 inferrer.types.getInferredTypeOf(called) == currentUser) { | 90 inferrer.types.getInferredTypeOfMember(called) == currentUser) { |
91 // This node can be a closure call as well. For example, `foo()` | 91 // This node can be a closure call as well. For example, `foo()` |
92 // where `foo` is a getter. | 92 // where `foo` is a getter. |
93 _registerCallForLaterAnalysis(info); | 93 _registerCallForLaterAnalysis(info); |
94 } | 94 } |
95 if (called is MemberElement && | 95 if (called is MemberElement && |
96 _checkIfFunctionApply(called) && | 96 _checkIfFunctionApply(called) && |
97 info.arguments != null && | 97 info.arguments != null && |
98 info.arguments.contains(currentUser)) { | 98 info.arguments.contains(currentUser)) { |
99 _tagAsFunctionApplyTarget("static call"); | 99 _tagAsFunctionApplyTarget("static call"); |
100 } | 100 } |
101 } | 101 } |
102 | 102 |
103 bool _checkIfCurrentUser(element) => | 103 bool _checkIfCurrentUser(MemberElement element) => |
104 inferrer.types.getInferredTypeOf(element) == currentUser; | 104 inferrer.types.getInferredTypeOfMember(element) == currentUser; |
105 | 105 |
106 bool _checkIfFunctionApply(MemberElement element) { | 106 bool _checkIfFunctionApply(MemberElement element) { |
107 return inferrer.closedWorld.commonElements.isFunctionApplyMethod(element); | 107 return inferrer.closedWorld.commonElements.isFunctionApplyMethod(element); |
108 } | 108 } |
109 | 109 |
110 @override | 110 @override |
111 visitDynamicCallSiteTypeInformation(DynamicCallSiteTypeInformation info) { | 111 visitDynamicCallSiteTypeInformation(DynamicCallSiteTypeInformation info) { |
112 super.visitDynamicCallSiteTypeInformation(info); | 112 super.visitDynamicCallSiteTypeInformation(info); |
113 if (info.selector.isCall) { | 113 if (info.selector.isCall) { |
114 if (info.arguments.contains(currentUser)) { | 114 if (info.arguments.contains(currentUser)) { |
(...skipping 21 matching lines...) Expand all Loading... |
136 @override | 136 @override |
137 visitStaticCallSiteTypeInformation(StaticCallSiteTypeInformation info) { | 137 visitStaticCallSiteTypeInformation(StaticCallSiteTypeInformation info) { |
138 super.visitStaticCallSiteTypeInformation(info); | 138 super.visitStaticCallSiteTypeInformation(info); |
139 if (info.calledElement == tracedElements.first && | 139 if (info.calledElement == tracedElements.first && |
140 info.selector != null && | 140 info.selector != null && |
141 info.selector.isGetter) { | 141 info.selector.isGetter) { |
142 addNewEscapeInformation(info); | 142 addNewEscapeInformation(info); |
143 } | 143 } |
144 } | 144 } |
145 } | 145 } |
OLD | NEW |