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

Side by Side Diff: dart/pkg/dart2js_incremental/lib/library_updater.dart

Issue 796463003: Incremental compilation: correctly track emitted constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Constant output list may be null. Created 6 years 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
« no previous file with comments | « no previous file | dart/tests/try/web/incremental_compilation_update_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 dart2js_incremental.library_updater; 5 library dart2js_incremental.library_updater;
6 6
7 import 'dart:async' show 7 import 'dart:async' show
8 Future; 8 Future;
9 9
10 import 'dart:convert' show 10 import 'dart:convert' show
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 137
138 bool _hasComputedNeeds = false; 138 bool _hasComputedNeeds = false;
139 139
140 LibraryUpdater( 140 LibraryUpdater(
141 Compiler compiler, 141 Compiler compiler,
142 this.inputProvider, 142 this.inputProvider,
143 this.uri, 143 this.uri,
144 this.logTime, 144 this.logTime,
145 this.logVerbose) 145 this.logVerbose)
146 : this.compiler = compiler, 146 : this.compiler = compiler,
147 _emittedClasses = new Set.from( 147 _emittedClasses = _getEmittedClasses(compiler),
148 compiler == null 148 _directlyInstantiatedClasses =
149 ? [] : compiler.backend.emitter.neededClasses), 149 _getDirectlyInstantiatedClasses(compiler),
150 _directlyInstantiatedClasses = new Set.from( 150 _compiledConstants = _getEmittedConstants(compiler);
151 compiler == null 151
152 ? [] : compiler.codegenWorld.directlyInstantiatedClasses), 152 /// Returns the classes emitted by [compiler].
153 _compiledConstants = new Set<ConstantValue>.identity()..addAll( 153 static Set<ClassElementX> _getEmittedClasses(Compiler compiler) {
154 compiler == null 154 if (compiler == null) return null;
155 ? [] : compiler.backend.constants.compiledConstants); 155 return new Set.from(compiler.backend.emitter.neededClasses);
156 }
157
158 /// Returns the directly instantantiated classes seen by [compiler].
159 static Set<ClassElementX> _getDirectlyInstantiatedClasses(Compiler compiler) {
160 if (compiler == null) return null;
161 return new Set.from(compiler.codegenWorld.directlyInstantiatedClasses);
162 }
163
164 /// Returns the constants emitted by [compiler].
165 static Set<ConstantValue> _getEmittedConstants(Compiler compiler) {
166 if (compiler != null) {
167 List<ConstantValue> constants =
168 compiler.backend.emitter.outputConstantLists[
169 compiler.deferredLoadTask.mainOutputUnit];
170 if (constants != null) {
171 return new Set<ConstantValue>.identity()..addAll(constants);
172 }
173 }
174 return null;
175 }
156 176
157 /// When [true], updates must be applied (using [applyUpdates]) before the 177 /// When [true], updates must be applied (using [applyUpdates]) before the
158 /// [compiler]'s state correctly reflects the updated program. 178 /// [compiler]'s state correctly reflects the updated program.
159 bool get hasPendingUpdates => !updates.isEmpty; 179 bool get hasPendingUpdates => !updates.isEmpty;
160 180
161 bool get failed => !_failedUpdates.isEmpty; 181 bool get failed => !_failedUpdates.isEmpty;
162 182
163 /// Used as tear-off passed to [LibraryLoaderTask.resetAsync]. 183 /// Used as tear-off passed to [LibraryLoaderTask.resetAsync].
164 Future<bool> reuseLibrary(LibraryElement library) { 184 Future<bool> reuseLibrary(LibraryElement library) {
165 assert(compiler != null); 185 assert(compiler != null);
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 Set<ConstantValue> newConstants = new Set<ConstantValue>.identity()..addAll( 701 Set<ConstantValue> newConstants = new Set<ConstantValue>.identity()..addAll(
682 compiler.backend.constants.compiledConstants); 702 compiler.backend.constants.compiledConstants);
683 newConstants.removeAll(_compiledConstants); 703 newConstants.removeAll(_compiledConstants);
684 704
685 if (!newConstants.isEmpty) { 705 if (!newConstants.isEmpty) {
686 _ensureAllNeededEntitiesComputed(); 706 _ensureAllNeededEntitiesComputed();
687 List<ConstantValue> constants = 707 List<ConstantValue> constants =
688 emitter.outputConstantLists[compiler.deferredLoadTask.mainOutputUnit]; 708 emitter.outputConstantLists[compiler.deferredLoadTask.mainOutputUnit];
689 if (constants != null) { 709 if (constants != null) {
690 for (ConstantValue constant in constants) { 710 for (ConstantValue constant in constants) {
691 if (newConstants.contains(constant)) { 711 if (!_compiledConstants.contains(constant)) {
692 jsAst.Statement constantInitializer = emitter.oldEmitter 712 jsAst.Statement constantInitializer =
693 .buildConstantInitializer(constant).toStatement(); 713 emitter.oldEmitter.buildConstantInitializer(constant)
714 .toStatement();
694 updates.add(constantInitializer); 715 updates.add(constantInitializer);
695 } 716 }
696 } 717 }
697 } 718 }
698 } 719 }
699 720
700 updates.add(js.statement(r''' 721 updates.add(js.statement(r'''
701 if (#helper.pendingStubs) { 722 if (#helper.pendingStubs) {
702 #helper.pendingStubs.map(function(e) { return e(); }); 723 #helper.pendingStubs.map(function(e) { return e(); });
703 #helper.pendingStubs = void 0; 724 #helper.pendingStubs = void 0;
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
1274 List<String> computeFields(ClassElement cls) { 1295 List<String> computeFields(ClassElement cls) {
1275 // TODO(ahe): Rewrite for new emitter. 1296 // TODO(ahe): Rewrite for new emitter.
1276 ClassBuilder builder = new ClassBuilder(cls, namer); 1297 ClassBuilder builder = new ClassBuilder(cls, namer);
1277 classEmitter.emitFields(cls, builder); 1298 classEmitter.emitFields(cls, builder);
1278 return builder.fields; 1299 return builder.fields;
1279 } 1300 }
1280 } 1301 }
1281 1302
1282 // TODO(ahe): Remove this method. 1303 // TODO(ahe): Remove this method.
1283 NO_WARN(x) => x; 1304 NO_WARN(x) => x;
OLDNEW
« no previous file with comments | « no previous file | dart/tests/try/web/incremental_compilation_update_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698