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 class SsaCodeGeneratorTask extends CompilerTask { | 5 class SsaCodeGeneratorTask extends CompilerTask { |
| 6 | 6 |
| 7 final JavaScriptBackend backend; | 7 final JavaScriptBackend backend; |
| 8 | 8 |
| 9 SsaCodeGeneratorTask(JavaScriptBackend backend) | 9 SsaCodeGeneratorTask(JavaScriptBackend backend) |
| 10 : this.backend = backend, | 10 : this.backend = backend, |
| (...skipping 1782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1793 if (instruction is !HRelational) return false; | 1793 if (instruction is !HRelational) return false; |
| 1794 HRelational relational = instruction; | 1794 HRelational relational = instruction; |
| 1795 return relational.isBuiltin(types); | 1795 return relational.isBuiltin(types); |
| 1796 } | 1796 } |
| 1797 | 1797 |
| 1798 if (input is HBoolify && isGenerateAtUseSite(input)) { | 1798 if (input is HBoolify && isGenerateAtUseSite(input)) { |
| 1799 use(input.inputs[0]); | 1799 use(input.inputs[0]); |
| 1800 push(new js.Binary("!==", pop(), new js.LiteralBool(true)), input); | 1800 push(new js.Binary("!==", pop(), new js.LiteralBool(true)), input); |
| 1801 } else if (isBuiltinRelational(input) && | 1801 } else if (isBuiltinRelational(input) && |
| 1802 isGenerateAtUseSite(input) && | 1802 isGenerateAtUseSite(input) && |
| 1803 types[input.inputs[0]].isUseful() && | |
| 1804 !input.inputs[0].isDouble(types) && | |
| 1805 types[input.inputs[1]].isUseful() && | 1803 types[input.inputs[1]].isUseful() && |
|
floitsch
2012/10/04 11:35:26
I really think we should make this input.left, inp
| |
| 1806 !input.inputs[1].isDouble(types)) { | 1804 !input.inputs[1].isDouble(types) && |
| 1805 types[input.inputs[2]].isUseful() && | |
| 1806 !input.inputs[2].isDouble(types)) { | |
| 1807 // This optimization doesn't work for NaN, so we only do it if the | 1807 // This optimization doesn't work for NaN, so we only do it if the |
| 1808 // type is known to be non-Double. | 1808 // type is known to be non-Double. |
| 1809 Map<String, String> inverseOperator = const <String, String>{ | 1809 Map<String, String> inverseOperator = const <String, String>{ |
| 1810 "==" : "!=", | 1810 "==" : "!=", |
| 1811 "!=" : "==", | 1811 "!=" : "==", |
| 1812 "===": "!==", | 1812 "===": "!==", |
| 1813 "!==": "===", | 1813 "!==": "===", |
| 1814 "<" : ">=", | 1814 "<" : ">=", |
| 1815 "<=" : ">", | 1815 "<=" : ">", |
| 1816 ">" : "<=", | 1816 ">" : "<=", |
| 1817 ">=" : "<" | 1817 ">=" : "<" |
| 1818 }; | 1818 }; |
| 1819 HRelational relational = input; | 1819 HRelational relational = input; |
| 1820 | 1820 BinaryOperation operation = relational.operation(backend.constantSystem); |
| 1821 visitInvokeBinary(input, | 1821 visitInvokeBinary(input, inverseOperator[operation.name.stringValue]); |
| 1822 inverseOperator[relational.operation.name.stringValue]); | |
| 1823 } else { | 1822 } else { |
| 1824 use(input); | 1823 use(input); |
| 1825 push(new js.Prefix("!", pop())); | 1824 push(new js.Prefix("!", pop())); |
| 1826 } | 1825 } |
| 1827 } | 1826 } |
| 1828 | 1827 |
| 1829 visitParameterValue(HParameterValue node) => visitLocalValue(node); | 1828 visitParameterValue(HParameterValue node) => visitLocalValue(node); |
| 1830 | 1829 |
| 1831 visitLocalValue(HLocalValue node) { | 1830 visitLocalValue(HLocalValue node) { |
| 1832 assert(isGenerateAtUseSite(node)); | 1831 assert(isGenerateAtUseSite(node)); |
| (...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2984 if (leftType.canBeNull() && rightType.canBeNull()) { | 2983 if (leftType.canBeNull() && rightType.canBeNull()) { |
| 2985 if (left.isConstantNull() || right.isConstantNull() || | 2984 if (left.isConstantNull() || right.isConstantNull() || |
| 2986 (leftType.isPrimitive() && leftType == rightType)) { | 2985 (leftType.isPrimitive() && leftType == rightType)) { |
| 2987 return '=='; | 2986 return '=='; |
| 2988 } | 2987 } |
| 2989 return null; | 2988 return null; |
| 2990 } else { | 2989 } else { |
| 2991 return '==='; | 2990 return '==='; |
| 2992 } | 2991 } |
| 2993 } | 2992 } |
| OLD | NEW |