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

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

Issue 11092104: Reserve a state variable for the bailout function. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comment. Created 8 years, 2 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: lib/compiler/implementation/ssa/variable_allocator.dart
diff --git a/lib/compiler/implementation/ssa/variable_allocator.dart b/lib/compiler/implementation/ssa/variable_allocator.dart
index 167c91f975ccef5f681980e8e9e06c2385c5e867..d317a4a959e9d46c78d7ea5758aa87b9682a0acc 100644
--- a/lib/compiler/implementation/ssa/variable_allocator.dart
+++ b/lib/compiler/implementation/ssa/variable_allocator.dart
@@ -369,22 +369,30 @@ class VariableNames {
final Map<HInstruction, String> ownName;
final Map<HBasicBlock, CopyHandler> copyHandlers;
/**
- * Name that is being used as a temporary to break cycles in
+ * Name that is 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.
*/
final String swapTemp;
+ /**
+ * Name that is used in bailout code. We make sure this name is not being used
+ * anywhere by reserving it when we allocate names for instructions.
+ */
+ final String stateName;
VariableNames(Map<Element, String> parameterNames)
: ownName = new Map<HInstruction, String>(),
copyHandlers = new Map<HBasicBlock, CopyHandler>(),
- swapTemp = computeSwapTemp(parameterNames);
+ swapTemp = computeFreshWithPrefix("t", parameterNames),
+ stateName = computeFreshWithPrefix("state", parameterNames);
- static String computeSwapTemp(Map<Element, String> parameterNames) {
+ /** Returns a fresh variable with the given prefix. */
+ static String computeFreshWithPrefix(String prefix,
+ Map<Element, String> parameterNames) {
Set<String> parameters = new Set<String>.from(parameterNames.getValues());
- String name = 't0';
+ String name = '${prefix}0';
int i = 1;
- while (parameters.contains(name)) name = 't${i++}';
+ while (parameters.contains(name)) name = '$prefix${i++}';
return name;
}
@@ -424,9 +432,11 @@ class VariableNamer {
VariableNamer(LiveEnvironment environment, this.names, this.parameterNames)
: 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.
+ // [VariableNames.swapTemp] and [VariableNames.stateName] are being used
+ // throughout the function. Therefore we make sure no one uses it at any
ngeoffray 2012/10/15 14:12:29 I'd prefer keeping the comment that was there befo
floitsch 2012/10/18 14:58:47 https://codereview.chromium.org/11186048
+ // time.
usedNames.add(names.swapTemp);
+ usedNames.add(names.stateName);
// All liveIns instructions must have a name at this point, so we
// add them to the list of used names.

Powered by Google App Engine
This is Rietveld 408576698