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

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

Issue 22067002: Ignore unused classes when constructing set for deferred loading. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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
« no previous file with comments | « no previous file | tests/compiler/dart2js_extra/deferred/deferred_unused_classes_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 library deferred_load; 5 library deferred_load;
6 6
7 import 'dart:collection' 7 import 'dart:collection'
8 show LinkedHashMap, 8 show LinkedHashMap,
9 LinkedHashSet; 9 LinkedHashSet;
10 10
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // When instantiating a class, we record a reference to the 146 // When instantiating a class, we record a reference to the
147 // constructor, not the class itself. We must add all the 147 // constructor, not the class itself. We must add all the
148 // instance members of the constructor's class (see below). 148 // instance members of the constructor's class (see below).
149 result.addAll( 149 result.addAll(
150 allElementsResolvedFrom(element.getEnclosingClass().implementation)); 150 allElementsResolvedFrom(element.getEnclosingClass().implementation));
151 } 151 }
152 if (element.isClass()) { 152 if (element.isClass()) {
153 // If we see a class, add everything its instance members refer 153 // If we see a class, add everything its instance members refer
154 // to. Static members are not relevant. 154 // to. Static members are not relevant.
155 ClassElement cls = element.declaration; 155 ClassElement cls = element.declaration;
156 cls.forEachLocalMember((Element e) { 156 // Make sure that class has been used - type has been computed.
157 if (!e.isInstanceMember()) return; 157 if (cls.thisType != null) {
ahe 2013/08/06 16:00:34 I think this check belongs on line 92, and it feel
aam-me 2013/08/07 03:20:42 Thanks, makes sense. Done.
158 result.addAll(DependencyCollector.collect(e.implementation, compiler)); 158 cls.forEachLocalMember((Element e) {
159 });
160 if (cls.implementation != cls) {
161 // TODO(ahe): Why doesn't ClassElement.forEachLocalMember do this?
162 cls.implementation.forEachLocalMember((Element e) {
163 if (!e.isInstanceMember()) return; 159 if (!e.isInstanceMember()) return;
164 result.addAll(DependencyCollector.collect(e.implementation, 160 result.addAll(DependencyCollector.collect(e.implementation, compiler)) ;
165 compiler));
166 }); 161 });
162 if (cls.implementation != cls) {
163 // TODO(ahe): Why doesn't ClassElement.forEachLocalMember do this?
164 cls.implementation.forEachLocalMember((Element e) {
165 if (!e.isInstanceMember()) return;
166 result.addAll(DependencyCollector.collect(e.implementation,
167 compiler));
168 });
169 }
170 for (var type in cls.allSupertypes) {
171 result.add(type.element.implementation);
172 }
173 result.add(cls.implementation);
167 } 174 }
168 for (var type in cls.allSupertypes) {
169 result.add(type.element.implementation);
170 }
171 result.add(cls.implementation);
172 } else if (Elements.isStaticOrTopLevel(element) 175 } else if (Elements.isStaticOrTopLevel(element)
173 || element.isConstructor()) { 176 || element.isConstructor()) {
174 result.addAll(DependencyCollector.collect(element, compiler)); 177 result.addAll(DependencyCollector.collect(element, compiler));
175 } 178 }
176 // Other elements, in particular instance members, are ignored as 179 // Other elements, in particular instance members, are ignored as
177 // they are processed as part of the class. 180 // they are processed as part of the class.
178 return result; 181 return result;
179 } 182 }
180 183
181 void addTransitiveClosureTo(Set<Element> elements) { 184 void addTransitiveClosureTo(Set<Element> elements) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 compiler.enqueuer.resolution.getCachedElements(element); 245 compiler.enqueuer.resolution.getCachedElements(element);
243 if (elements == null) return new LinkedHashSet<Element>(); 246 if (elements == null) return new LinkedHashSet<Element>();
244 Node node = element.parseNode(compiler); 247 Node node = element.parseNode(compiler);
245 if (node == null) return new LinkedHashSet<Element>(); 248 if (node == null) return new LinkedHashSet<Element>();
246 var collector = new DependencyCollector(elements, compiler); 249 var collector = new DependencyCollector(elements, compiler);
247 node.accept(collector); 250 node.accept(collector);
248 collector.dependencies.addAll(elements.otherDependencies); 251 collector.dependencies.addAll(elements.otherDependencies);
249 return collector.dependencies; 252 return collector.dependencies;
250 } 253 }
251 } 254 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js_extra/deferred/deferred_unused_classes_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698