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 345d190cbc51dab315889de75bd3bbabd2023116..382ec1b9207c5c2a7826093fa6ad718a823cbe67 100644 |
--- a/dart/pkg/dart2js_incremental/lib/library_updater.dart |
+++ b/dart/pkg/dart2js_incremental/lib/library_updater.dart |
@@ -75,6 +75,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; |
@@ -129,6 +132,10 @@ class LibraryUpdater extends JsFeatures { |
final Set<ClassElementX> _directlyInstantiatedClasses; |
+ final Set<ConstantValue> _compiledConstants; |
+ |
+ bool _hasComputedNeeds = false; |
+ |
LibraryUpdater( |
Compiler compiler, |
this.inputProvider, |
@@ -138,7 +145,9 @@ class LibraryUpdater extends JsFeatures { |
: this.compiler = compiler, |
_emittedClasses = new Set.from(compiler.backend.emitter.neededClasses), |
_directlyInstantiatedClasses = new Set.from( |
- compiler.codegenWorld.directlyInstantiatedClasses); |
+ compiler.codegenWorld.directlyInstantiatedClasses), |
+ _compiledConstants = new Set<ConstantValue>.identity()..addAll( |
+ compiler.backend.constants.compiledConstants); |
/// When [true], updates must be applied (using [applyUpdates]) before the |
/// [compiler]'s state correctly reflects the updated program. |
@@ -602,7 +611,7 @@ class LibraryUpdater extends JsFeatures { |
if (!newClasses.isEmpty) { |
// Ask the emitter to compute "needs" (only) if new classes were |
// instantiated. |
- emitter.computeNeeds(); |
+ _ensureNeedsComputed(); |
newClasses = new Set.from(emitter.neededClasses); |
newClasses.removeAll(_emittedClasses); |
} else { |
@@ -661,6 +670,25 @@ class LibraryUpdater extends JsFeatures { |
} |
} |
+ Set<ConstantValue> newConstants = new Set<ConstantValue>.identity()..addAll( |
+ compiler.backend.constants.compiledConstants); |
+ newConstants.removeAll(_compiledConstants); |
+ |
+ if (!newConstants.isEmpty) { |
+ _ensureNeedsComputed(); |
+ 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(); }); |
@@ -764,6 +792,12 @@ if (self.$dart_unsafe_eval.pendingStubs) { |
List<String> computeFields(ClassElement cls) { |
return new EmitterHelper(compiler).computeFields(cls); |
} |
+ |
+ void _ensureNeedsComputed() { |
+ if (_hasComputedNeeds) return; |
+ emitter.computeNeeds(); |
+ _hasComputedNeeds = true; |
+ } |
} |
/// Represents an update (aka patch) of [before] to [after]. We use the word |