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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/enqueue.dart

Issue 24282005: Move compile-time constant registrations to the backend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status Created 7 years, 2 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 | Annotate | Revision Log
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 /// Returns [:true:] if [member] has been processed by this enqueuer. 97 /// Returns [:true:] if [member] has been processed by this enqueuer.
98 bool isProcessed(Element member); 98 bool isProcessed(Element member);
99 99
100 /** 100 /**
101 * Documentation wanted -- johnniwinther 101 * Documentation wanted -- johnniwinther
102 * 102 *
103 * Invariant: [element] must be a declaration element. 103 * Invariant: [element] must be a declaration element.
104 */ 104 */
105 void addToWorkList(Element element) { 105 void addToWorkList(Element element) {
106 assert(invariant(element, element.isDeclaration)); 106 assert(invariant(element, element.isDeclaration));
107 if (element.isForeign(compiler)) return;
108 internalAddToWorkList(element); 107 internalAddToWorkList(element);
109 } 108 }
110 109
111 /** 110 /**
112 * Adds [element] to the work list if it has not already been processed. 111 * Adds [element] to the work list if it has not already been processed.
113 */ 112 */
114 void internalAddToWorkList(Element element); 113 void internalAddToWorkList(Element element);
115 114
116 void registerInstantiatedType(InterfaceType type, TreeElements elements) { 115 void registerInstantiatedType(InterfaceType type, TreeElements elements) {
117 task.measure(() { 116 task.measure(() {
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 if (owner == null) { 606 if (owner == null) {
608 owner = element; 607 owner = element;
609 } 608 }
610 return resolvedElements[owner.declaration]; 609 return resolvedElements[owner.declaration];
611 } 610 }
612 611
613 void internalAddToWorkList(Element element) { 612 void internalAddToWorkList(Element element) {
614 if (getCachedElements(element) != null) return; 613 if (getCachedElements(element) != null) return;
615 if (queueIsClosed) { 614 if (queueIsClosed) {
616 throw new SpannableAssertionFailure(element, 615 throw new SpannableAssertionFailure(element,
617 "Resolution work list is closed."); 616 "Resolution work list is closed. Trying to add $element.");
618 } 617 }
619 compiler.world.registerUsedElement(element); 618 compiler.world.registerUsedElement(element);
620 619
621 queue.add(new ResolutionWorkItem(element, itemCompilationContextCreator())); 620 queue.add(new ResolutionWorkItem(element, itemCompilationContextCreator()));
622 621
623 // Enable isolate support if we start using something from the 622 // Enable isolate support if we start using something from the
624 // isolate library, or timers for the async library. 623 // isolate library, or timers for the async library.
625 LibraryElement library = element.getLibrary(); 624 LibraryElement library = element.getLibrary();
626 if (!compiler.hasIsolateSupport()) { 625 if (!compiler.hasIsolateSupport()) {
627 String uri = library.canonicalUri.toString(); 626 String uri = library.canonicalUri.toString();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 compiler.enabledNoSuchMethod = true; 673 compiler.enabledNoSuchMethod = true;
675 compiler.backend.enableNoSuchMethod(this); 674 compiler.backend.enableNoSuchMethod(this);
676 } 675 }
677 676
678 /** 677 /**
679 * Adds an action to the post-processing queue. 678 * Adds an action to the post-processing queue.
680 * 679 *
681 * The action is performed as part of the post-processing immediately after 680 * The action is performed as part of the post-processing immediately after
682 * the resolution queue has been closed. As a consequence, [action] must not 681 * the resolution queue has been closed. As a consequence, [action] must not
683 * add elements to the resolution queue. 682 * add elements to the resolution queue.
683 *
684 * The queue is processed in FIFO order.
684 */ 685 */
685 void addPostProcessAction(Element element, PostProcessAction action) { 686 void addPostProcessAction(Element element, PostProcessAction action) {
686 if (queueIsClosed) { 687 if (queueIsClosed) {
687 throw new SpannableAssertionFailure(element, 688 throw new SpannableAssertionFailure(element,
688 "Resolution work list is closed."); 689 "Resolution work list is closed. "
690 "Trying to add post process action for $element");
689 } 691 }
690 postQueue.add(new PostProcessTask(element, action)); 692 postQueue.add(new PostProcessTask(element, action));
691 } 693 }
692 694
693 void forEachPostProcessTask(f(PostProcessTask work)) { 695 void forEachPostProcessTask(f(PostProcessTask work)) {
694 while (!postQueue.isEmpty) { 696 while (!postQueue.isEmpty) {
695 f(postQueue.removeFirst()); 697 f(postQueue.removeFirst());
696 } 698 }
697 } 699 }
698 700
(...skipping 14 matching lines...) Expand all
713 715
714 CodegenEnqueuer(Compiler compiler, 716 CodegenEnqueuer(Compiler compiler,
715 ItemCompilationContext itemCompilationContextCreator()) 717 ItemCompilationContext itemCompilationContextCreator())
716 : super('codegen enqueuer', compiler, itemCompilationContextCreator), 718 : super('codegen enqueuer', compiler, itemCompilationContextCreator),
717 queue = new Queue<CodegenWorkItem>(); 719 queue = new Queue<CodegenWorkItem>();
718 720
719 bool isProcessed(Element member) => 721 bool isProcessed(Element member) =>
720 member.isAbstract(compiler) || generatedCode.containsKey(member); 722 member.isAbstract(compiler) || generatedCode.containsKey(member);
721 723
722 void internalAddToWorkList(Element element) { 724 void internalAddToWorkList(Element element) {
725 // Don't generate code for foreign elements.
726 if (element.isForeign(compiler)) return;
727
723 // Codegen inlines field initializers, so it does not need to add 728 // Codegen inlines field initializers, so it does not need to add
724 // individual fields in the work list. 729 // individual fields in the work list.
725 if (element.isField() && element.isInstanceMember()) return; 730 if (element.isField() && element.isInstanceMember()) return;
726 731
727 if (queueIsClosed) { 732 if (queueIsClosed) {
728 throw new SpannableAssertionFailure(element, 733 throw new SpannableAssertionFailure(element,
729 "Codegen work list is closed."); 734 "Codegen work list is closed. Trying to add $element");
730 } 735 }
731 CodegenWorkItem workItem = new CodegenWorkItem( 736 CodegenWorkItem workItem = new CodegenWorkItem(
732 element, itemCompilationContextCreator()); 737 element, itemCompilationContextCreator());
733 queue.add(workItem); 738 queue.add(workItem);
734 } 739 }
735 740
736 void _logSpecificSummary(log(message)) { 741 void _logSpecificSummary(log(message)) {
737 log('Compiled ${generatedCode.length} methods.'); 742 log('Compiled ${generatedCode.length} methods.');
738 } 743 }
739 } 744 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698