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

Side by Side Diff: pkg/compiler/lib/src/deferred_load.dart

Issue 1117223002: dart2js: Inline across deferred output units if that leads to reduced size. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Comments. Created 5 years, 7 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 'constants/expressions.dart'; 7 import 'constants/expressions.dart';
8 import 'constants/values.dart' show 8 import 'constants/values.dart' show
9 ConstantValue, 9 ConstantValue,
10 ConstructedConstantValue, 10 ConstructedConstantValue,
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 /// Returns the [OutputUnit] where [constant] belongs. 194 /// Returns the [OutputUnit] where [constant] belongs.
195 OutputUnit outputUnitForConstant(ConstantValue constant) { 195 OutputUnit outputUnitForConstant(ConstantValue constant) {
196 if (!isProgramSplit) return mainOutputUnit; 196 if (!isProgramSplit) return mainOutputUnit;
197 return _constantToOutputUnit[constant]; 197 return _constantToOutputUnit[constant];
198 } 198 }
199 199
200 bool isDeferred(Element element) { 200 bool isDeferred(Element element) {
201 return outputUnitForElement(element) != mainOutputUnit; 201 return outputUnitForElement(element) != mainOutputUnit;
202 } 202 }
203 203
204 /// Returns true if e1 and e2 are in the same output unit. 204 /// Returns `true` if element [to] is reachable from element [from] without
205 bool inSameOutputUnit(Element e1, Element e2) { 205 /// crossing a deferred import.
206 return outputUnitForElement(e1) == outputUnitForElement(e2); 206 ///
207 /// For example, if we have two deferred libraries `A` and `B` that both
208 /// import a library `C`, then even though elements from `A` and `C` end up in
209 /// different output units, there is a non-deferred path between `A` and `C`.
210 bool hasOnlyNonDeferredImportPaths(Element from, Element to) {
211 OutputUnit outputUnitFrom = outputUnitForElement(from);
212 OutputUnit outputUnitTo = outputUnitForElement(to);
213 return outputUnitTo.imports.containsAll(outputUnitFrom.imports);
214 }
215
216 bool isFromMainOutputUnit(Element element) {
217 return outputUnitForElement(element) == mainOutputUnit;
207 } 218 }
208 219
209 void registerConstantDeferredUse(DeferredConstantValue constant, 220 void registerConstantDeferredUse(DeferredConstantValue constant,
210 PrefixElement prefix) { 221 PrefixElement prefix) {
211 OutputUnit outputUnit = new OutputUnit(); 222 OutputUnit outputUnit = new OutputUnit();
212 outputUnit.imports.add(prefix.deferredImport); 223 outputUnit.imports.add(prefix.deferredImport);
213 _constantToOutputUnit[constant] = outputUnit; 224 _constantToOutputUnit[constant] = outputUnit;
214 } 225 }
215 226
216 /// Answers whether [element] is explicitly deferred when referred to from 227 /// Answers whether [element] is explicitly deferred when referred to from
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 _importingLibrary = importingLibrary; 893 _importingLibrary = importingLibrary;
883 894
884 String get importingLibraryName { 895 String get importingLibraryName {
885 String libraryName = _importingLibrary.getLibraryName(); 896 String libraryName = _importingLibrary.getLibraryName();
886 return libraryName == "" 897 return libraryName == ""
887 ? "<unnamed>" 898 ? "<unnamed>"
888 : libraryName; 899 : libraryName;
889 } 900 }
890 901
891 } 902 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/ssa/builder.dart » ('j') | pkg/compiler/lib/src/ssa/builder.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698