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 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 jsgraph()->ZeroConstant())); | 920 jsgraph()->ZeroConstant())); |
921 node->TrimInputCount(1); | 921 node->TrimInputCount(1); |
922 NodeProperties::ChangeOp(node, simplified()->BooleanNot()); | 922 NodeProperties::ChangeOp(node, simplified()->BooleanNot()); |
923 return Changed(node); | 923 return Changed(node); |
924 } else if (input_type->Is(Type::Number())) { | 924 } else if (input_type->Is(Type::Number())) { |
925 // JSToBoolean(x:number) => NumberToBoolean(x) | 925 // JSToBoolean(x:number) => NumberToBoolean(x) |
926 RelaxEffectsAndControls(node); | 926 RelaxEffectsAndControls(node); |
927 node->TrimInputCount(1); | 927 node->TrimInputCount(1); |
928 NodeProperties::ChangeOp(node, simplified()->NumberToBoolean()); | 928 NodeProperties::ChangeOp(node, simplified()->NumberToBoolean()); |
929 return Changed(node); | 929 return Changed(node); |
930 } else if (input_type->Is(Type::String())) { | |
931 // JSToBoolean(x:string) => NumberLessThan(#0,x.length) | |
932 FieldAccess const access = AccessBuilder::ForStringLength(); | |
933 Node* length = graph()->NewNode(simplified()->LoadField(access), input, | |
934 graph()->start(), graph()->start()); | |
935 ReplaceWithValue(node, node, length); | |
936 node->ReplaceInput(0, jsgraph()->ZeroConstant()); | |
937 node->ReplaceInput(1, length); | |
938 NodeProperties::ChangeOp(node, simplified()->NumberLessThan()); | |
939 return Changed(node); | |
940 } | 930 } |
941 return NoChange(); | 931 return NoChange(); |
942 } | 932 } |
943 | 933 |
944 Reduction JSTypedLowering::ReduceJSToInteger(Node* node) { | 934 Reduction JSTypedLowering::ReduceJSToInteger(Node* node) { |
945 Node* const input = NodeProperties::GetValueInput(node, 0); | 935 Node* const input = NodeProperties::GetValueInput(node, 0); |
946 Type* const input_type = NodeProperties::GetType(input); | 936 Type* const input_type = NodeProperties::GetType(input); |
947 if (input_type->Is(type_cache_.kIntegerOrMinusZero)) { | 937 if (input_type->Is(type_cache_.kIntegerOrMinusZero)) { |
948 // JSToInteger(x:integer) => x | 938 // JSToInteger(x:integer) => x |
949 ReplaceWithValue(node, input); | 939 ReplaceWithValue(node, input); |
(...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2151 } | 2141 } |
2152 | 2142 |
2153 | 2143 |
2154 CompilationDependencies* JSTypedLowering::dependencies() const { | 2144 CompilationDependencies* JSTypedLowering::dependencies() const { |
2155 return dependencies_; | 2145 return dependencies_; |
2156 } | 2146 } |
2157 | 2147 |
2158 } // namespace compiler | 2148 } // namespace compiler |
2159 } // namespace internal | 2149 } // namespace internal |
2160 } // namespace v8 | 2150 } // namespace v8 |
OLD | NEW |