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

Unified Diff: dart/sdk/lib/_internal/lib/js_helper.dart

Issue 23149002: Don't cache non-Interceptor interceptors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Long lines Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | dart/sdk/lib/_internal/lib/js_mirrors.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/sdk/lib/_internal/lib/js_helper.dart
diff --git a/dart/sdk/lib/_internal/lib/js_helper.dart b/dart/sdk/lib/_internal/lib/js_helper.dart
index 4ad179a2c39a9f22536acf471306a13cdeb44c08..ab69f61f4867d2b92b91bce4047777f8b7ca5a39 100644
--- a/dart/sdk/lib/_internal/lib/js_helper.dart
+++ b/dart/sdk/lib/_internal/lib/js_helper.dart
@@ -155,16 +155,20 @@ class JSInvocationMirror implements Invocation {
JS('int', '#.indexOf(#)', interceptedNames, name) != -1;
if (isIntercepted) {
receiver = interceptor;
+ if (JS('bool', '# === #', object, interceptor)) {
+ interceptor = null;
+ }
+ } else {
+ interceptor = null;
}
var method = JS('var', '#[#]', receiver, name);
if (JS('String', 'typeof #', method) == 'function') {
- return new CachedInvocation(method, isIntercepted ? interceptor : null);
+ return new CachedInvocation(method, isIntercepted, interceptor);
} else {
// In this case, receiver doesn't implement name. So we should
// invoke noSuchMethod instead (which will often throw a
// NoSuchMethodError).
- return new CachedNoSuchMethodInvocation(
- isIntercepted ? interceptor : null);
+ return new CachedNoSuchMethodInvocation(interceptor);
}
}
@@ -187,10 +191,14 @@ class CachedInvocation {
/// The JS function to call.
var jsFunction;
- /// Non-null interceptor if this is an intercepted call, otherwise null.
- var interceptor;
+ /// True if this is an intercepted call.
+ bool isIntercepted;
- CachedInvocation(this.jsFunction, this.interceptor);
+ /// Non-null interceptor if this is an intercepted call through an
+ /// [Interceptor].
+ Interceptor cachedInterceptor;
+
+ CachedInvocation(this.jsFunction, this.isIntercepted, this.cachedInterceptor);
bool get isNoSuchMethod => false;
@@ -198,18 +206,19 @@ class CachedInvocation {
/// Users of this class must take care to check the arguments first.
invokeOn(Object victim, List arguments) {
var receiver = victim;
- if (interceptor == null) {
+ if (!isIntercepted) {
if (arguments is! JSArray) arguments = new List.from(arguments);
} else {
arguments = [victim]..addAll(arguments);
- receiver = interceptor;
+ if (cachedInterceptor != null) receiver = cachedInterceptor;
}
return JS("var", "#.apply(#, #)", jsFunction, receiver, arguments);
}
}
class CachedNoSuchMethodInvocation {
- /// Non-null interceptor if this is an intercepted call, otherwise null.
+ /// Non-null interceptor if this is an intercepted call through an
+ /// [Interceptor].
var interceptor;
CachedNoSuchMethodInvocation(this.interceptor);
« no previous file with comments | « no previous file | dart/sdk/lib/_internal/lib/js_mirrors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698