Chromium Code Reviews| 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 883265042a9c3508ddc520c03f00f1d4ba59af61..345d190cbc51dab315889de75bd3bbabd2023116 100644 |
| --- a/dart/pkg/dart2js_incremental/lib/library_updater.dart |
| +++ b/dart/pkg/dart2js_incremental/lib/library_updater.dart |
| @@ -125,16 +125,20 @@ class LibraryUpdater extends JsFeatures { |
| final Set<ClassElementX> _classesWithSchemaChanges = |
| new Set<ClassElementX>(); |
| - final Set<ClassElementX> _existingClasses = new Set(); |
| + final Set<ClassElementX> _emittedClasses; |
| + |
| + final Set<ClassElementX> _directlyInstantiatedClasses; |
| LibraryUpdater( |
| - this.compiler, |
| + Compiler compiler, |
| this.inputProvider, |
| this.uri, |
| this.logTime, |
| - this.logVerbose) { |
| - _existingClasses.addAll(emitter.neededClasses); |
| - } |
| + this.logVerbose) |
| + : this.compiler = compiler, |
| + _emittedClasses = new Set.from(compiler.backend.emitter.neededClasses), |
| + _directlyInstantiatedClasses = new Set.from( |
| + compiler.codegenWorld.directlyInstantiatedClasses); |
| /// When [true], updates must be applied (using [applyUpdates]) before the |
| /// [compiler]'s state correctly reflects the updated program. |
| @@ -591,20 +595,24 @@ class LibraryUpdater extends JsFeatures { |
| List<jsAst.Statement> updates = <jsAst.Statement>[]; |
| - // TODO(ahe): allInstantiatedClasses seem to include interfaces that aren't |
| - // needed. |
| Set<ClassElementX> newClasses = new Set.from( |
| - compiler.codegenWorld.allInstantiatedClasses.where( |
| - emitter.computeClassFilter())); |
| - newClasses.removeAll(_existingClasses); |
| - |
| - // TODO(ahe): When more than one updated is computed, we need to make sure |
| - // that existing classes aren't overwritten. No test except the one test |
| - // that tests more than one update is affected by this problem, and only |
| - // because main is closurized because we always enable tear-off. Is that |
| - // really necessary? Also, add a test which tests directly that what |
| - // happens when tear-off is introduced in second update. |
| - emitter.neededClasses.addAll(newClasses); |
| + compiler.codegenWorld.directlyInstantiatedClasses); |
| + newClasses.removeAll(_directlyInstantiatedClasses); |
| + |
| + if (!newClasses.isEmpty) { |
| + // Ask the emitter to compute "needs" (only) if new classes were |
|
karlklose
2014/12/01 10:13:32
Please document what "needs" are.
ahe
2014/12/01 10:28:35
I'm being vague because I don't know precisely.
|
| + // instantiated. |
| + emitter.computeNeeds(); |
| + newClasses = new Set.from(emitter.neededClasses); |
| + newClasses.removeAll(_emittedClasses); |
| + } else { |
| + // Make sure that the set of emitted classes is preserved for subsequent |
| + // updates. |
| + // TODO(ahe): This is a bit convoluted, find a better approach. |
| + emitter.neededClasses |
|
karlklose
2014/12/01 10:13:31
Why not `new Set.fom`?
ahe
2014/12/01 10:28:35
The field is final.
|
| + ..clear() |
| + ..addAll(_emittedClasses); |
| + } |
| List<jsAst.Statement> inherits = <jsAst.Statement>[]; |