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

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

Issue 10386047: Make sure all loop-phis are declared. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 | tests/language/recursive_loop_phis_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/ssa/codegen.dart
diff --git a/lib/compiler/implementation/ssa/codegen.dart b/lib/compiler/implementation/ssa/codegen.dart
index b486e0c62e1453be31363255855eb58daf207840..06f1cc9dae74d965d57b55e2f35f45f6dbfabc9f 100644
--- a/lib/compiler/implementation/ssa/codegen.dart
+++ b/lib/compiler/implementation/ssa/codegen.dart
@@ -145,6 +145,7 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
final Map<Element, String> parameterNames;
final Map<int, String> names;
final Set<String> usedNames;
+ final Set<HInstruction> declaredInstructions;
final Map<String, int> prefixes;
final Set<HInstruction> generateAtUseSite;
final Map<HPhi, String> logicalOperations;
@@ -190,6 +191,7 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
: names = new Map<int, String>(),
prefixes = new Map<String, int>(),
usedNames = new Set<String>(),
+ declaredInstructions = new Set<HInstruction>(),
buffer = new StringBuffer(),
generateAtUseSite = new Set<HInstruction>(),
logicalOperations = new Map<HPhi, String>(),
@@ -449,10 +451,6 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
return result;
}
- bool temporaryExists(HInstruction instruction) {
- return names.containsKey(instruction.id);
- }
-
String newName(int id, String name) {
String result = JsNames.getValid(name);
names[id] = result;
@@ -516,6 +514,12 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
}
}
+ void declareInstruction(HInstruction instruction) {
+ declaredInstructions.add(instruction);
+ String name = temporary(instruction);
+ declareVariable(name);
+ }
+
bool needsNewVariable(HInstruction instruction) {
bool needsVar = !instruction.usedBy.isEmpty();
if (needsVar && instruction is HCheck) {
@@ -551,8 +555,7 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
void define(HInstruction instruction) {
if (needsNewVariable(instruction)) {
- String name = temporary(instruction);
- declareVariable(name);
+ declareInstruction(instruction);
buffer.add(" = ");
visit(instruction, JSPrecedence.ASSIGNMENT_PRECEDENCE);
} else {
@@ -1030,8 +1033,8 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
temporaryNamesOfPhis.containsKey(canonicalPhi)) {
// This is the assignment to the temporary.
declareVariable(temporaryNamesOfPhis[canonicalPhi]);
- } else if (!temporaryExists(canonicalPhi)) {
- declareVariable(temporary(canonicalPhi));
+ } else if (!declaredInstructions.contains(canonicalPhi)) {
+ declareInstruction(canonicalPhi);
} else {
buffer.add(temporary(canonicalPhi));
}
« no previous file with comments | « no previous file | tests/language/recursive_loop_phis_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698