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 2072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2083 return; | 2083 return; |
2084 } | 2084 } |
2085 case IrOpcode::kStringFromCharCode: { | 2085 case IrOpcode::kStringFromCharCode: { |
2086 VisitUnop(node, UseInfo::TruncatingWord32(), | 2086 VisitUnop(node, UseInfo::TruncatingWord32(), |
2087 MachineRepresentation::kTagged); | 2087 MachineRepresentation::kTagged); |
2088 return; | 2088 return; |
2089 } | 2089 } |
2090 | 2090 |
2091 case IrOpcode::kCheckBounds: { | 2091 case IrOpcode::kCheckBounds: { |
2092 Type* index_type = TypeOf(node->InputAt(0)); | 2092 Type* index_type = TypeOf(node->InputAt(0)); |
| 2093 Type* length_type = TypeOf(node->InputAt(1)); |
2093 if (index_type->Is(Type::Unsigned32())) { | 2094 if (index_type->Is(Type::Unsigned32())) { |
2094 VisitBinop(node, UseInfo::TruncatingWord32(), | 2095 VisitBinop(node, UseInfo::TruncatingWord32(), |
2095 MachineRepresentation::kWord32); | 2096 MachineRepresentation::kWord32); |
| 2097 if (lower() && index_type->Max() < length_type->Min()) { |
| 2098 // The bounds check is redundant if we already know that |
| 2099 // the index is within the bounds of [0.0, length[. |
| 2100 DeferReplacement(node, node->InputAt(0)); |
| 2101 } |
2096 } else { | 2102 } else { |
2097 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(), | 2103 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(), |
2098 UseInfo::TruncatingWord32(), | 2104 UseInfo::TruncatingWord32(), |
2099 MachineRepresentation::kWord32); | 2105 MachineRepresentation::kWord32); |
2100 } | 2106 } |
2101 if (lower()) { | |
2102 // The bounds check is redundant if we already know that | |
2103 // the index is within the bounds of [0.0, length[. | |
2104 if (index_type->Is(NodeProperties::GetType(node))) { | |
2105 DeferReplacement(node, node->InputAt(0)); | |
2106 } | |
2107 } | |
2108 return; | 2107 return; |
2109 } | 2108 } |
2110 case IrOpcode::kCheckIf: { | 2109 case IrOpcode::kCheckIf: { |
2111 ProcessInput(node, 0, UseInfo::Bool()); | 2110 ProcessInput(node, 0, UseInfo::Bool()); |
2112 ProcessRemainingInputs(node, 1); | 2111 ProcessRemainingInputs(node, 1); |
2113 SetOutput(node, MachineRepresentation::kNone); | 2112 SetOutput(node, MachineRepresentation::kNone); |
2114 return; | 2113 return; |
2115 } | 2114 } |
2116 case IrOpcode::kCheckNumber: { | 2115 case IrOpcode::kCheckNumber: { |
2117 if (InputIs(node, Type::Number())) { | 2116 if (InputIs(node, Type::Number())) { |
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3195 isolate(), graph()->zone(), callable.descriptor(), 0, flags, | 3194 isolate(), graph()->zone(), callable.descriptor(), 0, flags, |
3196 Operator::kNoProperties); | 3195 Operator::kNoProperties); |
3197 to_number_operator_.set(common()->Call(desc)); | 3196 to_number_operator_.set(common()->Call(desc)); |
3198 } | 3197 } |
3199 return to_number_operator_.get(); | 3198 return to_number_operator_.get(); |
3200 } | 3199 } |
3201 | 3200 |
3202 } // namespace compiler | 3201 } // namespace compiler |
3203 } // namespace internal | 3202 } // namespace internal |
3204 } // namespace v8 | 3203 } // namespace v8 |
OLD | NEW |