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

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

Issue 3008133002: Handle local invoke in inferrer (Closed)
Patch Set: dartfmt Created 3 years, 3 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
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 '../../compiler_new.dart'; 7 import '../../compiler_new.dart';
8 import '../common.dart'; 8 import '../common.dart';
9 import '../common/names.dart'; 9 import '../common/names.dart';
10 import '../compiler.dart'; 10 import '../compiler.dart';
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 /// Sets the type of a parameter's default value to [type]. If the global 116 /// Sets the type of a parameter's default value to [type]. If the global
117 /// mapping in [defaultTypeOfParameter] already contains a type, it must be 117 /// mapping in [defaultTypeOfParameter] already contains a type, it must be
118 /// a [PlaceholderTypeInformation], which will be replaced. All its uses are 118 /// a [PlaceholderTypeInformation], which will be replaced. All its uses are
119 /// updated. 119 /// updated.
120 void setDefaultTypeOfParameter(Local parameter, TypeInformation type, 120 void setDefaultTypeOfParameter(Local parameter, TypeInformation type,
121 {bool isInstanceMember}); 121 {bool isInstanceMember});
122 122
123 Iterable<MemberEntity> getCallersOf(MemberEntity element); 123 Iterable<MemberEntity> getCallersOf(MemberEntity element);
124 124
125 // TODO(johnniwinther): Make this private again. 125 // TODO(johnniwinther): Make this private again.
126 GlobalTypeInferenceElementData dataOfMember(MemberEntity element); 126 GlobalTypeInferenceElementData<T> dataOfMember(MemberEntity element);
127 127
128 GlobalTypeInferenceElementData lookupDataOfMember(MemberEntity element); 128 GlobalTypeInferenceElementData<T> lookupDataOfMember(MemberEntity element);
129 129
130 bool checkIfExposesThis(ConstructorEntity element); 130 bool checkIfExposesThis(ConstructorEntity element);
131 131
132 void recordExposesThis(ConstructorEntity element, bool exposesThis); 132 void recordExposesThis(ConstructorEntity element, bool exposesThis);
133 133
134 /// Records that the return type [element] is of type [type]. 134 /// Records that the return type [element] is of type [type].
135 void recordReturnType(FunctionEntity element, TypeInformation type); 135 void recordReturnType(FunctionEntity element, TypeInformation type);
136 136
137 /// Records that [element] is of type [type]. 137 /// Records that [element] is of type [type].
138 void recordTypeOfField(FieldEntity element, TypeInformation type); 138 void recordTypeOfField(FieldEntity element, TypeInformation type);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 /// [inLoop] tells whether the call happens in a loop. 187 /// [inLoop] tells whether the call happens in a loop.
188 TypeInformation registerCalledSelector( 188 TypeInformation registerCalledSelector(
189 CallType callType, 189 CallType callType,
190 T node, 190 T node,
191 Selector selector, 191 Selector selector,
192 TypeMask mask, 192 TypeMask mask,
193 TypeInformation receiverType, 193 TypeInformation receiverType,
194 MemberEntity caller, 194 MemberEntity caller,
195 ArgumentsTypes arguments, 195 ArgumentsTypes arguments,
196 SideEffects sideEffects, 196 SideEffects sideEffects,
197 bool inLoop, 197 {bool inLoop,
198 bool isConditional); 198 bool isConditional});
199 199
200 /// Update the assignments to parameters in the graph. [remove] tells whether 200 /// Update the assignments to parameters in the graph. [remove] tells whether
201 /// assignments must be added or removed. If [init] is false, parameters are 201 /// assignments must be added or removed. If [init] is false, parameters are
202 /// added to the work queue. 202 /// added to the work queue.
203 void updateParameterAssignments(TypeInformation caller, MemberEntity callee, 203 void updateParameterAssignments(TypeInformation caller, MemberEntity callee,
204 ArgumentsTypes arguments, Selector selector, TypeMask mask, 204 ArgumentsTypes arguments, Selector selector, TypeMask mask,
205 {bool remove, bool addToQueue: true}); 205 {bool remove, bool addToQueue: true});
206 206
207 void updateSelectorInMember(MemberEntity owner, CallType callType, T node, 207 void updateSelectorInMember(MemberEntity owner, CallType callType, T node,
208 Selector selector, TypeMask mask); 208 Selector selector, TypeMask mask);
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 997
998 TypeInformation registerCalledSelector( 998 TypeInformation registerCalledSelector(
999 CallType callType, 999 CallType callType,
1000 T node, 1000 T node,
1001 Selector selector, 1001 Selector selector,
1002 TypeMask mask, 1002 TypeMask mask,
1003 TypeInformation receiverType, 1003 TypeInformation receiverType,
1004 MemberEntity caller, 1004 MemberEntity caller,
1005 ArgumentsTypes arguments, 1005 ArgumentsTypes arguments,
1006 SideEffects sideEffects, 1006 SideEffects sideEffects,
1007 bool inLoop, 1007 {bool inLoop,
1008 bool isConditional) { 1008 bool isConditional}) {
1009 if (selector.isClosureCall) { 1009 if (selector.isClosureCall) {
1010 return registerCalledClosure(node, selector, mask, receiverType, caller, 1010 return registerCalledClosure(node, selector, mask, receiverType, caller,
1011 arguments, sideEffects, inLoop); 1011 arguments, sideEffects, inLoop);
1012 } 1012 }
1013 1013
1014 closedWorld.locateMembers(selector, mask).forEach((callee) { 1014 closedWorld.locateMembers(selector, mask).forEach((callee) {
1015 updateSideEffects(sideEffects, selector, callee); 1015 updateSideEffects(sideEffects, selector, callee);
1016 }); 1016 });
1017 1017
1018 CallSiteTypeInformation info = new DynamicCallSiteTypeInformation( 1018 CallSiteTypeInformation info = new DynamicCallSiteTypeInformation(
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 types.allocatedMaps.values.forEach(cleanup); 1098 types.allocatedMaps.values.forEach(cleanup);
1099 types.allocatedLists.values.forEach(cleanup); 1099 types.allocatedLists.values.forEach(cleanup);
1100 } 1100 }
1101 1101
1102 Iterable<MemberEntity> getCallersOf(MemberEntity element) { 1102 Iterable<MemberEntity> getCallersOf(MemberEntity element) {
1103 MemberTypeInformation info = types.getInferredTypeOfMember(element); 1103 MemberTypeInformation info = types.getInferredTypeOfMember(element);
1104 return info.callers; 1104 return info.callers;
1105 } 1105 }
1106 1106
1107 TypeInformation typeOfMemberWithSelector( 1107 TypeInformation typeOfMemberWithSelector(
1108 covariant MemberElement element, Selector selector) { 1108 MemberEntity element, Selector selector) {
1109 if (element.name == Identifiers.noSuchMethod_ && 1109 if (element.name == Identifiers.noSuchMethod_ &&
1110 selector.name != element.name) { 1110 selector.name != element.name) {
1111 // An invocation can resolve to a [noSuchMethod], in which case 1111 // An invocation can resolve to a [noSuchMethod], in which case
1112 // we get the return type of [noSuchMethod]. 1112 // we get the return type of [noSuchMethod].
1113 return returnTypeOfMember(element); 1113 return returnTypeOfMember(element);
1114 } else if (selector.isGetter) { 1114 } else if (selector.isGetter) {
1115 if (element.isFunction) { 1115 if (element.isFunction) {
1116 // [functionType] is null if the inferrer did not run. 1116 // [functionType] is null if the inferrer did not run.
1117 return types.functionType == null 1117 return types.functionType == null
1118 ? types.dynamicType 1118 ? types.dynamicType
1119 : types.functionType; 1119 : types.functionType;
1120 } else if (element.isField) { 1120 } else if (element.isField) {
1121 return typeOfMember(element); 1121 return typeOfMember(element);
1122 } else if (Elements.isUnresolved(element)) { 1122 } else if (element.isGetter) {
1123 return returnTypeOfMember(element);
1124 } else {
1125 assert(element is MemberElement && Elements.isUnresolved(element));
1123 return types.dynamicType; 1126 return types.dynamicType;
1124 } else {
1125 assert(element.isGetter);
1126 return returnTypeOfMember(element);
1127 } 1127 }
1128 } else if (element.isGetter || element.isField) { 1128 } else if (element.isGetter || element.isField) {
1129 assert(selector.isCall || selector.isSetter); 1129 assert(selector.isCall || selector.isSetter);
1130 return types.dynamicType; 1130 return types.dynamicType;
1131 } else { 1131 } else {
1132 return returnTypeOfMember(element); 1132 return returnTypeOfMember(element);
1133 } 1133 }
1134 } 1134 }
1135 1135
1136 /// Returns true if global optimizations such as type inferencing can apply to 1136 /// Returns true if global optimizations such as type inferencing can apply to
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 // Put the other operators in buckets by size, later to be added in 1183 // Put the other operators in buckets by size, later to be added in
1184 // size order. 1184 // size order.
1185 int size = computeSize(element); 1185 int size = computeSize(element);
1186 Set<MemberEntity> set = 1186 Set<MemberEntity> set =
1187 methodSizes.putIfAbsent(size, () => new Setlet<MemberEntity>()); 1187 methodSizes.putIfAbsent(size, () => new Setlet<MemberEntity>());
1188 set.add(element); 1188 set.add(element);
1189 }); 1189 });
1190 return methodSizes; 1190 return methodSizes;
1191 } 1191 }
1192 } 1192 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698