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

Side by Side Diff: pkg/compiler/lib/src/enqueue.dart

Issue 1192103002: Support serialization of the compiler backbone. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of dart2js; 5 part of dart2js;
6 6
7 typedef ItemCompilationContext ItemCompilationContextCreator(); 7 typedef ItemCompilationContext ItemCompilationContextCreator();
8 8
9 class EnqueueTask extends CompilerTask { 9 class EnqueueTask extends CompilerTask {
10 final ResolutionEnqueuer resolution; 10 final ResolutionEnqueuer resolution;
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 // supertypes. 252 // supertypes.
253 cls.ensureResolved(compiler); 253 cls.ensureResolved(compiler);
254 254
255 void processClass(ClassElement cls) { 255 void processClass(ClassElement cls) {
256 if (_processedClasses.contains(cls)) return; 256 if (_processedClasses.contains(cls)) return;
257 257
258 _processedClasses.add(cls); 258 _processedClasses.add(cls);
259 recentClasses.add(cls); 259 recentClasses.add(cls);
260 cls.ensureResolved(compiler); 260 cls.ensureResolved(compiler);
261 cls.implementation.forEachMember(processInstantiatedClassMember); 261 cls.implementation.forEachMember(processInstantiatedClassMember);
262 if (isResolutionQueue) { 262 if (isResolutionQueue && !cls.isSynthesized) {
263 compiler.resolver.checkClass(cls); 263 compiler.resolver.checkClass(cls);
264 } 264 }
265 // We only tell the backend once that [cls] was instantiated, so 265 // We only tell the backend once that [cls] was instantiated, so
266 // any additional dependencies must be treated as global 266 // any additional dependencies must be treated as global
267 // dependencies. 267 // dependencies.
268 compiler.backend.registerInstantiatedClass( 268 compiler.backend.registerInstantiatedClass(
269 cls, this, compiler.globalDependencies); 269 cls, this, compiler.globalDependencies);
270 } 270 }
271 processClass(cls); 271 processClass(cls);
272 for (Link<DartType> supertypes = cls.allSupertypes; 272 for (Link<DartType> supertypes = cls.allSupertypes;
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 * [MirrorsUsed] pattern, as we do not have a complete picture of the world, 717 * [MirrorsUsed] pattern, as we do not have a complete picture of the world,
718 * yet. 718 * yet.
719 */ 719 */
720 bool shouldIncludeElementDueToMirrors(Element element, 720 bool shouldIncludeElementDueToMirrors(Element element,
721 {bool includedEnclosing}) { 721 {bool includedEnclosing}) {
722 return includedEnclosing || compiler.backend.requiredByMirrorSystem(element) ; 722 return includedEnclosing || compiler.backend.requiredByMirrorSystem(element) ;
723 } 723 }
724 724
725 bool internalAddToWorkList(Element element) { 725 bool internalAddToWorkList(Element element) {
726 if (element.isErroneous) return false; 726 if (element.isErroneous) return false;
727
727 assert(invariant(element, element is AnalyzableElement, 728 assert(invariant(element, element is AnalyzableElement,
728 message: 'Element $element is not analyzable.')); 729 message: 'Element $element is not analyzable.'));
729 if (hasBeenResolved(element)) return false; 730 if (hasBeenResolved(element)) return false;
730 if (queueIsClosed) { 731 if (queueIsClosed) {
731 throw new SpannableAssertionFailure(element, 732 throw new SpannableAssertionFailure(element,
732 "Resolution work list is closed. Trying to add $element."); 733 "Resolution work list is closed. Trying to add $element.");
733 } 734 }
734 735
735 compiler.world.registerUsedElement(element); 736 compiler.world.registerUsedElement(element);
736 737
737 queue.add(new ResolutionWorkItem(element, itemCompilationContextCreator())); 738 ResolutionWorkItem workItem;
739 if (compiler.serialization.isDeserialized(element)) {
740 workItem = compiler.serialization.createResolutionWorkItem(
741 element, itemCompilationContextCreator());
742 } else {
743 workItem = new ResolutionWorkItem(
744 element, itemCompilationContextCreator());
745 }
746 queue.add(workItem);
738 747
739 // Enable isolate support if we start using something from the isolate 748 // Enable isolate support if we start using something from the isolate
740 // library, or timers for the async library. We exclude constant fields, 749 // library, or timers for the async library. We exclude constant fields,
741 // which are ending here because their initializing expression is compiled. 750 // which are ending here because their initializing expression is compiled.
742 LibraryElement library = element.library; 751 LibraryElement library = element.library;
743 if (!compiler.hasIsolateSupport && 752 if (!compiler.hasIsolateSupport &&
744 (!element.isField || !element.isConst)) { 753 (!element.isField || !element.isConst)) {
745 String uri = library.canonicalUri.toString(); 754 String uri = library.canonicalUri.toString();
746 if (uri == 'dart:isolate') { 755 if (uri == 'dart:isolate') {
747 enableIsolateSupport(); 756 enableIsolateSupport();
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 void processWorkItem(void f(WorkItem work), WorkItem work) { 952 void processWorkItem(void f(WorkItem work), WorkItem work) {
944 f(work); 953 f(work);
945 } 954 }
946 } 955 }
947 956
948 void removeFromSet(Map<String, Set<Element>> map, Element element) { 957 void removeFromSet(Map<String, Set<Element>> map, Element element) {
949 Set<Element> set = map[element.name]; 958 Set<Element> set = map[element.name];
950 if (set == null) return; 959 if (set == null) return;
951 set.remove(element); 960 set.remove(element);
952 } 961 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698