Index: sdk/lib/_internal/compiler/implementation/ssa/codegen.dart |
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart b/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart |
index 4f14f5064533f0250cdcdaea653d49c14863a715..38d324b62053d61a3ea9576be8f056b23e772564 100644 |
--- a/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart |
+++ b/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart |
@@ -656,20 +656,36 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
inputIndex < inputs.length; |
statementIndex++) { |
HBasicBlock successor = successors[inputIndex - 1]; |
- do { |
- visit(inputs[inputIndex]); |
- currentContainer = new js.Block.empty(); |
- cases.add(new js.Case(pop(), currentContainer)); |
- inputIndex++; |
- } while ((successors[inputIndex - 1] == successor) |
- && (inputIndex < inputs.length)); |
- |
- generateStatements(info.statements[statementIndex]); |
+ // If liveness analysis has figured out that this case is dead, |
+ // omit the code for it. |
+ if (successor.isLive) { |
+ do { |
+ visit(inputs[inputIndex]); |
+ currentContainer = new js.Block.empty(); |
+ cases.add(new js.Case(pop(), currentContainer)); |
+ inputIndex++; |
+ } while ((successors[inputIndex - 1] == successor) |
+ && (inputIndex < inputs.length)); |
+ |
+ generateStatements(info.statements[statementIndex]); |
+ } else { |
+ // Skip all the case statements that belong to this |
+ // block. |
+ while ((successors[inputIndex - 1] == successor) |
+ && (inputIndex < inputs.length)) { |
+ ++inputIndex; |
+ } |
+ } |
} |
- currentContainer = new js.Block.empty(); |
- cases.add(new js.Default(currentContainer)); |
- generateStatements(info.statements.last); |
+ // If the default case is dead, we omit it. Likewise, if it is an |
+ // empty block, we omit it, too. |
+ if (info.statements.last.start.isLive) { |
+ currentContainer = new js.Block.empty(); |
+ generateStatements(info.statements.last); |
karlklose
2014/03/12 14:43:45
Why did you change the order here?
herhut
2014/03/13 13:27:45
I need to generate the statements to see whether t
|
+ if (currentContainer.statements.isNotEmpty) |
karlklose
2014/03/12 14:43:45
Please use curly braces.
herhut
2014/03/13 13:27:45
Done.
|
+ cases.add(new js.Default(currentContainer)); |
+ } |
currentContainer = oldContainer; |