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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/universe/full_function_set.dart

Issue 14416014: After a dynamic call, refine the receiver type by looking at the potential targets of that call. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of universe; 5 part of universe;
6 6
7 class FullFunctionSet extends FunctionSet { 7 class FullFunctionSet extends FunctionSet {
8 FullFunctionSet(Compiler compiler) : super(compiler); 8 FullFunctionSet(Compiler compiler) : super(compiler);
9 9
10 FunctionSetNode newNode(SourceString name) 10 FunctionSetNode newNode(SourceString name)
(...skipping 15 matching lines...) Expand all
26 List<ClassElement> classes = computeClasses(functions, compiler); 26 List<ClassElement> classes = computeClasses(functions, compiler);
27 bool isExact = selector.hasExactMask || isExactClass(classes, compiler); 27 bool isExact = selector.hasExactMask || isExactClass(classes, compiler);
28 return new FullFunctionSetQuery(functions, classes, isExact); 28 return new FullFunctionSetQuery(functions, classes, isExact);
29 } 29 }
30 30
31 static List<ClassElement> computeClasses(List<Element> functions, 31 static List<ClassElement> computeClasses(List<Element> functions,
32 Compiler compiler) { 32 Compiler compiler) {
33 // TODO(kasperl): Check if any of the found classes may have a 33 // TODO(kasperl): Check if any of the found classes may have a
34 // non-throwing noSuchMethod implementation in a subclass instead 34 // non-throwing noSuchMethod implementation in a subclass instead
35 // of always disabling the class list computation. 35 // of always disabling the class list computation.
36 if (compiler.enabledNoSuchMethod) return null; 36 if (compiler.enabledNoSuchMethod) {
37 return <ClassElement>[compiler.objectClass];
38 }
37 List<ClassElement> classes = <ClassElement>[]; 39 List<ClassElement> classes = <ClassElement>[];
38 int budget = MAX_CLASSES_STEPS; 40 int budget = MAX_CLASSES_STEPS;
39 L: for (Element element in functions) { 41 L: for (Element element in functions) {
40 ClassElement enclosing = element.getEnclosingClass(); 42 ClassElement enclosing = element.getEnclosingClass();
41 for (int i = 0; i < classes.length; i++) { 43 for (int i = 0; i < classes.length; i++) {
42 if (--budget <= 0) { 44 if (--budget <= 0) {
43 return null; 45 return <ClassElement>[compiler.objectClass];
44 } else if (enclosing.isSubclassOf(classes[i])) { 46 } else if (enclosing.isSubclassOf(classes[i])) {
45 continue L; 47 continue L;
46 } else if (classes[i].isSubclassOf(enclosing)) { 48 } else if (classes[i].isSubclassOf(enclosing)) {
47 classes[i] = enclosing; 49 classes[i] = enclosing;
48 continue L; 50 continue L;
49 } 51 }
50 } 52 }
51 if (classes.length >= MAX_CLASSES) return null; 53 if (classes.length >= MAX_CLASSES) {
54 return <ClassElement>[compiler.objectClass];
55 }
52 classes.add(enclosing); 56 classes.add(enclosing);
53 } 57 }
54 return classes; 58 return classes;
55 } 59 }
56 60
57 static bool isExactClass(List<ClassElement> classes, Compiler compiler) { 61 static bool isExactClass(List<ClassElement> classes, Compiler compiler) {
58 if (classes == null || classes.length != 1) return false; 62 if (classes.length != 1) return false;
59 ClassElement single = classes[0]; 63 ClassElement single = classes[0];
60 // Return true if the single class in our list does not have a 64 // Return true if the single class in our list does not have a
61 // single instantiated subclass. 65 // single instantiated subclass.
62 Set<ClassElement> subtypes = compiler.world.subtypes[single]; 66 Set<ClassElement> subclasses = compiler.world.subclasses[single];
63 return subtypes == null 67 return subclasses == null || subclasses.isEmpty;
64 || subtypes.every((ClassElement each) => !each.isSubclassOf(single));
65 } 68 }
66 } 69 }
67 70
68 class FullFunctionSetQuery extends FunctionSetQuery { 71 class FullFunctionSetQuery extends FunctionSetQuery {
69 final List<ClassElement> classes;
70 final bool isExact; 72 final bool isExact;
71 FullFunctionSetQuery(List<Element> functions, this.classes, this.isExact) 73 FullFunctionSetQuery(List<Element> functions,
72 : super(functions); 74 Iterable<ClassElement> classes,
75 this.isExact)
76 : super(functions, classes);
73 } 77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698