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/js-typed-lowering.h" | 5 #include "src/compiler/js-typed-lowering.h" |
6 | 6 |
7 #include "src/builtins/builtins-utils.h" | 7 #include "src/builtins/builtins-utils.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/compilation-dependencies.h" | 9 #include "src/compilation-dependencies.h" |
10 #include "src/compiler/access-builder.h" | 10 #include "src/compiler/access-builder.h" |
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 Reduction JSTypedLowering::ReduceJSToLength(Node* node) { | 976 Reduction JSTypedLowering::ReduceJSToLength(Node* node) { |
977 Node* input = NodeProperties::GetValueInput(node, 0); | 977 Node* input = NodeProperties::GetValueInput(node, 0); |
978 Type* input_type = NodeProperties::GetType(input); | 978 Type* input_type = NodeProperties::GetType(input); |
979 if (input_type->Is(type_cache_.kIntegerOrMinusZero)) { | 979 if (input_type->Is(type_cache_.kIntegerOrMinusZero)) { |
980 if (input_type->Max() <= 0.0) { | 980 if (input_type->Max() <= 0.0) { |
981 input = jsgraph()->ZeroConstant(); | 981 input = jsgraph()->ZeroConstant(); |
982 } else if (input_type->Min() >= kMaxSafeInteger) { | 982 } else if (input_type->Min() >= kMaxSafeInteger) { |
983 input = jsgraph()->Constant(kMaxSafeInteger); | 983 input = jsgraph()->Constant(kMaxSafeInteger); |
984 } else { | 984 } else { |
985 if (input_type->Min() <= 0.0) { | 985 if (input_type->Min() <= 0.0) { |
986 input = graph()->NewNode( | 986 input = graph()->NewNode(simplified()->NumberMax(), |
987 common()->Select(MachineRepresentation::kTagged), | 987 jsgraph()->ZeroConstant(), input); |
988 graph()->NewNode(simplified()->NumberLessThanOrEqual(), input, | |
989 jsgraph()->ZeroConstant()), | |
990 jsgraph()->ZeroConstant(), input); | |
991 input_type = Type::Range(0.0, input_type->Max(), graph()->zone()); | |
992 NodeProperties::SetType(input, input_type); | |
993 } | 988 } |
994 if (input_type->Max() > kMaxSafeInteger) { | 989 if (input_type->Max() > kMaxSafeInteger) { |
995 input = graph()->NewNode( | 990 input = graph()->NewNode(simplified()->NumberMin(), |
996 common()->Select(MachineRepresentation::kTagged), | 991 jsgraph()->Constant(kMaxSafeInteger), input); |
997 graph()->NewNode(simplified()->NumberLessThanOrEqual(), | |
998 jsgraph()->Constant(kMaxSafeInteger), input), | |
999 jsgraph()->Constant(kMaxSafeInteger), input); | |
1000 input_type = | |
1001 Type::Range(input_type->Min(), kMaxSafeInteger, graph()->zone()); | |
1002 NodeProperties::SetType(input, input_type); | |
1003 } | 992 } |
1004 } | 993 } |
1005 ReplaceWithValue(node, input); | 994 ReplaceWithValue(node, input); |
1006 return Replace(input); | 995 return Replace(input); |
1007 } | 996 } |
1008 return NoChange(); | 997 return NoChange(); |
1009 } | 998 } |
1010 | 999 |
1011 Reduction JSTypedLowering::ReduceJSToNumberInput(Node* input) { | 1000 Reduction JSTypedLowering::ReduceJSToNumberInput(Node* input) { |
1012 // Try constant-folding of JSToNumber with constant inputs. | 1001 // Try constant-folding of JSToNumber with constant inputs. |
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2179 } | 2168 } |
2180 | 2169 |
2181 | 2170 |
2182 CompilationDependencies* JSTypedLowering::dependencies() const { | 2171 CompilationDependencies* JSTypedLowering::dependencies() const { |
2183 return dependencies_; | 2172 return dependencies_; |
2184 } | 2173 } |
2185 | 2174 |
2186 } // namespace compiler | 2175 } // namespace compiler |
2187 } // namespace internal | 2176 } // namespace internal |
2188 } // namespace v8 | 2177 } // namespace v8 |
OLD | NEW |