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

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

Issue 1422623014: Add TypeUse. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 import 'js/js.dart' as js; 47 import 'js/js.dart' as js;
48 import 'native/native.dart' as native; 48 import 'native/native.dart' as native;
49 import 'types/types.dart' show 49 import 'types/types.dart' show
50 TypeMaskStrategy; 50 TypeMaskStrategy;
51 import 'universe/selector.dart' show 51 import 'universe/selector.dart' show
52 Selector; 52 Selector;
53 import 'universe/universe.dart'; 53 import 'universe/universe.dart';
54 import 'universe/use.dart' show 54 import 'universe/use.dart' show
55 DynamicUse, 55 DynamicUse,
56 StaticUse, 56 StaticUse,
57 StaticUseKind; 57 StaticUseKind,
58 TypeUse,
59 TypeUseKind;
58 import 'universe/world_impact.dart' show 60 import 'universe/world_impact.dart' show
59 WorldImpact; 61 WorldImpact;
60 import 'util/util.dart' show 62 import 'util/util.dart' show
61 Link, 63 Link,
62 Setlet; 64 Setlet;
63 65
64 typedef ItemCompilationContext ItemCompilationContextCreator(); 66 typedef ItemCompilationContext ItemCompilationContextCreator();
65 67
66 class EnqueueTask extends CompilerTask { 68 class EnqueueTask extends CompilerTask {
67 final ResolutionEnqueuer resolution; 69 final ResolutionEnqueuer resolution;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 * 162 *
161 * Returns [true] if the element was actually added to the queue. 163 * Returns [true] if the element was actually added to the queue.
162 */ 164 */
163 bool internalAddToWorkList(Element element); 165 bool internalAddToWorkList(Element element);
164 166
165 /// Apply the [worldImpact] of processing [element] to this enqueuer. 167 /// Apply the [worldImpact] of processing [element] to this enqueuer.
166 void applyImpact(Element element, WorldImpact worldImpact) { 168 void applyImpact(Element element, WorldImpact worldImpact) {
167 // TODO(johnniwinther): Optimize the application of the world impact. 169 // TODO(johnniwinther): Optimize the application of the world impact.
168 worldImpact.dynamicUses.forEach(registerDynamicUse); 170 worldImpact.dynamicUses.forEach(registerDynamicUse);
169 worldImpact.staticUses.forEach(registerStaticUse); 171 worldImpact.staticUses.forEach(registerStaticUse);
170 worldImpact.instantiatedTypes.forEach(registerInstantiatedType); 172 worldImpact.typeUses.forEach(registerTypeUse);
171 worldImpact.isChecks.forEach(registerIsCheck);
172 worldImpact.asCasts.forEach(registerIsCheck);
173 if (compiler.enableTypeAssertions) {
174 worldImpact.checkedModeChecks.forEach(registerIsCheck);
175 }
176 worldImpact.onCatchTypes.forEach(registerIsCheck);
177 worldImpact.closures.forEach(registerClosure); 173 worldImpact.closures.forEach(registerClosure);
178 } 174 }
179 175
180 void registerInstantiatedType(InterfaceType type, 176 void registerInstantiatedType(InterfaceType type,
181 {bool mirrorUsage: false}) { 177 {bool mirrorUsage: false}) {
182 task.measure(() { 178 task.measure(() {
183 ClassElement cls = type.element; 179 ClassElement cls = type.element;
184 cls.ensureResolved(resolution); 180 cls.ensureResolved(resolution);
185 universe.registerTypeInstantiation( 181 universe.registerTypeInstantiation(
186 type, 182 type,
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 break; 629 break;
634 case StaticUseKind.SUPER_TEAR_OFF: 630 case StaticUseKind.SUPER_TEAR_OFF:
635 case StaticUseKind.GENERAL: 631 case StaticUseKind.GENERAL:
636 break; 632 break;
637 } 633 }
638 if (addElement) { 634 if (addElement) {
639 addToWorkList(element); 635 addToWorkList(element);
640 } 636 }
641 } 637 }
642 638
643 void registerIsCheck(DartType type) { 639 void registerTypeUse(TypeUse typeUse) {
640 DartType type = typeUse.type;
641 switch (typeUse.kind) {
642 case TypeUseKind.INSTANTIATION:
643 registerInstantiatedType(type);
644 break;
645 case TypeUseKind.INSTANTIATION:
646 case TypeUseKind.IS_CHECK:
647 case TypeUseKind.AS_CAST:
648 case TypeUseKind.CATCH_TYPE:
649 _registerIsCheck(type);
650 break;
651 case TypeUseKind.CHECKED_MODE_CHECK:
652 if (compiler.enableTypeAssertions) {
653 _registerIsCheck(type);
654 }
655 break;
656 case TypeUseKind.TYPE_LITERAL:
657 break;
658 }
659 }
660
661 void _registerIsCheck(DartType type) {
644 type = universe.registerIsCheck(type, compiler); 662 type = universe.registerIsCheck(type, compiler);
645 // Even in checked mode, type annotations for return type and argument 663 // Even in checked mode, type annotations for return type and argument
646 // types do not imply type checks, so there should never be a check 664 // types do not imply type checks, so there should never be a check
647 // against the type variable of a typedef. 665 // against the type variable of a typedef.
648 assert(!type.isTypeVariable || 666 assert(!type.isTypeVariable ||
649 !type.element.enclosingElement.isTypedef); 667 !type.element.enclosingElement.isTypedef);
650 } 668 }
651 669
652 void registerCallMethodWithFreeTypeVariables(Element element) { 670 void registerCallMethodWithFreeTypeVariables(Element element) {
653 compiler.backend.registerCallMethodWithFreeTypeVariables( 671 compiler.backend.registerCallMethodWithFreeTypeVariables(
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 @override 1030 @override
1013 void processStaticUse(Enqueuer enqueuer, StaticUse staticUse) { 1031 void processStaticUse(Enqueuer enqueuer, StaticUse staticUse) {
1014 enqueuer.registerStaticUseInternal(staticUse); 1032 enqueuer.registerStaticUseInternal(staticUse);
1015 } 1033 }
1016 1034
1017 @override 1035 @override
1018 void processDynamicUse(Enqueuer enqueuer, DynamicUse dynamicUse) { 1036 void processDynamicUse(Enqueuer enqueuer, DynamicUse dynamicUse) {
1019 enqueuer.handleUnseenSelectorInternal(dynamicUse); 1037 enqueuer.handleUnseenSelectorInternal(dynamicUse);
1020 } 1038 }
1021 } 1039 }
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