| 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 f5a51a49e0451c8d405704fc2dce24365b9f7ced..b9901e4c793c65f9e40f00f931cfe0afa8acb2a9 100644
|
| --- a/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
|
| +++ b/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
|
| @@ -165,11 +165,17 @@ class JavaScriptBackend extends Backend {
|
| * know whether a send must be intercepted or not.
|
| */
|
| final Map<String, Set<Element>> interceptedElements;
|
| - // TODO(sra): Not all methods in the Set always require an interceptor. A
|
| - // method may be mixed into a true interceptor *and* a plain class. For the
|
| - // method to work on the interceptor class it needs to use the explicit
|
| - // receiver. This constrains the call on a known plain receiver to pass the
|
| - // explicit receiver. https://code.google.com/p/dart/issues/detail?id=8942
|
| +
|
| + /**
|
| + * 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<String, Set<Element>> interceptedMixinElements =
|
| + new Map<String, Set<Element>>();
|
|
|
| /**
|
| * A map of specialized versions of the [getInterceptorMethod].
|
| @@ -368,6 +374,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>>();
|
|
|
| @@ -1855,6 +1884,8 @@ class ConstantCopier implements ConstantVisitor {
|
|
|
| void visitInterceptor(InterceptorConstant constant) => copy(constant);
|
|
|
| + void visitDummyReceiver(DummyReceiverConstant constant) => copy(constant);
|
| +
|
| void visitList(ListConstant constant) {
|
| copy(constant.entries);
|
| copy(constant);
|
|
|