| 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 'common/names.dart' show Identifiers; | 9 import 'common/names.dart' show Identifiers; |
| 10 import 'common/resolution.dart' show Resolution; | 10 import 'common/resolution.dart' show Resolution; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 /// Enqueue the static fields that have been marked as used by reflective | 103 /// Enqueue the static fields that have been marked as used by reflective |
| 104 /// usage through `MirrorsUsed`. | 104 /// usage through `MirrorsUsed`. |
| 105 void enqueueReflectiveStaticFields(Iterable<Element> elements); | 105 void enqueueReflectiveStaticFields(Iterable<Element> elements); |
| 106 | 106 |
| 107 /// Enqueue all elements that are matched by the mirrors used | 107 /// Enqueue all elements that are matched by the mirrors used |
| 108 /// annotation or, in lack thereof, all elements. | 108 /// annotation or, in lack thereof, all elements. |
| 109 void enqueueReflectiveElements(Iterable<ClassElement> recents); | 109 void enqueueReflectiveElements(Iterable<ClassElement> recents); |
| 110 | 110 |
| 111 void registerInstantiatedType(InterfaceType type, {bool mirrorUsage: false}); | 111 void registerInstantiatedType(InterfaceType type, {bool mirrorUsage: false}); |
| 112 void forEach(void f(WorkItem work)); | 112 void forEach(void f(WorkItem work)); |
| 113 void applyImpact(Element element, WorldImpact worldImpact); | 113 |
| 114 /// Apply the [worldImpact] to this enqueuer. If the [impactSource] is provide
d |
| 115 /// the impact strategy will remove it from the element impact cache, if it is |
| 116 /// no longer needed. |
| 117 void applyImpact(WorldImpact worldImpact, {Element impactSource}); |
| 114 bool checkNoEnqueuedInvokedInstanceMethods(); | 118 bool checkNoEnqueuedInvokedInstanceMethods(); |
| 115 void logSummary(log(message)); | 119 void logSummary(log(message)); |
| 116 | 120 |
| 117 /// Returns [:true:] if [member] has been processed by this enqueuer. | 121 /// Returns [:true:] if [member] has been processed by this enqueuer. |
| 118 bool isProcessed(Element member); | 122 bool isProcessed(Element member); |
| 119 | 123 |
| 120 Iterable<Entity> get processedEntities; | 124 Iterable<Entity> get processedEntities; |
| 121 } | 125 } |
| 122 | 126 |
| 123 /// [Enqueuer] which is specific to resolution. | 127 /// [Enqueuer] which is specific to resolution. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 void addToWorkList(Element element) { | 180 void addToWorkList(Element element) { |
| 177 assert(invariant(element, element.isDeclaration)); | 181 assert(invariant(element, element.isDeclaration)); |
| 178 if (internalAddToWorkList(element) && compiler.options.dumpInfo) { | 182 if (internalAddToWorkList(element) && compiler.options.dumpInfo) { |
| 179 // TODO(sigmund): add other missing dependencies (internals, selectors | 183 // TODO(sigmund): add other missing dependencies (internals, selectors |
| 180 // enqueued after allocations), also enable only for the codegen enqueuer. | 184 // enqueued after allocations), also enable only for the codegen enqueuer. |
| 181 compiler.dumpInfoTask | 185 compiler.dumpInfoTask |
| 182 .registerDependency(compiler.currentElement, element); | 186 .registerDependency(compiler.currentElement, element); |
| 183 } | 187 } |
| 184 } | 188 } |
| 185 | 189 |
| 186 /// Apply the [worldImpact] of processing [element] to this enqueuer. | 190 void applyImpact(WorldImpact worldImpact, {Element impactSource}) { |
| 187 void applyImpact(Element element, WorldImpact worldImpact) { | |
| 188 compiler.impactStrategy | 191 compiler.impactStrategy |
| 189 .visitImpact(element, worldImpact, impactVisitor, impactUse); | 192 .visitImpact(impactSource, worldImpact, impactVisitor, impactUse); |
| 190 } | 193 } |
| 191 | 194 |
| 192 void registerInstantiatedType(InterfaceType type, {bool mirrorUsage: false}) { | 195 void registerInstantiatedType(InterfaceType type, {bool mirrorUsage: false}) { |
| 193 task.measure(() { | 196 task.measure(() { |
| 194 ClassElement cls = type.element; | 197 ClassElement cls = type.element; |
| 195 cls.ensureResolved(resolution); | 198 cls.ensureResolved(resolution); |
| 196 bool isNative = compiler.backend.isNative(cls); | 199 bool isNative = compiler.backend.isNative(cls); |
| 197 _universe.registerTypeInstantiation(type, | 200 _universe.registerTypeInstantiation(type, |
| 198 isNative: isNative, | 201 isNative: isNative, |
| 199 byMirrors: mirrorUsage, onImplemented: (ClassElement cls) { | 202 byMirrors: mirrorUsage, onImplemented: (ClassElement cls) { |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 */ | 570 */ |
| 568 void registerStaticUse(StaticUse staticUse) { | 571 void registerStaticUse(StaticUse staticUse) { |
| 569 strategy.processStaticUse(this, staticUse); | 572 strategy.processStaticUse(this, staticUse); |
| 570 } | 573 } |
| 571 | 574 |
| 572 void registerStaticUseInternal(StaticUse staticUse) { | 575 void registerStaticUseInternal(StaticUse staticUse) { |
| 573 Element element = staticUse.element; | 576 Element element = staticUse.element; |
| 574 assert(invariant(element, element.isDeclaration, | 577 assert(invariant(element, element.isDeclaration, |
| 575 message: "Element ${element} is not the declaration.")); | 578 message: "Element ${element} is not the declaration.")); |
| 576 _universe.registerStaticUse(staticUse); | 579 _universe.registerStaticUse(staticUse); |
| 577 compiler.backend.registerStaticUse(element, this); | 580 compiler.backend.registerStaticUse(element, forResolution: true); |
| 578 bool addElement = true; | 581 bool addElement = true; |
| 579 switch (staticUse.kind) { | 582 switch (staticUse.kind) { |
| 580 case StaticUseKind.STATIC_TEAR_OFF: | 583 case StaticUseKind.STATIC_TEAR_OFF: |
| 581 compiler.backend.registerGetOfStaticFunction(this); | 584 compiler.backend.registerGetOfStaticFunction(this); |
| 582 break; | 585 break; |
| 583 case StaticUseKind.FIELD_GET: | 586 case StaticUseKind.FIELD_GET: |
| 584 case StaticUseKind.FIELD_SET: | 587 case StaticUseKind.FIELD_SET: |
| 585 case StaticUseKind.CLOSURE: | 588 case StaticUseKind.CLOSURE: |
| 586 // TODO(johnniwinther): Avoid this. Currently [FIELD_GET] and | 589 // TODO(johnniwinther): Avoid this. Currently [FIELD_GET] and |
| 587 // [FIELD_SET] contains [BoxFieldElement]s which we cannot enqueue. | 590 // [FIELD_SET] contains [BoxFieldElement]s which we cannot enqueue. |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 } | 908 } |
| 906 | 909 |
| 907 typedef void _DeferredActionFunction(); | 910 typedef void _DeferredActionFunction(); |
| 908 | 911 |
| 909 class _DeferredAction { | 912 class _DeferredAction { |
| 910 final Element element; | 913 final Element element; |
| 911 final _DeferredActionFunction action; | 914 final _DeferredActionFunction action; |
| 912 | 915 |
| 913 _DeferredAction(this.element, this.action); | 916 _DeferredAction(this.element, this.action); |
| 914 } | 917 } |
| OLD | NEW |