Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: test/unittests/compiler/js-typed-lowering-unittest.cc

Issue 2034673002: [turbofan] Remove eager frame state from property access. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_turbofan-checkpoint-3
Patch Set: Rebased. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/operator-properties.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 factory()->NewJSTypedArray(type, buffer, 0, kLength); 596 factory()->NewJSTypedArray(type, buffer, 0, kLength);
597 int const element_size = static_cast<int>(array->element_size()); 597 int const element_size = static_cast<int>(array->element_size());
598 598
599 Node* key = Parameter( 599 Node* key = Parameter(
600 Type::Range(kMinInt / element_size, kMaxInt / element_size, zone())); 600 Type::Range(kMinInt / element_size, kMaxInt / element_size, zone()));
601 Node* base = HeapConstant(array); 601 Node* base = HeapConstant(array);
602 Node* vector = UndefinedConstant(); 602 Node* vector = UndefinedConstant();
603 Node* context = UndefinedConstant(); 603 Node* context = UndefinedConstant();
604 Node* effect = graph()->start(); 604 Node* effect = graph()->start();
605 Node* control = graph()->start(); 605 Node* control = graph()->start();
606 Reduction r = Reduce(graph()->NewNode( 606 Reduction r = Reduce(graph()->NewNode(javascript()->LoadProperty(feedback),
607 javascript()->LoadProperty(feedback), base, key, vector, context, 607 base, key, vector, context,
608 EmptyFrameState(), EmptyFrameState(), effect, control)); 608 EmptyFrameState(), effect, control));
609 609
610 Matcher<Node*> offset_matcher = 610 Matcher<Node*> offset_matcher =
611 element_size == 1 611 element_size == 1
612 ? key 612 ? key
613 : IsWord32Shl(key, IsInt32Constant(WhichPowerOf2(element_size))); 613 : IsWord32Shl(key, IsInt32Constant(WhichPowerOf2(element_size)));
614 614
615 ASSERT_TRUE(r.Changed()); 615 ASSERT_TRUE(r.Changed());
616 EXPECT_THAT( 616 EXPECT_THAT(
617 r.replacement(), 617 r.replacement(),
618 IsLoadBuffer(BufferAccess(type), 618 IsLoadBuffer(BufferAccess(type),
(...skipping 18 matching lines...) Expand all
637 637
638 int min = random_number_generator()->NextInt(static_cast<int>(kLength)); 638 int min = random_number_generator()->NextInt(static_cast<int>(kLength));
639 int max = random_number_generator()->NextInt(static_cast<int>(kLength)); 639 int max = random_number_generator()->NextInt(static_cast<int>(kLength));
640 if (min > max) std::swap(min, max); 640 if (min > max) std::swap(min, max);
641 Node* key = Parameter(Type::Range(min, max, zone())); 641 Node* key = Parameter(Type::Range(min, max, zone()));
642 Node* base = HeapConstant(array); 642 Node* base = HeapConstant(array);
643 Node* vector = UndefinedConstant(); 643 Node* vector = UndefinedConstant();
644 Node* context = UndefinedConstant(); 644 Node* context = UndefinedConstant();
645 Node* effect = graph()->start(); 645 Node* effect = graph()->start();
646 Node* control = graph()->start(); 646 Node* control = graph()->start();
647 Reduction r = Reduce(graph()->NewNode( 647 Reduction r = Reduce(graph()->NewNode(javascript()->LoadProperty(feedback),
648 javascript()->LoadProperty(feedback), base, key, vector, context, 648 base, key, vector, context,
649 EmptyFrameState(), EmptyFrameState(), effect, control)); 649 EmptyFrameState(), effect, control));
650 650
651 ASSERT_TRUE(r.Changed()); 651 ASSERT_TRUE(r.Changed());
652 EXPECT_THAT( 652 EXPECT_THAT(
653 r.replacement(), 653 r.replacement(),
654 IsLoadElement(access, 654 IsLoadElement(access,
655 IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])), 655 IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])),
656 key, effect, control)); 656 key, effect, control));
657 } 657 }
658 } 658 }
659 659
(...skipping 18 matching lines...) Expand all
678 Node* base = HeapConstant(array); 678 Node* base = HeapConstant(array);
679 Node* value = 679 Node* value =
680 Parameter(AccessBuilder::ForTypedArrayElement(type, true).type); 680 Parameter(AccessBuilder::ForTypedArrayElement(type, true).type);
681 Node* vector = UndefinedConstant(); 681 Node* vector = UndefinedConstant();
682 Node* context = UndefinedConstant(); 682 Node* context = UndefinedConstant();
683 Node* effect = graph()->start(); 683 Node* effect = graph()->start();
684 Node* control = graph()->start(); 684 Node* control = graph()->start();
685 VectorSlotPair feedback; 685 VectorSlotPair feedback;
686 const Operator* op = javascript()->StoreProperty(language_mode, feedback); 686 const Operator* op = javascript()->StoreProperty(language_mode, feedback);
687 Node* node = graph()->NewNode(op, base, key, value, vector, context, 687 Node* node = graph()->NewNode(op, base, key, value, vector, context,
688 EmptyFrameState(), EmptyFrameState(), 688 EmptyFrameState(), effect, control);
689 effect, control);
690 Reduction r = Reduce(node); 689 Reduction r = Reduce(node);
691 690
692 Matcher<Node*> offset_matcher = 691 Matcher<Node*> offset_matcher =
693 element_size == 1 692 element_size == 1
694 ? key 693 ? key
695 : IsWord32Shl(key, IsInt32Constant(WhichPowerOf2(element_size))); 694 : IsWord32Shl(key, IsInt32Constant(WhichPowerOf2(element_size)));
696 695
697 ASSERT_TRUE(r.Changed()); 696 ASSERT_TRUE(r.Changed());
698 EXPECT_THAT( 697 EXPECT_THAT(
699 r.replacement(), 698 r.replacement(),
(...skipping 19 matching lines...) Expand all
719 int const element_size = static_cast<int>(array->element_size()); 718 int const element_size = static_cast<int>(array->element_size());
720 719
721 Node* key = Parameter( 720 Node* key = Parameter(
722 Type::Range(kMinInt / element_size, kMaxInt / element_size, zone())); 721 Type::Range(kMinInt / element_size, kMaxInt / element_size, zone()));
723 Node* base = HeapConstant(array); 722 Node* base = HeapConstant(array);
724 Node* value = Parameter(Type::Any()); 723 Node* value = Parameter(Type::Any());
725 Node* vector = UndefinedConstant(); 724 Node* vector = UndefinedConstant();
726 Node* context = UndefinedConstant(); 725 Node* context = UndefinedConstant();
727 Node* effect = graph()->start(); 726 Node* effect = graph()->start();
728 Node* control = graph()->start(); 727 Node* control = graph()->start();
728 // TODO(mstarzinger): Once the effect-control-linearizer provides a frame
729 // state we can get rid of this checkpoint again. The reducer won't care.
730 Node* checkpoint = graph()->NewNode(common()->Checkpoint(),
731 EmptyFrameState(), effect, control);
729 VectorSlotPair feedback; 732 VectorSlotPair feedback;
730 const Operator* op = javascript()->StoreProperty(language_mode, feedback); 733 const Operator* op = javascript()->StoreProperty(language_mode, feedback);
731 Node* node = graph()->NewNode(op, base, key, value, vector, context, 734 Node* node = graph()->NewNode(op, base, key, value, vector, context,
732 EmptyFrameState(), EmptyFrameState(), 735 EmptyFrameState(), checkpoint, control);
733 effect, control);
734 Reduction r = Reduce(node); 736 Reduction r = Reduce(node);
735 737
736 Matcher<Node*> offset_matcher = 738 Matcher<Node*> offset_matcher =
737 element_size == 1 739 element_size == 1
738 ? key 740 ? key
739 : IsWord32Shl(key, IsInt32Constant(WhichPowerOf2(element_size))); 741 : IsWord32Shl(key, IsInt32Constant(WhichPowerOf2(element_size)));
740 742
741 Matcher<Node*> value_matcher = 743 Matcher<Node*> value_matcher =
742 IsToNumber(value, context, effect, control); 744 IsToNumber(value, context, checkpoint, control);
743 Matcher<Node*> effect_matcher = value_matcher; 745 Matcher<Node*> effect_matcher = value_matcher;
744 746
745 ASSERT_TRUE(r.Changed()); 747 ASSERT_TRUE(r.Changed());
746 EXPECT_THAT( 748 EXPECT_THAT(
747 r.replacement(), 749 r.replacement(),
748 IsStoreBuffer(BufferAccess(type), 750 IsStoreBuffer(BufferAccess(type),
749 IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])), 751 IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])),
750 offset_matcher, 752 offset_matcher,
751 IsNumberConstant(array->byte_length()->Number()), 753 IsNumberConstant(array->byte_length()->Number()),
752 value_matcher, effect_matcher, control)); 754 value_matcher, effect_matcher, control));
(...skipping 19 matching lines...) Expand all
772 Node* key = Parameter(Type::Range(min, max, zone())); 774 Node* key = Parameter(Type::Range(min, max, zone()));
773 Node* base = HeapConstant(array); 775 Node* base = HeapConstant(array);
774 Node* value = Parameter(access.type); 776 Node* value = Parameter(access.type);
775 Node* vector = UndefinedConstant(); 777 Node* vector = UndefinedConstant();
776 Node* context = UndefinedConstant(); 778 Node* context = UndefinedConstant();
777 Node* effect = graph()->start(); 779 Node* effect = graph()->start();
778 Node* control = graph()->start(); 780 Node* control = graph()->start();
779 VectorSlotPair feedback; 781 VectorSlotPair feedback;
780 const Operator* op = javascript()->StoreProperty(language_mode, feedback); 782 const Operator* op = javascript()->StoreProperty(language_mode, feedback);
781 Node* node = graph()->NewNode(op, base, key, value, vector, context, 783 Node* node = graph()->NewNode(op, base, key, value, vector, context,
782 EmptyFrameState(), EmptyFrameState(), 784 EmptyFrameState(), effect, control);
783 effect, control);
784 Reduction r = Reduce(node); 785 Reduction r = Reduce(node);
785 786
786 ASSERT_TRUE(r.Changed()); 787 ASSERT_TRUE(r.Changed());
787 EXPECT_THAT( 788 EXPECT_THAT(
788 r.replacement(), 789 r.replacement(),
789 IsStoreElement( 790 IsStoreElement(
790 access, IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])), 791 access, IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])),
791 key, value, effect, control)); 792 key, value, effect, control));
792 } 793 }
793 } 794 }
794 } 795 }
795 796
796 797
797 // ----------------------------------------------------------------------------- 798 // -----------------------------------------------------------------------------
798 // JSLoadNamed 799 // JSLoadNamed
799 800
800 801
801 TEST_F(JSTypedLoweringTest, JSLoadNamedStringLength) { 802 TEST_F(JSTypedLoweringTest, JSLoadNamedStringLength) {
802 VectorSlotPair feedback; 803 VectorSlotPair feedback;
803 Handle<Name> name = factory()->length_string(); 804 Handle<Name> name = factory()->length_string();
804 Node* const receiver = Parameter(Type::String(), 0); 805 Node* const receiver = Parameter(Type::String(), 0);
805 Node* const vector = Parameter(Type::Internal(), 1); 806 Node* const vector = Parameter(Type::Internal(), 1);
806 Node* const context = UndefinedConstant(); 807 Node* const context = UndefinedConstant();
807 Node* const effect = graph()->start(); 808 Node* const effect = graph()->start();
808 Node* const control = graph()->start(); 809 Node* const control = graph()->start();
809 Reduction const r = Reduce(graph()->NewNode( 810 Reduction const r = Reduce(
810 javascript()->LoadNamed(name, feedback), receiver, vector, context, 811 graph()->NewNode(javascript()->LoadNamed(name, feedback), receiver,
811 EmptyFrameState(), EmptyFrameState(), effect, control)); 812 vector, context, EmptyFrameState(), effect, control));
812 ASSERT_TRUE(r.Changed()); 813 ASSERT_TRUE(r.Changed());
813 EXPECT_THAT(r.replacement(), IsLoadField(AccessBuilder::ForStringLength(), 814 EXPECT_THAT(r.replacement(), IsLoadField(AccessBuilder::ForStringLength(),
814 receiver, effect, control)); 815 receiver, effect, control));
815 } 816 }
816 817
817 818
818 // ----------------------------------------------------------------------------- 819 // -----------------------------------------------------------------------------
819 // JSAdd 820 // JSAdd
820 821
821 822
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context, 946 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context,
946 frame_state, effect, control); 947 frame_state, effect, control);
947 Reduction r = Reduce(instanceOf); 948 Reduction r = Reduce(instanceOf);
948 ASSERT_FALSE(r.Changed()); 949 ASSERT_FALSE(r.Changed());
949 ASSERT_EQ(instanceOf, dummy->InputAt(0)); 950 ASSERT_EQ(instanceOf, dummy->InputAt(0));
950 } 951 }
951 952
952 } // namespace compiler 953 } // namespace compiler
953 } // namespace internal 954 } // namespace internal
954 } // namespace v8 955 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/operator-properties.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698