| 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; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 ResolutionEnqueuer get resolution => _resolution; | 60 ResolutionEnqueuer get resolution => _resolution; |
| 61 Enqueuer get codegen => _codegen; | 61 Enqueuer get codegen => _codegen; |
| 62 | 62 |
| 63 void forgetEntity(Entity entity) { | 63 void forgetEntity(Entity entity) { |
| 64 resolution.forgetEntity(entity, compiler); | 64 resolution.forgetEntity(entity, compiler); |
| 65 codegen.forgetEntity(entity, compiler); | 65 codegen.forgetEntity(entity, compiler); |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 | 68 |
| 69 abstract class Enqueuer { | 69 abstract class Enqueuer { |
| 70 // TODO(johnniwinther): Rename to `worldBuilder`. | 70 WorldBuilder get worldBuilder; |
| 71 WorldBuilder get universe; | |
| 72 native.NativeEnqueuer get nativeEnqueuer; | 71 native.NativeEnqueuer get nativeEnqueuer; |
| 73 void forgetEntity(Entity entity, Compiler compiler); | 72 void forgetEntity(Entity entity, Compiler compiler); |
| 74 | 73 |
| 75 // TODO(johnniwinther): Initialize [_impactStrategy] to `null`. | 74 // TODO(johnniwinther): Initialize [_impactStrategy] to `null`. |
| 76 ImpactStrategy _impactStrategy = const ImpactStrategy(); | 75 ImpactStrategy _impactStrategy = const ImpactStrategy(); |
| 77 | 76 |
| 78 ImpactStrategy get impactStrategy => _impactStrategy; | 77 ImpactStrategy get impactStrategy => _impactStrategy; |
| 79 | 78 |
| 80 void open(ImpactStrategy impactStrategy) { | 79 void open(ImpactStrategy impactStrategy) { |
| 81 _impactStrategy = impactStrategy; | 80 _impactStrategy = impactStrategy; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 [this.name = 'resolution enqueuer']) | 160 [this.name = 'resolution enqueuer']) |
| 162 : this.backend = backend, | 161 : this.backend = backend, |
| 163 this._resolution = resolution, | 162 this._resolution = resolution, |
| 164 this.nativeEnqueuer = backend.nativeResolutionEnqueuer(), | 163 this.nativeEnqueuer = backend.nativeResolutionEnqueuer(), |
| 165 _universe = new ResolutionWorldBuilderImpl( | 164 _universe = new ResolutionWorldBuilderImpl( |
| 166 backend, resolution, cacheStrategy, const OpenWorldStrategy()), | 165 backend, resolution, cacheStrategy, const OpenWorldStrategy()), |
| 167 _workItemBuilder = new ResolutionWorkItemBuilder(resolution) { | 166 _workItemBuilder = new ResolutionWorkItemBuilder(resolution) { |
| 168 _impactVisitor = new EnqueuerImplImpactVisitor(this); | 167 _impactVisitor = new EnqueuerImplImpactVisitor(this); |
| 169 } | 168 } |
| 170 | 169 |
| 171 ResolutionWorldBuilder get universe => _universe; | 170 ResolutionWorldBuilder get worldBuilder => _universe; |
| 172 | 171 |
| 173 bool get queueIsEmpty => _queue.isEmpty; | 172 bool get queueIsEmpty => _queue.isEmpty; |
| 174 | 173 |
| 175 DiagnosticReporter get _reporter => _resolution.reporter; | 174 DiagnosticReporter get _reporter => _resolution.reporter; |
| 176 | 175 |
| 177 Iterable<ClassEntity> get processedClasses => _universe.processedClasses; | 176 Iterable<ClassEntity> get processedClasses => _universe.processedClasses; |
| 178 | 177 |
| 179 void applyImpact(WorldImpact worldImpact, {var impactSource}) { | 178 void applyImpact(WorldImpact worldImpact, {var impactSource}) { |
| 180 if (worldImpact.isEmpty) return; | 179 if (worldImpact.isEmpty) return; |
| 181 impactStrategy.visitImpact( | 180 impactStrategy.visitImpact( |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 case TypeUseKind.CATCH_TYPE: | 290 case TypeUseKind.CATCH_TYPE: |
| 292 _registerIsCheck(type); | 291 _registerIsCheck(type); |
| 293 break; | 292 break; |
| 294 case TypeUseKind.CHECKED_MODE_CHECK: | 293 case TypeUseKind.CHECKED_MODE_CHECK: |
| 295 if (_options.enableTypeAssertions) { | 294 if (_options.enableTypeAssertions) { |
| 296 _registerIsCheck(type); | 295 _registerIsCheck(type); |
| 297 } | 296 } |
| 298 break; | 297 break; |
| 299 case TypeUseKind.TYPE_LITERAL: | 298 case TypeUseKind.TYPE_LITERAL: |
| 300 if (type.isTypedef) { | 299 if (type.isTypedef) { |
| 301 universe.registerTypedef(type.element); | 300 worldBuilder.registerTypedef(type.element); |
| 302 } | 301 } |
| 303 break; | 302 break; |
| 304 } | 303 } |
| 305 } | 304 } |
| 306 | 305 |
| 307 void _registerIsCheck(ResolutionDartType type) { | 306 void _registerIsCheck(ResolutionDartType type) { |
| 308 type = _universe.registerIsCheck(type); | 307 type = _universe.registerIsCheck(type); |
| 309 // Even in checked mode, type annotations for return type and argument | 308 // Even in checked mode, type annotations for return type and argument |
| 310 // types do not imply type checks, so there should never be a check | 309 // types do not imply type checks, so there should never be a check |
| 311 // against the type variable of a typedef. | 310 // against the type variable of a typedef. |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 @override | 475 @override |
| 477 void processDynamicUse(EnqueuerImpl enqueuer, DynamicUse dynamicUse) { | 476 void processDynamicUse(EnqueuerImpl enqueuer, DynamicUse dynamicUse) { |
| 478 enqueuer.processDynamicUse(dynamicUse); | 477 enqueuer.processDynamicUse(dynamicUse); |
| 479 } | 478 } |
| 480 | 479 |
| 481 /// Check enqueuer consistency after the queue has been closed. | 480 /// Check enqueuer consistency after the queue has been closed. |
| 482 bool checkEnqueuerConsistency(EnqueuerImpl enqueuer) { | 481 bool checkEnqueuerConsistency(EnqueuerImpl enqueuer) { |
| 483 enqueuer.task.measure(() { | 482 enqueuer.task.measure(() { |
| 484 // Run through the classes and see if we need to enqueue more methods. | 483 // Run through the classes and see if we need to enqueue more methods. |
| 485 for (ClassElement classElement | 484 for (ClassElement classElement |
| 486 in enqueuer.universe.directlyInstantiatedClasses) { | 485 in enqueuer.worldBuilder.directlyInstantiatedClasses) { |
| 487 for (ClassElement currentClass = classElement; | 486 for (ClassElement currentClass = classElement; |
| 488 currentClass != null; | 487 currentClass != null; |
| 489 currentClass = currentClass.superclass) { | 488 currentClass = currentClass.superclass) { |
| 490 enqueuer.checkClass(currentClass); | 489 enqueuer.checkClass(currentClass); |
| 491 } | 490 } |
| 492 } | 491 } |
| 493 }); | 492 }); |
| 494 return true; | 493 return true; |
| 495 } | 494 } |
| 496 } | 495 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 @override | 539 @override |
| 541 WorkItem createWorkItem(MemberElement element) { | 540 WorkItem createWorkItem(MemberElement element) { |
| 542 assert(invariant(element, element.isDeclaration)); | 541 assert(invariant(element, element.isDeclaration)); |
| 543 if (element.isMalformed) return null; | 542 if (element.isMalformed) return null; |
| 544 | 543 |
| 545 assert(invariant(element, element is AnalyzableElement, | 544 assert(invariant(element, element is AnalyzableElement, |
| 546 message: 'Element $element is not analyzable.')); | 545 message: 'Element $element is not analyzable.')); |
| 547 return _resolution.createWorkItem(element); | 546 return _resolution.createWorkItem(element); |
| 548 } | 547 } |
| 549 } | 548 } |
| OLD | NEW |