| 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 class SsaCodeGeneratorTask extends CompilerTask { | 5 class SsaCodeGeneratorTask extends CompilerTask { |
| 6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler); | 6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler); |
| 7 String get name() => 'SSA code generator'; | 7 String get name() => 'SSA code generator'; |
| 8 | 8 |
| 9 | 9 |
| 10 String buildJavaScriptFunction(FunctionElement element, | 10 String buildJavaScriptFunction(FunctionElement element, |
| (...skipping 1657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1668 visitBasicBlock(branchBlock.successors[1]); | 1668 visitBasicBlock(branchBlock.successors[1]); |
| 1669 // With labeled breaks we can have more dominated blocks. | 1669 // With labeled breaks we can have more dominated blocks. |
| 1670 if (dominated.length >= 3) { | 1670 if (dominated.length >= 3) { |
| 1671 for (int i = 2; i < dominated.length; i++) { | 1671 for (int i = 2; i < dominated.length; i++) { |
| 1672 visitBasicBlock(dominated[i]); | 1672 visitBasicBlock(dominated[i]); |
| 1673 } | 1673 } |
| 1674 } | 1674 } |
| 1675 } | 1675 } |
| 1676 | 1676 |
| 1677 visitNot(HNot node) { | 1677 visitNot(HNot node) { |
| 1678 bool isBuiltinRelational(HInstruction instruction) { |
| 1679 if (instruction is !HRelational) return false; |
| 1680 HRelational relational = instruction; |
| 1681 return relational.builtin; |
| 1682 } |
| 1683 |
| 1678 assert(node.inputs.length == 1); | 1684 assert(node.inputs.length == 1); |
| 1679 HInstruction input = node.inputs[0]; | 1685 HInstruction input = node.inputs[0]; |
| 1680 if (input is HBoolify && isGenerateAtUseSite(input)) { | 1686 if (input is HBoolify && isGenerateAtUseSite(input)) { |
| 1681 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE); | 1687 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE); |
| 1682 assert(node.inputs.length == 1); | 1688 assert(node.inputs.length == 1); |
| 1683 use(node.inputs[0], JSPrecedence.EQUALITY_PRECEDENCE); | 1689 use(node.inputs[0], JSPrecedence.EQUALITY_PRECEDENCE); |
| 1684 buffer.add(' !== true'); | 1690 buffer.add(' !== true'); |
| 1685 endExpression(JSPrecedence.EQUALITY_PRECEDENCE); | 1691 endExpression(JSPrecedence.EQUALITY_PRECEDENCE); |
| 1686 } else if (input is HRelational && | 1692 } else if (isBuiltinRelational(input) && isGenerateAtUseSite(input)) { |
| 1687 input.builtin && | |
| 1688 isGenerateAtUseSite(input)) { | |
| 1689 Map<String, String> inverseOperator = const <String>{ | 1693 Map<String, String> inverseOperator = const <String>{ |
| 1690 "==" : "!=", | 1694 "==" : "!=", |
| 1691 "!=" : "==", | 1695 "!=" : "==", |
| 1692 "===": "!==", | 1696 "===": "!==", |
| 1693 "!==": "===", | 1697 "!==": "===", |
| 1694 "<" : ">=", | 1698 "<" : ">=", |
| 1695 "<=" : ">", | 1699 "<=" : ">", |
| 1696 ">" : "<=", | 1700 ">" : "<=", |
| 1697 ">=" : "<" | 1701 ">=" : "<" |
| 1698 }; | 1702 }; |
| 1703 HRelational relational = input; |
| 1699 visitInvokeBinary(input, | 1704 visitInvokeBinary(input, |
| 1700 inverseOperator[input.operation.name.stringValue]); | 1705 inverseOperator[relational.operation.name.stringValue]); |
| 1701 } else { | 1706 } else { |
| 1702 beginExpression(JSPrecedence.PREFIX_PRECEDENCE); | 1707 beginExpression(JSPrecedence.PREFIX_PRECEDENCE); |
| 1703 buffer.add('!'); | 1708 buffer.add('!'); |
| 1704 use(input, JSPrecedence.PREFIX_PRECEDENCE); | 1709 use(input, JSPrecedence.PREFIX_PRECEDENCE); |
| 1705 endExpression(JSPrecedence.PREFIX_PRECEDENCE); | 1710 endExpression(JSPrecedence.PREFIX_PRECEDENCE); |
| 1706 } | 1711 } |
| 1707 } | 1712 } |
| 1708 | 1713 |
| 1709 visitParameterValue(HParameterValue node) { | 1714 visitParameterValue(HParameterValue node) { |
| 1710 assert(isGenerateAtUseSite(node)); | 1715 assert(isGenerateAtUseSite(node)); |
| (...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2593 startBailoutSwitch(); | 2598 startBailoutSwitch(); |
| 2594 } | 2599 } |
| 2595 } | 2600 } |
| 2596 | 2601 |
| 2597 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { | 2602 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { |
| 2598 if (labeledBlockInfo.body.start.hasGuards()) { | 2603 if (labeledBlockInfo.body.start.hasGuards()) { |
| 2599 endBailoutSwitch(); | 2604 endBailoutSwitch(); |
| 2600 } | 2605 } |
| 2601 } | 2606 } |
| 2602 } | 2607 } |
| OLD | NEW |