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

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

Issue 11416007: Fix this longstanding bug that luckily did not bite us yet: Use Class.prototype.foo$bailout.call(th… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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 | sdk/lib/_internal/compiler/implementation/ssa/codegen.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/js_backend/namer.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/js_backend/namer.dart (revision 14946)
+++ sdk/lib/_internal/compiler/implementation/js_backend/namer.dart (working copy)
@@ -30,12 +30,23 @@
final Map<String, int> usedGlobals;
final Map<String, LibraryElement> shortPrivateNameOwners;
+ /// A cache of names used for bailout methods. We make sure two
karlklose 2012/11/16 09:31:17 I think you should /**...*/ here.
ngeoffray 2012/11/16 10:37:56 Done.
+ /// bailout methods cannot have the same name because if one is
karlklose 2012/11/16 09:31:17 I find "because if one is defined in a class that
ngeoffray 2012/11/16 10:37:56 Done.
+ /// defined in a class that is a subclass of the other, we would
+ /// resolve to the wrong bailout method at runtime. To make it
+ /// simple, we don't keep track of inheritance and always avoid
+ /// similar names.
+ final Set<String> usedBailoutNames;
+ final Map<Element, String> bailoutNames;
+
final Map<Constant, String> constantNames;
Namer(this.compiler)
: globals = new Map<Element, String>(),
usedGlobals = new Map<String, int>(),
shortPrivateNameOwners = new Map<String, LibraryElement>(),
+ bailoutNames = new Map<Element, String>(),
+ usedBailoutNames = new Set<String>(),
constantNames = new Map<Constant, String>();
final String CURRENT_ISOLATE = r'$';
@@ -237,7 +248,15 @@
}
String getBailoutName(Element element) {
- return '${getName(element)}\$bailout';
+ String name = bailoutNames[element];
+ if (name != null) return name;
+ String candidate = '${getName(element)}\$bailout';
+ name = candidate;
+ int i = 0;
+ while (usedBailoutNames.contains(name)) name = '$candidate${i++}';
karlklose 2012/11/16 09:31:17 Should we have a UniqueElementNameGenerator abstra
+ bailoutNames[element] = name;
+ usedBailoutNames.add(name);
+ return name;
}
/**
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/ssa/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698