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

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

Issue 12210142: Implement is-checks against type variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix computation of classes that need rti. Created 7 years, 10 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 dart2js; 5 part of dart2js;
6 6
7 class World { 7 class World {
8 final Compiler compiler; 8 final Compiler compiler;
9 final Map<ClassElement, Set<ClassElement>> subtypes; 9 final Map<ClassElement, Set<ClassElement>> subtypes;
10 final Map<ClassElement, Set<MixinApplicationElement>> mixinUses; 10 final Map<ClassElement, Set<MixinApplicationElement>> mixinUses;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 compiler.resolverWorld.instantiatedClasses.forEach(addSubtypes); 54 compiler.resolverWorld.instantiatedClasses.forEach(addSubtypes);
55 55
56 // Find the classes that need runtime type information. Such 56 // Find the classes that need runtime type information. Such
57 // classes are: 57 // classes are:
58 // (1) used in a is check with type variables, 58 // (1) used in a is check with type variables,
59 // (2) dependencies of classes in (1), 59 // (2) dependencies of classes in (1),
60 // (3) subclasses of (2) and (3). 60 // (3) subclasses of (2) and (3).
61 61
62 void potentiallyAddForRti(ClassElement cls) { 62 void potentiallyAddForRti(ClassElement cls) {
63 if (cls.typeVariables.isEmpty) return;
64 if (classesNeedingRti.contains(cls)) return; 63 if (classesNeedingRti.contains(cls)) return;
65 classesNeedingRti.add(cls); 64 classesNeedingRti.add(cls);
66 65
67 Set<ClassElement> classes = subtypes[cls]; 66 Set<ClassElement> classes = subtypes[cls];
68 if (classes != null) { 67 if (classes != null) {
69 classes.forEach((ClassElement sub) { 68 classes.forEach((ClassElement sub) {
70 potentiallyAddForRti(sub); 69 potentiallyAddForRti(sub);
71 }); 70 });
72 } 71 }
73 72
74 Set<ClassElement> dependencies = rtiDependencies[cls]; 73 Set<ClassElement> dependencies = rtiDependencies[cls];
75 if (dependencies != null) { 74 if (dependencies != null) {
76 dependencies.forEach((ClassElement other) { 75 dependencies.forEach((ClassElement other) {
77 potentiallyAddForRti(other); 76 potentiallyAddForRti(other);
78 }); 77 });
79 } 78 }
80 } 79 }
81 80
82 compiler.resolverWorld.isChecks.forEach((DartType type) { 81 compiler.resolverWorld.isChecks.forEach((DartType type) {
83 if (type is InterfaceType) { 82 if (type is InterfaceType) {
84 InterfaceType itf = type; 83 InterfaceType itf = type;
85 if (!itf.isRaw) { 84 if (!itf.isRaw) {
86 potentiallyAddForRti(itf.element); 85 potentiallyAddForRti(itf.element);
87 } 86 }
87 } else if (type is TypeVariableType) {
88 TypeVariableElement variable = type.element;
89 potentiallyAddForRti(variable.enclosingElement);
88 } 90 }
89 }); 91 });
90 } 92 }
91 93
92 void registerMixinUse(MixinApplicationElement mixinApplication, 94 void registerMixinUse(MixinApplicationElement mixinApplication,
93 ClassElement mixin) { 95 ClassElement mixin) {
94 Set<MixinApplicationElement> users = 96 Set<MixinApplicationElement> users =
95 mixinUses.putIfAbsent(mixin, () => 97 mixinUses.putIfAbsent(mixin, () =>
96 new Set<MixinApplicationElement>()); 98 new Set<MixinApplicationElement>());
97 users.add(mixinApplication); 99 users.add(mixinApplication);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 noSuchMethodSelector = new TypedSelector( 166 noSuchMethodSelector = new TypedSelector(
165 receiverType, selector.typeKind, noSuchMethodSelector); 167 receiverType, selector.typeKind, noSuchMethodSelector);
166 } 168 }
167 ClassElement objectClass = compiler.objectClass; 169 ClassElement objectClass = compiler.objectClass;
168 return allFunctions 170 return allFunctions
169 .filter(noSuchMethodSelector) 171 .filter(noSuchMethodSelector)
170 .map((Element member) => member.getEnclosingClass()) 172 .map((Element member) => member.getEnclosingClass())
171 .where((ClassElement holder) => !identical(holder, objectClass)); 173 .where((ClassElement holder) => !identical(holder, objectClass));
172 } 174 }
173 } 175 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698