| 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 1799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1810 // This optimization doesn't work for NaN, so we only do it if the | 1810 // This optimization doesn't work for NaN, so we only do it if the |
| 1811 // type is known to be an integer. | 1811 // type is known to be an integer. |
| 1812 return left.isInteger(compiler) && right.isInteger(compiler); | 1812 return left.isInteger(compiler) && right.isInteger(compiler); |
| 1813 } | 1813 } |
| 1814 | 1814 |
| 1815 bool handledBySpecialCase = false; | 1815 bool handledBySpecialCase = false; |
| 1816 if (isGenerateAtUseSite(input)) { | 1816 if (isGenerateAtUseSite(input)) { |
| 1817 handledBySpecialCase = true; | 1817 handledBySpecialCase = true; |
| 1818 if (input is HIs) { | 1818 if (input is HIs) { |
| 1819 emitIs(input, '!=='); | 1819 emitIs(input, '!=='); |
| 1820 } else if (input is HNot) { |
| 1821 use(input.inputs[0]); |
| 1820 } else if (input is HIdentity) { | 1822 } else if (input is HIdentity) { |
| 1821 HIdentity identity = input; | 1823 HIdentity identity = input; |
| 1822 emitIdentityComparison(identity.left, identity.right, true); | 1824 emitIdentityComparison(identity.left, identity.right, true); |
| 1823 } else if (input is HBoolify) { | 1825 } else if (input is HBoolify) { |
| 1824 use(input.inputs[0]); | 1826 use(input.inputs[0]); |
| 1825 push(new js.Binary("!==", pop(), newLiteralBool(true)), input); | 1827 push(new js.Binary("!==", pop(), newLiteralBool(true)), input); |
| 1826 } else if (canGenerateOptimizedComparison(input)) { | 1828 } else if (canGenerateOptimizedComparison(input)) { |
| 1827 HRelational relational = input; | 1829 HRelational relational = input; |
| 1828 BinaryOperation operation = | 1830 BinaryOperation operation = |
| 1829 relational.operation(backend.constantSystem); | 1831 relational.operation(backend.constantSystem); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1859 HBasicBlock ifBlock = node.block.dominator; | 1861 HBasicBlock ifBlock = node.block.dominator; |
| 1860 assert(controlFlowOperators.contains(ifBlock.last)); | 1862 assert(controlFlowOperators.contains(ifBlock.last)); |
| 1861 HInstruction input = ifBlock.last.inputs[0]; | 1863 HInstruction input = ifBlock.last.inputs[0]; |
| 1862 if (input.isConstantFalse()) { | 1864 if (input.isConstantFalse()) { |
| 1863 use(node.inputs[1]); | 1865 use(node.inputs[1]); |
| 1864 } else if (input.isConstantTrue()) { | 1866 } else if (input.isConstantTrue()) { |
| 1865 use(node.inputs[0]); | 1867 use(node.inputs[0]); |
| 1866 } else if (node.inputs[1].isConstantBoolean()) { | 1868 } else if (node.inputs[1].isConstantBoolean()) { |
| 1867 String operation = node.inputs[1].isConstantFalse() ? '&&' : '||'; | 1869 String operation = node.inputs[1].isConstantFalse() ? '&&' : '||'; |
| 1868 if (operation == '||') { | 1870 if (operation == '||') { |
| 1869 if (input is HNot) { | 1871 generateNot(input); |
| 1870 use(input.inputs[0]); | |
| 1871 } else { | |
| 1872 generateNot(input); | |
| 1873 } | |
| 1874 } else { | 1872 } else { |
| 1875 use(input); | 1873 use(input); |
| 1876 } | 1874 } |
| 1877 js.Expression left = pop(); | 1875 js.Expression left = pop(); |
| 1878 use(node.inputs[0]); | 1876 use(node.inputs[0]); |
| 1879 push(new js.Binary(operation, left, pop())); | 1877 push(new js.Binary(operation, left, pop())); |
| 1880 } else { | 1878 } else { |
| 1881 use(input); | 1879 use(input); |
| 1882 js.Expression test = pop(); | 1880 js.Expression test = pop(); |
| 1883 use(node.inputs[0]); | 1881 use(node.inputs[0]); |
| (...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2670 if (left.isConstantNull() || right.isConstantNull() || | 2668 if (left.isConstantNull() || right.isConstantNull() || |
| 2671 (left.isPrimitive(compiler) && | 2669 (left.isPrimitive(compiler) && |
| 2672 left.instructionType == right.instructionType)) { | 2670 left.instructionType == right.instructionType)) { |
| 2673 return '=='; | 2671 return '=='; |
| 2674 } | 2672 } |
| 2675 return null; | 2673 return null; |
| 2676 } else { | 2674 } else { |
| 2677 return '==='; | 2675 return '==='; |
| 2678 } | 2676 } |
| 2679 } | 2677 } |
| OLD | NEW |