| 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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 Node* const context = UndefinedConstant(); | 460 Node* const context = UndefinedConstant(); |
| 461 Node* const effect = graph()->start(); | 461 Node* const effect = graph()->start(); |
| 462 Node* const control = graph()->start(); | 462 Node* const control = graph()->start(); |
| 463 TRACED_FORRANGE(double, rhs, 0, 31) { | 463 TRACED_FORRANGE(double, rhs, 0, 31) { |
| 464 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { | 464 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { |
| 465 Reduction r = Reduce(graph()->NewNode( | 465 Reduction r = Reduce(graph()->NewNode( |
| 466 javascript()->ShiftLeft(language_mode), lhs, NumberConstant(rhs), | 466 javascript()->ShiftLeft(language_mode), lhs, NumberConstant(rhs), |
| 467 context, EmptyFrameState(), EmptyFrameState(), effect, control)); | 467 context, EmptyFrameState(), EmptyFrameState(), effect, control)); |
| 468 ASSERT_TRUE(r.Changed()); | 468 ASSERT_TRUE(r.Changed()); |
| 469 EXPECT_THAT(r.replacement(), | 469 EXPECT_THAT(r.replacement(), |
| 470 IsWord32Shl(lhs, IsNumberConstant(BitEq(rhs)))); | 470 IsNumberShiftLeft(lhs, IsNumberConstant(BitEq(rhs)))); |
| 471 } | 471 } |
| 472 } | 472 } |
| 473 } | 473 } |
| 474 | 474 |
| 475 | 475 |
| 476 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndUnsigned32) { | 476 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndUnsigned32) { |
| 477 Node* const lhs = Parameter(Type::Signed32()); | 477 Node* const lhs = Parameter(Type::Signed32()); |
| 478 Node* const rhs = Parameter(Type::Unsigned32()); | 478 Node* const rhs = Parameter(Type::Unsigned32()); |
| 479 Node* const context = UndefinedConstant(); | 479 Node* const context = UndefinedConstant(); |
| 480 Node* const effect = graph()->start(); | 480 Node* const effect = graph()->start(); |
| 481 Node* const control = graph()->start(); | 481 Node* const control = graph()->start(); |
| 482 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { | 482 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { |
| 483 Reduction r = Reduce(graph()->NewNode( | 483 Reduction r = Reduce(graph()->NewNode( |
| 484 javascript()->ShiftLeft(language_mode), lhs, rhs, context, | 484 javascript()->ShiftLeft(language_mode), lhs, rhs, context, |
| 485 EmptyFrameState(), EmptyFrameState(), effect, control)); | 485 EmptyFrameState(), EmptyFrameState(), effect, control)); |
| 486 ASSERT_TRUE(r.Changed()); | 486 ASSERT_TRUE(r.Changed()); |
| 487 EXPECT_THAT(r.replacement(), | 487 EXPECT_THAT(r.replacement(), IsNumberShiftLeft(lhs, rhs)); |
| 488 IsWord32Shl(lhs, IsWord32And(rhs, IsInt32Constant(0x1f)))); | |
| 489 } | 488 } |
| 490 } | 489 } |
| 491 | 490 |
| 492 | 491 |
| 493 // ----------------------------------------------------------------------------- | 492 // ----------------------------------------------------------------------------- |
| 494 // JSShiftRight | 493 // JSShiftRight |
| 495 | 494 |
| 496 | 495 |
| 497 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndConstant) { | 496 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndConstant) { |
| 498 Node* const lhs = Parameter(Type::Signed32()); | 497 Node* const lhs = Parameter(Type::Signed32()); |
| 499 Node* const context = UndefinedConstant(); | 498 Node* const context = UndefinedConstant(); |
| 500 Node* const effect = graph()->start(); | 499 Node* const effect = graph()->start(); |
| 501 Node* const control = graph()->start(); | 500 Node* const control = graph()->start(); |
| 502 TRACED_FORRANGE(double, rhs, 0, 31) { | 501 TRACED_FORRANGE(double, rhs, 0, 31) { |
| 503 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { | 502 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { |
| 504 Reduction r = Reduce(graph()->NewNode( | 503 Reduction r = Reduce(graph()->NewNode( |
| 505 javascript()->ShiftRight(language_mode), lhs, NumberConstant(rhs), | 504 javascript()->ShiftRight(language_mode), lhs, NumberConstant(rhs), |
| 506 context, EmptyFrameState(), EmptyFrameState(), effect, control)); | 505 context, EmptyFrameState(), EmptyFrameState(), effect, control)); |
| 507 ASSERT_TRUE(r.Changed()); | 506 ASSERT_TRUE(r.Changed()); |
| 508 EXPECT_THAT(r.replacement(), | 507 EXPECT_THAT(r.replacement(), |
| 509 IsWord32Sar(lhs, IsNumberConstant(BitEq(rhs)))); | 508 IsNumberShiftRight(lhs, IsNumberConstant(BitEq(rhs)))); |
| 510 } | 509 } |
| 511 } | 510 } |
| 512 } | 511 } |
| 513 | 512 |
| 514 | 513 |
| 515 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndUnsigned32) { | 514 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndUnsigned32) { |
| 516 Node* const lhs = Parameter(Type::Signed32()); | 515 Node* const lhs = Parameter(Type::Signed32()); |
| 517 Node* const rhs = Parameter(Type::Unsigned32()); | 516 Node* const rhs = Parameter(Type::Unsigned32()); |
| 518 Node* const context = UndefinedConstant(); | 517 Node* const context = UndefinedConstant(); |
| 519 Node* const effect = graph()->start(); | 518 Node* const effect = graph()->start(); |
| 520 Node* const control = graph()->start(); | 519 Node* const control = graph()->start(); |
| 521 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { | 520 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { |
| 522 Reduction r = Reduce(graph()->NewNode( | 521 Reduction r = Reduce(graph()->NewNode( |
| 523 javascript()->ShiftRight(language_mode), lhs, rhs, context, | 522 javascript()->ShiftRight(language_mode), lhs, rhs, context, |
| 524 EmptyFrameState(), EmptyFrameState(), effect, control)); | 523 EmptyFrameState(), EmptyFrameState(), effect, control)); |
| 525 ASSERT_TRUE(r.Changed()); | 524 ASSERT_TRUE(r.Changed()); |
| 526 EXPECT_THAT(r.replacement(), | 525 EXPECT_THAT(r.replacement(), IsNumberShiftRight(lhs, rhs)); |
| 527 IsWord32Sar(lhs, IsWord32And(rhs, IsInt32Constant(0x1f)))); | |
| 528 } | 526 } |
| 529 } | 527 } |
| 530 | 528 |
| 531 | 529 |
| 532 // ----------------------------------------------------------------------------- | 530 // ----------------------------------------------------------------------------- |
| 533 // JSShiftRightLogical | 531 // JSShiftRightLogical |
| 534 | 532 |
| 535 | 533 |
| 536 TEST_F(JSTypedLoweringTest, | 534 TEST_F(JSTypedLoweringTest, |
| 537 JSShiftRightLogicalWithUnsigned32AndConstant) { | 535 JSShiftRightLogicalWithUnsigned32AndConstant) { |
| 538 Node* const lhs = Parameter(Type::Unsigned32()); | 536 Node* const lhs = Parameter(Type::Unsigned32()); |
| 539 Node* const context = UndefinedConstant(); | 537 Node* const context = UndefinedConstant(); |
| 540 Node* const effect = graph()->start(); | 538 Node* const effect = graph()->start(); |
| 541 Node* const control = graph()->start(); | 539 Node* const control = graph()->start(); |
| 542 TRACED_FORRANGE(double, rhs, 0, 31) { | 540 TRACED_FORRANGE(double, rhs, 0, 31) { |
| 543 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { | 541 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { |
| 544 Reduction r = Reduce( | 542 Reduction r = Reduce( |
| 545 graph()->NewNode(javascript()->ShiftRightLogical(language_mode), lhs, | 543 graph()->NewNode(javascript()->ShiftRightLogical(language_mode), lhs, |
| 546 NumberConstant(rhs), context, EmptyFrameState(), | 544 NumberConstant(rhs), context, EmptyFrameState(), |
| 547 EmptyFrameState(), effect, control)); | 545 EmptyFrameState(), effect, control)); |
| 548 ASSERT_TRUE(r.Changed()); | 546 ASSERT_TRUE(r.Changed()); |
| 549 EXPECT_THAT(r.replacement(), | 547 EXPECT_THAT(r.replacement(), |
| 550 IsWord32Shr(lhs, IsNumberConstant(BitEq(rhs)))); | 548 IsNumberShiftRightLogical(lhs, IsNumberConstant(BitEq(rhs)))); |
| 551 } | 549 } |
| 552 } | 550 } |
| 553 } | 551 } |
| 554 | 552 |
| 555 | 553 |
| 556 TEST_F(JSTypedLoweringTest, | 554 TEST_F(JSTypedLoweringTest, |
| 557 JSShiftRightLogicalWithUnsigned32AndUnsigned32) { | 555 JSShiftRightLogicalWithUnsigned32AndUnsigned32) { |
| 558 Node* const lhs = Parameter(Type::Unsigned32()); | 556 Node* const lhs = Parameter(Type::Unsigned32()); |
| 559 Node* const rhs = Parameter(Type::Unsigned32()); | 557 Node* const rhs = Parameter(Type::Unsigned32()); |
| 560 Node* const context = UndefinedConstant(); | 558 Node* const context = UndefinedConstant(); |
| 561 Node* const effect = graph()->start(); | 559 Node* const effect = graph()->start(); |
| 562 Node* const control = graph()->start(); | 560 Node* const control = graph()->start(); |
| 563 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { | 561 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { |
| 564 Reduction r = Reduce(graph()->NewNode( | 562 Reduction r = Reduce(graph()->NewNode( |
| 565 javascript()->ShiftRightLogical(language_mode), lhs, rhs, context, | 563 javascript()->ShiftRightLogical(language_mode), lhs, rhs, context, |
| 566 EmptyFrameState(), EmptyFrameState(), effect, control)); | 564 EmptyFrameState(), EmptyFrameState(), effect, control)); |
| 567 ASSERT_TRUE(r.Changed()); | 565 ASSERT_TRUE(r.Changed()); |
| 568 EXPECT_THAT(r.replacement(), | 566 EXPECT_THAT(r.replacement(), IsNumberShiftRightLogical(lhs, rhs)); |
| 569 IsWord32Shr(lhs, IsWord32And(rhs, IsInt32Constant(0x1f)))); | |
| 570 } | 567 } |
| 571 } | 568 } |
| 572 | 569 |
| 573 | 570 |
| 574 // ----------------------------------------------------------------------------- | 571 // ----------------------------------------------------------------------------- |
| 575 // JSLoadContext | 572 // JSLoadContext |
| 576 | 573 |
| 577 | 574 |
| 578 TEST_F(JSTypedLoweringTest, JSLoadContext) { | 575 TEST_F(JSTypedLoweringTest, JSLoadContext) { |
| 579 Node* const context = Parameter(Type::Any()); | 576 Node* const context = Parameter(Type::Any()); |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 EXPECT_THAT(r.replacement(), | 1096 EXPECT_THAT(r.replacement(), |
| 1100 IsFinish(IsAllocate(IsNumberConstant(Context::SizeFor( | 1097 IsFinish(IsAllocate(IsNumberConstant(Context::SizeFor( |
| 1101 Context::MIN_CONTEXT_SLOTS)), | 1098 Context::MIN_CONTEXT_SLOTS)), |
| 1102 effect, control), | 1099 effect, control), |
| 1103 _)); | 1100 _)); |
| 1104 } | 1101 } |
| 1105 | 1102 |
| 1106 } // namespace compiler | 1103 } // namespace compiler |
| 1107 } // namespace internal | 1104 } // namespace internal |
| 1108 } // namespace v8 | 1105 } // namespace v8 |
| OLD | NEW |