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

Unified Diff: pkg/compiler/lib/src/inferrer/type_graph_nodes.dart

Issue 1182913003: Split TypedSelector into Selector and TypeMask. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/inferrer/type_graph_nodes.dart
diff --git a/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart b/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart
index 7df1cbbc2cfcc5e0316915943b9c938b6d4db669..51c39f58df7681c92c6fb1f14fd291858a2b4775 100644
--- a/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart
+++ b/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart
@@ -627,6 +627,7 @@ abstract class CallSiteTypeInformation extends TypeInformation
final Spannable call;
final Element caller;
final Selector selector;
+ final TypeMask mask;
final ArgumentsTypes arguments;
final bool inLoop;
@@ -635,6 +636,7 @@ abstract class CallSiteTypeInformation extends TypeInformation
this.call,
this.caller,
this.selector,
+ this.mask,
this.arguments,
this.inLoop) : super.noAssignments(context);
@@ -656,9 +658,10 @@ class StaticCallSiteTypeInformation extends CallSiteTypeInformation {
Element enclosing,
this.calledElement,
Selector selector,
+ TypeMask mask,
ArgumentsTypes arguments,
bool inLoop)
- : super(context, call, enclosing, selector, arguments, inLoop);
+ : super(context, call, enclosing, selector, mask, arguments, inLoop);
void addToGraph(TypeGraphInferrerEngine inferrer) {
MemberTypeInformation callee =
@@ -669,7 +672,7 @@ class StaticCallSiteTypeInformation extends CallSiteTypeInformation {
arguments.forEach((info) => info.addUser(this));
}
inferrer.updateParameterAssignments(
- this, calledElement, arguments, selector, remove: false,
+ this, calledElement, arguments, selector, mask, remove: false,
addToQueue: false);
}
@@ -723,15 +726,16 @@ class DynamicCallSiteTypeInformation extends CallSiteTypeInformation {
Spannable call,
Element enclosing,
Selector selector,
+ TypeMask mask,
this.receiver,
ArgumentsTypes arguments,
bool inLoop)
- : super(context, call, enclosing, selector, arguments, inLoop);
+ : super(context, call, enclosing, selector, mask, arguments, inLoop);
void addToGraph(TypeGraphInferrerEngine inferrer) {
assert(receiver != null);
- Selector typedSelector = computeTypedSelector(inferrer);
- targets = inferrer.compiler.world.allFunctions.filter(typedSelector);
+ TypeMask typeMask = computeTypedSelector(inferrer);
+ targets = inferrer.compiler.world.allFunctions.filter(selector, typeMask);
receiver.addUser(this);
if (arguments != null) {
arguments.forEach((info) => info.addUser(this));
@@ -741,22 +745,21 @@ class DynamicCallSiteTypeInformation extends CallSiteTypeInformation {
callee.addCall(caller, call);
callee.addUser(this);
inferrer.updateParameterAssignments(
- this, element, arguments, typedSelector, remove: false,
+ this, element, arguments, selector, typeMask, remove: false,
addToQueue: false);
}
}
Iterable<Element> get callees => targets.map((e) => e.implementation);
- Selector computeTypedSelector(TypeGraphInferrerEngine inferrer) {
+ TypeMask computeTypedSelector(TypeGraphInferrerEngine inferrer) {
TypeMask receiverType = receiver.type;
- if (selector.mask != receiverType) {
+ if (mask != receiverType) {
return receiverType == inferrer.compiler.typesTask.dynamicType
- ? selector.asUntyped
- : new TypedSelector(receiverType, selector, inferrer.classWorld);
+ ? null : receiverType;
} else {
- return selector;
+ return mask;
}
}
@@ -776,12 +779,13 @@ class DynamicCallSiteTypeInformation extends CallSiteTypeInformation {
* [int.operator+] only says it returns a [num].
*/
TypeInformation handleIntrisifiedSelector(Selector selector,
+ TypeMask mask,
TypeGraphInferrerEngine inferrer) {
ClassWorld classWorld = inferrer.classWorld;
if (!classWorld.backend.intImplementation.isResolved) return null;
TypeMask emptyType = const TypeMask.nonNullEmpty();
- if (selector.mask == null) return null;
- if (!selector.mask.containsOnlyInt(classWorld)) {
+ if (mask == null) return null;
+ if (!mask.containsOnlyInt(classWorld)) {
return null;
}
if (!selector.isCall && !selector.isOperator) return null;
@@ -855,21 +859,22 @@ class DynamicCallSiteTypeInformation extends CallSiteTypeInformation {
TypeMask computeType(TypeGraphInferrerEngine inferrer) {
Iterable<Element> oldTargets = targets;
- Selector typedSelector = computeTypedSelector(inferrer);
- inferrer.updateSelectorInTree(caller, call, typedSelector);
+ TypeMask typeMask = computeTypedSelector(inferrer);
+ inferrer.updateSelectorInTree(caller, call, selector, typeMask);
Compiler compiler = inferrer.compiler;
- Selector selectorToUse = typedSelector.extendIfReachesAll(compiler);
+ TypeMask maskToUse =
+ compiler.world.extendMaskIfReachesAll(selector, typeMask);
bool canReachAll = compiler.enabledInvokeOn &&
- (selectorToUse != typedSelector);
+ (maskToUse != typeMask);
// If this call could potentially reach all methods that satisfy
// the untyped selector (through noSuchMethod's `Invocation`
// and a call to `delegate`), we iterate over all these methods to
// update their parameter types.
- targets = compiler.world.allFunctions.filter(selectorToUse);
+ targets = compiler.world.allFunctions.filter(selector, maskToUse);
Iterable<Element> typedTargets = canReachAll
- ? compiler.world.allFunctions.filter(typedSelector)
+ ? compiler.world.allFunctions.filter(selector, typeMask)
: targets;
// Add calls to new targets to the graph.
@@ -879,7 +884,7 @@ class DynamicCallSiteTypeInformation extends CallSiteTypeInformation {
callee.addCall(caller, call);
callee.addUser(this);
inferrer.updateParameterAssignments(
- this, element, arguments, typedSelector, remove: false,
+ this, element, arguments, selector, typeMask, remove: false,
addToQueue: true);
});
@@ -891,7 +896,7 @@ class DynamicCallSiteTypeInformation extends CallSiteTypeInformation {
callee.removeCall(caller, call);
callee.removeUser(this);
inferrer.updateParameterAssignments(
- this, element, arguments, typedSelector, remove: true,
+ this, element, arguments, selector, typeMask, remove: true,
addToQueue: true);
});
@@ -907,20 +912,21 @@ class DynamicCallSiteTypeInformation extends CallSiteTypeInformation {
return const TypeMask.nonNullEmpty();
}
- if (inferrer.returnsListElementType(typedSelector)) {
- ContainerTypeMask mask = receiver.type;
- return mask.elementType;
- } else if (inferrer.returnsMapValueType(typedSelector)) {
- if (typedSelector.mask.isDictionary &&
+ if (inferrer.returnsListElementType(selector, typeMask)) {
+ ContainerTypeMask containerTypeMask = receiver.type;
+ return containerTypeMask.elementType;
+ } else if (inferrer.returnsMapValueType(selector, typeMask)) {
+ if (typeMask.isDictionary &&
arguments.positional[0].type.isValue) {
- DictionaryTypeMask mask = typedSelector.mask;
+ DictionaryTypeMask dictionaryTypeMask = typeMask;
ValueTypeMask arg = arguments.positional[0].type;
String key = arg.value;
- if (mask.typeMap.containsKey(key)) {
+ if (dictionaryTypeMask.typeMap.containsKey(key)) {
if (_VERBOSE) {
- print("Dictionary lookup for $key yields ${mask.typeMap[key]}.");
+ print("Dictionary lookup for $key yields "
+ "${dictionaryTypeMask.typeMap[key]}.");
}
- return mask.typeMap[key];
+ return dictionaryTypeMask.typeMap[key];
} else {
// The typeMap is precise, so if we do not find the key, the lookup
// will be [null] at runtime.
@@ -930,16 +936,17 @@ class DynamicCallSiteTypeInformation extends CallSiteTypeInformation {
return inferrer.types.nullType.type;
}
}
- MapTypeMask mask = typedSelector.mask;
+ MapTypeMask mapTypeMask = typeMask;
if (_VERBOSE) {
- print("Map lookup for $typedSelector yields ${mask.valueType}.");
+ print(
+ "Map lookup for $selector yields ${mapTypeMask.valueType}.");
}
- return mask.valueType;
+ return mapTypeMask.valueType;
} else {
TypeInformation info =
- handleIntrisifiedSelector(typedSelector, inferrer);
+ handleIntrisifiedSelector(selector, typeMask, inferrer);
if (info != null) return info.type;
- return inferrer.typeOfElementWithSelector(element, typedSelector).type;
+ return inferrer.typeOfElementWithSelector(element, selector).type;
}
}));
@@ -955,16 +962,16 @@ class DynamicCallSiteTypeInformation extends CallSiteTypeInformation {
void giveUp(TypeGraphInferrerEngine inferrer, {bool clearAssignments: true}) {
if (!abandonInferencing) {
- inferrer.updateSelectorInTree(caller, call, selector);
+ inferrer.updateSelectorInTree(caller, call, selector, mask);
Iterable<Element> oldTargets = targets;
- targets = inferrer.compiler.world.allFunctions.filter(selector);
+ targets = inferrer.compiler.world.allFunctions.filter(selector, mask);
for (Element element in targets) {
if (!oldTargets.contains(element)) {
MemberTypeInformation callee =
inferrer.types.getInferredTypeOf(element);
callee.addCall(caller, call);
inferrer.updateParameterAssignments(
- this, element, arguments, selector, remove: false,
+ this, element, arguments, selector, mask, remove: false,
addToQueue: true);
}
}
@@ -1006,10 +1013,11 @@ class ClosureCallSiteTypeInformation extends CallSiteTypeInformation {
Spannable call,
Element enclosing,
Selector selector,
+ TypeMask mask,
this.closure,
ArgumentsTypes arguments,
bool inLoop)
- : super(context, call, enclosing, selector, arguments, inLoop);
+ : super(context, call, enclosing, selector, mask, arguments, inLoop);
void addToGraph(TypeGraphInferrerEngine inferrer) {
arguments.forEach((info) => info.addUser(this));
« no previous file with comments | « pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart ('k') | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698