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

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
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) {
kasperl 2012/04/23 12:34:45 Not sure I understand the name of this method.
ngeoffray 2012/04/23 13:48:18 The method is whether the selector applies to this
+ 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,27 @@
return orderedNamedArguments;
}
}
+
+class TypedInvocation extends Invocation {
kasperl 2012/04/23 12:34:45 So this is a special invocation where we know some
ngeoffray 2012/04/23 13:48:18 Done.
+ final Type type;
kasperl 2012/04/23 12:34:45 type -> receiverType?
ngeoffray 2012/04/23 13:48:18 Done.
+
+ TypedInvocation(this.type, 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 = type.element;
+ if (other === self || other.isSubclassOf(self)) {
+ return super.applies(element, compiler);
+ }
+ return false;
+ }
+
+ bool operator ==(other) {
+ if (other is !TypedInvocation) return false;
+ if (other.type !== type) return false;
+ return super == other;
+ }
+}
« lib/compiler/implementation/ssa/codegen.dart ('K') | « lib/compiler/implementation/ssa/optimize.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698