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

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

Issue 2993463002: Add CallType to DynamicCallSiteTypeInformation (Closed)
Patch Set: 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 switch (callType) {
365 case CallType.complex:
366 assert(node.asSendSet() != null);
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:
377 assert(node.asSend() != null);
378 data.setTypeMask(node, mask);
379 break;
380 case CallType.forIn:
381 assert(node.asForIn() != null);
382 if (selector == Selectors.iterator) {
383 data.setIteratorTypeMask(node, mask);
384 } else if (selector == Selectors.current) {
385 data.setCurrentTypeMask(node, mask);
386 } else {
387 assert(selector == Selectors.moveNext);
388 data.setMoveNextTypeMask(node, mask);
389 }
390 break;
391 }
392 /*if (node.asSendSet() != null) {
Siggi Cherem (dart-lang) 2017/07/31 19:30:29 delete old code
Johnni Winther 2017/08/01 13:09:20 Done.
364 if (selector.isSetter || selector.isIndexSet) { 393 if (selector.isSetter || selector.isIndexSet) {
365 data.setTypeMask(node, mask); 394 data.setTypeMask(node, mask);
366 } else if (selector.isGetter || selector.isIndex) { 395 } else if (selector.isGetter || selector.isIndex) {
367 data.setGetterTypeMaskInComplexSendSet(node, mask); 396 data.setGetterTypeMaskInComplexSendSet(node, mask);
368 } else { 397 } else {
369 assert(selector.isOperator); 398 assert(selector.isOperator);
370 data.setOperatorTypeMaskInComplexSendSet(node, mask); 399 data.setOperatorTypeMaskInComplexSendSet(node, mask);
371 } 400 }
372 } else if (node.asSend() != null) { 401 } else if (node.asSend() != null) {
373 data.setTypeMask(node, mask); 402 data.setTypeMask(node, mask);
374 } else { 403 } else {
375 assert(node.asForIn() != null); 404 assert(node.asForIn() != null);
376 if (selector == Selectors.iterator) { 405 if (selector == Selectors.iterator) {
377 data.setIteratorTypeMask(node, mask); 406 data.setIteratorTypeMask(node, mask);
378 } else if (selector == Selectors.current) { 407 } else if (selector == Selectors.current) {
379 data.setCurrentTypeMask(node, mask); 408 data.setCurrentTypeMask(node, mask);
380 } else { 409 } else {
381 assert(selector == Selectors.moveNext); 410 assert(selector == Selectors.moveNext);
382 data.setMoveNextTypeMask(node, mask); 411 data.setMoveNextTypeMask(node, mask);
383 } 412 }
384 } 413 }*/
385 } 414 }
386 415
387 bool checkIfExposesThis(ConstructorEntity element) { 416 bool checkIfExposesThis(ConstructorEntity element) {
388 assert(!(element is ConstructorElement && !element.isDeclaration)); 417 assert(!(element is ConstructorElement && !element.isDeclaration));
389 return generativeConstructorsExposingThis.contains(element); 418 return generativeConstructorsExposingThis.contains(element);
390 } 419 }
391 420
392 void recordExposesThis(ConstructorEntity element, bool exposesThis) { 421 void recordExposesThis(ConstructorEntity element, bool exposesThis) {
393 assert(!(element is ConstructorElement && !element.isDeclaration)); 422 assert(!(element is ConstructorElement && !element.isDeclaration));
394 if (exposesThis) { 423 if (exposesThis) {
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 types.allocatedClosures.add(info); 998 types.allocatedClosures.add(info);
970 } 999 }
971 } 1000 }
972 info.addToGraph(this); 1001 info.addToGraph(this);
973 types.allocatedCalls.add(info); 1002 types.allocatedCalls.add(info);
974 updateSideEffects(sideEffects, selector, callee); 1003 updateSideEffects(sideEffects, selector, callee);
975 return info; 1004 return info;
976 } 1005 }
977 1006
978 TypeInformation registerCalledSelector( 1007 TypeInformation registerCalledSelector(
1008 CallType callType,
979 ast.Node node, 1009 ast.Node node,
980 Selector selector, 1010 Selector selector,
981 TypeMask mask, 1011 TypeMask mask,
982 TypeInformation receiverType, 1012 TypeInformation receiverType,
983 MemberEntity caller, 1013 MemberEntity caller,
984 ArgumentsTypes arguments, 1014 ArgumentsTypes arguments,
985 SideEffects sideEffects, 1015 SideEffects sideEffects,
986 bool inLoop, 1016 bool inLoop,
987 bool isConditional) { 1017 bool isConditional) {
988 if (selector.isClosureCall) { 1018 if (selector.isClosureCall) {
989 return registerCalledClosure(node, selector, mask, receiverType, caller, 1019 return registerCalledClosure(node, selector, mask, receiverType, caller,
990 arguments, sideEffects, inLoop); 1020 arguments, sideEffects, inLoop);
991 } 1021 }
992 1022
993 closedWorld.locateMembers(selector, mask).forEach((callee) { 1023 closedWorld.locateMembers(selector, mask).forEach((callee) {
994 updateSideEffects(sideEffects, selector, callee); 1024 updateSideEffects(sideEffects, selector, callee);
995 }); 1025 });
996 1026
997 CallSiteTypeInformation info = new DynamicCallSiteTypeInformation( 1027 CallSiteTypeInformation info = new DynamicCallSiteTypeInformation(
998 types.currentMember, 1028 types.currentMember,
1029 callType,
999 node, 1030 node,
1000 caller, 1031 caller,
1001 selector, 1032 selector,
1002 mask, 1033 mask,
1003 receiverType, 1034 receiverType,
1004 arguments, 1035 arguments,
1005 inLoop, 1036 inLoop,
1006 isConditional); 1037 isConditional);
1007 1038
1008 info.addToGraph(this); 1039 info.addToGraph(this);
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 @override 1280 @override
1250 bool checkPhiNode(ast.Node node) { 1281 bool checkPhiNode(ast.Node node) {
1251 return true; 1282 return true;
1252 } 1283 }
1253 1284
1254 @override 1285 @override
1255 bool checkClassEntity(covariant ClassElement cls) { 1286 bool checkClassEntity(covariant ClassElement cls) {
1256 return cls.isDeclaration; 1287 return cls.isDeclaration;
1257 } 1288 }
1258 } 1289 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698