| 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 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 // JSToBoolean(x:boolean) => x | 823 // JSToBoolean(x:boolean) => x |
| 824 return Replace(input); | 824 return Replace(input); |
| 825 } else if (input_type->Is(Type::OrderedNumber())) { | 825 } else if (input_type->Is(Type::OrderedNumber())) { |
| 826 // JSToBoolean(x:ordered-number) => BooleanNot(NumberEqual(x,#0)) | 826 // JSToBoolean(x:ordered-number) => BooleanNot(NumberEqual(x,#0)) |
| 827 RelaxEffectsAndControls(node); | 827 RelaxEffectsAndControls(node); |
| 828 node->ReplaceInput(0, graph()->NewNode(simplified()->NumberEqual(), input, | 828 node->ReplaceInput(0, graph()->NewNode(simplified()->NumberEqual(), input, |
| 829 jsgraph()->ZeroConstant())); | 829 jsgraph()->ZeroConstant())); |
| 830 node->TrimInputCount(1); | 830 node->TrimInputCount(1); |
| 831 NodeProperties::ChangeOp(node, simplified()->BooleanNot()); | 831 NodeProperties::ChangeOp(node, simplified()->BooleanNot()); |
| 832 return Changed(node); | 832 return Changed(node); |
| 833 } else if (input_type->Is(Type::Number())) { |
| 834 // JSToBoolean(x:number) => NumberLessThan(#0,NumberAbs(x)) |
| 835 RelaxEffectsAndControls(node); |
| 836 node->ReplaceInput(0, jsgraph()->ZeroConstant()); |
| 837 node->ReplaceInput(1, graph()->NewNode(simplified()->NumberAbs(), input)); |
| 838 node->TrimInputCount(2); |
| 839 NodeProperties::ChangeOp(node, simplified()->NumberLessThan()); |
| 840 return Changed(node); |
| 833 } else if (input_type->Is(Type::String())) { | 841 } else if (input_type->Is(Type::String())) { |
| 834 // JSToBoolean(x:string) => NumberLessThan(#0,x.length) | 842 // JSToBoolean(x:string) => NumberLessThan(#0,x.length) |
| 835 FieldAccess const access = AccessBuilder::ForStringLength(); | 843 FieldAccess const access = AccessBuilder::ForStringLength(); |
| 836 Node* length = graph()->NewNode(simplified()->LoadField(access), input, | 844 Node* length = graph()->NewNode(simplified()->LoadField(access), input, |
| 837 graph()->start(), graph()->start()); | 845 graph()->start(), graph()->start()); |
| 838 ReplaceWithValue(node, node, length); | 846 ReplaceWithValue(node, node, length); |
| 839 node->ReplaceInput(0, jsgraph()->ZeroConstant()); | 847 node->ReplaceInput(0, jsgraph()->ZeroConstant()); |
| 840 node->ReplaceInput(1, length); | 848 node->ReplaceInput(1, length); |
| 841 NodeProperties::ChangeOp(node, simplified()->NumberLessThan()); | 849 NodeProperties::ChangeOp(node, simplified()->NumberLessThan()); |
| 842 return Changed(node); | 850 return Changed(node); |
| (...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2051 } | 2059 } |
| 2052 | 2060 |
| 2053 | 2061 |
| 2054 CompilationDependencies* JSTypedLowering::dependencies() const { | 2062 CompilationDependencies* JSTypedLowering::dependencies() const { |
| 2055 return dependencies_; | 2063 return dependencies_; |
| 2056 } | 2064 } |
| 2057 | 2065 |
| 2058 } // namespace compiler | 2066 } // namespace compiler |
| 2059 } // namespace internal | 2067 } // namespace internal |
| 2060 } // namespace v8 | 2068 } // namespace v8 |
| OLD | NEW |