Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: pkg/compiler/lib/src/js_backend/backend.dart

Issue 1182913003: Split TypedSelector into Selector and TypeMask. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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) { 787 bool isInterceptedMixinSelector(Selector selector, TypeMask mask) {
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) => selector.applies(element, compiler.world)); 802 return elements.any((element) {
803 return selector.applies(element, compiler.world) &&
804 (mask == null || mask.canHit(element, selector, compiler.world));
805 });
803 } 806 }
804 807
805 final Map<String, Set<ClassElement>> interceptedClassesCache = 808 final Map<String, Set<ClassElement>> interceptedClassesCache =
806 new Map<String, Set<ClassElement>>(); 809 new Map<String, Set<ClassElement>>();
807 810
808 /** 811 /**
809 * Returns a set of interceptor classes that contain a member named 812 * Returns a set of interceptor classes that contain a member named
810 * [name]. Returns [:null:] if there is no class. 813 * [name]. Returns [:null:] if there is no class.
811 */ 814 */
812 Set<ClassElement> getInterceptedClassesOn(String name) { 815 Set<ClassElement> getInterceptedClassesOn(String name) {
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 // Also register the types of the arguments passed to this method. 1266 // Also register the types of the arguments passed to this method.
1264 enqueueClass(compiler.enqueuer.resolution, compiler.stringClass, registry); 1267 enqueueClass(compiler.enqueuer.resolution, compiler.stringClass, registry);
1265 } 1268 }
1266 1269
1267 void registerNoSuchMethod(FunctionElement noSuchMethod) { 1270 void registerNoSuchMethod(FunctionElement noSuchMethod) {
1268 noSuchMethodRegistry.registerNoSuchMethod(noSuchMethod); 1271 noSuchMethodRegistry.registerNoSuchMethod(noSuchMethod);
1269 } 1272 }
1270 1273
1271 void enableNoSuchMethod(Enqueuer world) { 1274 void enableNoSuchMethod(Enqueuer world) {
1272 enqueue(world, getCreateInvocationMirror(), compiler.globalDependencies); 1275 enqueue(world, getCreateInvocationMirror(), compiler.globalDependencies);
1273 world.registerInvocation(compiler.noSuchMethodSelector); 1276 world.registerInvocation(
1277 new UniverseSelector(compiler.noSuchMethodSelector, null));
1274 } 1278 }
1275 1279
1276 void enableIsolateSupport(Enqueuer enqueuer) { 1280 void enableIsolateSupport(Enqueuer enqueuer) {
1277 // TODO(floitsch): We should also ensure that the class IsolateMessage is 1281 // TODO(floitsch): We should also ensure that the class IsolateMessage is
1278 // instantiated. Currently, just enabling isolate support works. 1282 // instantiated. Currently, just enabling isolate support works.
1279 if (compiler.mainFunction != null) { 1283 if (compiler.mainFunction != null) {
1280 // The JavaScript backend implements [Isolate.spawn] by looking up 1284 // The JavaScript backend implements [Isolate.spawn] by looking up
1281 // top-level functions by name. So all top-level function tear-off 1285 // top-level functions by name. So all top-level function tear-off
1282 // closures have a private name field. 1286 // closures have a private name field.
1283 // 1287 //
(...skipping 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after
2975 } 2979 }
2976 } 2980 }
2977 2981
2978 /// Records that [constant] is used by the element behind [registry]. 2982 /// Records that [constant] is used by the element behind [registry].
2979 class Dependency { 2983 class Dependency {
2980 final ConstantValue constant; 2984 final ConstantValue constant;
2981 final Element annotatedElement; 2985 final Element annotatedElement;
2982 2986
2983 const Dependency(this.constant, this.annotatedElement); 2987 const Dependency(this.constant, this.annotatedElement);
2984 } 2988 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698