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/compiler/simplified-lowering.h" | 5 #include "src/compiler/simplified-lowering.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "src/address-map.h" | 9 #include "src/address-map.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 2043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2054 if (lower()) NodeProperties::ChangeOp(node, Uint32Op(node)); | 2054 if (lower()) NodeProperties::ChangeOp(node, Uint32Op(node)); |
2055 return; | 2055 return; |
2056 } | 2056 } |
2057 case IrOpcode::kNumberFround: { | 2057 case IrOpcode::kNumberFround: { |
2058 VisitUnop(node, UseInfo::TruncatingFloat64(), | 2058 VisitUnop(node, UseInfo::TruncatingFloat64(), |
2059 MachineRepresentation::kFloat32); | 2059 MachineRepresentation::kFloat32); |
2060 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); | 2060 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); |
2061 return; | 2061 return; |
2062 } | 2062 } |
2063 case IrOpcode::kNumberMax: { | 2063 case IrOpcode::kNumberMax: { |
2064 // TODO(turbofan): We should consider feedback types here as well. | 2064 // It is safe to use the feedback types for left and right hand side |
2065 if (BothInputsAreUnsigned32(node)) { | 2065 // here, since we can only narrow those types and thus we can only |
| 2066 // promise a more specific truncation. |
| 2067 Type* const lhs_type = TypeOf(node->InputAt(0)); |
| 2068 Type* const rhs_type = TypeOf(node->InputAt(1)); |
| 2069 if (lhs_type->Is(Type::Unsigned32()) && |
| 2070 rhs_type->Is(Type::Unsigned32())) { |
2066 VisitWord32TruncatingBinop(node); | 2071 VisitWord32TruncatingBinop(node); |
2067 if (lower()) { | 2072 if (lower()) { |
2068 lowering->DoMax(node, lowering->machine()->Uint32LessThan(), | 2073 lowering->DoMax(node, lowering->machine()->Uint32LessThan(), |
2069 MachineRepresentation::kWord32); | 2074 MachineRepresentation::kWord32); |
2070 } | 2075 } |
2071 } else if (BothInputsAreSigned32(node)) { | 2076 } else if (lhs_type->Is(Type::Signed32()) && |
| 2077 rhs_type->Is(Type::Signed32())) { |
2072 VisitWord32TruncatingBinop(node); | 2078 VisitWord32TruncatingBinop(node); |
2073 if (lower()) { | 2079 if (lower()) { |
2074 lowering->DoMax(node, lowering->machine()->Int32LessThan(), | 2080 lowering->DoMax(node, lowering->machine()->Int32LessThan(), |
2075 MachineRepresentation::kWord32); | 2081 MachineRepresentation::kWord32); |
2076 } | 2082 } |
2077 } else if (BothInputsAre(node, Type::PlainNumber())) { | 2083 } else if (lhs_type->Is(Type::PlainNumber()) && |
| 2084 rhs_type->Is(Type::PlainNumber())) { |
2078 VisitFloat64Binop(node); | 2085 VisitFloat64Binop(node); |
2079 if (lower()) { | 2086 if (lower()) { |
2080 lowering->DoMax(node, lowering->machine()->Float64LessThan(), | 2087 lowering->DoMax(node, lowering->machine()->Float64LessThan(), |
2081 MachineRepresentation::kFloat64); | 2088 MachineRepresentation::kFloat64); |
2082 } | 2089 } |
2083 } else { | 2090 } else { |
2084 VisitFloat64Binop(node); | 2091 VisitFloat64Binop(node); |
2085 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); | 2092 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); |
2086 } | 2093 } |
2087 return; | 2094 return; |
2088 } | 2095 } |
2089 case IrOpcode::kNumberMin: { | 2096 case IrOpcode::kNumberMin: { |
2090 // TODO(turbofan): We should consider feedback types here as well. | 2097 // It is safe to use the feedback types for left and right hand side |
2091 if (BothInputsAreUnsigned32(node)) { | 2098 // here, since we can only narrow those types and thus we can only |
| 2099 // promise a more specific truncation. |
| 2100 Type* const lhs_type = TypeOf(node->InputAt(0)); |
| 2101 Type* const rhs_type = TypeOf(node->InputAt(1)); |
| 2102 if (lhs_type->Is(Type::Unsigned32()) && |
| 2103 rhs_type->Is(Type::Unsigned32())) { |
2092 VisitWord32TruncatingBinop(node); | 2104 VisitWord32TruncatingBinop(node); |
2093 if (lower()) { | 2105 if (lower()) { |
2094 lowering->DoMin(node, lowering->machine()->Uint32LessThan(), | 2106 lowering->DoMin(node, lowering->machine()->Uint32LessThan(), |
2095 MachineRepresentation::kWord32); | 2107 MachineRepresentation::kWord32); |
2096 } | 2108 } |
2097 } else if (BothInputsAreSigned32(node)) { | 2109 } else if (lhs_type->Is(Type::Signed32()) && |
| 2110 rhs_type->Is(Type::Signed32())) { |
2098 VisitWord32TruncatingBinop(node); | 2111 VisitWord32TruncatingBinop(node); |
2099 if (lower()) { | 2112 if (lower()) { |
2100 lowering->DoMin(node, lowering->machine()->Int32LessThan(), | 2113 lowering->DoMin(node, lowering->machine()->Int32LessThan(), |
2101 MachineRepresentation::kWord32); | 2114 MachineRepresentation::kWord32); |
2102 } | 2115 } |
2103 } else if (BothInputsAre(node, Type::PlainNumber())) { | 2116 } else if (lhs_type->Is(Type::PlainNumber()) && |
| 2117 rhs_type->Is(Type::PlainNumber())) { |
2104 VisitFloat64Binop(node); | 2118 VisitFloat64Binop(node); |
2105 if (lower()) { | 2119 if (lower()) { |
2106 lowering->DoMin(node, lowering->machine()->Float64LessThan(), | 2120 lowering->DoMin(node, lowering->machine()->Float64LessThan(), |
2107 MachineRepresentation::kFloat64); | 2121 MachineRepresentation::kFloat64); |
2108 } | 2122 } |
2109 } else { | 2123 } else { |
2110 VisitFloat64Binop(node); | 2124 VisitFloat64Binop(node); |
2111 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); | 2125 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); |
2112 } | 2126 } |
2113 return; | 2127 return; |
(...skipping 1456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3570 isolate(), graph()->zone(), callable.descriptor(), 0, flags, | 3584 isolate(), graph()->zone(), callable.descriptor(), 0, flags, |
3571 Operator::kNoProperties); | 3585 Operator::kNoProperties); |
3572 to_number_operator_.set(common()->Call(desc)); | 3586 to_number_operator_.set(common()->Call(desc)); |
3573 } | 3587 } |
3574 return to_number_operator_.get(); | 3588 return to_number_operator_.get(); |
3575 } | 3589 } |
3576 | 3590 |
3577 } // namespace compiler | 3591 } // namespace compiler |
3578 } // namespace internal | 3592 } // namespace internal |
3579 } // namespace v8 | 3593 } // namespace v8 |
OLD | NEW |