Chromium Code Reviews| 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()); |
|
Lasse Reichstein Nielsen
2012/06/07 08:53:21
Can't you use this.names somehow, since it's initi
ngeoffray
2012/06/07 09:10:41
As discussed, there is no extra field in this clas
|
| + String name = 't0'; |
| + int i = 1; |
| + while (parameters.contains(name)) name = 't${i++}'; |
| + return name; |
| + } |
| + |
| String getName(HInstruction instruction) { |
| return ownName[instruction]; |
| } |
| @@ -390,9 +397,9 @@ |
| 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,9 +421,7 @@ |
| } |
| String allocateTemporary() { |
| - // Don't start at 0 because t0 is being used for |
| - // [VariableNames.SWAP_TEMP]. |
| - int i = 1; |
| + int i = 0; |
| String name = 't${i++}'; |
| while (usedNames.contains(name)) name = 't${i++}'; |
|
Lasse Reichstein Nielsen
2012/06/07 08:53:21
This looks like something that has quadratic perfo
ngeoffray
2012/06/07 09:10:41
Good point. Done.
|
| 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); |