OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/code-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/compilation-dependencies.h" | 6 #include "src/compilation-dependencies.h" |
7 #include "src/compiler/access-builder.h" | 7 #include "src/compiler/access-builder.h" |
8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
9 #include "src/compiler/js-typed-lowering.h" | 9 #include "src/compiler/js-typed-lowering.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 1829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1840 } | 1840 } |
1841 if (vtrue_type->Is(false_type_) && vfalse_type->Is(true_type_)) { | 1841 if (vtrue_type->Is(false_type_) && vfalse_type->Is(true_type_)) { |
1842 // Select(condition, vtrue:false, vfalse:true) => BooleanNot(condition) | 1842 // Select(condition, vtrue:false, vfalse:true) => BooleanNot(condition) |
1843 node->TrimInputCount(1); | 1843 node->TrimInputCount(1); |
1844 NodeProperties::ChangeOp(node, simplified()->BooleanNot()); | 1844 NodeProperties::ChangeOp(node, simplified()->BooleanNot()); |
1845 return Changed(node); | 1845 return Changed(node); |
1846 } | 1846 } |
1847 return NoChange(); | 1847 return NoChange(); |
1848 } | 1848 } |
1849 | 1849 |
| 1850 Reduction JSTypedLowering::ReduceNumberRoundop(Node* node) { |
| 1851 // TODO(bmeurer): Find a better home for this thing! |
| 1852 Node* const input = NodeProperties::GetValueInput(node, 0); |
| 1853 Type* const input_type = NodeProperties::GetType(input); |
| 1854 if (input_type->Is(type_cache_.kIntegerOrMinusZeroOrNaN)) { |
| 1855 return Replace(input); |
| 1856 } |
| 1857 return NoChange(); |
| 1858 } |
1850 | 1859 |
1851 Reduction JSTypedLowering::Reduce(Node* node) { | 1860 Reduction JSTypedLowering::Reduce(Node* node) { |
1852 // Check if the output type is a singleton. In that case we already know the | 1861 // Check if the output type is a singleton. In that case we already know the |
1853 // result value and can simply replace the node if it's eliminable. | 1862 // result value and can simply replace the node if it's eliminable. |
1854 if (!NodeProperties::IsConstant(node) && NodeProperties::IsTyped(node) && | 1863 if (!NodeProperties::IsConstant(node) && NodeProperties::IsTyped(node) && |
1855 node->op()->HasProperty(Operator::kEliminatable)) { | 1864 node->op()->HasProperty(Operator::kEliminatable)) { |
1856 // We can only constant-fold nodes here, that are known to not cause any | 1865 // We can only constant-fold nodes here, that are known to not cause any |
1857 // side-effect, may it be a JavaScript observable side-effect or a possible | 1866 // side-effect, may it be a JavaScript observable side-effect or a possible |
1858 // eager deoptimization exit (i.e. {node} has an operator that doesn't have | 1867 // eager deoptimization exit (i.e. {node} has an operator that doesn't have |
1859 // the Operator::kNoDeopt property). | 1868 // the Operator::kNoDeopt property). |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1961 case IrOpcode::kJSForInStep: | 1970 case IrOpcode::kJSForInStep: |
1962 return ReduceJSForInStep(node); | 1971 return ReduceJSForInStep(node); |
1963 case IrOpcode::kJSGeneratorStore: | 1972 case IrOpcode::kJSGeneratorStore: |
1964 return ReduceJSGeneratorStore(node); | 1973 return ReduceJSGeneratorStore(node); |
1965 case IrOpcode::kJSGeneratorRestoreContinuation: | 1974 case IrOpcode::kJSGeneratorRestoreContinuation: |
1966 return ReduceJSGeneratorRestoreContinuation(node); | 1975 return ReduceJSGeneratorRestoreContinuation(node); |
1967 case IrOpcode::kJSGeneratorRestoreRegister: | 1976 case IrOpcode::kJSGeneratorRestoreRegister: |
1968 return ReduceJSGeneratorRestoreRegister(node); | 1977 return ReduceJSGeneratorRestoreRegister(node); |
1969 case IrOpcode::kSelect: | 1978 case IrOpcode::kSelect: |
1970 return ReduceSelect(node); | 1979 return ReduceSelect(node); |
| 1980 case IrOpcode::kNumberCeil: |
| 1981 case IrOpcode::kNumberFloor: |
| 1982 case IrOpcode::kNumberRound: |
| 1983 case IrOpcode::kNumberTrunc: |
| 1984 return ReduceNumberRoundop(node); |
1971 default: | 1985 default: |
1972 break; | 1986 break; |
1973 } | 1987 } |
1974 return NoChange(); | 1988 return NoChange(); |
1975 } | 1989 } |
1976 | 1990 |
1977 | 1991 |
1978 Node* JSTypedLowering::Word32Shl(Node* const lhs, int32_t const rhs) { | 1992 Node* JSTypedLowering::Word32Shl(Node* const lhs, int32_t const rhs) { |
1979 if (rhs == 0) return lhs; | 1993 if (rhs == 0) return lhs; |
1980 return graph()->NewNode(machine()->Word32Shl(), lhs, | 1994 return graph()->NewNode(machine()->Word32Shl(), lhs, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2019 } | 2033 } |
2020 | 2034 |
2021 | 2035 |
2022 CompilationDependencies* JSTypedLowering::dependencies() const { | 2036 CompilationDependencies* JSTypedLowering::dependencies() const { |
2023 return dependencies_; | 2037 return dependencies_; |
2024 } | 2038 } |
2025 | 2039 |
2026 } // namespace compiler | 2040 } // namespace compiler |
2027 } // namespace internal | 2041 } // namespace internal |
2028 } // namespace v8 | 2042 } // namespace v8 |
OLD | NEW |