| 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 library dart2js.enqueue; | 5 library dart2js.enqueue; |
| 6 | 6 |
| 7 import 'dart:collection' show | 7 import 'dart:collection' show |
| 8 Queue; | 8 Queue; |
| 9 | 9 |
| 10 import 'common.dart'; | 10 import 'common.dart'; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 * Returns [true] if the element was actually added to the queue. | 163 * Returns [true] if the element was actually added to the queue. |
| 164 */ | 164 */ |
| 165 bool internalAddToWorkList(Element element); | 165 bool internalAddToWorkList(Element element); |
| 166 | 166 |
| 167 /// Apply the [worldImpact] of processing [element] to this enqueuer. | 167 /// Apply the [worldImpact] of processing [element] to this enqueuer. |
| 168 void applyImpact(Element element, WorldImpact worldImpact) { | 168 void applyImpact(Element element, WorldImpact worldImpact) { |
| 169 // TODO(johnniwinther): Optimize the application of the world impact. | 169 // TODO(johnniwinther): Optimize the application of the world impact. |
| 170 worldImpact.dynamicUses.forEach(registerDynamicUse); | 170 worldImpact.dynamicUses.forEach(registerDynamicUse); |
| 171 worldImpact.staticUses.forEach(registerStaticUse); | 171 worldImpact.staticUses.forEach(registerStaticUse); |
| 172 worldImpact.typeUses.forEach(registerTypeUse); | 172 worldImpact.typeUses.forEach(registerTypeUse); |
| 173 worldImpact.closures.forEach(registerClosure); | |
| 174 } | 173 } |
| 175 | 174 |
| 176 void registerInstantiatedType(InterfaceType type, | 175 void registerInstantiatedType(InterfaceType type, |
| 177 {bool mirrorUsage: false}) { | 176 {bool mirrorUsage: false}) { |
| 178 task.measure(() { | 177 task.measure(() { |
| 179 ClassElement cls = type.element; | 178 ClassElement cls = type.element; |
| 180 cls.ensureResolved(resolution); | 179 cls.ensureResolved(resolution); |
| 181 bool isNative = compiler.backend.isNative(cls); | 180 bool isNative = compiler.backend.isNative(cls); |
| 182 universe.registerTypeInstantiation( | 181 universe.registerTypeInstantiation( |
| 183 type, | 182 type, |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 message: "Element ${element} is not the declaration.")); | 620 message: "Element ${element} is not the declaration.")); |
| 622 universe.registerStaticUse(staticUse); | 621 universe.registerStaticUse(staticUse); |
| 623 compiler.backend.registerStaticUse(element, this); | 622 compiler.backend.registerStaticUse(element, this); |
| 624 bool addElement = true; | 623 bool addElement = true; |
| 625 switch (staticUse.kind) { | 624 switch (staticUse.kind) { |
| 626 case StaticUseKind.STATIC_TEAR_OFF: | 625 case StaticUseKind.STATIC_TEAR_OFF: |
| 627 compiler.backend.registerGetOfStaticFunction(this); | 626 compiler.backend.registerGetOfStaticFunction(this); |
| 628 break; | 627 break; |
| 629 case StaticUseKind.FIELD_GET: | 628 case StaticUseKind.FIELD_GET: |
| 630 case StaticUseKind.FIELD_SET: | 629 case StaticUseKind.FIELD_SET: |
| 630 case StaticUseKind.CLOSURE: |
| 631 // TODO(johnniwinther): Avoid this. Currently [FIELD_GET] and | 631 // TODO(johnniwinther): Avoid this. Currently [FIELD_GET] and |
| 632 // [FIELD_SET] contains [BoxFieldElement]s which we cannot enqueue. | 632 // [FIELD_SET] contains [BoxFieldElement]s which we cannot enqueue. |
| 633 // Also [CLOSURE] contains [LocalFunctionElement] which we cannot |
| 634 // enqueue. |
| 633 addElement = false; | 635 addElement = false; |
| 634 break; | 636 break; |
| 635 case StaticUseKind.SUPER_TEAR_OFF: | 637 case StaticUseKind.SUPER_TEAR_OFF: |
| 636 case StaticUseKind.GENERAL: | 638 case StaticUseKind.GENERAL: |
| 637 break; | 639 break; |
| 638 } | 640 } |
| 639 if (addElement) { | 641 if (addElement) { |
| 640 addToWorkList(element); | 642 addToWorkList(element); |
| 641 } | 643 } |
| 642 } | 644 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 void registerClosurizedMember(TypedElement element) { | 683 void registerClosurizedMember(TypedElement element) { |
| 682 assert(element.isInstanceMember); | 684 assert(element.isInstanceMember); |
| 683 if (element.computeType(resolution).containsTypeVariables) { | 685 if (element.computeType(resolution).containsTypeVariables) { |
| 684 compiler.backend.registerClosureWithFreeTypeVariables( | 686 compiler.backend.registerClosureWithFreeTypeVariables( |
| 685 element, this, compiler.globalDependencies); | 687 element, this, compiler.globalDependencies); |
| 686 } | 688 } |
| 687 compiler.backend.registerBoundClosure(this); | 689 compiler.backend.registerBoundClosure(this); |
| 688 universe.closurizedMembers.add(element); | 690 universe.closurizedMembers.add(element); |
| 689 } | 691 } |
| 690 | 692 |
| 691 void registerClosure(LocalFunctionElement element) { | |
| 692 universe.allClosures.add(element); | |
| 693 } | |
| 694 | |
| 695 void forEach(void f(WorkItem work)) { | 693 void forEach(void f(WorkItem work)) { |
| 696 do { | 694 do { |
| 697 while (queue.isNotEmpty) { | 695 while (queue.isNotEmpty) { |
| 698 // TODO(johnniwinther): Find an optimal process order. | 696 // TODO(johnniwinther): Find an optimal process order. |
| 699 filter.processWorkItem(f, queue.removeLast()); | 697 filter.processWorkItem(f, queue.removeLast()); |
| 700 } | 698 } |
| 701 List recents = recentClasses.toList(growable: false); | 699 List recents = recentClasses.toList(growable: false); |
| 702 recentClasses.clear(); | 700 recentClasses.clear(); |
| 703 if (!onQueueEmpty(recents)) recentClasses.addAll(recents); | 701 if (!onQueueEmpty(recents)) recentClasses.addAll(recents); |
| 704 } while (queue.isNotEmpty || recentClasses.isNotEmpty); | 702 } while (queue.isNotEmpty || recentClasses.isNotEmpty); |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 @override | 1033 @override |
| 1036 void processStaticUse(Enqueuer enqueuer, StaticUse staticUse) { | 1034 void processStaticUse(Enqueuer enqueuer, StaticUse staticUse) { |
| 1037 enqueuer.registerStaticUseInternal(staticUse); | 1035 enqueuer.registerStaticUseInternal(staticUse); |
| 1038 } | 1036 } |
| 1039 | 1037 |
| 1040 @override | 1038 @override |
| 1041 void processDynamicUse(Enqueuer enqueuer, DynamicUse dynamicUse) { | 1039 void processDynamicUse(Enqueuer enqueuer, DynamicUse dynamicUse) { |
| 1042 enqueuer.handleUnseenSelectorInternal(dynamicUse); | 1040 enqueuer.handleUnseenSelectorInternal(dynamicUse); |
| 1043 } | 1041 } |
| 1044 } | 1042 } |
| OLD | NEW |