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 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
921 return Changed(input); | 921 return Changed(input); |
922 } | 922 } |
923 if (input_type->Is(Type::Undefined())) { | 923 if (input_type->Is(Type::Undefined())) { |
924 // JSToNumber(undefined) => #NaN | 924 // JSToNumber(undefined) => #NaN |
925 return Replace(jsgraph()->NaNConstant()); | 925 return Replace(jsgraph()->NaNConstant()); |
926 } | 926 } |
927 if (input_type->Is(Type::Null())) { | 927 if (input_type->Is(Type::Null())) { |
928 // JSToNumber(null) => #0 | 928 // JSToNumber(null) => #0 |
929 return Replace(jsgraph()->ZeroConstant()); | 929 return Replace(jsgraph()->ZeroConstant()); |
930 } | 930 } |
931 if (input_type->Is(Type::Boolean())) { | |
932 // JSToNumber(x:boolean) => BooleanToNumber(x) | |
933 return Replace(graph()->NewNode(simplified()->BooleanToNumber(), input)); | |
934 } | |
935 if (input_type->Is(Type::String())) { | |
936 // JSToNumber(x:string) => StringToNumber(x) | |
937 return Replace(graph()->NewNode(simplified()->StringToNumber(), input)); | |
938 } | |
939 return NoChange(); | 931 return NoChange(); |
940 } | 932 } |
941 | 933 |
942 | 934 |
943 Reduction JSTypedLowering::ReduceJSToNumber(Node* node) { | 935 Reduction JSTypedLowering::ReduceJSToNumber(Node* node) { |
944 // Try to reduce the input first. | 936 // Try to reduce the input first. |
945 Node* const input = node->InputAt(0); | 937 Node* const input = node->InputAt(0); |
946 Reduction reduction = ReduceJSToNumberInput(input); | 938 Reduction reduction = ReduceJSToNumberInput(input); |
947 if (reduction.Changed()) { | 939 if (reduction.Changed()) { |
948 ReplaceWithValue(node, reduction.replacement()); | 940 ReplaceWithValue(node, reduction.replacement()); |
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2072 } | 2064 } |
2073 | 2065 |
2074 | 2066 |
2075 CompilationDependencies* JSTypedLowering::dependencies() const { | 2067 CompilationDependencies* JSTypedLowering::dependencies() const { |
2076 return dependencies_; | 2068 return dependencies_; |
2077 } | 2069 } |
2078 | 2070 |
2079 } // namespace compiler | 2071 } // namespace compiler |
2080 } // namespace internal | 2072 } // namespace internal |
2081 } // namespace v8 | 2073 } // namespace v8 |
OLD | NEW |