| 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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 // JSShiftLeft | 452 // JSShiftLeft |
| 453 | 453 |
| 454 | 454 |
| 455 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndConstant) { | 455 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndConstant) { |
| 456 Node* const lhs = Parameter(Type::Signed32()); | 456 Node* const lhs = Parameter(Type::Signed32()); |
| 457 Node* const context = UndefinedConstant(); | 457 Node* const context = UndefinedConstant(); |
| 458 Node* const effect = graph()->start(); | 458 Node* const effect = graph()->start(); |
| 459 Node* const control = graph()->start(); | 459 Node* const control = graph()->start(); |
| 460 TRACED_FORRANGE(double, rhs, 0, 31) { | 460 TRACED_FORRANGE(double, rhs, 0, 31) { |
| 461 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { | 461 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { |
| 462 Reduction r = | 462 Reduction r = Reduce(graph()->NewNode( |
| 463 Reduce(graph()->NewNode(javascript()->ShiftLeft(language_mode), lhs, | 463 javascript()->ShiftLeft(language_mode), lhs, NumberConstant(rhs), |
| 464 NumberConstant(rhs), context, effect, | 464 context, EmptyFrameState(), EmptyFrameState(), effect, control)); |
| 465 control)); | |
| 466 ASSERT_TRUE(r.Changed()); | 465 ASSERT_TRUE(r.Changed()); |
| 467 EXPECT_THAT(r.replacement(), | 466 EXPECT_THAT(r.replacement(), |
| 468 IsWord32Shl(lhs, IsNumberConstant(BitEq(rhs)))); | 467 IsWord32Shl(lhs, IsNumberConstant(BitEq(rhs)))); |
| 469 } | 468 } |
| 470 } | 469 } |
| 471 } | 470 } |
| 472 | 471 |
| 473 | 472 |
| 474 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndUnsigned32) { | 473 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndUnsigned32) { |
| 475 Node* const lhs = Parameter(Type::Signed32()); | 474 Node* const lhs = Parameter(Type::Signed32()); |
| 476 Node* const rhs = Parameter(Type::Unsigned32()); | 475 Node* const rhs = Parameter(Type::Unsigned32()); |
| 477 Node* const context = UndefinedConstant(); | 476 Node* const context = UndefinedConstant(); |
| 478 Node* const effect = graph()->start(); | 477 Node* const effect = graph()->start(); |
| 479 Node* const control = graph()->start(); | 478 Node* const control = graph()->start(); |
| 480 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { | 479 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { |
| 481 Reduction r = | 480 Reduction r = Reduce(graph()->NewNode( |
| 482 Reduce(graph()->NewNode(javascript()->ShiftLeft(language_mode), lhs, | 481 javascript()->ShiftLeft(language_mode), lhs, rhs, context, |
| 483 rhs, context, effect, control)); | 482 EmptyFrameState(), EmptyFrameState(), effect, control)); |
| 484 ASSERT_TRUE(r.Changed()); | 483 ASSERT_TRUE(r.Changed()); |
| 485 EXPECT_THAT(r.replacement(), | 484 EXPECT_THAT(r.replacement(), |
| 486 IsWord32Shl(lhs, IsWord32And(rhs, IsInt32Constant(0x1f)))); | 485 IsWord32Shl(lhs, IsWord32And(rhs, IsInt32Constant(0x1f)))); |
| 487 } | 486 } |
| 488 } | 487 } |
| 489 | 488 |
| 490 | 489 |
| 491 // ----------------------------------------------------------------------------- | 490 // ----------------------------------------------------------------------------- |
| 492 // JSShiftRight | 491 // JSShiftRight |
| 493 | 492 |
| 494 | 493 |
| 495 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndConstant) { | 494 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndConstant) { |
| 496 Node* const lhs = Parameter(Type::Signed32()); | 495 Node* const lhs = Parameter(Type::Signed32()); |
| 497 Node* const context = UndefinedConstant(); | 496 Node* const context = UndefinedConstant(); |
| 498 Node* const effect = graph()->start(); | 497 Node* const effect = graph()->start(); |
| 499 Node* const control = graph()->start(); | 498 Node* const control = graph()->start(); |
| 500 TRACED_FORRANGE(double, rhs, 0, 31) { | 499 TRACED_FORRANGE(double, rhs, 0, 31) { |
| 501 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { | 500 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { |
| 502 Reduction r = | 501 Reduction r = Reduce(graph()->NewNode( |
| 503 Reduce(graph()->NewNode(javascript()-> ShiftRight(language_mode), lhs, | 502 javascript()->ShiftRight(language_mode), lhs, NumberConstant(rhs), |
| 504 NumberConstant(rhs), context, effect, | 503 context, EmptyFrameState(), EmptyFrameState(), effect, control)); |
| 505 control)); | |
| 506 ASSERT_TRUE(r.Changed()); | 504 ASSERT_TRUE(r.Changed()); |
| 507 EXPECT_THAT(r.replacement(), | 505 EXPECT_THAT(r.replacement(), |
| 508 IsWord32Sar(lhs, IsNumberConstant(BitEq(rhs)))); | 506 IsWord32Sar(lhs, IsNumberConstant(BitEq(rhs)))); |
| 509 } | 507 } |
| 510 } | 508 } |
| 511 } | 509 } |
| 512 | 510 |
| 513 | 511 |
| 514 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndUnsigned32) { | 512 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndUnsigned32) { |
| 515 Node* const lhs = Parameter(Type::Signed32()); | 513 Node* const lhs = Parameter(Type::Signed32()); |
| 516 Node* const rhs = Parameter(Type::Unsigned32()); | 514 Node* const rhs = Parameter(Type::Unsigned32()); |
| 517 Node* const context = UndefinedConstant(); | 515 Node* const context = UndefinedConstant(); |
| 518 Node* const effect = graph()->start(); | 516 Node* const effect = graph()->start(); |
| 519 Node* const control = graph()->start(); | 517 Node* const control = graph()->start(); |
| 520 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { | 518 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { |
| 521 Reduction r = Reduce(graph()->NewNode(javascript()-> | 519 Reduction r = Reduce(graph()->NewNode( |
| 522 ShiftRight(language_mode), lhs, rhs, | 520 javascript()->ShiftRight(language_mode), lhs, rhs, context, |
| 523 context, effect, control)); | 521 EmptyFrameState(), EmptyFrameState(), effect, control)); |
| 524 ASSERT_TRUE(r.Changed()); | 522 ASSERT_TRUE(r.Changed()); |
| 525 EXPECT_THAT(r.replacement(), | 523 EXPECT_THAT(r.replacement(), |
| 526 IsWord32Sar(lhs, IsWord32And(rhs, IsInt32Constant(0x1f)))); | 524 IsWord32Sar(lhs, IsWord32And(rhs, IsInt32Constant(0x1f)))); |
| 527 } | 525 } |
| 528 } | 526 } |
| 529 | 527 |
| 530 | 528 |
| 531 // ----------------------------------------------------------------------------- | 529 // ----------------------------------------------------------------------------- |
| 532 // JSShiftRightLogical | 530 // JSShiftRightLogical |
| 533 | 531 |
| 534 | 532 |
| 535 TEST_F(JSTypedLoweringTest, | 533 TEST_F(JSTypedLoweringTest, |
| 536 JSShiftRightLogicalWithUnsigned32AndConstant) { | 534 JSShiftRightLogicalWithUnsigned32AndConstant) { |
| 537 Node* const lhs = Parameter(Type::Unsigned32()); | 535 Node* const lhs = Parameter(Type::Unsigned32()); |
| 538 Node* const context = UndefinedConstant(); | 536 Node* const context = UndefinedConstant(); |
| 539 Node* const effect = graph()->start(); | 537 Node* const effect = graph()->start(); |
| 540 Node* const control = graph()->start(); | 538 Node* const control = graph()->start(); |
| 541 TRACED_FORRANGE(double, rhs, 0, 31) { | 539 TRACED_FORRANGE(double, rhs, 0, 31) { |
| 542 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { | 540 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { |
| 543 Reduction r = | 541 Reduction r = Reduce( |
| 544 Reduce(graph()->NewNode(javascript()-> | 542 graph()->NewNode(javascript()->ShiftRightLogical(language_mode), lhs, |
| 545 ShiftRightLogical(language_mode), lhs, | 543 NumberConstant(rhs), context, EmptyFrameState(), |
| 546 NumberConstant(rhs), context, effect, | 544 EmptyFrameState(), effect, control)); |
| 547 control)); | |
| 548 ASSERT_TRUE(r.Changed()); | 545 ASSERT_TRUE(r.Changed()); |
| 549 EXPECT_THAT(r.replacement(), | 546 EXPECT_THAT(r.replacement(), |
| 550 IsWord32Shr(lhs, IsNumberConstant(BitEq(rhs)))); | 547 IsWord32Shr(lhs, IsNumberConstant(BitEq(rhs)))); |
| 551 } | 548 } |
| 552 } | 549 } |
| 553 } | 550 } |
| 554 | 551 |
| 555 | 552 |
| 556 TEST_F(JSTypedLoweringTest, | 553 TEST_F(JSTypedLoweringTest, |
| 557 JSShiftRightLogicalWithUnsigned32AndUnsigned32) { | 554 JSShiftRightLogicalWithUnsigned32AndUnsigned32) { |
| 558 Node* const lhs = Parameter(Type::Unsigned32()); | 555 Node* const lhs = Parameter(Type::Unsigned32()); |
| 559 Node* const rhs = Parameter(Type::Unsigned32()); | 556 Node* const rhs = Parameter(Type::Unsigned32()); |
| 560 Node* const context = UndefinedConstant(); | 557 Node* const context = UndefinedConstant(); |
| 561 Node* const effect = graph()->start(); | 558 Node* const effect = graph()->start(); |
| 562 Node* const control = graph()->start(); | 559 Node* const control = graph()->start(); |
| 563 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { | 560 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) { |
| 564 Reduction r = Reduce(graph()->NewNode(javascript()-> | 561 Reduction r = Reduce(graph()->NewNode( |
| 565 ShiftRightLogical(language_mode), lhs, | 562 javascript()->ShiftRightLogical(language_mode), lhs, rhs, context, |
| 566 rhs, context, effect, control)); | 563 EmptyFrameState(), EmptyFrameState(), effect, control)); |
| 567 ASSERT_TRUE(r.Changed()); | 564 ASSERT_TRUE(r.Changed()); |
| 568 EXPECT_THAT(r.replacement(), | 565 EXPECT_THAT(r.replacement(), |
| 569 IsWord32Shr(lhs, IsWord32And(rhs, IsInt32Constant(0x1f)))); | 566 IsWord32Shr(lhs, IsWord32And(rhs, IsInt32Constant(0x1f)))); |
| 570 } | 567 } |
| 571 } | 568 } |
| 572 | 569 |
| 573 | 570 |
| 574 // ----------------------------------------------------------------------------- | 571 // ----------------------------------------------------------------------------- |
| 575 // JSLoadContext | 572 // JSLoadContext |
| 576 | 573 |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 | 877 |
| 881 VectorSlotPair feedback(Handle<TypeFeedbackVector>::null(), | 878 VectorSlotPair feedback(Handle<TypeFeedbackVector>::null(), |
| 882 FeedbackVectorICSlot::Invalid()); | 879 FeedbackVectorICSlot::Invalid()); |
| 883 Node* global = Parameter(Type::GlobalObject()); | 880 Node* global = Parameter(Type::GlobalObject()); |
| 884 Node* context = UndefinedConstant(); | 881 Node* context = UndefinedConstant(); |
| 885 Node* effect = graph()->start(); | 882 Node* effect = graph()->start(); |
| 886 Node* control = graph()->start(); | 883 Node* control = graph()->start(); |
| 887 | 884 |
| 888 for (size_t i = 0; i < arraysize(names); i++) { | 885 for (size_t i = 0; i < arraysize(names); i++) { |
| 889 Unique<Name> name = Unique<Name>::CreateImmovable(names[i]); | 886 Unique<Name> name = Unique<Name>::CreateImmovable(names[i]); |
| 890 Reduction r = | 887 Reduction r = Reduce(graph()->NewNode( |
| 891 Reduce(graph()->NewNode(javascript()->LoadNamed(name, feedback), global, | 888 javascript()->LoadNamed(name, feedback), global, context, |
| 892 context, EmptyFrameState(), effect, control)); | 889 EmptyFrameState(), EmptyFrameState(), effect, control)); |
| 893 | 890 |
| 894 ASSERT_TRUE(r.Changed()); | 891 ASSERT_TRUE(r.Changed()); |
| 895 EXPECT_THAT(r.replacement(), matches[i]); | 892 EXPECT_THAT(r.replacement(), matches[i]); |
| 896 } | 893 } |
| 897 } | 894 } |
| 898 | 895 |
| 899 | 896 |
| 900 // ----------------------------------------------------------------------------- | 897 // ----------------------------------------------------------------------------- |
| 901 // JSCreateClosure | 898 // JSCreateClosure |
| 902 | 899 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 EXPECT_THAT(r.replacement(), | 986 EXPECT_THAT(r.replacement(), |
| 990 IsFinish(IsAllocate(IsNumberConstant(Context::SizeFor( | 987 IsFinish(IsAllocate(IsNumberConstant(Context::SizeFor( |
| 991 Context::MIN_CONTEXT_SLOTS)), | 988 Context::MIN_CONTEXT_SLOTS)), |
| 992 effect, control), | 989 effect, control), |
| 993 _)); | 990 _)); |
| 994 } | 991 } |
| 995 | 992 |
| 996 } // namespace compiler | 993 } // namespace compiler |
| 997 } // namespace internal | 994 } // namespace internal |
| 998 } // namespace v8 | 995 } // namespace v8 |
| OLD | NEW |