Index: dart/pkg/dart2js_incremental/lib/library_updater.dart |
diff --git a/dart/pkg/dart2js_incremental/lib/library_updater.dart b/dart/pkg/dart2js_incremental/lib/library_updater.dart |
index f6a19dc5afb7bc26f7efdc90937e8dffb8124a4b..18321507666bf52c6506c0e88653ff0b6fdda21a 100644 |
--- a/dart/pkg/dart2js_incremental/lib/library_updater.dart |
+++ b/dart/pkg/dart2js_incremental/lib/library_updater.dart |
@@ -76,6 +76,9 @@ import 'package:compiler/src/elements/modelx.dart' show |
import 'package:compiler/src/universe/universe.dart' show |
Selector; |
+import 'package:compiler/src/constants/values.dart' show |
+ ConstantValue; |
+ |
import 'diff.dart' show |
Difference, |
computeDifference; |
@@ -130,6 +133,10 @@ class LibraryUpdater extends JsFeatures { |
final Set<ClassElementX> _directlyInstantiatedClasses; |
+ final Set<ConstantValue> _compiledConstants; |
+ |
+ bool _hasComputedNeeds = false; |
+ |
LibraryUpdater( |
Compiler compiler, |
this.inputProvider, |
@@ -142,7 +149,10 @@ class LibraryUpdater extends JsFeatures { |
? [] : compiler.backend.emitter.neededClasses), |
_directlyInstantiatedClasses = new Set.from( |
compiler == null |
- ? [] : compiler.codegenWorld.directlyInstantiatedClasses); |
+ ? [] : compiler.codegenWorld.directlyInstantiatedClasses), |
+ _compiledConstants = new Set<ConstantValue>.identity()..addAll( |
+ compiler == null |
+ ? [] : compiler.backend.constants.compiledConstants); |
ahe
2014/12/11 10:09:00
Conflict resolution.
|
/// When [true], updates must be applied (using [applyUpdates]) before the |
/// [compiler]'s state correctly reflects the updated program. |
@@ -608,7 +618,7 @@ class LibraryUpdater extends JsFeatures { |
if (!newClasses.isEmpty) { |
// Ask the emitter to compute "needs" (only) if new classes were |
// instantiated. |
- emitter.computeAllNeededEntities(); |
+ _ensureNeedsComputed(); |
ahe
2014/12/11 10:09:00
Conflict resolution.
|
newClasses = new Set.from(emitter.neededClasses); |
newClasses.removeAll(_emittedClasses); |
} else { |
@@ -668,6 +678,25 @@ class LibraryUpdater extends JsFeatures { |
} |
} |
+ Set<ConstantValue> newConstants = new Set<ConstantValue>.identity()..addAll( |
+ compiler.backend.constants.compiledConstants); |
+ newConstants.removeAll(_compiledConstants); |
+ |
+ if (!newConstants.isEmpty) { |
+ _ensureNeedsComputed(); |
ahe
2014/12/11 10:09:00
Conflict resolution.
|
+ List<ConstantValue> constants = |
+ emitter.outputConstantLists[compiler.deferredLoadTask.mainOutputUnit]; |
+ if (constants != null) { |
+ for (ConstantValue constant in constants) { |
+ if (newConstants.contains(constant)) { |
+ jsAst.Statement constantInitializer = emitter.oldEmitter |
+ .buildConstantInitializer(constant).toStatement(); |
+ updates.add(constantInitializer); |
+ } |
+ } |
+ } |
+ } |
+ |
updates.add(js.statement(r''' |
if (self.$dart_unsafe_eval.pendingStubs) { |
self.$dart_unsafe_eval.pendingStubs.map(function(e) { return e(); }); |
@@ -771,6 +800,12 @@ if (self.$dart_unsafe_eval.pendingStubs) { |
List<String> computeFields(ClassElement cls) { |
return new EmitterHelper(compiler).computeFields(cls); |
} |
+ |
+ void _ensureNeedsComputed() { |
+ if (_hasComputedNeeds) return; |
+ emitter.computeAllNeededEntities(); |
ahe
2014/12/11 10:09:00
Conflict resolution (computeAllNeededEntities was
|
+ _hasComputedNeeds = true; |
+ } |
} |
/// Represents an update (aka patch) of [before] to [after]. We use the word |