| OLD | NEW |
| 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 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 log('Resolved ${resolvedElements.length} elements.'); | 714 log('Resolved ${resolvedElements.length} elements.'); |
| 715 } | 715 } |
| 716 } | 716 } |
| 717 | 717 |
| 718 /// [Enqueuer] which is specific to code generation. | 718 /// [Enqueuer] which is specific to code generation. |
| 719 class CodegenEnqueuer extends Enqueuer { | 719 class CodegenEnqueuer extends Enqueuer { |
| 720 final Queue<CodegenWorkItem> queue; | 720 final Queue<CodegenWorkItem> queue; |
| 721 final Map<Element, js.Expression> generatedCode = | 721 final Map<Element, js.Expression> generatedCode = |
| 722 new Map<Element, js.Expression>(); | 722 new Map<Element, js.Expression>(); |
| 723 | 723 |
| 724 final Set<Element> newlyEnqueuedElements; |
| 725 |
| 724 CodegenEnqueuer(Compiler compiler, | 726 CodegenEnqueuer(Compiler compiler, |
| 725 ItemCompilationContext itemCompilationContextCreator()) | 727 ItemCompilationContext itemCompilationContextCreator()) |
| 726 : super('codegen enqueuer', compiler, itemCompilationContextCreator), | 728 : queue = new Queue<CodegenWorkItem>(), |
| 727 queue = new Queue<CodegenWorkItem>(); | 729 newlyEnqueuedElements = compiler.cacheStrategy.newSet(), |
| 730 super('codegen enqueuer', compiler, itemCompilationContextCreator); |
| 728 | 731 |
| 729 bool isProcessed(Element member) => | 732 bool isProcessed(Element member) => |
| 730 member.isAbstract || generatedCode.containsKey(member); | 733 member.isAbstract || generatedCode.containsKey(member); |
| 731 | 734 |
| 732 void internalAddToWorkList(Element element) { | 735 void internalAddToWorkList(Element element) { |
| 736 if (compiler.hasIncrementalSupport) { |
| 737 newlyEnqueuedElements.add(element); |
| 738 } |
| 733 // Don't generate code for foreign elements. | 739 // Don't generate code for foreign elements. |
| 734 if (element.isForeign(compiler)) return; | 740 if (element.isForeign(compiler)) return; |
| 735 | 741 |
| 736 // Codegen inlines field initializers. It only needs to generate | 742 // Codegen inlines field initializers. It only needs to generate |
| 737 // code for checked setters. | 743 // code for checked setters. |
| 738 if (element.isField && element.isInstanceMember) { | 744 if (element.isField && element.isInstanceMember) { |
| 739 if (!compiler.enableTypeAssertions | 745 if (!compiler.enableTypeAssertions |
| 740 || element.enclosingElement.isClosure) { | 746 || element.enclosingElement.isClosure) { |
| 741 return; | 747 return; |
| 742 } | 748 } |
| 743 } | 749 } |
| 744 | 750 |
| 745 if (queueIsClosed) { | 751 if (queueIsClosed) { |
| 746 throw new SpannableAssertionFailure(element, | 752 throw new SpannableAssertionFailure(element, |
| 747 "Codegen work list is closed. Trying to add $element"); | 753 "Codegen work list is closed. Trying to add $element"); |
| 748 } | 754 } |
| 749 CodegenWorkItem workItem = new CodegenWorkItem( | 755 CodegenWorkItem workItem = new CodegenWorkItem( |
| 750 element, itemCompilationContextCreator()); | 756 element, itemCompilationContextCreator()); |
| 751 queue.add(workItem); | 757 queue.add(workItem); |
| 752 } | 758 } |
| 753 | 759 |
| 754 void _logSpecificSummary(log(message)) { | 760 void _logSpecificSummary(log(message)) { |
| 755 log('Compiled ${generatedCode.length} methods.'); | 761 log('Compiled ${generatedCode.length} methods.'); |
| 756 } | 762 } |
| 757 } | 763 } |
| OLD | NEW |