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

Unified Diff: pkg/compiler/lib/src/js_backend/minify_namer.dart

Issue 1212613009: dart2js: Implement frequency based naming. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/js_backend/minify_namer.dart
diff --git a/pkg/compiler/lib/src/js_backend/minify_namer.dart b/pkg/compiler/lib/src/js_backend/minify_namer.dart
index 9a2d1e3fc4a1290eb5a086a1cceeaae5933d20fe..b6801684b7a65aac77cd1e0808819e968a3ce39b 100644
--- a/pkg/compiler/lib/src/js_backend/minify_namer.dart
+++ b/pkg/compiler/lib/src/js_backend/minify_namer.dart
@@ -7,7 +7,8 @@ part of js_backend;
/**
* Assigns JavaScript identifiers to Dart variables, class-names and members.
*/
-class MinifyNamer extends Namer with _MinifiedFieldNamer {
+class MinifyNamer extends Namer with _MinifiedFieldNamer,
+ _MinifiedOneShotInterceptorNamer {
MinifyNamer(Compiler compiler) : super(compiler) {
reserveBackendNames();
fieldRegistry = new _FieldNamingRegistry(this);
@@ -32,11 +33,11 @@ class MinifyNamer extends Namer with _MinifiedFieldNamer {
/// [sanitizeForNatives] and [sanitizeForAnnotations] are ignored because the
/// minified names will always avoid clashing with annotated names or natives.
@override
- jsAst.Name getFreshName(String proposedName,
- Set<String> usedNames,
- Map<String, String> suggestedNames,
- {bool sanitizeForNatives: false,
- bool sanitizeForAnnotations: false}) {
+ String _generateFreshStringForName(String proposedName,
+ Set<String> usedNames,
+ Map<String, String> suggestedNames,
+ {bool sanitizeForNatives: false,
+ bool sanitizeForAnnotations: false}) {
String freshName;
String suggestion = suggestedNames[proposedName];
if (suggestion != null && !usedNames.contains(suggestion)) {
@@ -46,7 +47,7 @@ class MinifyNamer extends Namer with _MinifiedFieldNamer {
suggestedNames.values);
}
usedNames.add(freshName);
- return new StringBackedName(freshName);
+ return freshName;
}
// From issue 7554. These should not be used on objects (as instance
@@ -192,7 +193,7 @@ class MinifyNamer extends Namer with _MinifiedFieldNamer {
/// Instance members starting with g and s are reserved for getters and
/// setters.
- bool _hasBannedPrefix(String name) {
+ static bool _hasBannedPrefix(String name) {
int code = name.codeUnitAt(0);
return code == $g || code == $s;
}
@@ -255,3 +256,18 @@ class MinifyNamer extends Namer with _MinifiedFieldNamer {
}
}
+abstract class _MinifiedOneShotInterceptorNamer implements Namer {
+ /// Property name used for the one-shot interceptor method for the given
+ /// [selector] and return-type specialization.
+ jsAst.Name nameForGetOneShotInterceptor(Selector selector,
+ Iterable<ClassElement> classes) {
+ String root = selector.isOperator ? operatorNameToIdentifier(selector.name)
+ : privateName(selector.memberName);
+ String prefix = selector.isGetter ? r"$get"
+ : selector.isSetter ? r"$set" : "";
+ String arity = selector.isCall ? "${selector.argumentCount}" : "";
+ String suffix = suffixForGetInterceptor(classes);
+ String fullName = "\$intercepted$prefix\$$root$arity\$$suffix";
+ return _disambiguateInternalGlobal(fullName);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698