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

Unified Diff: frog/leg/ssa/codegen.dart

Issue 9601009: Change labeled statement to use visitSubGraph for its body instead of marking its "exit block" spec… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 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: frog/leg/ssa/codegen.dart
diff --git a/frog/leg/ssa/codegen.dart b/frog/leg/ssa/codegen.dart
index bc9aa4aec4be6c1ca8b4f06fd72261685675fb49..282094fe74e0bc898d0e95dc419068dc30cc9102 100644
--- a/frog/leg/ssa/codegen.dart
+++ b/frog/leg/ssa/codegen.dart
@@ -161,7 +161,7 @@ class SsaCodeGenerator implements HVisitor {
void visitSubGraph(SubGraph newSubGraph) {
SubGraph oldSubGraph = subGraph;
subGraph = newSubGraph;
- visitBasicBlock(subGraph.start);
+ iterateBasicBlock(subGraph.start);
subGraph = oldSubGraph;
}
@@ -239,45 +239,42 @@ class SsaCodeGenerator implements HVisitor {
void handleLabeledBlock(HBasicBlock node) {
HLabeledBlockInformation labeledBlockInfo = node.labeledBlockInformation;
- if (labeledBlockInfo.start === node) {
- addIndentation();
- for (SourceString label in labeledBlockInfo.labels) {
- addLabel(label);
- buffer.add(":");
- }
- buffer.add("{\n");
- indent++;
- } else {
- assert(labeledBlockInfo.end === node);
- assert((){
- // Check that this block is (transitively) dominated by the start block.
- HBasicBlock block = node;
- while (block.dominator !== null) {
- block = block.dominator;
- if (block === labeledBlockInfo.start) return true;
- }
- return false;
- });
- indent--;
- addIndentation();
- buffer.add("}\n");
+
+ addIndentation();
+ for (SourceString label in labeledBlockInfo.labels) {
+ addLabel(label);
+ buffer.add(":");
}
+ buffer.add("{\n");
+ indent++;
+
+ visitSubGraph(labeledBlockInfo.body);
+
+ indent--;
+ addIndentation();
+ buffer.add("}\n");
+
+ visitBasicBlock(labeledBlockInfo.joinBlock);
}
visitBasicBlock(HBasicBlock node) {
if (!subGraph.contains(node)) return;
- currentBlock = node;
-
if (node.hasLabeledBlockInformation()) {
handleLabeledBlock(node);
- } else if (currentBlock.isLoopHeader()) {
+ return;
+ }
+ iterateBasicBlock(node);
+ }
+
+ iterateBasicBlock(HBasicBlock node) {
ngeoffray 2012/03/05 14:12:48 Was this change (adding iterateBasicBlock) necessa
Lasse Reichstein Nielsen 2012/03/05 14:16:49 Sadly, yes, something is necessary, but I'm not en
+ currentBlock = node;
+ if (node.isLoopHeader()) {
// While loop will be closed by the conditional loop-branch.
// TODO(floitsch): HACK HACK HACK.
beginLoop(node);
}
-
HInstruction instruction = node.first;
while (instruction != null) {
if (instruction is HGoto || instruction is HExit || instruction is HTry) {

Powered by Google App Engine
This is Rietveld 408576698