Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/js_backend/backend.dart |
| diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart b/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart |
| index 9151b71b64d9c5716c39bb68541acdd54f0cf6f0..34a7e16739ed51e1ac18320e1dfc8e35233e6b8d 100644 |
| --- a/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart |
| +++ b/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart |
| @@ -171,6 +171,17 @@ class JavaScriptBackend extends Backend { |
| // explicit receiver. https://code.google.com/p/dart/issues/detail?id=8942 |
|
floitsch
2013/12/18 19:20:12
Update comment.
sra1
2013/12/19 03:28:15
Done.
|
| /** |
| + * The members of mixin classes that are mixed into an instantiated |
| + * interceptor class. This is a cached subset of [interceptedElements]. |
| + * These members must be invoked with a correct explicit receiver even when |
| + * the receiver is not an intercepted class because the function uses the |
| + * explicit interceptor parameter since it may be called on an intercepted |
| + * class. |
| + */ |
| + final Map<SourceString, Set<Element>> interceptedMixinElements = |
| + new Map<SourceString, Set<Element>>(); |
| + |
| + /** |
| * A map of specialized versions of the [getInterceptorMethod]. |
| * Since [getInterceptorMethod] is a hot method at runtime, we're |
| * always specializing it based on the incoming type. The keys in |
| @@ -367,6 +378,29 @@ class JavaScriptBackend extends Backend { |
| return interceptedElements[selector.name] != null; |
| } |
| + /** |
| + * Returns `true` iff [selector] matches an element defined in a class mixed |
| + * into an intercepted class. These selectors are not eligible for the 'dummy |
| + * explicit receiver' optimization. |
| + */ |
| + bool isInterceptedMixinSelector(Selector selector) { |
| + Set<Element> elements = interceptedMixinElements.putIfAbsent( |
| + selector.name, |
| + () { |
| + Set<Element> elements = interceptedElements[selector.name]; |
| + if (elements == null) return null; |
| + return elements |
| + .where((element) => |
| + classesMixedIntoNativeClasses.contains( |
| + element.getEnclosingClass())) |
| + .toSet(); |
| + }); |
| + |
| + if (elements == null) return false; |
| + if (elements.isEmpty) return false; |
| + return elements.any((element) => selector.applies(element, compiler)); |
| + } |
| + |
| final Map<String, Set<ClassElement>> interceptedClassesCache = |
| new Map<String, Set<ClassElement>>(); |