| 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 | 7 import 'dart:collection' show |
| 8 Queue; | 8 Queue; |
| 9 | 9 |
| 10 import 'common.dart'; | 10 import 'common.dart'; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 } | 229 } |
| 230 | 230 |
| 231 // TODO(johnniwinther): Remove the need for passing the [registry]. | 231 // TODO(johnniwinther): Remove the need for passing the [registry]. |
| 232 void registerInstantiatedType(InterfaceType type, | 232 void registerInstantiatedType(InterfaceType type, |
| 233 {bool mirrorUsage: false}) { | 233 {bool mirrorUsage: false}) { |
| 234 task.measure(() { | 234 task.measure(() { |
| 235 ClassElement cls = type.element; | 235 ClassElement cls = type.element; |
| 236 cls.ensureResolved(resolution); | 236 cls.ensureResolved(resolution); |
| 237 universe.registerTypeInstantiation( | 237 universe.registerTypeInstantiation( |
| 238 type, | 238 type, |
| 239 isNative: compiler.backend.isNative(cls), |
| 239 byMirrors: mirrorUsage, | 240 byMirrors: mirrorUsage, |
| 240 onImplemented: (ClassElement cls) { | 241 onImplemented: (ClassElement cls) { |
| 241 compiler.backend.registerImplementedClass( | 242 compiler.backend.registerImplementedClass( |
| 242 cls, this, compiler.globalDependencies); | 243 cls, this, compiler.globalDependencies); |
| 243 }); | 244 }); |
| 244 processInstantiatedClass(cls); | 245 processInstantiatedClass(cls); |
| 245 }); | 246 }); |
| 246 } | 247 } |
| 247 | 248 |
| 248 bool checkNoEnqueuedInvokedInstanceMethods() { | 249 bool checkNoEnqueuedInvokedInstanceMethods() { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 260 String memberName = member.name; | 261 String memberName = member.name; |
| 261 | 262 |
| 262 if (member.isField) { | 263 if (member.isField) { |
| 263 // The obvious thing to test here would be "member.isNative", | 264 // The obvious thing to test here would be "member.isNative", |
| 264 // however, that only works after metadata has been parsed/analyzed, | 265 // however, that only works after metadata has been parsed/analyzed, |
| 265 // and that may not have happened yet. | 266 // and that may not have happened yet. |
| 266 // So instead we use the enclosing class, which we know have had | 267 // So instead we use the enclosing class, which we know have had |
| 267 // its metadata parsed and analyzed. | 268 // its metadata parsed and analyzed. |
| 268 // Note: this assumes that there are no non-native fields on native | 269 // Note: this assumes that there are no non-native fields on native |
| 269 // classes, which may not be the case when a native class is subclassed. | 270 // classes, which may not be the case when a native class is subclassed. |
| 270 if (cls.isNative) { | 271 if (compiler.backend.isNative(cls)) { |
| 271 compiler.world.registerUsedElement(member); | 272 compiler.world.registerUsedElement(member); |
| 272 nativeEnqueuer.handleFieldAnnotations(member); | 273 nativeEnqueuer.handleFieldAnnotations(member); |
| 273 if (universe.hasInvokedGetter(member, compiler.world) || | 274 if (universe.hasInvokedGetter(member, compiler.world) || |
| 274 universe.hasInvocation(member, compiler.world)) { | 275 universe.hasInvocation(member, compiler.world)) { |
| 275 nativeEnqueuer.registerFieldLoad(member); | 276 nativeEnqueuer.registerFieldLoad(member); |
| 276 // In handleUnseenSelector we can't tell if the field is loaded or | 277 // In handleUnseenSelector we can't tell if the field is loaded or |
| 277 // stored. We need the basic algorithm to be Church-Rosser, since the | 278 // stored. We need the basic algorithm to be Church-Rosser, since the |
| 278 // resolution 'reduction' order is different to the codegen order. So | 279 // resolution 'reduction' order is different to the codegen order. So |
| 279 // register that the field is also stored. In other words: if we | 280 // register that the field is also stored. In other words: if we |
| 280 // don't register the store here during resolution, the store could be | 281 // don't register the store here during resolution, the store could be |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 } | 632 } |
| 632 | 633 |
| 633 void handleUnseenSelectorInternal(UniverseSelector universeSelector) { | 634 void handleUnseenSelectorInternal(UniverseSelector universeSelector) { |
| 634 Selector selector = universeSelector.selector; | 635 Selector selector = universeSelector.selector; |
| 635 String methodName = selector.name; | 636 String methodName = selector.name; |
| 636 processInstanceMembers(methodName, (Element member) { | 637 processInstanceMembers(methodName, (Element member) { |
| 637 if (universeSelector.appliesUnnamed(member, compiler.world)) { | 638 if (universeSelector.appliesUnnamed(member, compiler.world)) { |
| 638 if (member.isFunction && selector.isGetter) { | 639 if (member.isFunction && selector.isGetter) { |
| 639 registerClosurizedMember(member); | 640 registerClosurizedMember(member); |
| 640 } | 641 } |
| 641 if (member.isField && member.enclosingClass.isNative) { | 642 if (member.isField && compiler.backend.isNative(member.enclosingClass))
{ |
| 642 if (selector.isGetter || selector.isCall) { | 643 if (selector.isGetter || selector.isCall) { |
| 643 nativeEnqueuer.registerFieldLoad(member); | 644 nativeEnqueuer.registerFieldLoad(member); |
| 644 // We have to also handle storing to the field because we only get | 645 // We have to also handle storing to the field because we only get |
| 645 // one look at each member and there might be a store we have not | 646 // one look at each member and there might be a store we have not |
| 646 // seen yet. | 647 // seen yet. |
| 647 // TODO(sra): Process fields for storing separately. | 648 // TODO(sra): Process fields for storing separately. |
| 648 nativeEnqueuer.registerFieldStore(member); | 649 nativeEnqueuer.registerFieldStore(member); |
| 649 } else { | 650 } else { |
| 650 assert(selector.isSetter); | 651 assert(selector.isSetter); |
| 651 nativeEnqueuer.registerFieldStore(member); | 652 nativeEnqueuer.registerFieldStore(member); |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 @override | 1106 @override |
| 1106 void processStaticUse(Enqueuer enqueuer, Element element) { | 1107 void processStaticUse(Enqueuer enqueuer, Element element) { |
| 1107 enqueuer.registerStaticUseInternal(element); | 1108 enqueuer.registerStaticUseInternal(element); |
| 1108 } | 1109 } |
| 1109 | 1110 |
| 1110 @override | 1111 @override |
| 1111 void processSelector(Enqueuer enqueuer, UniverseSelector selector) { | 1112 void processSelector(Enqueuer enqueuer, UniverseSelector selector) { |
| 1112 enqueuer.handleUnseenSelectorInternal(selector); | 1113 enqueuer.handleUnseenSelectorInternal(selector); |
| 1113 } | 1114 } |
| 1114 } | 1115 } |
| OLD | NEW |