| 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/compiler/access-builder.h" | 6 #include "src/compiler/access-builder.h" |
| 7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
| 8 #include "src/compiler/js-operator.h" | 8 #include "src/compiler/js-operator.h" |
| 9 #include "src/compiler/js-typed-lowering.h" | 9 #include "src/compiler/js-typed-lowering.h" |
| 10 #include "src/compiler/machine-operator.h" | 10 #include "src/compiler/machine-operator.h" |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 TEST_F(JSTypedLoweringTest, JSToBooleanWithOrderedNumber) { | 277 TEST_F(JSTypedLoweringTest, JSToBooleanWithOrderedNumber) { |
| 278 Node* input = Parameter(Type::OrderedNumber(), 0); | 278 Node* input = Parameter(Type::OrderedNumber(), 0); |
| 279 Node* context = Parameter(Type::Any(), 1); | 279 Node* context = Parameter(Type::Any(), 1); |
| 280 Reduction r = Reduce(graph()->NewNode( | 280 Reduction r = Reduce(graph()->NewNode( |
| 281 javascript()->ToBoolean(ToBooleanHint::kAny), input, context)); | 281 javascript()->ToBoolean(ToBooleanHint::kAny), input, context)); |
| 282 ASSERT_TRUE(r.Changed()); | 282 ASSERT_TRUE(r.Changed()); |
| 283 EXPECT_THAT(r.replacement(), | 283 EXPECT_THAT(r.replacement(), |
| 284 IsBooleanNot(IsNumberEqual(input, IsNumberConstant(0.0)))); | 284 IsBooleanNot(IsNumberEqual(input, IsNumberConstant(0.0)))); |
| 285 } | 285 } |
| 286 | 286 |
| 287 TEST_F(JSTypedLoweringTest, JSToBooleanWithNumber) { |
| 288 Node* input = Parameter(Type::Number(), 0); |
| 289 Node* context = Parameter(Type::Any(), 1); |
| 290 Reduction r = Reduce(graph()->NewNode( |
| 291 javascript()->ToBoolean(ToBooleanHint::kAny), input, context)); |
| 292 ASSERT_TRUE(r.Changed()); |
| 293 EXPECT_THAT(r.replacement(), |
| 294 IsNumberLessThan(IsNumberConstant(0.0), IsNumberAbs(input))); |
| 295 } |
| 287 | 296 |
| 288 TEST_F(JSTypedLoweringTest, JSToBooleanWithString) { | 297 TEST_F(JSTypedLoweringTest, JSToBooleanWithString) { |
| 289 Node* input = Parameter(Type::String(), 0); | 298 Node* input = Parameter(Type::String(), 0); |
| 290 Node* context = Parameter(Type::Any(), 1); | 299 Node* context = Parameter(Type::Any(), 1); |
| 291 Reduction r = Reduce(graph()->NewNode( | 300 Reduction r = Reduce(graph()->NewNode( |
| 292 javascript()->ToBoolean(ToBooleanHint::kAny), input, context)); | 301 javascript()->ToBoolean(ToBooleanHint::kAny), input, context)); |
| 293 ASSERT_TRUE(r.Changed()); | 302 ASSERT_TRUE(r.Changed()); |
| 294 EXPECT_THAT( | 303 EXPECT_THAT( |
| 295 r.replacement(), | 304 r.replacement(), |
| 296 IsNumberLessThan(IsNumberConstant(0.0), | 305 IsNumberLessThan(IsNumberConstant(0.0), |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context, | 947 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context, |
| 939 frame_state, effect, control); | 948 frame_state, effect, control); |
| 940 Reduction r = Reduce(instanceOf); | 949 Reduction r = Reduce(instanceOf); |
| 941 ASSERT_FALSE(r.Changed()); | 950 ASSERT_FALSE(r.Changed()); |
| 942 ASSERT_EQ(instanceOf, dummy->InputAt(0)); | 951 ASSERT_EQ(instanceOf, dummy->InputAt(0)); |
| 943 } | 952 } |
| 944 | 953 |
| 945 } // namespace compiler | 954 } // namespace compiler |
| 946 } // namespace internal | 955 } // namespace internal |
| 947 } // namespace v8 | 956 } // namespace v8 |
| OLD | NEW |