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

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

Issue 1435853002: Register closures using StaticUse. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « pkg/compiler/lib/src/deferred_load.dart ('k') | pkg/compiler/lib/src/js_backend/backend.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) 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
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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
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:
631 // TODO(johnniwinther): Avoid this. Currently [FIELD_GET] and 630 // TODO(johnniwinther): Avoid this. Currently [FIELD_GET] and
632 // [FIELD_SET] contains [BoxFieldElement]s which we cannot enqueue. 631 // [FIELD_SET] contains [BoxFieldElement]s which we cannot enqueue.
633 addElement = false; 632 addElement = false;
634 break; 633 break;
634 case StaticUseKind.CLOSURE:
sigurdm 2015/11/11 11:19:02 Merge with previous 2 cases?
Johnni Winther 2015/11/11 18:34:02 Done.
635 addElement = false;
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 }
643 645
644 void registerTypeUse(TypeUse typeUse) { 646 void registerTypeUse(TypeUse typeUse) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/deferred_load.dart ('k') | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698