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

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: Updated cf. comments. 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 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 // Also register the types of the arguments passed to this method. 1274 // Also register the types of the arguments passed to this method.
1272 enqueueClass(compiler.enqueuer.resolution, compiler.stringClass, registry); 1275 enqueueClass(compiler.enqueuer.resolution, compiler.stringClass, registry);
1273 } 1276 }
1274 1277
1275 void registerNoSuchMethod(FunctionElement noSuchMethod) { 1278 void registerNoSuchMethod(FunctionElement noSuchMethod) {
1276 noSuchMethodRegistry.registerNoSuchMethod(noSuchMethod); 1279 noSuchMethodRegistry.registerNoSuchMethod(noSuchMethod);
1277 } 1280 }
1278 1281
1279 void enableNoSuchMethod(Enqueuer world) { 1282 void enableNoSuchMethod(Enqueuer world) {
1280 enqueue(world, getCreateInvocationMirror(), compiler.globalDependencies); 1283 enqueue(world, getCreateInvocationMirror(), compiler.globalDependencies);
1281 world.registerInvocation(compiler.noSuchMethodSelector); 1284 world.registerInvocation(
1285 new UniverseSelector(compiler.noSuchMethodSelector, null));
1282 } 1286 }
1283 1287
1284 void enableIsolateSupport(Enqueuer enqueuer) { 1288 void enableIsolateSupport(Enqueuer enqueuer) {
1285 // TODO(floitsch): We should also ensure that the class IsolateMessage is 1289 // TODO(floitsch): We should also ensure that the class IsolateMessage is
1286 // instantiated. Currently, just enabling isolate support works. 1290 // instantiated. Currently, just enabling isolate support works.
1287 if (compiler.mainFunction != null) { 1291 if (compiler.mainFunction != null) {
1288 // The JavaScript backend implements [Isolate.spawn] by looking up 1292 // The JavaScript backend implements [Isolate.spawn] by looking up
1289 // top-level functions by name. So all top-level function tear-off 1293 // top-level functions by name. So all top-level function tear-off
1290 // closures have a private name field. 1294 // closures have a private name field.
1291 // 1295 //
(...skipping 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after
2983 } 2987 }
2984 } 2988 }
2985 2989
2986 /// Records that [constant] is used by the element behind [registry]. 2990 /// Records that [constant] is used by the element behind [registry].
2987 class Dependency { 2991 class Dependency {
2988 final ConstantValue constant; 2992 final ConstantValue constant;
2989 final Element annotatedElement; 2993 final Element annotatedElement;
2990 2994
2991 const Dependency(this.constant, this.annotatedElement); 2995 const Dependency(this.constant, this.annotatedElement);
2992 } 2996 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/inferrer/type_graph_nodes.dart ('k') | pkg/compiler/lib/src/js_backend/codegen/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698