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

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

Issue 10532047: Try to reuse temporary 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
« 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: dart/lib/compiler/implementation/ssa/variable_allocator.dart
===================================================================
--- dart/lib/compiler/implementation/ssa/variable_allocator.dart (revision 8385)
+++ dart/lib/compiler/implementation/ssa/variable_allocator.dart (working copy)
@@ -399,10 +399,12 @@
final VariableNames names;
final Set<String> usedNames;
final Map<Element, String> parameterNames;
+ final List<String> freeTemporaryNames;
int temporaryIndex = 0;
VariableNamer(LiveEnvironment environment, this.names, this.parameterNames)
- : usedNames = new Set<String>() {
+ : usedNames = new Set<String>(),
+ freeTemporaryNames = new List<String>() {
// [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(names.swapTemp);
@@ -427,6 +429,10 @@
}
String allocateTemporary() {
+ while (!freeTemporaryNames.isEmpty()) {
+ String name = freeTemporaryNames.removeLast();
+ if (!usedNames.contains(name)) return name;
+ }
String name = 't${temporaryIndex++}';
while (usedNames.contains(name)) name = 't${temporaryIndex++}';
return name;
@@ -490,6 +496,14 @@
void freeName(HInstruction instruction) {
String ownName = names.ownName[instruction];
if (ownName != null) {
+ RegExp regexp = const RegExp('t[0-9]+');
+ // We check if we have already looked for temporary names
+ // because if we haven't, chances are the temporary we allocate
+ // in this block can match a phi with the same name in the
+ // successor block.
+ if (temporaryIndex != 0 && regexp.hasMatch(ownName)) {
+ freeTemporaryNames.addLast(ownName);
+ }
usedNames.remove(ownName);
}
}
« 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