| 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/js-operator.h" | 7 #include "src/compiler/js-operator.h" |
| 8 #include "src/compiler/js-typed-lowering.h" | 8 #include "src/compiler/js-typed-lowering.h" |
| 9 #include "src/compiler/machine-operator.h" | 9 #include "src/compiler/machine-operator.h" |
| 10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 // JSShiftLeft | 448 // JSShiftLeft |
| 449 | 449 |
| 450 | 450 |
| 451 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndConstant) { | 451 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndConstant) { |
| 452 Node* const lhs = Parameter(Type::Signed32()); | 452 Node* const lhs = Parameter(Type::Signed32()); |
| 453 Node* const context = UndefinedConstant(); | 453 Node* const context = UndefinedConstant(); |
| 454 Node* const effect = graph()->start(); | 454 Node* const effect = graph()->start(); |
| 455 Node* const control = graph()->start(); | 455 Node* const control = graph()->start(); |
| 456 TRACED_FORRANGE(double, rhs, 0, 31) { | 456 TRACED_FORRANGE(double, rhs, 0, 31) { |
| 457 Reduction r = | 457 Reduction r = |
| 458 Reduce(graph()->NewNode(javascript()->ShiftLeft(), lhs, | 458 Reduce(graph()->NewNode(javascript()->ShiftLeft(LanguageMode::SLOPPY), |
| 459 NumberConstant(rhs), context, effect, control)); | 459 lhs, NumberConstant(rhs), context, effect, |
| 460 control)); |
| 460 ASSERT_TRUE(r.Changed()); | 461 ASSERT_TRUE(r.Changed()); |
| 461 EXPECT_THAT(r.replacement(), | 462 EXPECT_THAT(r.replacement(), |
| 462 IsWord32Shl(lhs, IsNumberConstant(BitEq(rhs)))); | 463 IsWord32Shl(lhs, IsNumberConstant(BitEq(rhs)))); |
| 463 } | 464 } |
| 464 } | 465 } |
| 465 | 466 |
| 466 | 467 |
| 467 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndUnsigned32) { | 468 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndUnsigned32) { |
| 468 Node* const lhs = Parameter(Type::Signed32()); | 469 Node* const lhs = Parameter(Type::Signed32()); |
| 469 Node* const rhs = Parameter(Type::Unsigned32()); | 470 Node* const rhs = Parameter(Type::Unsigned32()); |
| 470 Node* const context = UndefinedConstant(); | 471 Node* const context = UndefinedConstant(); |
| 471 Node* const effect = graph()->start(); | 472 Node* const effect = graph()->start(); |
| 472 Node* const control = graph()->start(); | 473 Node* const control = graph()->start(); |
| 473 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftLeft(), lhs, rhs, | 474 Reduction r = |
| 474 context, effect, control)); | 475 Reduce(graph()->NewNode(javascript()->ShiftLeft(LanguageMode::SLOPPY), |
| 476 lhs, rhs, context, effect, control)); |
| 475 ASSERT_TRUE(r.Changed()); | 477 ASSERT_TRUE(r.Changed()); |
| 476 EXPECT_THAT(r.replacement(), | 478 EXPECT_THAT(r.replacement(), |
| 477 IsWord32Shl(lhs, IsWord32And(rhs, IsInt32Constant(0x1f)))); | 479 IsWord32Shl(lhs, IsWord32And(rhs, IsInt32Constant(0x1f)))); |
| 478 } | 480 } |
| 479 | 481 |
| 480 | 482 |
| 481 // ----------------------------------------------------------------------------- | 483 // ----------------------------------------------------------------------------- |
| 482 // JSShiftRight | 484 // JSShiftRight |
| 483 | 485 |
| 484 | 486 |
| 485 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndConstant) { | 487 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndConstant) { |
| 486 Node* const lhs = Parameter(Type::Signed32()); | 488 Node* const lhs = Parameter(Type::Signed32()); |
| 487 Node* const context = UndefinedConstant(); | 489 Node* const context = UndefinedConstant(); |
| 488 Node* const effect = graph()->start(); | 490 Node* const effect = graph()->start(); |
| 489 Node* const control = graph()->start(); | 491 Node* const control = graph()->start(); |
| 490 TRACED_FORRANGE(double, rhs, 0, 31) { | 492 TRACED_FORRANGE(double, rhs, 0, 31) { |
| 491 Reduction r = | 493 Reduction r = |
| 492 Reduce(graph()->NewNode(javascript()->ShiftRight(), lhs, | 494 Reduce(graph()->NewNode(javascript()-> |
| 495 ShiftRight(LanguageMode::SLOPPY), lhs, |
| 493 NumberConstant(rhs), context, effect, control)); | 496 NumberConstant(rhs), context, effect, control)); |
| 494 ASSERT_TRUE(r.Changed()); | 497 ASSERT_TRUE(r.Changed()); |
| 495 EXPECT_THAT(r.replacement(), | 498 EXPECT_THAT(r.replacement(), |
| 496 IsWord32Sar(lhs, IsNumberConstant(BitEq(rhs)))); | 499 IsWord32Sar(lhs, IsNumberConstant(BitEq(rhs)))); |
| 497 } | 500 } |
| 498 } | 501 } |
| 499 | 502 |
| 500 | 503 |
| 501 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndUnsigned32) { | 504 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndUnsigned32) { |
| 502 Node* const lhs = Parameter(Type::Signed32()); | 505 Node* const lhs = Parameter(Type::Signed32()); |
| 503 Node* const rhs = Parameter(Type::Unsigned32()); | 506 Node* const rhs = Parameter(Type::Unsigned32()); |
| 504 Node* const context = UndefinedConstant(); | 507 Node* const context = UndefinedConstant(); |
| 505 Node* const effect = graph()->start(); | 508 Node* const effect = graph()->start(); |
| 506 Node* const control = graph()->start(); | 509 Node* const control = graph()->start(); |
| 507 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRight(), lhs, rhs, | 510 Reduction r = Reduce(graph()->NewNode(javascript()-> |
| 508 context, effect, control)); | 511 ShiftRight(LanguageMode::SLOPPY), |
| 512 lhs, rhs, context, effect, control)); |
| 509 ASSERT_TRUE(r.Changed()); | 513 ASSERT_TRUE(r.Changed()); |
| 510 EXPECT_THAT(r.replacement(), | 514 EXPECT_THAT(r.replacement(), |
| 511 IsWord32Sar(lhs, IsWord32And(rhs, IsInt32Constant(0x1f)))); | 515 IsWord32Sar(lhs, IsWord32And(rhs, IsInt32Constant(0x1f)))); |
| 512 } | 516 } |
| 513 | 517 |
| 514 | 518 |
| 515 // ----------------------------------------------------------------------------- | 519 // ----------------------------------------------------------------------------- |
| 516 // JSShiftRightLogical | 520 // JSShiftRightLogical |
| 517 | 521 |
| 518 | 522 |
| 519 TEST_F(JSTypedLoweringTest, JSShiftRightLogicalWithUnsigned32AndConstant) { | 523 TEST_F(JSTypedLoweringTest, |
| 524 JSShiftRightLogicalWithUnsigned32AndConstant) { |
| 520 Node* const lhs = Parameter(Type::Unsigned32()); | 525 Node* const lhs = Parameter(Type::Unsigned32()); |
| 521 Node* const context = UndefinedConstant(); | 526 Node* const context = UndefinedConstant(); |
| 522 Node* const effect = graph()->start(); | 527 Node* const effect = graph()->start(); |
| 523 Node* const control = graph()->start(); | 528 Node* const control = graph()->start(); |
| 524 TRACED_FORRANGE(double, rhs, 0, 31) { | 529 TRACED_FORRANGE(double, rhs, 0, 31) { |
| 525 Reduction r = | 530 Reduction r = |
| 526 Reduce(graph()->NewNode(javascript()->ShiftRightLogical(), lhs, | 531 Reduce(graph()->NewNode(javascript()-> |
| 527 NumberConstant(rhs), context, effect, control)); | 532 ShiftRightLogical(LanguageMode::SLOPPY), |
| 533 lhs, NumberConstant(rhs), context, effect, |
| 534 control)); |
| 528 ASSERT_TRUE(r.Changed()); | 535 ASSERT_TRUE(r.Changed()); |
| 529 EXPECT_THAT(r.replacement(), | 536 EXPECT_THAT(r.replacement(), |
| 530 IsWord32Shr(lhs, IsNumberConstant(BitEq(rhs)))); | 537 IsWord32Shr(lhs, IsNumberConstant(BitEq(rhs)))); |
| 531 } | 538 } |
| 532 } | 539 } |
| 533 | 540 |
| 534 | 541 |
| 535 TEST_F(JSTypedLoweringTest, JSShiftRightLogicalWithUnsigned32AndUnsigned32) { | 542 TEST_F(JSTypedLoweringTest, |
| 543 JSShiftRightLogicalWithUnsigned32AndUnsigned32) { |
| 536 Node* const lhs = Parameter(Type::Unsigned32()); | 544 Node* const lhs = Parameter(Type::Unsigned32()); |
| 537 Node* const rhs = Parameter(Type::Unsigned32()); | 545 Node* const rhs = Parameter(Type::Unsigned32()); |
| 538 Node* const context = UndefinedConstant(); | 546 Node* const context = UndefinedConstant(); |
| 539 Node* const effect = graph()->start(); | 547 Node* const effect = graph()->start(); |
| 540 Node* const control = graph()->start(); | 548 Node* const control = graph()->start(); |
| 541 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRightLogical(), lhs, | 549 Reduction r = Reduce(graph()->NewNode(javascript()-> |
| 542 rhs, context, effect, control)); | 550 ShiftRightLogical(LanguageMode::SLOPPY), |
| 551 lhs, rhs, context, effect, control)); |
| 543 ASSERT_TRUE(r.Changed()); | 552 ASSERT_TRUE(r.Changed()); |
| 544 EXPECT_THAT(r.replacement(), | 553 EXPECT_THAT(r.replacement(), |
| 545 IsWord32Shr(lhs, IsWord32And(rhs, IsInt32Constant(0x1f)))); | 554 IsWord32Shr(lhs, IsWord32And(rhs, IsInt32Constant(0x1f)))); |
| 546 } | 555 } |
| 547 | 556 |
| 548 | 557 |
| 549 // ----------------------------------------------------------------------------- | 558 // ----------------------------------------------------------------------------- |
| 550 // JSLoadContext | 559 // JSLoadContext |
| 551 | 560 |
| 552 | 561 |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 context, EmptyFrameState(), effect, control)); | 876 context, EmptyFrameState(), effect, control)); |
| 868 | 877 |
| 869 ASSERT_TRUE(r.Changed()); | 878 ASSERT_TRUE(r.Changed()); |
| 870 EXPECT_THAT(r.replacement(), matches[i]); | 879 EXPECT_THAT(r.replacement(), matches[i]); |
| 871 } | 880 } |
| 872 } | 881 } |
| 873 | 882 |
| 874 } // namespace compiler | 883 } // namespace compiler |
| 875 } // namespace internal | 884 } // namespace internal |
| 876 } // namespace v8 | 885 } // namespace v8 |
| OLD | NEW |