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

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

Issue 2993463002: Add CallType to DynamicCallSiteTypeInformation (Closed)
Patch Set: Updated cf. comments Created 3 years, 4 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 '../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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 bool inLoop); 176 bool inLoop);
177 177
178 /// Registers that [caller] calls [selector] with [receiverType] as receiver, 178 /// Registers that [caller] calls [selector] with [receiverType] as receiver,
179 /// and [arguments]. 179 /// and [arguments].
180 /// 180 ///
181 /// [sideEffects] will be updated to incorporate the potential callees' side 181 /// [sideEffects] will be updated to incorporate the potential callees' side
182 /// effects. 182 /// effects.
183 /// 183 ///
184 /// [inLoop] tells whether the call happens in a loop. 184 /// [inLoop] tells whether the call happens in a loop.
185 TypeInformation registerCalledSelector( 185 TypeInformation registerCalledSelector(
186 CallType callType,
186 ast.Node node, 187 ast.Node node,
187 Selector selector, 188 Selector selector,
188 TypeMask mask, 189 TypeMask mask,
189 TypeInformation receiverType, 190 TypeInformation receiverType,
190 MemberEntity caller, 191 MemberEntity caller,
191 ArgumentsTypes arguments, 192 ArgumentsTypes arguments,
192 SideEffects sideEffects, 193 SideEffects sideEffects,
193 bool inLoop, 194 bool inLoop,
194 bool isConditional); 195 bool isConditional);
195 196
196 /// Update the assignments to parameters in the graph. [remove] tells whether 197 /// Update the assignments to parameters in the graph. [remove] tells whether
197 /// assignments must be added or removed. If [init] is false, parameters are 198 /// assignments must be added or removed. If [init] is false, parameters are
198 /// added to the work queue. 199 /// added to the work queue.
199 void updateParameterAssignments(TypeInformation caller, MemberEntity callee, 200 void updateParameterAssignments(TypeInformation caller, MemberEntity callee,
200 ArgumentsTypes arguments, Selector selector, TypeMask mask, 201 ArgumentsTypes arguments, Selector selector, TypeMask mask,
201 {bool remove, bool addToQueue: true}); 202 {bool remove, bool addToQueue: true});
202 203
203 void updateSelectorInMember( 204 void updateSelectorInMember(MemberEntity owner, CallType callType,
204 MemberEntity owner, ast.Node node, Selector selector, TypeMask mask); 205 ast.Node node, Selector selector, TypeMask mask);
205 206
206 /// Returns the return type of [element]. 207 /// Returns the return type of [element].
207 TypeInformation returnTypeOfMember(MemberEntity element); 208 TypeInformation returnTypeOfMember(MemberEntity element);
208 209
209 /// Returns the type of [element] when being called with [selector]. 210 /// Returns the type of [element] when being called with [selector].
210 TypeInformation typeOfMemberWithSelector( 211 TypeInformation typeOfMemberWithSelector(
211 MemberEntity element, Selector selector); 212 MemberEntity element, Selector selector);
212 213
213 /// Returns the type of [element]. 214 /// Returns the type of [element].
214 TypeInformation typeOfMember(MemberEntity element); 215 TypeInformation typeOfMember(MemberEntity element);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 mappedType = types.nonNullSubtype(type.element); 351 mappedType = types.nonNullSubtype(type.element);
351 } 352 }
352 returnType = types.computeLUB(returnType, mappedType); 353 returnType = types.computeLUB(returnType, mappedType);
353 if (returnType == types.dynamicType) { 354 if (returnType == types.dynamicType) {
354 break; 355 break;
355 } 356 }
356 } 357 }
357 return returnType; 358 return returnType;
358 } 359 }
359 360
360 void updateSelectorInMember( 361 void updateSelectorInMember(MemberEntity owner, CallType callType,
361 MemberEntity owner, ast.Node node, Selector selector, TypeMask mask) { 362 ast.Node node, Selector selector, TypeMask mask) {
362 GlobalTypeInferenceElementData data = dataOfMember(owner); 363 GlobalTypeInferenceElementData data = dataOfMember(owner);
363 if (node.asSendSet() != null) { 364 assert(validCallType(callType, node));
364 if (selector.isSetter || selector.isIndexSet) { 365 switch (callType) {
366 case CallType.complex:
367 if (selector.isSetter || selector.isIndexSet) {
368 data.setTypeMask(node, mask);
369 } else if (selector.isGetter || selector.isIndex) {
370 data.setGetterTypeMaskInComplexSendSet(node, mask);
371 } else {
372 assert(selector.isOperator);
373 data.setOperatorTypeMaskInComplexSendSet(node, mask);
374 }
375 break;
376 case CallType.access:
365 data.setTypeMask(node, mask); 377 data.setTypeMask(node, mask);
366 } else if (selector.isGetter || selector.isIndex) { 378 break;
367 data.setGetterTypeMaskInComplexSendSet(node, mask); 379 case CallType.forIn:
368 } else { 380 if (selector == Selectors.iterator) {
369 assert(selector.isOperator); 381 data.setIteratorTypeMask(node, mask);
370 data.setOperatorTypeMaskInComplexSendSet(node, mask); 382 } else if (selector == Selectors.current) {
371 } 383 data.setCurrentTypeMask(node, mask);
372 } else if (node.asSend() != null) { 384 } else {
373 data.setTypeMask(node, mask); 385 assert(selector == Selectors.moveNext);
374 } else { 386 data.setMoveNextTypeMask(node, mask);
375 assert(node.asForIn() != null); 387 }
376 if (selector == Selectors.iterator) { 388 break;
377 data.setIteratorTypeMask(node, mask);
378 } else if (selector == Selectors.current) {
379 data.setCurrentTypeMask(node, mask);
380 } else {
381 assert(selector == Selectors.moveNext);
382 data.setMoveNextTypeMask(node, mask);
383 }
384 } 389 }
385 } 390 }
386 391
387 bool checkIfExposesThis(ConstructorEntity element) { 392 bool checkIfExposesThis(ConstructorEntity element) {
388 assert(!(element is ConstructorElement && !element.isDeclaration)); 393 assert(!(element is ConstructorElement && !element.isDeclaration));
389 return generativeConstructorsExposingThis.contains(element); 394 return generativeConstructorsExposingThis.contains(element);
390 } 395 }
391 396
392 void recordExposesThis(ConstructorEntity element, bool exposesThis) { 397 void recordExposesThis(ConstructorEntity element, bool exposesThis) {
393 assert(!(element is ConstructorElement && !element.isDeclaration)); 398 assert(!(element is ConstructorElement && !element.isDeclaration));
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 types.allocatedClosures.add(info); 974 types.allocatedClosures.add(info);
970 } 975 }
971 } 976 }
972 info.addToGraph(this); 977 info.addToGraph(this);
973 types.allocatedCalls.add(info); 978 types.allocatedCalls.add(info);
974 updateSideEffects(sideEffects, selector, callee); 979 updateSideEffects(sideEffects, selector, callee);
975 return info; 980 return info;
976 } 981 }
977 982
978 TypeInformation registerCalledSelector( 983 TypeInformation registerCalledSelector(
984 CallType callType,
979 ast.Node node, 985 ast.Node node,
980 Selector selector, 986 Selector selector,
981 TypeMask mask, 987 TypeMask mask,
982 TypeInformation receiverType, 988 TypeInformation receiverType,
983 MemberEntity caller, 989 MemberEntity caller,
984 ArgumentsTypes arguments, 990 ArgumentsTypes arguments,
985 SideEffects sideEffects, 991 SideEffects sideEffects,
986 bool inLoop, 992 bool inLoop,
987 bool isConditional) { 993 bool isConditional) {
988 if (selector.isClosureCall) { 994 if (selector.isClosureCall) {
989 return registerCalledClosure(node, selector, mask, receiverType, caller, 995 return registerCalledClosure(node, selector, mask, receiverType, caller,
990 arguments, sideEffects, inLoop); 996 arguments, sideEffects, inLoop);
991 } 997 }
992 998
993 closedWorld.locateMembers(selector, mask).forEach((callee) { 999 closedWorld.locateMembers(selector, mask).forEach((callee) {
994 updateSideEffects(sideEffects, selector, callee); 1000 updateSideEffects(sideEffects, selector, callee);
995 }); 1001 });
996 1002
997 CallSiteTypeInformation info = new DynamicCallSiteTypeInformation( 1003 CallSiteTypeInformation info = new DynamicCallSiteTypeInformation(
998 types.currentMember, 1004 types.currentMember,
1005 callType,
999 node, 1006 node,
1000 caller, 1007 caller,
1001 selector, 1008 selector,
1002 mask, 1009 mask,
1003 receiverType, 1010 receiverType,
1004 arguments, 1011 arguments,
1005 inLoop, 1012 inLoop,
1006 isConditional); 1013 isConditional);
1007 1014
1008 info.addToGraph(this); 1015 info.addToGraph(this);
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 @override 1256 @override
1250 bool checkPhiNode(ast.Node node) { 1257 bool checkPhiNode(ast.Node node) {
1251 return true; 1258 return true;
1252 } 1259 }
1253 1260
1254 @override 1261 @override
1255 bool checkClassEntity(covariant ClassElement cls) { 1262 bool checkClassEntity(covariant ClassElement cls) {
1256 return cls.isDeclaration; 1263 return cls.isDeclaration;
1257 } 1264 }
1258 } 1265 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/inferrer/builder.dart ('k') | pkg/compiler/lib/src/inferrer/type_graph_nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698