| 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-graph.h" | 5 #include "src/compiler/js-graph.h" |
| 6 #include "src/compiler/simplified-operator.h" | 6 #include "src/compiler/simplified-operator.h" |
| 7 #include "src/compiler/simplified-operator-reducer.h" | 7 #include "src/compiler/simplified-operator-reducer.h" |
| 8 #include "src/conversions.h" | 8 #include "src/conversions.h" |
| 9 #include "src/types.h" | 9 #include "src/types.h" |
| 10 #include "test/unittests/compiler/graph-unittest.h" | 10 #include "test/unittests/compiler/graph-unittest.h" |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 // LoadElement | 483 // LoadElement |
| 484 | 484 |
| 485 | 485 |
| 486 TEST_F(SimplifiedOperatorReducerTest, LoadElementWithConstantKeyAndLength) { | 486 TEST_F(SimplifiedOperatorReducerTest, LoadElementWithConstantKeyAndLength) { |
| 487 ElementAccess const access = {kTypedArrayBoundsCheck, kUntaggedBase, 0, | 487 ElementAccess const access = {kTypedArrayBoundsCheck, kUntaggedBase, 0, |
| 488 Type::Any(), kMachAnyTagged}; | 488 Type::Any(), kMachAnyTagged}; |
| 489 ElementAccess access_nocheck = access; | 489 ElementAccess access_nocheck = access; |
| 490 access_nocheck.bounds_check = kNoBoundsCheck; | 490 access_nocheck.bounds_check = kNoBoundsCheck; |
| 491 Node* const base = Parameter(0); | 491 Node* const base = Parameter(0); |
| 492 Node* const effect = graph()->start(); | 492 Node* const effect = graph()->start(); |
| 493 Node* const control = graph()->start(); | |
| 494 { | 493 { |
| 495 Node* const key = NumberConstant(-42.0); | 494 Node* const key = NumberConstant(-42.0); |
| 496 Node* const length = NumberConstant(100.0); | 495 Node* const length = NumberConstant(100.0); |
| 497 Reduction r = Reduce(graph()->NewNode(simplified()->LoadElement(access), | 496 Reduction r = Reduce(graph()->NewNode(simplified()->LoadElement(access), |
| 498 base, key, length, effect, control)); | 497 base, key, length, effect)); |
| 499 ASSERT_FALSE(r.Changed()); | 498 ASSERT_FALSE(r.Changed()); |
| 500 } | 499 } |
| 501 { | 500 { |
| 502 Node* const key = NumberConstant(-0.0); | 501 Node* const key = NumberConstant(-0.0); |
| 503 Node* const length = NumberConstant(1.0); | 502 Node* const length = NumberConstant(1.0); |
| 504 Reduction r = Reduce(graph()->NewNode(simplified()->LoadElement(access), | 503 Reduction r = Reduce(graph()->NewNode(simplified()->LoadElement(access), |
| 505 base, key, length, effect, control)); | 504 base, key, length, effect)); |
| 506 ASSERT_TRUE(r.Changed()); | 505 ASSERT_TRUE(r.Changed()); |
| 507 EXPECT_THAT(r.replacement(), IsLoadElement(access_nocheck, base, key, | 506 EXPECT_THAT(r.replacement(), |
| 508 length, effect, control)); | 507 IsLoadElement(access_nocheck, base, key, length, effect)); |
| 509 } | 508 } |
| 510 { | 509 { |
| 511 Node* const key = NumberConstant(0); | 510 Node* const key = NumberConstant(0); |
| 512 Node* const length = NumberConstant(1); | 511 Node* const length = NumberConstant(1); |
| 513 Reduction r = Reduce(graph()->NewNode(simplified()->LoadElement(access), | 512 Reduction r = Reduce(graph()->NewNode(simplified()->LoadElement(access), |
| 514 base, key, length, effect, control)); | 513 base, key, length, effect)); |
| 515 ASSERT_TRUE(r.Changed()); | 514 ASSERT_TRUE(r.Changed()); |
| 516 EXPECT_THAT(r.replacement(), IsLoadElement(access_nocheck, base, key, | 515 EXPECT_THAT(r.replacement(), |
| 517 length, effect, control)); | 516 IsLoadElement(access_nocheck, base, key, length, effect)); |
| 518 } | 517 } |
| 519 { | 518 { |
| 520 Node* const key = NumberConstant(42.2); | 519 Node* const key = NumberConstant(42.2); |
| 521 Node* const length = NumberConstant(128); | 520 Node* const length = NumberConstant(128); |
| 522 Reduction r = Reduce(graph()->NewNode(simplified()->LoadElement(access), | 521 Reduction r = Reduce(graph()->NewNode(simplified()->LoadElement(access), |
| 523 base, key, length, effect, control)); | 522 base, key, length, effect)); |
| 524 ASSERT_TRUE(r.Changed()); | 523 ASSERT_TRUE(r.Changed()); |
| 525 EXPECT_THAT(r.replacement(), IsLoadElement(access_nocheck, base, key, | 524 EXPECT_THAT(r.replacement(), |
| 526 length, effect, control)); | 525 IsLoadElement(access_nocheck, base, key, length, effect)); |
| 527 } | 526 } |
| 528 { | 527 { |
| 529 Node* const key = NumberConstant(39.2); | 528 Node* const key = NumberConstant(39.2); |
| 530 Node* const length = NumberConstant(32.0); | 529 Node* const length = NumberConstant(32.0); |
| 531 Reduction r = Reduce(graph()->NewNode(simplified()->LoadElement(access), | 530 Reduction r = Reduce(graph()->NewNode(simplified()->LoadElement(access), |
| 532 base, key, length, effect, control)); | 531 base, key, length, effect)); |
| 533 ASSERT_FALSE(r.Changed()); | 532 ASSERT_FALSE(r.Changed()); |
| 534 } | 533 } |
| 535 } | 534 } |
| 536 | 535 |
| 537 | 536 |
| 538 // ----------------------------------------------------------------------------- | 537 // ----------------------------------------------------------------------------- |
| 539 // StoreElement | 538 // StoreElement |
| 540 | 539 |
| 541 | 540 |
| 542 TEST_F(SimplifiedOperatorReducerTest, StoreElementWithConstantKeyAndLength) { | 541 TEST_F(SimplifiedOperatorReducerTest, StoreElementWithConstantKeyAndLength) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 Reduction r = | 594 Reduction r = |
| 596 Reduce(graph()->NewNode(simplified()->StoreElement(access), base, key, | 595 Reduce(graph()->NewNode(simplified()->StoreElement(access), base, key, |
| 597 length, value, effect, control)); | 596 length, value, effect, control)); |
| 598 ASSERT_FALSE(r.Changed()); | 597 ASSERT_FALSE(r.Changed()); |
| 599 } | 598 } |
| 600 } | 599 } |
| 601 | 600 |
| 602 } // namespace compiler | 601 } // namespace compiler |
| 603 } // namespace internal | 602 } // namespace internal |
| 604 } // namespace v8 | 603 } // namespace v8 |
| OLD | NEW |