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

Unified Diff: sdk/lib/_internal/compiler/implementation/js_backend/namer.dart

Issue 12033056: Implement "one-shot" interceptors. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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
Index: sdk/lib/_internal/compiler/implementation/js_backend/namer.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/js_backend/namer.dart (revision 17552)
+++ sdk/lib/_internal/compiler/implementation/js_backend/namer.dart (working copy)
@@ -47,6 +47,7 @@
*/
final Compiler compiler;
final Map<Element, String> globals;
+ final Map<Selector, String> oneShotInterceptorNames;
final Map<String, LibraryElement> shortPrivateNameOwners;
final Set<String> usedGlobalNames;
final Set<String> usedInstanceNames;
@@ -70,6 +71,7 @@
Namer(this.compiler)
: globals = new Map<Element, String>(),
+ oneShotInterceptorNames = new Map<Selector, String>(),
shortPrivateNameOwners = new Map<String, LibraryElement>(),
bailoutNames = new Map<Element, String>(),
usedBailoutInstanceNames = new Set<String>(),
@@ -394,7 +396,12 @@
return name;
}
- String getSpecializedName(Element element, Collection<ClassElement> classes) {
+ String getInterceptorName(Element element, Collection<ClassElement> classes) {
+ if (classes.contains(compiler.objectClass)) {
+ // If the object class is in the set of intercepted classes, we
+ // need to go through the generic getInterceptorMethod.
+ return getName(element);
+ }
// This gets the minified name, but it doesn't really make much difference.
// The important thing is that it is a unique name.
StringBuffer buffer = new StringBuffer('${getName(element)}\$');
@@ -533,6 +540,18 @@
return name;
}
+ String oneShotInterceptorName(Selector selector) {
+ // TODO(ngeoffray): What to do about typed selectors? We could
+ // filter them out, or keep them and hope the generated one shot
+ // interceptor takes advantage of the type.
+ String cached = oneShotInterceptorNames[selector];
+ if (cached != null) return cached;
+ SourceString name = operatorNameToIdentifier(selector.name);
+ String result = getFreshName(name.slowToString(), usedGlobalNames);
+ oneShotInterceptorNames[selector] = result;
+ return result;
+ }
+
SourceString operatorNameToIdentifier(SourceString name) {
if (name == null) return null;
String value = name.stringValue;

Powered by Google App Engine
This is Rietveld 408576698