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

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

Issue 10543050: Compute the swap temporary to not clash with parameter names. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 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: dart/lib/compiler/implementation/ssa/variable_allocator.dart
===================================================================
--- dart/lib/compiler/implementation/ssa/variable_allocator.dart (revision 8378)
+++ dart/lib/compiler/implementation/ssa/variable_allocator.dart (working copy)
@@ -348,15 +348,22 @@
* Name that is being used as a temporary to break cycles in
* parallel copies. We make sure this name is not being used
* anywhere by reserving it when we allocate names for instructions.
- * TODO(ngeoffray): This isn't true for parameters, and we should
- * rename the parameter name, to keep it simple.
*/
- static final String SWAP_TEMP = 't0';
+ final String swapTemp;
- VariableNames()
+ VariableNames(Map<Element, String> parameterNames)
: ownName = new Map<HInstruction, String>(),
- copyHandlers = new Map<HBasicBlock, CopyHandler>();
+ copyHandlers = new Map<HBasicBlock, CopyHandler>(),
+ swapTemp = computeSwapTemp(parameterNames);
+ static String computeSwapTemp(Map<Element, String> parameterNames) {
+ Set<String> parameters = new Set<String>.from(parameterNames.getValues());
+ String name = 't0';
+ int i = 1;
+ while (parameters.contains(name)) name = 't${i++}';
+ return name;
+ }
+
String getName(HInstruction instruction) {
return ownName[instruction];
}
@@ -387,12 +394,13 @@
final VariableNames names;
final Set<String> usedNames;
final Map<Element, String> parameterNames;
+ int temporaryIndex = 0;
VariableNamer(LiveEnvironment environment, this.names, this.parameterNames)
: usedNames = new Set<String>() {
- // [VariableNames.SWAP_TEMP] is being used when there is a cycle
+ // [VariableNames.swapTemp] is being used when there is a cycle
// in a copy handler. Therefore we make sure no one will use it.
- usedNames.add(VariableNames.SWAP_TEMP);
+ usedNames.add(names.swapTemp);
// All liveIns instructions must have a name at this point, so we
// add them to the list of used names.
@@ -414,11 +422,8 @@
}
String allocateTemporary() {
- // Don't start at 0 because t0 is being used for
- // [VariableNames.SWAP_TEMP].
- int i = 1;
- String name = 't${i++}';
- while (usedNames.contains(name)) name = 't${i++}';
+ String name = 't${temporaryIndex++}';
floitsch 2012/06/07 09:27:32 I thought we wanted to avoid this, because variabl
ngeoffray 2012/06/07 09:33:45 It's ok on one instance of a VariableNamer because
+ while (usedNames.contains(name)) name = 't${temporaryIndex++}';
return name;
}
@@ -503,8 +508,9 @@
this.liveInstructions,
this.liveIntervals,
this.generateAtUseSite,
- this.parameterNames)
- : names = new VariableNames();
+ parameterNames)
+ : this.names = new VariableNames(parameterNames),
+ this.parameterNames = parameterNames;
void visitGraph(HGraph graph) {
visitDominatorTree(graph);
« no previous file with comments | « dart/lib/compiler/implementation/ssa/codegen.dart ('k') | dart/tests/language/parameter_name_conflict_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698