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_helpers.dart'; | 9 import '../js_backend/backend_helpers.dart'; |
10 import '../types/types.dart' show TypeMask; | 10 import '../types/types.dart' show TypeMask; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 83 } |
84 } | 84 } |
85 if (called.isGetter && | 85 if (called.isGetter && |
86 info.selector != null && | 86 info.selector != null && |
87 info.selector.isCall && | 87 info.selector.isCall && |
88 inferrer.types.getInferredTypeOf(called) == currentUser) { | 88 inferrer.types.getInferredTypeOf(called) == currentUser) { |
89 // This node can be a closure call as well. For example, `foo()` | 89 // This node can be a closure call as well. For example, `foo()` |
90 // where `foo` is a getter. | 90 // where `foo` is a getter. |
91 _registerCallForLaterAnalysis(info); | 91 _registerCallForLaterAnalysis(info); |
92 } | 92 } |
93 if (_checkIfFunctionApply(called) && | 93 if (called is MemberElement && |
| 94 _checkIfFunctionApply(called) && |
94 info.arguments != null && | 95 info.arguments != null && |
95 info.arguments.contains(currentUser)) { | 96 info.arguments.contains(currentUser)) { |
96 _tagAsFunctionApplyTarget("static call"); | 97 _tagAsFunctionApplyTarget("static call"); |
97 } | 98 } |
98 } | 99 } |
99 | 100 |
100 bool _checkIfCurrentUser(element) => | 101 bool _checkIfCurrentUser(element) => |
101 inferrer.types.getInferredTypeOf(element) == currentUser; | 102 inferrer.types.getInferredTypeOf(element) == currentUser; |
102 | 103 |
103 bool _checkIfFunctionApply(Element element) { | 104 bool _checkIfFunctionApply(MemberElement element) { |
104 return element is MemberElement && | 105 return compiler.commonElements.isFunctionApplyMethod(element); |
105 compiler.commonElements.isFunctionApplyMethod(element); | |
106 } | 106 } |
107 | 107 |
108 @override | 108 @override |
109 visitDynamicCallSiteTypeInformation(DynamicCallSiteTypeInformation info) { | 109 visitDynamicCallSiteTypeInformation(DynamicCallSiteTypeInformation info) { |
110 super.visitDynamicCallSiteTypeInformation(info); | 110 super.visitDynamicCallSiteTypeInformation(info); |
111 if (info.selector.isCall) { | 111 if (info.selector.isCall) { |
112 if (info.arguments.contains(currentUser)) { | 112 if (info.arguments.contains(currentUser)) { |
113 if (!info.targets.every((element) => element.isFunction)) { | 113 if (!info.targets.every((element) => element.isFunction)) { |
114 bailout('Passed to a closure'); | 114 bailout('Passed to a closure'); |
115 } | 115 } |
(...skipping 18 matching lines...) Expand all Loading... |
134 @override | 134 @override |
135 visitStaticCallSiteTypeInformation(StaticCallSiteTypeInformation info) { | 135 visitStaticCallSiteTypeInformation(StaticCallSiteTypeInformation info) { |
136 super.visitStaticCallSiteTypeInformation(info); | 136 super.visitStaticCallSiteTypeInformation(info); |
137 if (info.calledElement == tracedElements.first && | 137 if (info.calledElement == tracedElements.first && |
138 info.selector != null && | 138 info.selector != null && |
139 info.selector.isGetter) { | 139 info.selector.isGetter) { |
140 addNewEscapeInformation(info); | 140 addNewEscapeInformation(info); |
141 } | 141 } |
142 } | 142 } |
143 } | 143 } |
OLD | NEW |