Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 class SsaCodeGeneratorTask extends CompilerTask { | 7 class SsaCodeGeneratorTask extends CompilerTask { |
| 8 | 8 |
| 9 final JavaScriptBackend backend; | 9 final JavaScriptBackend backend; |
| 10 | 10 |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 649 List<js.SwitchClause> cases = <js.SwitchClause>[]; | 649 List<js.SwitchClause> cases = <js.SwitchClause>[]; |
| 650 HSwitch switchInstruction = info.expression.end.last; | 650 HSwitch switchInstruction = info.expression.end.last; |
| 651 List<HInstruction> inputs = switchInstruction.inputs; | 651 List<HInstruction> inputs = switchInstruction.inputs; |
| 652 List<HBasicBlock> successors = switchInstruction.block.successors; | 652 List<HBasicBlock> successors = switchInstruction.block.successors; |
| 653 | 653 |
| 654 js.Block oldContainer = currentContainer; | 654 js.Block oldContainer = currentContainer; |
| 655 for (int inputIndex = 1, statementIndex = 0; | 655 for (int inputIndex = 1, statementIndex = 0; |
| 656 inputIndex < inputs.length; | 656 inputIndex < inputs.length; |
| 657 statementIndex++) { | 657 statementIndex++) { |
| 658 HBasicBlock successor = successors[inputIndex - 1]; | 658 HBasicBlock successor = successors[inputIndex - 1]; |
| 659 do { | 659 // If liveness analysis has figured out that this case is dead, |
| 660 visit(inputs[inputIndex]); | 660 // omit the code for it. |
| 661 currentContainer = new js.Block.empty(); | 661 if (successor.isLive) { |
| 662 cases.add(new js.Case(pop(), currentContainer)); | 662 do { |
| 663 inputIndex++; | 663 visit(inputs[inputIndex]); |
| 664 } while ((successors[inputIndex - 1] == successor) | 664 currentContainer = new js.Block.empty(); |
| 665 && (inputIndex < inputs.length)); | 665 cases.add(new js.Case(pop(), currentContainer)); |
| 666 inputIndex++; | |
| 667 } while ((successors[inputIndex - 1] == successor) | |
| 668 && (inputIndex < inputs.length)); | |
| 666 | 669 |
| 667 generateStatements(info.statements[statementIndex]); | 670 generateStatements(info.statements[statementIndex]); |
| 671 } else { | |
| 672 // Skip all the case statements that belong to this | |
| 673 // block. | |
| 674 while ((successors[inputIndex - 1] == successor) | |
| 675 && (inputIndex < inputs.length)) { | |
| 676 ++inputIndex; | |
| 677 } | |
| 678 } | |
| 668 } | 679 } |
| 669 | 680 |
| 670 currentContainer = new js.Block.empty(); | 681 // If the default case is dead, we omit it. Likewise, if it is an |
| 671 cases.add(new js.Default(currentContainer)); | 682 // empty block, we omit it, too. |
| 672 generateStatements(info.statements.last); | 683 if (info.statements.last.start.isLive) { |
| 684 currentContainer = new js.Block.empty(); | |
| 685 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
| |
| 686 if (currentContainer.statements.isNotEmpty) | |
|
karlklose
2014/03/12 14:43:45
Please use curly braces.
herhut
2014/03/13 13:27:45
Done.
| |
| 687 cases.add(new js.Default(currentContainer)); | |
| 688 } | |
| 673 | 689 |
| 674 currentContainer = oldContainer; | 690 currentContainer = oldContainer; |
| 675 | 691 |
| 676 js.Statement result = new js.Switch(key, cases); | 692 js.Statement result = new js.Switch(key, cases); |
| 677 pushStatement(wrapIntoLabels(result, info.labels)); | 693 pushStatement(wrapIntoLabels(result, info.labels)); |
| 678 return true; | 694 return true; |
| 679 } | 695 } |
| 680 | 696 |
| 681 bool visitSequenceInfo(HStatementSequenceInformation info) { | 697 bool visitSequenceInfo(HStatementSequenceInformation info) { |
| 682 return false; | 698 return false; |
| (...skipping 1978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2661 if (left.isConstantNull() || right.isConstantNull() || | 2677 if (left.isConstantNull() || right.isConstantNull() || |
| 2662 (left.isPrimitive(compiler) && | 2678 (left.isPrimitive(compiler) && |
| 2663 left.instructionType == right.instructionType)) { | 2679 left.instructionType == right.instructionType)) { |
| 2664 return '=='; | 2680 return '=='; |
| 2665 } | 2681 } |
| 2666 return null; | 2682 return null; |
| 2667 } else { | 2683 } else { |
| 2668 return '==='; | 2684 return '==='; |
| 2669 } | 2685 } |
| 2670 } | 2686 } |
| OLD | NEW |