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 part of js_backend; | 5 part of js_backend; |
6 | 6 |
7 const VERBOSE_OPTIMIZER_HINTS = false; | 7 const VERBOSE_OPTIMIZER_HINTS = false; |
8 | 8 |
9 class JavaScriptItemCompilationContext extends ItemCompilationContext { | 9 class JavaScriptItemCompilationContext extends ItemCompilationContext { |
10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); | 10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); |
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 | 777 |
778 bool isInterceptedSelector(Selector selector) { | 778 bool isInterceptedSelector(Selector selector) { |
779 return interceptedElements[selector.name] != null; | 779 return interceptedElements[selector.name] != null; |
780 } | 780 } |
781 | 781 |
782 /** | 782 /** |
783 * Returns `true` iff [selector] matches an element defined in a class mixed | 783 * Returns `true` iff [selector] matches an element defined in a class mixed |
784 * into an intercepted class. These selectors are not eligible for the 'dummy | 784 * into an intercepted class. These selectors are not eligible for the 'dummy |
785 * explicit receiver' optimization. | 785 * explicit receiver' optimization. |
786 */ | 786 */ |
787 bool isInterceptedMixinSelector(Selector selector, TypeMask mask) { | 787 bool isInterceptedMixinSelector(Selector selector) { |
788 Set<Element> elements = interceptedMixinElements.putIfAbsent( | 788 Set<Element> elements = interceptedMixinElements.putIfAbsent( |
789 selector.name, | 789 selector.name, |
790 () { | 790 () { |
791 Set<Element> elements = interceptedElements[selector.name]; | 791 Set<Element> elements = interceptedElements[selector.name]; |
792 if (elements == null) return null; | 792 if (elements == null) return null; |
793 return elements | 793 return elements |
794 .where((element) => | 794 .where((element) => |
795 classesMixedIntoInterceptedClasses.contains( | 795 classesMixedIntoInterceptedClasses.contains( |
796 element.enclosingClass)) | 796 element.enclosingClass)) |
797 .toSet(); | 797 .toSet(); |
798 }); | 798 }); |
799 | 799 |
800 if (elements == null) return false; | 800 if (elements == null) return false; |
801 if (elements.isEmpty) return false; | 801 if (elements.isEmpty) return false; |
802 return elements.any((element) { | 802 return elements.any((element) => selector.applies(element, compiler.world)); |
803 return selector.applies(element, compiler.world) && | |
804 (mask == null || mask.canHit(element, selector, compiler.world)); | |
805 }); | |
806 } | 803 } |
807 | 804 |
808 final Map<String, Set<ClassElement>> interceptedClassesCache = | 805 final Map<String, Set<ClassElement>> interceptedClassesCache = |
809 new Map<String, Set<ClassElement>>(); | 806 new Map<String, Set<ClassElement>>(); |
810 | 807 |
811 /** | 808 /** |
812 * Returns a set of interceptor classes that contain a member named | 809 * Returns a set of interceptor classes that contain a member named |
813 * [name]. Returns [:null:] if there is no class. | 810 * [name]. Returns [:null:] if there is no class. |
814 */ | 811 */ |
815 Set<ClassElement> getInterceptedClassesOn(String name) { | 812 Set<ClassElement> getInterceptedClassesOn(String name) { |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1274 // Also register the types of the arguments passed to this method. | 1271 // Also register the types of the arguments passed to this method. |
1275 enqueueClass(compiler.enqueuer.resolution, compiler.stringClass, registry); | 1272 enqueueClass(compiler.enqueuer.resolution, compiler.stringClass, registry); |
1276 } | 1273 } |
1277 | 1274 |
1278 void registerNoSuchMethod(FunctionElement noSuchMethod) { | 1275 void registerNoSuchMethod(FunctionElement noSuchMethod) { |
1279 noSuchMethodRegistry.registerNoSuchMethod(noSuchMethod); | 1276 noSuchMethodRegistry.registerNoSuchMethod(noSuchMethod); |
1280 } | 1277 } |
1281 | 1278 |
1282 void enableNoSuchMethod(Enqueuer world) { | 1279 void enableNoSuchMethod(Enqueuer world) { |
1283 enqueue(world, getCreateInvocationMirror(), compiler.globalDependencies); | 1280 enqueue(world, getCreateInvocationMirror(), compiler.globalDependencies); |
1284 world.registerInvocation( | 1281 world.registerInvocation(compiler.noSuchMethodSelector); |
1285 new UniverseSelector(compiler.noSuchMethodSelector, null)); | |
1286 } | 1282 } |
1287 | 1283 |
1288 void enableIsolateSupport(Enqueuer enqueuer) { | 1284 void enableIsolateSupport(Enqueuer enqueuer) { |
1289 // TODO(floitsch): We should also ensure that the class IsolateMessage is | 1285 // TODO(floitsch): We should also ensure that the class IsolateMessage is |
1290 // instantiated. Currently, just enabling isolate support works. | 1286 // instantiated. Currently, just enabling isolate support works. |
1291 if (compiler.mainFunction != null) { | 1287 if (compiler.mainFunction != null) { |
1292 // The JavaScript backend implements [Isolate.spawn] by looking up | 1288 // The JavaScript backend implements [Isolate.spawn] by looking up |
1293 // top-level functions by name. So all top-level function tear-off | 1289 // top-level functions by name. So all top-level function tear-off |
1294 // closures have a private name field. | 1290 // closures have a private name field. |
1295 // | 1291 // |
(...skipping 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2987 } | 2983 } |
2988 } | 2984 } |
2989 | 2985 |
2990 /// Records that [constant] is used by the element behind [registry]. | 2986 /// Records that [constant] is used by the element behind [registry]. |
2991 class Dependency { | 2987 class Dependency { |
2992 final ConstantValue constant; | 2988 final ConstantValue constant; |
2993 final Element annotatedElement; | 2989 final Element annotatedElement; |
2994 | 2990 |
2995 const Dependency(this.constant, this.annotatedElement); | 2991 const Dependency(this.constant, this.annotatedElement); |
2996 } | 2992 } |
OLD | NEW |