Chromium Code Reviews| Index: dart/frog/leg/ssa/builder.dart |
| diff --git a/dart/frog/leg/ssa/builder.dart b/dart/frog/leg/ssa/builder.dart |
| index c75d86b755013ebb3f999eddf7680a956565e96c..ef263dec1cb9d53d47f8d9a61877ef069a9d7457 100644 |
| --- a/dart/frog/leg/ssa/builder.dart |
| +++ b/dart/frog/leg/ssa/builder.dart |
| @@ -452,7 +452,7 @@ class LocalsHandler { |
| * goto loop-entry; |
| * loop-exit: |
| */ |
| - void startLoop(Loop node) { |
| + void startLoop(Node node) { |
| ClosureScope scopeData = closureData.capturingScopes[node]; |
| if (scopeData == null) return; |
| if (scopeData.hasBoxedLoopVariables()) { |
| @@ -1957,7 +1957,11 @@ class SsaBuilder implements Visitor { |
| visitNodeList(NodeList node) { |
| for (Link<Node> link = node.nodes; !link.isEmpty(); link = link.tail) { |
| - visit(link.head); |
| + if (isAborted()) { |
| + compiler.reportWarning(link.head, 'dead code'); |
| + } else { |
| + visit(link.head); |
| + } |
| } |
| } |
| @@ -2281,7 +2285,62 @@ class SsaBuilder implements Visitor { |
| } |
| visitSwitchStatement(SwitchStatement node) { |
| - generateUnimplemented('switch statement not implemented'); |
| + work.allowSpeculativeOptimization = false; |
| + visit(node.expression); |
| + HInstruction expression = pop(); |
| + Link cases = node.cases.nodes; |
|
ngeoffray
2012/03/06 11:49:48
Link -> Link<Node> ?
ahe
2012/03/06 12:24:35
Done.
|
| + int count = 0; |
| + handleThen() { |
| + if (cases.head.statements.nodes.isEmpty()) { |
| + compiler.unimplemented('fall-through', node: cases.head); |
| + } |
| + visit(cases.head.statements); |
| + cases = cases.tail; |
| + } |
| + handleElse() { |
| + if (cases.isEmpty()) return; |
| + if (cases.head is DefaultCase) { |
|
ngeoffray
2012/03/06 11:49:48
is DefaultCase -> asDefaultCase() != null
ahe
2012/03/06 12:24:35
Done.
|
| + stack.add(graph.addNewLiteralBool(true)); |
| + if (!cases.tail.isEmpty()) { |
| + compiler.unimplemented('default case not last', node: cases.head); |
| + } |
| + } else { |
| + SwitchCase switchCase = cases.head; |
| + visit(switchCase.expression); |
| + HInstruction caseExpression = pop(); |
| + Element equalsHelper = compiler.findHelper(const SourceString('eq')); |
|
ngeoffray
2012/03/06 11:49:48
maybe make that a method in the Interceptors class
ahe
2012/03/06 12:24:35
Done.
|
| + HInstruction target = new HStatic(equalsHelper); |
| + add(target); |
| + push(new HEquals(target, caseExpression, expression)); |
| + } |
| + handleIf(handleThen, handleElse); |
| + } |
| + |
| + localsHandler.startLoop(node); |
| + BreakHandler breakHandler = beginLoopHeader(node); |
| + HBasicBlock loopEntryBlock = current; |
| + localsHandler.enterLoopBody(node); |
| + |
| + handleElse(); |
| + |
| + if (isAborted()) { |
| + compiler.unimplemented("SsaBuilder for loop with aborting body", |
|
ngeoffray
2012/03/06 11:49:48
Err, not really :)
ahe
2012/03/06 12:24:35
Yes. Really. That is the problem.
ngeoffray
2012/03/06 12:32:55
In 'for loop' I read 'for' as in 'for (;;) {}' :)
Lasse Reichstein Nielsen
2012/03/06 12:53:50
I don't read it as that, but it's still a confusin
ahe
2012/03/06 13:10:51
I understand that the loop is purely synthetic and
Lasse Reichstein Nielsen
2012/03/06 13:23:36
I think that, in the long run, we should have diff
|
| + node: node); |
| + } |
| + |
| + HBasicBlock bodyExitBlock = close(new HGoto()); |
| + HBasicBlock conditionBlock = addNewBlock(); |
| + bodyExitBlock.addSuccessor(conditionBlock); |
| + open(conditionBlock); |
| + stack.add(graph.addNewLiteralBool(false)); |
| + |
| + conditionBlock = close(new HLoopBranch(popBoolified(), |
| + HLoopBranch.DO_WHILE_LOOP)); |
| + |
| + conditionBlock.addSuccessor(loopEntryBlock); // The back-edge. |
| + loopEntryBlock.postProcessLoopHeader(); |
| + |
| + endLoop(loopEntryBlock, conditionBlock, breakHandler); |
| } |
| visitTryStatement(TryStatement node) { |