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

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

Issue 12224130: Stable naming of interceptors (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/js_backend/minify_namer.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of js_backend; 5 part of js_backend;
6 6
7 /** 7 /**
8 * Assigns JavaScript identifiers to Dart variables, class-names and members. 8 * Assigns JavaScript identifiers to Dart variables, class-names and members.
9 */ 9 */
10 class Namer implements ClosureNamer { 10 class Namer implements ClosureNamer {
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 } 532 }
533 533
534 String getInterceptorName(Element element, Collection<ClassElement> classes) { 534 String getInterceptorName(Element element, Collection<ClassElement> classes) {
535 if (classes.contains(compiler.objectClass)) { 535 if (classes.contains(compiler.objectClass)) {
536 // If the object class is in the set of intercepted classes, we 536 // If the object class is in the set of intercepted classes, we
537 // need to go through the generic getInterceptorMethod. 537 // need to go through the generic getInterceptorMethod.
538 return getName(element); 538 return getName(element);
539 } 539 }
540 // Use the unminified names here to construct the interceptor names. This 540 // Use the unminified names here to construct the interceptor names. This
541 // helps ensure that they don't all suddenly change names due to a name 541 // helps ensure that they don't all suddenly change names due to a name
542 // clash in the minifier, which would affect the diff size. 542 // clash in the minifier, which would affect the diff size. Sort the names
543 // of the classes to ensure name is stable and predicatble for the suggested
544 // names.
543 StringBuffer buffer = new StringBuffer('${element.name.slowToString()}\$'); 545 StringBuffer buffer = new StringBuffer('${element.name.slowToString()}\$');
544 for (ClassElement cls in classes) { 546 List<String> names = classes.map((cls) => cls.name.slowToString()).toList();
545 buffer.add(cls.name.slowToString()); 547 names.sort();
546 } 548 names.forEach(buffer.add);
547 return getMappedGlobalName(buffer.toString()); 549 return getMappedGlobalName(buffer.toString());
548 } 550 }
549 551
550 String getBailoutName(Element element) { 552 String getBailoutName(Element element) {
551 String name = bailoutNames[element]; 553 String name = bailoutNames[element];
552 if (name != null) return name; 554 if (name != null) return name;
553 bool global = !element.isInstanceMember(); 555 bool global = !element.isInstanceMember();
554 // Despite the name of the variable, this gets the minified name when we 556 // Despite the name of the variable, this gets the minified name when we
555 // are minifying, but it doesn't really make much difference. The 557 // are minifying, but it doesn't really make much difference. The
556 // important thing is that it is a unique name. We add $bailout and, if we 558 // important thing is that it is a unique name. We add $bailout and, if we
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 return const SourceString(r'$or'); 753 return const SourceString(r'$or');
752 } else if (value == '-') { 754 } else if (value == '-') {
753 return const SourceString(r'$sub'); 755 return const SourceString(r'$sub');
754 } else if (value == 'unary-') { 756 } else if (value == 'unary-') {
755 return const SourceString(r'$negate'); 757 return const SourceString(r'$negate');
756 } else { 758 } else {
757 return name; 759 return name;
758 } 760 }
759 } 761 }
760 } 762 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/js_backend/minify_namer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698