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

Unified Diff: pkg/compiler/lib/src/deferred_load.dart

Issue 2315973002: When registering deferred constant, use canonical output unit. (Closed)
Patch Set: inline _getCanonicalUnit vars Created 4 years, 3 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/dump_info.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/deferred_load.dart
diff --git a/pkg/compiler/lib/src/deferred_load.dart b/pkg/compiler/lib/src/deferred_load.dart
index 114bdcaaf8886442f87a8fc3b0fd7dbe63de1948..b4e586a8de10b3b67f5837caee73943ee882e17b 100644
--- a/pkg/compiler/lib/src/deferred_load.dart
+++ b/pkg/compiler/lib/src/deferred_load.dart
@@ -222,11 +222,23 @@ class DeferredLoadTask extends CompilerTask {
return outputUnitTo.imports.containsAll(outputUnitFrom.imports);
}
+ // TODO(het): use a union-find to canonicalize output units
+ OutputUnit _getCanonicalUnit(OutputUnit outputUnit) {
+ OutputUnit representative = allOutputUnits.lookup(outputUnit);
+ if (representative == null) {
+ representative = outputUnit;
+ allOutputUnits.add(representative);
+ }
+ return representative;
+ }
+
void registerConstantDeferredUse(
DeferredConstantValue constant, PrefixElement prefix) {
OutputUnit outputUnit = new OutputUnit();
outputUnit.imports.add(new _DeclaredDeferredImport(prefix.deferredImport));
- _constantToOutputUnit[constant] = outputUnit;
+
+ // Check to see if there is already a canonical output unit registered.
+ _constantToOutputUnit[constant] = _getCanonicalUnit(outputUnit);
}
/// Answers whether [element] is explicitly deferred when referred to from
@@ -679,6 +691,11 @@ class DeferredLoadTask extends CompilerTask {
Map<ConstantValue, OutputUnit> constantToOutputUnitBuilder =
new Map<ConstantValue, OutputUnit>();
+ // Add all constants that may have been registered during
+ // resolution with [registerConstantDeferredUse].
+ constantToOutputUnitBuilder.addAll(_constantToOutputUnit);
+ _constantToOutputUnit.clear();
+
// Reverse the mappings. For each element record an OutputUnit
// collecting all deferred imports mapped to this element. Same
// for constants.
@@ -721,21 +738,11 @@ class DeferredLoadTask extends CompilerTask {
// to, and canonicalize them.
elementToOutputUnitBuilder
.forEach((Element element, OutputUnit outputUnit) {
- OutputUnit representative = allOutputUnits.lookup(outputUnit);
- if (representative == null) {
- representative = outputUnit;
- allOutputUnits.add(representative);
- }
- _elementToOutputUnit[element] = representative;
+ _elementToOutputUnit[element] = _getCanonicalUnit(outputUnit);
});
constantToOutputUnitBuilder
.forEach((ConstantValue constant, OutputUnit outputUnit) {
- OutputUnit representative = allOutputUnits.lookup(outputUnit);
- if (representative == null) {
- representative = outputUnit;
- allOutputUnits.add(representative);
- }
- _constantToOutputUnit[constant] = representative;
+ _constantToOutputUnit[constant] = _getCanonicalUnit(outputUnit);
});
// Generate a unique name for each OutputUnit.
« no previous file with comments | « no previous file | pkg/compiler/lib/src/dump_info.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698