Chromium Code Reviews| 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) { |