| 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/access-builder.h" | 5 #include "src/compiler/access-builder.h" |
| 6 #include "src/compiler/js-graph.h" | 6 #include "src/compiler/js-graph.h" |
| 7 #include "src/compiler/node-properties.h" | 7 #include "src/compiler/node-properties.h" |
| 8 #include "src/compiler/simplified-operator.h" | 8 #include "src/compiler/simplified-operator.h" |
| 9 #include "src/compiler/simplified-operator-reducer.h" | 9 #include "src/compiler/simplified-operator-reducer.h" |
| 10 #include "src/conversions-inl.h" | 10 #include "src/conversions-inl.h" |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 Node* effect = graph()->start(); | 392 Node* effect = graph()->start(); |
| 393 Node* control = graph()->start(); | 393 Node* control = graph()->start(); |
| 394 Node* value = NumberConstant(1.0); | 394 Node* value = NumberConstant(1.0); |
| 395 Reduction reduction = Reduce(graph()->NewNode( | 395 Reduction reduction = Reduce(graph()->NewNode( |
| 396 simplified()->CheckTaggedSigned(), value, effect, control)); | 396 simplified()->CheckTaggedSigned(), value, effect, control)); |
| 397 ASSERT_TRUE(reduction.Changed()); | 397 ASSERT_TRUE(reduction.Changed()); |
| 398 EXPECT_EQ(value, reduction.replacement()); | 398 EXPECT_EQ(value, reduction.replacement()); |
| 399 } | 399 } |
| 400 | 400 |
| 401 // ----------------------------------------------------------------------------- | 401 // ----------------------------------------------------------------------------- |
| 402 // NumberAbs |
| 403 |
| 404 TEST_F(SimplifiedOperatorReducerTest, NumberAbsWithNumberConstant) { |
| 405 TRACED_FOREACH(double, n, kFloat64Values) { |
| 406 Reduction reduction = |
| 407 Reduce(graph()->NewNode(simplified()->NumberAbs(), NumberConstant(n))); |
| 408 ASSERT_TRUE(reduction.Changed()); |
| 409 EXPECT_THAT(reduction.replacement(), IsNumberConstant(std::fabs(n))); |
| 410 } |
| 411 } |
| 412 |
| 413 // ----------------------------------------------------------------------------- |
| 402 // ObjectIsSmi | 414 // ObjectIsSmi |
| 403 | 415 |
| 404 TEST_F(SimplifiedOperatorReducerTest, ObjectIsSmiWithChangeBitToTagged) { | 416 TEST_F(SimplifiedOperatorReducerTest, ObjectIsSmiWithChangeBitToTagged) { |
| 405 Node* param0 = Parameter(0); | 417 Node* param0 = Parameter(0); |
| 406 Reduction reduction = Reduce(graph()->NewNode( | 418 Reduction reduction = Reduce(graph()->NewNode( |
| 407 simplified()->ObjectIsSmi(), | 419 simplified()->ObjectIsSmi(), |
| 408 graph()->NewNode(simplified()->ChangeBitToTagged(), param0))); | 420 graph()->NewNode(simplified()->ChangeBitToTagged(), param0))); |
| 409 ASSERT_TRUE(reduction.Changed()); | 421 ASSERT_TRUE(reduction.Changed()); |
| 410 EXPECT_THAT(reduction.replacement(), IsFalseConstant()); | 422 EXPECT_THAT(reduction.replacement(), IsFalseConstant()); |
| 411 } | 423 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 437 Reduction reduction = Reduce( | 449 Reduction reduction = Reduce( |
| 438 graph()->NewNode(simplified()->ObjectIsSmi(), NumberConstant(n))); | 450 graph()->NewNode(simplified()->ObjectIsSmi(), NumberConstant(n))); |
| 439 ASSERT_TRUE(reduction.Changed()); | 451 ASSERT_TRUE(reduction.Changed()); |
| 440 EXPECT_THAT(reduction.replacement(), IsBooleanConstant(IsSmiDouble(n))); | 452 EXPECT_THAT(reduction.replacement(), IsBooleanConstant(IsSmiDouble(n))); |
| 441 } | 453 } |
| 442 } | 454 } |
| 443 | 455 |
| 444 } // namespace compiler | 456 } // namespace compiler |
| 445 } // namespace internal | 457 } // namespace internal |
| 446 } // namespace v8 | 458 } // namespace v8 |
| OLD | NEW |