| 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 Queue; | 7 import 'dart:collection' show Queue; |
| 8 | 8 |
| 9 import 'cache_strategy.dart'; | 9 import 'cache_strategy.dart'; |
| 10 import 'common/backend_api.dart' show Backend; | 10 import 'common/backend_api.dart' show Backend; |
| 11 import 'common/names.dart' show Identifiers; | 11 import 'common/names.dart' show Identifiers; |
| 12 import 'common/resolution.dart' show Resolution, ResolutionWorkItem; | 12 import 'common/resolution.dart' show Resolution, ResolutionWorkItem; |
| 13 import 'common/tasks.dart' show CompilerTask; | 13 import 'common/tasks.dart' show CompilerTask; |
| 14 import 'common/work.dart' show WorkItem; | 14 import 'common/work.dart' show WorkItem; |
| 15 import 'common.dart'; | 15 import 'common.dart'; |
| 16 import 'compiler.dart' show Compiler, GlobalDependencyRegistry; | 16 import 'compiler.dart' show Compiler, GlobalDependencyRegistry; |
| 17 import 'core_types.dart' show CommonElements; | 17 import 'core_types.dart' show CommonElements; |
| 18 import 'options.dart'; | 18 import 'options.dart'; |
| 19 import 'dart_types.dart' show DartType, InterfaceType; | 19 import 'dart_types.dart' show DartType, InterfaceType; |
| 20 import 'elements/elements.dart' | 20 import 'elements/elements.dart' |
| 21 show | 21 show |
| 22 AnalyzableElement, | 22 AnalyzableElement, |
| 23 AstElement, | 23 AstElement, |
| 24 ClassElement, | 24 ClassElement, |
| 25 ConstructorElement, |
| 25 Element, | 26 Element, |
| 26 Entity, | 27 Entity, |
| 27 FunctionElement, | 28 FunctionElement, |
| 28 LibraryElement, | 29 LibraryElement, |
| 29 LocalFunctionElement, | 30 LocalFunctionElement, |
| 30 TypedElement; | 31 TypedElement; |
| 31 import 'native/native.dart' as native; | 32 import 'native/native.dart' as native; |
| 32 import 'types/types.dart' show TypeMaskStrategy; | 33 import 'types/types.dart' show TypeMaskStrategy; |
| 33 import 'universe/selector.dart' show Selector; | 34 import 'universe/selector.dart' show Selector; |
| 34 import 'universe/world_builder.dart'; | 35 import 'universe/world_builder.dart'; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 152 |
| 152 ResolutionEnqueuer( | 153 ResolutionEnqueuer( |
| 153 this.task, | 154 this.task, |
| 154 this.options, | 155 this.options, |
| 155 this.resolution, | 156 this.resolution, |
| 156 this.filter, | 157 this.filter, |
| 157 this.strategy, | 158 this.strategy, |
| 158 this.globalDependencies, | 159 this.globalDependencies, |
| 159 Backend backend, | 160 Backend backend, |
| 160 CommonElements commonElements, | 161 CommonElements commonElements, |
| 161 CacheStrategy cacheStrategy) | 162 CacheStrategy cacheStrategy, |
| 162 : this.name = 'resolution enqueuer', | 163 [this.name = 'resolution enqueuer']) |
| 163 this.backend = backend, | 164 : this.backend = backend, |
| 164 this.commonElements = commonElements, | 165 this.commonElements = commonElements, |
| 165 this.nativeEnqueuer = backend.nativeResolutionEnqueuer(), | 166 this.nativeEnqueuer = backend.nativeResolutionEnqueuer(), |
| 166 processedElements = new Set<AstElement>(), | 167 processedElements = new Set<AstElement>(), |
| 167 queue = new Queue<ResolutionWorkItem>(), | 168 queue = new Queue<ResolutionWorkItem>(), |
| 168 deferredQueue = new Queue<_DeferredAction>(), | 169 deferredQueue = new Queue<_DeferredAction>(), |
| 169 _universe = new ResolutionWorldBuilderImpl( | 170 _universe = new ResolutionWorldBuilderImpl( |
| 170 backend, commonElements, cacheStrategy, const TypeMaskStrategy()) { | 171 backend, commonElements, cacheStrategy, const TypeMaskStrategy()) { |
| 171 impactVisitor = new _EnqueuerImpactVisitor(this); | 172 impactVisitor = new _EnqueuerImpactVisitor(this); |
| 172 } | 173 } |
| 173 | 174 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 197 {Element impactSource}) { | 198 {Element impactSource}) { |
| 198 impactStrategy.visitImpact( | 199 impactStrategy.visitImpact( |
| 199 impactSource, worldImpact, impactVisitor, impactUse); | 200 impactSource, worldImpact, impactVisitor, impactUse); |
| 200 } | 201 } |
| 201 | 202 |
| 202 void registerInstantiatedType(InterfaceType type) { | 203 void registerInstantiatedType(InterfaceType type) { |
| 203 _registerInstantiatedType(type, globalDependency: true); | 204 _registerInstantiatedType(type, globalDependency: true); |
| 204 } | 205 } |
| 205 | 206 |
| 206 void _registerInstantiatedType(InterfaceType type, | 207 void _registerInstantiatedType(InterfaceType type, |
| 207 {bool mirrorUsage: false, | 208 {ConstructorElement constructor, |
| 209 bool mirrorUsage: false, |
| 208 bool nativeUsage: false, | 210 bool nativeUsage: false, |
| 209 bool globalDependency: false}) { | 211 bool globalDependency: false, |
| 212 bool isRedirection: false}) { |
| 210 task.measure(() { | 213 task.measure(() { |
| 211 ClassElement cls = type.element; | 214 ClassElement cls = type.element; |
| 212 cls.ensureResolved(resolution); | 215 cls.ensureResolved(resolution); |
| 213 bool isNative = backend.isNative(cls); | 216 bool isNative = backend.isNative(cls); |
| 214 _universe.registerTypeInstantiation(type, | 217 _universe.registerTypeInstantiation(type, |
| 218 constructor: constructor, |
| 215 isNative: isNative, | 219 isNative: isNative, |
| 216 byMirrors: mirrorUsage, onImplemented: (ClassElement cls) { | 220 byMirrors: mirrorUsage, |
| 221 isRedirection: isRedirection, onImplemented: (ClassElement cls) { |
| 217 backend.registerImplementedClass(cls, this); | 222 backend.registerImplementedClass(cls, this); |
| 218 }); | 223 }); |
| 219 if (globalDependency && !mirrorUsage) { | 224 if (globalDependency && !mirrorUsage) { |
| 220 globalDependencies.registerDependency(type.element); | 225 globalDependencies.registerDependency(type.element); |
| 221 } | 226 } |
| 222 if (nativeUsage) { | 227 if (nativeUsage) { |
| 223 nativeEnqueuer.onInstantiatedType(type); | 228 nativeEnqueuer.onInstantiatedType(type); |
| 224 } | 229 } |
| 225 backend.registerInstantiatedType(type); | 230 backend.registerInstantiatedType(type); |
| 226 // TODO(johnniwinther): Share this reasoning with [Universe]. | 231 // TODO(johnniwinther): Share this reasoning with [Universe]. |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 universe.closuresWithFreeTypeVariables.add(closure); | 451 universe.closuresWithFreeTypeVariables.add(closure); |
| 447 } | 452 } |
| 448 addElement = false; | 453 addElement = false; |
| 449 break; | 454 break; |
| 450 case StaticUseKind.SUPER_FIELD_SET: | 455 case StaticUseKind.SUPER_FIELD_SET: |
| 451 case StaticUseKind.SUPER_TEAR_OFF: | 456 case StaticUseKind.SUPER_TEAR_OFF: |
| 452 case StaticUseKind.GENERAL: | 457 case StaticUseKind.GENERAL: |
| 453 break; | 458 break; |
| 454 case StaticUseKind.CONSTRUCTOR_INVOKE: | 459 case StaticUseKind.CONSTRUCTOR_INVOKE: |
| 455 case StaticUseKind.CONST_CONSTRUCTOR_INVOKE: | 460 case StaticUseKind.CONST_CONSTRUCTOR_INVOKE: |
| 456 _registerTypeUse(new TypeUse.instantiation(staticUse.type)); | 461 _registerInstantiatedType(staticUse.type, |
| 462 constructor: staticUse.element, globalDependency: false); |
| 463 break; |
| 464 case StaticUseKind.REDIRECTION: |
| 465 _registerInstantiatedType(staticUse.type, |
| 466 constructor: staticUse.element, |
| 467 globalDependency: false, |
| 468 isRedirection: true); |
| 457 break; | 469 break; |
| 458 case StaticUseKind.DIRECT_INVOKE: | 470 case StaticUseKind.DIRECT_INVOKE: |
| 459 invariant( | 471 invariant( |
| 460 element, 'Direct static use is not supported for resolution.'); | 472 element, 'Direct static use is not supported for resolution.'); |
| 461 break; | 473 break; |
| 462 } | 474 } |
| 463 if (addElement) { | 475 if (addElement) { |
| 464 addToWorkList(element); | 476 addToWorkList(element); |
| 465 } | 477 } |
| 466 } | 478 } |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 } | 774 } |
| 763 | 775 |
| 764 typedef void _DeferredActionFunction(); | 776 typedef void _DeferredActionFunction(); |
| 765 | 777 |
| 766 class _DeferredAction { | 778 class _DeferredAction { |
| 767 final Element element; | 779 final Element element; |
| 768 final _DeferredActionFunction action; | 780 final _DeferredActionFunction action; |
| 769 | 781 |
| 770 _DeferredAction(this.element, this.action); | 782 _DeferredAction(this.element, this.action); |
| 771 } | 783 } |
| OLD | NEW |