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

Unified Diff: lib/compiler/implementation/universe.dart

Issue 10180001: Introduce typed selectors to do better tree shaking based on calls on 'this'. Getters and setters w… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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
« no previous file with comments | « lib/compiler/implementation/ssa/optimize.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/universe.dart
===================================================================
--- lib/compiler/implementation/universe.dart (revision 6835)
+++ lib/compiler/implementation/universe.dart (working copy)
@@ -78,7 +78,8 @@
static final Selector INVOCATION_2 =
const Selector(SelectorKind.INVOCATION, 2);
- bool applies(FunctionParameters parameters) {
+ bool applies(FunctionElement element, Compiler compiler) {
+ FunctionParameters parameters = element.computeParameters(compiler);
if (argumentCount > parameters.parameterCount) return false;
int requiredParameterCount = parameters.requiredParameterCount;
int optionalParameterCount = parameters.optionalParameterCount;
@@ -121,13 +122,15 @@
*/
bool addArgumentsToList(Link<Node> arguments,
List list,
- FunctionParameters parameters,
+ FunctionElement element,
compileArgument(Node argument),
- compileConstant(Element element)) {
- void addMatchingArgumentsToList(Link<Node> link) {
- }
+ compileConstant(Element element),
+ Compiler compiler) {
+ if (!this.applies(element, compiler)) return false;
- if (!this.applies(parameters)) return false;
+ void addMatchingArgumentsToList(Link<Node> link) {}
+
+ FunctionParameters parameters = element.computeParameters(compiler);
if (this.positionalArgumentCount == parameters.parameterCount) {
for (Link<Node> link = arguments; !link.isEmpty(); link = link.tail) {
list.add(compileArgument(link.head));
@@ -230,3 +233,34 @@
return orderedNamedArguments;
}
}
+
+/**
+ * A [TypedInvocation] is an invocation where we have information on
+ * the type of the receiver.
+ */
+class TypedInvocation extends Invocation {
+ /**
+ * The type of the receiver. Any subtype of that type can be the
+ * target of the invocation.
+ */
+ final Type receiverType;
+
+ TypedInvocation(this.receiverType, Selector selector)
+ : super(selector.argumentCount, selector.namedArguments);
+
+ bool applies(FunctionElement element, Compiler compiler) {
+ if (!element.enclosingElement.isClass()) return false;
+
+ ClassElement other = element.enclosingElement;
+ ClassElement self = receiverType.element;
+ if (!other.isSubclassOf(self)) return false;
+ return super.applies(element, compiler);
+ return false;
+ }
+
+ bool operator ==(other) {
+ if (other is !TypedInvocation) return false;
+ if (other.receiverType !== receiverType) return false;
+ return super == other;
+ }
+}
« no previous file with comments | « lib/compiler/implementation/ssa/optimize.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698