Chromium Code Reviews| 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. | |
| 2065 if (BothInputsAreUnsigned32(node)) { | 2064 if (BothInputsAreUnsigned32(node)) { |
| 2066 VisitWord32TruncatingBinop(node); | 2065 VisitWord32TruncatingBinop(node); |
| 2067 if (lower()) { | 2066 if (lower()) { |
| 2068 lowering->DoMax(node, lowering->machine()->Uint32LessThan(), | 2067 lowering->DoMax(node, lowering->machine()->Uint32LessThan(), |
| 2069 MachineRepresentation::kWord32); | 2068 MachineRepresentation::kWord32); |
| 2070 } | 2069 } |
| 2071 } else if (BothInputsAreSigned32(node)) { | 2070 } else if (BothInputsAreSigned32(node)) { |
| 2072 VisitWord32TruncatingBinop(node); | 2071 VisitWord32TruncatingBinop(node); |
| 2073 if (lower()) { | 2072 if (lower()) { |
| 2074 lowering->DoMax(node, lowering->machine()->Int32LessThan(), | 2073 lowering->DoMax(node, lowering->machine()->Int32LessThan(), |
| 2075 MachineRepresentation::kWord32); | 2074 MachineRepresentation::kWord32); |
| 2076 } | 2075 } |
| 2077 } else if (BothInputsAre(node, Type::PlainNumber())) { | 2076 } else { |
| 2078 VisitFloat64Binop(node); | 2077 // Below we use feedback types and thus we must always promise |
| 2079 if (lower()) { | 2078 // a consistent truncation, namely Truncation::Float64(). |
| 2080 lowering->DoMax(node, lowering->machine()->Float64LessThan(), | 2079 Type* const lhs_type = TypeOf(node->InputAt(0)); |
| 2081 MachineRepresentation::kFloat64); | 2080 Type* const rhs_type = TypeOf(node->InputAt(1)); |
| 2081 if (lhs_type->Is(Type::Unsigned32()) && | |
| 2082 rhs_type->Is(Type::Unsigned32())) { | |
| 2083 VisitBinop(node, UseInfo::TruncatingFloat64AsWord32(), | |
|
Jarin
2017/03/07 23:00:51
Hmm, now that I have been staring at this for long
Benedikt Meurer
2017/03/08 04:44:07
Yes, I think it's sufficient to look at the feedba
| |
| 2084 MachineRepresentation::kWord32); | |
| 2085 if (lower()) { | |
| 2086 lowering->DoMax(node, lowering->machine()->Uint32LessThan(), | |
| 2087 MachineRepresentation::kWord32); | |
| 2088 } | |
| 2089 } else if (lhs_type->Is(Type::Signed32()) && | |
| 2090 rhs_type->Is(Type::Signed32())) { | |
| 2091 VisitBinop(node, UseInfo::TruncatingFloat64AsWord32(), | |
| 2092 MachineRepresentation::kWord32); | |
| 2093 if (lower()) { | |
| 2094 lowering->DoMax(node, lowering->machine()->Int32LessThan(), | |
| 2095 MachineRepresentation::kWord32); | |
| 2096 } | |
| 2097 } else if (lhs_type->Is(Type::PlainNumber()) && | |
| 2098 rhs_type->Is(Type::PlainNumber())) { | |
| 2099 VisitFloat64Binop(node); | |
| 2100 if (lower()) { | |
| 2101 lowering->DoMax(node, lowering->machine()->Float64LessThan(), | |
| 2102 MachineRepresentation::kFloat64); | |
| 2103 } | |
| 2104 } else { | |
| 2105 VisitFloat64Binop(node); | |
| 2106 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); | |
| 2082 } | 2107 } |
| 2083 } else { | |
| 2084 VisitFloat64Binop(node); | |
| 2085 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); | |
| 2086 } | 2108 } |
| 2087 return; | 2109 return; |
| 2088 } | 2110 } |
| 2089 case IrOpcode::kNumberMin: { | 2111 case IrOpcode::kNumberMin: { |
| 2090 // TODO(turbofan): We should consider feedback types here as well. | |
| 2091 if (BothInputsAreUnsigned32(node)) { | 2112 if (BothInputsAreUnsigned32(node)) { |
| 2092 VisitWord32TruncatingBinop(node); | 2113 VisitWord32TruncatingBinop(node); |
| 2093 if (lower()) { | 2114 if (lower()) { |
| 2094 lowering->DoMin(node, lowering->machine()->Uint32LessThan(), | 2115 lowering->DoMin(node, lowering->machine()->Uint32LessThan(), |
| 2095 MachineRepresentation::kWord32); | 2116 MachineRepresentation::kWord32); |
| 2096 } | 2117 } |
| 2097 } else if (BothInputsAreSigned32(node)) { | 2118 } else if (BothInputsAreSigned32(node)) { |
| 2098 VisitWord32TruncatingBinop(node); | 2119 VisitWord32TruncatingBinop(node); |
| 2099 if (lower()) { | 2120 if (lower()) { |
| 2100 lowering->DoMin(node, lowering->machine()->Int32LessThan(), | 2121 lowering->DoMin(node, lowering->machine()->Int32LessThan(), |
| 2101 MachineRepresentation::kWord32); | 2122 MachineRepresentation::kWord32); |
| 2102 } | 2123 } |
| 2103 } else if (BothInputsAre(node, Type::PlainNumber())) { | 2124 } else { |
| 2104 VisitFloat64Binop(node); | 2125 // Below we use feedback types and thus we must always promise |
| 2105 if (lower()) { | 2126 // a consistent truncation, namely Truncation::Float64(). |
| 2106 lowering->DoMin(node, lowering->machine()->Float64LessThan(), | 2127 Type* const lhs_type = TypeOf(node->InputAt(0)); |
| 2107 MachineRepresentation::kFloat64); | 2128 Type* const rhs_type = TypeOf(node->InputAt(1)); |
| 2129 if (lhs_type->Is(Type::Unsigned32()) && | |
| 2130 rhs_type->Is(Type::Unsigned32())) { | |
| 2131 VisitBinop(node, UseInfo::TruncatingFloat64AsWord32(), | |
| 2132 MachineRepresentation::kWord32); | |
| 2133 if (lower()) { | |
| 2134 lowering->DoMin(node, lowering->machine()->Uint32LessThan(), | |
| 2135 MachineRepresentation::kWord32); | |
| 2136 } | |
| 2137 } else if (lhs_type->Is(Type::Signed32()) && | |
| 2138 rhs_type->Is(Type::Signed32())) { | |
| 2139 VisitBinop(node, UseInfo::TruncatingFloat64AsWord32(), | |
| 2140 MachineRepresentation::kWord32); | |
| 2141 if (lower()) { | |
| 2142 lowering->DoMin(node, lowering->machine()->Int32LessThan(), | |
| 2143 MachineRepresentation::kWord32); | |
| 2144 } | |
| 2145 } else if (lhs_type->Is(Type::PlainNumber()) && | |
| 2146 rhs_type->Is(Type::PlainNumber())) { | |
| 2147 VisitFloat64Binop(node); | |
| 2148 if (lower()) { | |
| 2149 lowering->DoMin(node, lowering->machine()->Float64LessThan(), | |
| 2150 MachineRepresentation::kFloat64); | |
| 2151 } | |
| 2152 } else { | |
| 2153 VisitFloat64Binop(node); | |
| 2154 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); | |
| 2108 } | 2155 } |
| 2109 } else { | |
| 2110 VisitFloat64Binop(node); | |
| 2111 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); | |
| 2112 } | 2156 } |
| 2113 return; | 2157 return; |
| 2114 } | 2158 } |
| 2115 case IrOpcode::kNumberAtan2: | 2159 case IrOpcode::kNumberAtan2: |
| 2116 case IrOpcode::kNumberPow: { | 2160 case IrOpcode::kNumberPow: { |
| 2117 VisitBinop(node, UseInfo::TruncatingFloat64(), | 2161 VisitBinop(node, UseInfo::TruncatingFloat64(), |
| 2118 MachineRepresentation::kFloat64); | 2162 MachineRepresentation::kFloat64); |
| 2119 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); | 2163 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); |
| 2120 return; | 2164 return; |
| 2121 } | 2165 } |
| (...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3570 isolate(), graph()->zone(), callable.descriptor(), 0, flags, | 3614 isolate(), graph()->zone(), callable.descriptor(), 0, flags, |
| 3571 Operator::kNoProperties); | 3615 Operator::kNoProperties); |
| 3572 to_number_operator_.set(common()->Call(desc)); | 3616 to_number_operator_.set(common()->Call(desc)); |
| 3573 } | 3617 } |
| 3574 return to_number_operator_.get(); | 3618 return to_number_operator_.get(); |
| 3575 } | 3619 } |
| 3576 | 3620 |
| 3577 } // namespace compiler | 3621 } // namespace compiler |
| 3578 } // namespace internal | 3622 } // namespace internal |
| 3579 } // namespace v8 | 3623 } // namespace v8 |
| OLD | NEW |