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

Unified Diff: lib/compiler/implementation/ssa/codegen.dart

Issue 10127010: New shot at mangling: try cleaning this up a bit. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/ssa/codegen.dart
===================================================================
--- lib/compiler/implementation/ssa/codegen.dart (revision 6745)
+++ lib/compiler/implementation/ssa/codegen.dart (working copy)
@@ -155,6 +155,9 @@
prefixes[name] = 0;
}
+ // Create a namespace for temporaries.
+ prefixes['t'] = 0;
+
equalsNullElement =
compiler.builder.interceptors.getEqualsNullInterceptor();
}
@@ -274,32 +277,29 @@
String name = names[id];
if (name !== null) return name;
- String prefix;
+ String prefix = 't';
if (instruction.sourceElement !== null) {
Element element = instruction.sourceElement;
if (element !== null && !element.name.isEmpty()) {
prefix = element.name.slowToString();
- } else {
- prefix = 'v';
+ // If we've never seen that prefix before, try to use it
+ // directly.
+ if (!prefixes.containsKey(prefix)) {
+ // Make sure the variable name does not conflict with our mangling.
+ while (usedNames.contains(prefix)) {
+ prefix = '${prefix}_';
+ }
+ prefixes[prefix] = 0;
+ return newName(id, prefix);
+ }
}
- } else {
- prefix = 't';
}
-
- while (usedNames.contains(prefix)) {
- prefix = '${prefix}_';
- }
- if (!prefixes.containsKey(prefix)) {
- prefixes[prefix] = 0;
- return newName(id, prefix);
- } else {
+ name = '${prefix}${prefixes[prefix]++}';
+ while (usedNames.contains(name)) {
name = '${prefix}${prefixes[prefix]++}';
- while (usedNames.contains(name)) {
- name = '${prefix}${prefixes[prefix]++}';
- }
- return newName(id, name);
}
+ return newName(id, name);
}
bool temporaryExists(HInstruction instruction) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698