| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 <stdlib.h> | 5 #include <stdlib.h> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "test/cctest/test-api.h" | 8 #include "test/cctest/test-api.h" |
| 9 | 9 |
| 10 #include "src/v8.h" | 10 #include "src/v8.h" |
| 11 | 11 |
| 12 #include "src/compilation-cache.h" | 12 #include "src/compilation-cache.h" |
| 13 #include "src/compilation-dependencies.h" | 13 #include "src/compilation-dependencies.h" |
| 14 #include "src/compilation-info.h" | 14 #include "src/compilation-info.h" |
| 15 #include "src/execution.h" | 15 #include "src/execution.h" |
| 16 #include "src/factory.h" | 16 #include "src/factory.h" |
| 17 #include "src/field-type.h" | 17 #include "src/field-type.h" |
| 18 #include "src/global-handles.h" | 18 #include "src/global-handles.h" |
| 19 #include "src/ic/stub-cache.h" | 19 #include "src/ic/stub-cache.h" |
| 20 #include "src/macro-assembler.h" | 20 #include "src/macro-assembler.h" |
| 21 | 21 |
| 22 using namespace v8::internal; | 22 using namespace v8::internal; |
| 23 | 23 |
| 24 | 24 |
| 25 // TODO(ishell): fix this once TransitionToPrototype stops generalizing | 25 // TODO(ishell): fix this once TransitionToPrototype stops generalizing |
| 26 // all field representations (similar to crbug/448711 where elements kind | 26 // all field representations (similar to crbug/448711 where elements kind |
| 27 // and observed transitions caused generalization of all field representations). | 27 // and observed transitions caused generalization of all fields). |
| 28 const bool IS_PROTO_TRANS_ISSUE_FIXED = false; | 28 const bool IS_PROTO_TRANS_ISSUE_FIXED = false; |
| 29 | 29 |
| 30 | 30 |
| 31 // TODO(ishell): fix this once TransitionToAccessorProperty is able to always | 31 // TODO(ishell): fix this once TransitionToAccessorProperty is able to always |
| 32 // keep map in fast mode. | 32 // keep map in fast mode. |
| 33 const bool IS_ACCESSOR_FIELD_SUPPORTED = false; | 33 const bool IS_ACCESSOR_FIELD_SUPPORTED = false; |
| 34 | 34 |
| 35 | 35 |
| 36 // Number of properties used in the tests. | 36 // Number of properties used in the tests. |
| 37 const int kPropCount = 7; | 37 const int kPropCount = 7; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 Handle<Object> setter) { | 214 Handle<Object> setter) { |
| 215 SetAccessorConstant(index, attributes_[index], getter, setter); | 215 SetAccessorConstant(index, attributes_[index], getter, setter); |
| 216 } | 216 } |
| 217 | 217 |
| 218 void SetAccessorConstant(int index, Handle<AccessorPair> pair) { | 218 void SetAccessorConstant(int index, Handle<AccessorPair> pair) { |
| 219 Handle<Object> getter = handle(pair->getter(), isolate_); | 219 Handle<Object> getter = handle(pair->getter(), isolate_); |
| 220 Handle<Object> setter = handle(pair->setter(), isolate_); | 220 Handle<Object> setter = handle(pair->setter(), isolate_); |
| 221 SetAccessorConstant(index, getter, setter); | 221 SetAccessorConstant(index, getter, setter); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void GeneralizeRepresentation(int index) { | 224 void GeneralizeField(int index) { |
| 225 CHECK(index < number_of_properties_); | 225 CHECK(index < number_of_properties_); |
| 226 representations_[index] = Representation::Tagged(); | 226 representations_[index] = Representation::Tagged(); |
| 227 if (locations_[index] == kField) { | 227 if (locations_[index] == kField) { |
| 228 values_[index] = FieldType::Any(isolate_); | 228 values_[index] = FieldType::Any(isolate_); |
| 229 } | 229 } |
| 230 } | 230 } |
| 231 | 231 |
| 232 bool Check(DescriptorArray* descriptors, int descriptor) const { | 232 bool Check(DescriptorArray* descriptors, int descriptor) const { |
| 233 PropertyDetails details = descriptors->GetDetails(descriptor); | 233 PropertyDetails details = descriptors->GetDetails(descriptor); |
| 234 | 234 |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 // Check that the property contains |value|. | 541 // Check that the property contains |value|. |
| 542 CHECK_EQ(1, obj->map()->NumberOfOwnDescriptors()); | 542 CHECK_EQ(1, obj->map()->NumberOfOwnDescriptors()); |
| 543 FieldIndex index = FieldIndex::ForDescriptor(obj->map(), 0); | 543 FieldIndex index = FieldIndex::ForDescriptor(obj->map(), 0); |
| 544 Object* the_value = obj->RawFastPropertyAt(index); | 544 Object* the_value = obj->RawFastPropertyAt(index); |
| 545 CHECK(the_value->IsSmi()); | 545 CHECK(the_value->IsSmi()); |
| 546 CHECK_EQ(42, Smi::cast(the_value)->value()); | 546 CHECK_EQ(42, Smi::cast(the_value)->value()); |
| 547 } | 547 } |
| 548 | 548 |
| 549 | 549 |
| 550 //////////////////////////////////////////////////////////////////////////////// | 550 //////////////////////////////////////////////////////////////////////////////// |
| 551 // A set of tests for representation generalization case. | 551 // A set of tests for field generalization case. |
| 552 // | 552 // |
| 553 | 553 |
| 554 // <Constness, Representation, FieldType> data. | 554 // <Constness, Representation, FieldType> data. |
| 555 struct CRFTData { | 555 struct CRFTData { |
| 556 PropertyConstness constness; | 556 PropertyConstness constness; |
| 557 Representation representation; | 557 Representation representation; |
| 558 Handle<FieldType> type; | 558 Handle<FieldType> type; |
| 559 }; | 559 }; |
| 560 | 560 |
| 561 // This test ensures that representation/field type generalization at | 561 // This test ensures that field generalization at |property_index| is done |
| 562 // |property_index| is done correctly independently of the fact that the |map| | 562 // correctly independently of the fact that the |map| is detached from |
| 563 // is detached from transition tree or not. | 563 // transition tree or not. |
| 564 // | 564 // |
| 565 // {} - p0 - p1 - p2: |detach_point_map| | 565 // {} - p0 - p1 - p2: |detach_point_map| |
| 566 // | | 566 // | |
| 567 // X - detached at |detach_property_at_index| | 567 // X - detached at |detach_property_at_index| |
| 568 // | | 568 // | |
| 569 // + - p3 - p4: |map| | 569 // + - p3 - p4: |map| |
| 570 // | 570 // |
| 571 // Detaching does not happen if |detach_property_at_index| is -1. | 571 // Detaching does not happen if |detach_property_at_index| is -1. |
| 572 // | 572 // |
| 573 static void TestGeneralizeRepresentation( | 573 static void TestGeneralizeField(int detach_property_at_index, |
| 574 int detach_property_at_index, int property_index, const CRFTData& from, | 574 int property_index, const CRFTData& from, |
| 575 const CRFTData& to, const CRFTData& expected, bool expected_deprecation, | 575 const CRFTData& to, const CRFTData& expected, |
| 576 bool expected_field_type_dependency) { | 576 bool expected_deprecation, |
| 577 bool expected_field_type_dependency) { |
| 577 Isolate* isolate = CcTest::i_isolate(); | 578 Isolate* isolate = CcTest::i_isolate(); |
| 578 Handle<FieldType> any_type = FieldType::Any(isolate); | 579 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 579 | 580 |
| 580 CHECK(detach_property_at_index >= -1 && | 581 CHECK(detach_property_at_index >= -1 && |
| 581 detach_property_at_index < kPropCount); | 582 detach_property_at_index < kPropCount); |
| 582 CHECK(property_index < kPropCount); | 583 CHECK(property_index < kPropCount); |
| 583 CHECK_NE(detach_property_at_index, property_index); | 584 CHECK_NE(detach_property_at_index, property_index); |
| 584 | 585 |
| 585 const bool is_detached_map = detach_property_at_index >= 0; | 586 const bool is_detached_map = detach_property_at_index >= 0; |
| 586 | 587 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 } | 669 } |
| 669 } | 670 } |
| 670 | 671 |
| 671 dependencies.Rollback(); // Properly cleanup compilation info. | 672 dependencies.Rollback(); // Properly cleanup compilation info. |
| 672 | 673 |
| 673 // Update all deprecated maps and check that they are now the same. | 674 // Update all deprecated maps and check that they are now the same. |
| 674 Handle<Map> updated_map = Map::Update(map); | 675 Handle<Map> updated_map = Map::Update(map); |
| 675 CHECK_EQ(*new_map, *updated_map); | 676 CHECK_EQ(*new_map, *updated_map); |
| 676 } | 677 } |
| 677 | 678 |
| 678 static void TestGeneralizeRepresentation(const CRFTData& from, | 679 static void TestGeneralizeField(const CRFTData& from, const CRFTData& to, |
| 679 const CRFTData& to, | 680 const CRFTData& expected, |
| 680 const CRFTData& expected, | 681 bool expected_deprecation, |
| 681 bool expected_deprecation, | 682 bool expected_field_type_dependency) { |
| 682 bool expected_field_type_dependency) { | |
| 683 // Check the cases when the map being reconfigured is a part of the | 683 // Check the cases when the map being reconfigured is a part of the |
| 684 // transition tree. | 684 // transition tree. |
| 685 STATIC_ASSERT(kPropCount > 4); | 685 STATIC_ASSERT(kPropCount > 4); |
| 686 int indices[] = {0, 2, kPropCount - 1}; | 686 int indices[] = {0, 2, kPropCount - 1}; |
| 687 for (int i = 0; i < static_cast<int>(arraysize(indices)); i++) { | 687 for (int i = 0; i < static_cast<int>(arraysize(indices)); i++) { |
| 688 TestGeneralizeRepresentation(-1, indices[i], from, to, expected, | 688 TestGeneralizeField(-1, indices[i], from, to, expected, |
| 689 expected_deprecation, | 689 expected_deprecation, expected_field_type_dependency); |
| 690 expected_field_type_dependency); | |
| 691 } | 690 } |
| 692 | 691 |
| 693 if (!from.representation.IsNone()) { | 692 if (!from.representation.IsNone()) { |
| 694 // Check the cases when the map being reconfigured is NOT a part of the | 693 // Check the cases when the map being reconfigured is NOT a part of the |
| 695 // transition tree. "None -> anything" representation changes make sense | 694 // transition tree. "None -> anything" representation changes make sense |
| 696 // only for "attached" maps. | 695 // only for "attached" maps. |
| 697 int indices[] = {0, kPropCount - 1}; | 696 int indices[] = {0, kPropCount - 1}; |
| 698 for (int i = 0; i < static_cast<int>(arraysize(indices)); i++) { | 697 for (int i = 0; i < static_cast<int>(arraysize(indices)); i++) { |
| 699 TestGeneralizeRepresentation(indices[i], 2, from, to, expected, | 698 TestGeneralizeField(indices[i], 2, from, to, expected, |
| 700 expected_deprecation, | 699 expected_deprecation, expected_field_type_dependency); |
| 701 expected_field_type_dependency); | |
| 702 } | 700 } |
| 703 | 701 |
| 704 // Check that reconfiguration to the very same field works correctly. | 702 // Check that reconfiguration to the very same field works correctly. |
| 705 CRFTData data = from; | 703 CRFTData data = from; |
| 706 TestGeneralizeRepresentation(-1, 2, data, data, data, false, false); | 704 TestGeneralizeField(-1, 2, data, data, data, false, false); |
| 707 } | 705 } |
| 708 } | 706 } |
| 709 | 707 |
| 710 static void TestGeneralizeRepresentation(const CRFTData& from, | 708 static void TestGeneralizeField(const CRFTData& from, const CRFTData& to, |
| 711 const CRFTData& to, | 709 const CRFTData& expected) { |
| 712 const CRFTData& expected) { | |
| 713 const bool expected_deprecation = true; | 710 const bool expected_deprecation = true; |
| 714 const bool expected_field_type_dependency = false; | 711 const bool expected_field_type_dependency = false; |
| 715 | 712 |
| 716 TestGeneralizeRepresentation(from, to, expected, expected_deprecation, | 713 TestGeneralizeField(from, to, expected, expected_deprecation, |
| 717 expected_field_type_dependency); | 714 expected_field_type_dependency); |
| 718 } | 715 } |
| 719 | 716 |
| 720 static void TestGeneralizeRepresentationTrivial( | 717 static void TestGeneralizeFieldTrivial( |
| 721 const CRFTData& from, const CRFTData& to, const CRFTData& expected, | 718 const CRFTData& from, const CRFTData& to, const CRFTData& expected, |
| 722 bool expected_field_type_dependency = true) { | 719 bool expected_field_type_dependency = true) { |
| 723 const bool expected_deprecation = false; | 720 const bool expected_deprecation = false; |
| 724 | 721 |
| 725 TestGeneralizeRepresentation(from, to, expected, expected_deprecation, | 722 TestGeneralizeField(from, to, expected, expected_deprecation, |
| 726 expected_field_type_dependency); | 723 expected_field_type_dependency); |
| 727 } | 724 } |
| 728 | 725 |
| 729 | 726 TEST(GeneralizeSmiFieldToDouble) { |
| 730 TEST(GeneralizeRepresentationSmiToDouble) { | |
| 731 CcTest::InitializeVM(); | 727 CcTest::InitializeVM(); |
| 732 v8::HandleScope scope(CcTest::isolate()); | 728 v8::HandleScope scope(CcTest::isolate()); |
| 733 Isolate* isolate = CcTest::i_isolate(); | 729 Isolate* isolate = CcTest::i_isolate(); |
| 734 Handle<FieldType> any_type = FieldType::Any(isolate); | 730 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 735 | 731 |
| 736 TestGeneralizeRepresentation({kMutable, Representation::Smi(), any_type}, | 732 TestGeneralizeField({kMutable, Representation::Smi(), any_type}, |
| 737 {kMutable, Representation::Double(), any_type}, | 733 {kMutable, Representation::Double(), any_type}, |
| 738 {kMutable, Representation::Double(), any_type}); | 734 {kMutable, Representation::Double(), any_type}); |
| 739 } | 735 } |
| 740 | 736 |
| 741 | 737 TEST(GeneralizeSmiFieldToTagged) { |
| 742 TEST(GeneralizeRepresentationSmiToTagged) { | |
| 743 CcTest::InitializeVM(); | 738 CcTest::InitializeVM(); |
| 744 v8::HandleScope scope(CcTest::isolate()); | 739 v8::HandleScope scope(CcTest::isolate()); |
| 745 Isolate* isolate = CcTest::i_isolate(); | 740 Isolate* isolate = CcTest::i_isolate(); |
| 746 Handle<FieldType> any_type = FieldType::Any(isolate); | 741 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 747 Handle<FieldType> value_type = | 742 Handle<FieldType> value_type = |
| 748 FieldType::Class(Map::Create(isolate, 0), isolate); | 743 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 749 | 744 |
| 750 TestGeneralizeRepresentation( | 745 TestGeneralizeField({kMutable, Representation::Smi(), any_type}, |
| 751 {kMutable, Representation::Smi(), any_type}, | 746 {kMutable, Representation::HeapObject(), value_type}, |
| 752 {kMutable, Representation::HeapObject(), value_type}, | 747 {kMutable, Representation::Tagged(), any_type}); |
| 753 {kMutable, Representation::Tagged(), any_type}); | |
| 754 } | 748 } |
| 755 | 749 |
| 756 | 750 TEST(GeneralizeDoubleFieldToTagged) { |
| 757 TEST(GeneralizeRepresentationDoubleToTagged) { | |
| 758 CcTest::InitializeVM(); | 751 CcTest::InitializeVM(); |
| 759 v8::HandleScope scope(CcTest::isolate()); | 752 v8::HandleScope scope(CcTest::isolate()); |
| 760 Isolate* isolate = CcTest::i_isolate(); | 753 Isolate* isolate = CcTest::i_isolate(); |
| 761 Handle<FieldType> any_type = FieldType::Any(isolate); | 754 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 762 Handle<FieldType> value_type = | 755 Handle<FieldType> value_type = |
| 763 FieldType::Class(Map::Create(isolate, 0), isolate); | 756 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 764 | 757 |
| 765 TestGeneralizeRepresentation( | 758 TestGeneralizeField({kMutable, Representation::Double(), any_type}, |
| 766 {kMutable, Representation::Double(), any_type}, | 759 {kMutable, Representation::HeapObject(), value_type}, |
| 767 {kMutable, Representation::HeapObject(), value_type}, | 760 {kMutable, Representation::Tagged(), any_type}); |
| 768 {kMutable, Representation::Tagged(), any_type}); | |
| 769 } | 761 } |
| 770 | 762 |
| 771 | 763 TEST(GeneralizeHeapObjectFieldToTagged) { |
| 772 TEST(GeneralizeRepresentationHeapObjectToTagged) { | |
| 773 CcTest::InitializeVM(); | 764 CcTest::InitializeVM(); |
| 774 v8::HandleScope scope(CcTest::isolate()); | 765 v8::HandleScope scope(CcTest::isolate()); |
| 775 Isolate* isolate = CcTest::i_isolate(); | 766 Isolate* isolate = CcTest::i_isolate(); |
| 776 Handle<FieldType> any_type = FieldType::Any(isolate); | 767 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 777 Handle<FieldType> value_type = | 768 Handle<FieldType> value_type = |
| 778 FieldType::Class(Map::Create(isolate, 0), isolate); | 769 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 779 | 770 |
| 780 TestGeneralizeRepresentation( | 771 TestGeneralizeField({kMutable, Representation::HeapObject(), value_type}, |
| 781 {kMutable, Representation::HeapObject(), value_type}, | 772 {kMutable, Representation::Smi(), any_type}, |
| 782 {kMutable, Representation::Smi(), any_type}, | 773 {kMutable, Representation::Tagged(), any_type}); |
| 783 {kMutable, Representation::Tagged(), any_type}); | |
| 784 } | 774 } |
| 785 | 775 |
| 786 | 776 TEST(GeneralizeHeapObjectFieldToHeapObject) { |
| 787 TEST(GeneralizeRepresentationHeapObjectToHeapObject) { | |
| 788 CcTest::InitializeVM(); | 777 CcTest::InitializeVM(); |
| 789 v8::HandleScope scope(CcTest::isolate()); | 778 v8::HandleScope scope(CcTest::isolate()); |
| 790 Isolate* isolate = CcTest::i_isolate(); | 779 Isolate* isolate = CcTest::i_isolate(); |
| 791 Handle<FieldType> any_type = FieldType::Any(isolate); | 780 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 792 | 781 |
| 793 Handle<FieldType> current_type = | 782 Handle<FieldType> current_type = |
| 794 FieldType::Class(Map::Create(isolate, 0), isolate); | 783 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 795 | 784 |
| 796 Handle<FieldType> new_type = | 785 Handle<FieldType> new_type = |
| 797 FieldType::Class(Map::Create(isolate, 0), isolate); | 786 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 798 | 787 |
| 799 Handle<FieldType> expected_type = any_type; | 788 Handle<FieldType> expected_type = any_type; |
| 800 | 789 |
| 801 TestGeneralizeRepresentationTrivial( | 790 TestGeneralizeFieldTrivial( |
| 802 {kMutable, Representation::HeapObject(), current_type}, | 791 {kMutable, Representation::HeapObject(), current_type}, |
| 803 {kMutable, Representation::HeapObject(), new_type}, | 792 {kMutable, Representation::HeapObject(), new_type}, |
| 804 {kMutable, Representation::HeapObject(), expected_type}); | 793 {kMutable, Representation::HeapObject(), expected_type}); |
| 805 current_type = expected_type; | 794 current_type = expected_type; |
| 806 | 795 |
| 807 new_type = FieldType::Class(Map::Create(isolate, 0), isolate); | 796 new_type = FieldType::Class(Map::Create(isolate, 0), isolate); |
| 808 | 797 |
| 809 TestGeneralizeRepresentationTrivial( | 798 TestGeneralizeFieldTrivial({kMutable, Representation::HeapObject(), any_type}, |
| 810 {kMutable, Representation::HeapObject(), any_type}, | 799 {kMutable, Representation::HeapObject(), new_type}, |
| 811 {kMutable, Representation::HeapObject(), new_type}, | 800 {kMutable, Representation::HeapObject(), any_type}, |
| 812 {kMutable, Representation::HeapObject(), any_type}, false); | 801 false); |
| 813 } | 802 } |
| 814 | 803 |
| 815 | 804 TEST(GeneralizeNoneFieldToSmi) { |
| 816 TEST(GeneralizeRepresentationNoneToSmi) { | |
| 817 CcTest::InitializeVM(); | 805 CcTest::InitializeVM(); |
| 818 v8::HandleScope scope(CcTest::isolate()); | 806 v8::HandleScope scope(CcTest::isolate()); |
| 819 Isolate* isolate = CcTest::i_isolate(); | 807 Isolate* isolate = CcTest::i_isolate(); |
| 820 Handle<FieldType> none_type = FieldType::None(isolate); | 808 Handle<FieldType> none_type = FieldType::None(isolate); |
| 821 Handle<FieldType> any_type = FieldType::Any(isolate); | 809 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 822 | 810 |
| 823 // None -> Smi representation change is trivial. | 811 // None -> Smi representation change is trivial. |
| 824 TestGeneralizeRepresentationTrivial( | 812 TestGeneralizeFieldTrivial({kMutable, Representation::None(), none_type}, |
| 825 {kMutable, Representation::None(), none_type}, | 813 {kMutable, Representation::Smi(), any_type}, |
| 826 {kMutable, Representation::Smi(), any_type}, | 814 {kMutable, Representation::Smi(), any_type}); |
| 827 {kMutable, Representation::Smi(), any_type}); | |
| 828 } | 815 } |
| 829 | 816 |
| 830 | 817 TEST(GeneralizeNoneFieldToDouble) { |
| 831 TEST(GeneralizeRepresentationNoneToDouble) { | |
| 832 CcTest::InitializeVM(); | 818 CcTest::InitializeVM(); |
| 833 v8::HandleScope scope(CcTest::isolate()); | 819 v8::HandleScope scope(CcTest::isolate()); |
| 834 Isolate* isolate = CcTest::i_isolate(); | 820 Isolate* isolate = CcTest::i_isolate(); |
| 835 Handle<FieldType> none_type = FieldType::None(isolate); | 821 Handle<FieldType> none_type = FieldType::None(isolate); |
| 836 Handle<FieldType> any_type = FieldType::Any(isolate); | 822 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 837 | 823 |
| 838 // None -> Double representation change is NOT trivial. | 824 // None -> Double representation change is NOT trivial. |
| 839 TestGeneralizeRepresentation({kMutable, Representation::None(), none_type}, | 825 TestGeneralizeField({kMutable, Representation::None(), none_type}, |
| 840 {kMutable, Representation::Double(), any_type}, | 826 {kMutable, Representation::Double(), any_type}, |
| 841 {kMutable, Representation::Double(), any_type}); | 827 {kMutable, Representation::Double(), any_type}); |
| 842 } | 828 } |
| 843 | 829 |
| 844 | 830 TEST(GeneralizeNoneFieldToHeapObject) { |
| 845 TEST(GeneralizeRepresentationNoneToHeapObject) { | |
| 846 CcTest::InitializeVM(); | 831 CcTest::InitializeVM(); |
| 847 v8::HandleScope scope(CcTest::isolate()); | 832 v8::HandleScope scope(CcTest::isolate()); |
| 848 Isolate* isolate = CcTest::i_isolate(); | 833 Isolate* isolate = CcTest::i_isolate(); |
| 849 Handle<FieldType> none_type = FieldType::None(isolate); | 834 Handle<FieldType> none_type = FieldType::None(isolate); |
| 850 Handle<FieldType> value_type = | 835 Handle<FieldType> value_type = |
| 851 FieldType::Class(Map::Create(isolate, 0), isolate); | 836 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 852 | 837 |
| 853 // None -> HeapObject representation change is trivial. | 838 // None -> HeapObject representation change is trivial. |
| 854 TestGeneralizeRepresentationTrivial( | 839 TestGeneralizeFieldTrivial( |
| 855 {kMutable, Representation::None(), none_type}, | 840 {kMutable, Representation::None(), none_type}, |
| 856 {kMutable, Representation::HeapObject(), value_type}, | 841 {kMutable, Representation::HeapObject(), value_type}, |
| 857 {kMutable, Representation::HeapObject(), value_type}); | 842 {kMutable, Representation::HeapObject(), value_type}); |
| 858 } | 843 } |
| 859 | 844 |
| 860 | 845 TEST(GeneralizeNoneFieldToTagged) { |
| 861 TEST(GeneralizeRepresentationNoneToTagged) { | |
| 862 CcTest::InitializeVM(); | 846 CcTest::InitializeVM(); |
| 863 v8::HandleScope scope(CcTest::isolate()); | 847 v8::HandleScope scope(CcTest::isolate()); |
| 864 Isolate* isolate = CcTest::i_isolate(); | 848 Isolate* isolate = CcTest::i_isolate(); |
| 865 Handle<FieldType> none_type = FieldType::None(isolate); | 849 Handle<FieldType> none_type = FieldType::None(isolate); |
| 866 Handle<FieldType> any_type = FieldType::Any(isolate); | 850 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 867 | 851 |
| 868 // None -> HeapObject representation change is trivial. | 852 // None -> HeapObject representation change is trivial. |
| 869 TestGeneralizeRepresentationTrivial( | 853 TestGeneralizeFieldTrivial({kMutable, Representation::None(), none_type}, |
| 870 {kMutable, Representation::None(), none_type}, | 854 {kMutable, Representation::Tagged(), any_type}, |
| 871 {kMutable, Representation::Tagged(), any_type}, | 855 {kMutable, Representation::Tagged(), any_type}); |
| 872 {kMutable, Representation::Tagged(), any_type}); | |
| 873 } | 856 } |
| 874 | 857 |
| 875 | 858 |
| 876 //////////////////////////////////////////////////////////////////////////////// | 859 //////////////////////////////////////////////////////////////////////////////// |
| 877 // A set of tests for representation generalization case with kAccessor | 860 // A set of tests for field generalization case with kAccessor properties. |
| 878 // properties. | |
| 879 // | 861 // |
| 880 | 862 |
| 881 TEST(GeneralizeRepresentationWithAccessorProperties) { | 863 TEST(GeneralizeFieldWithAccessorProperties) { |
| 882 CcTest::InitializeVM(); | 864 CcTest::InitializeVM(); |
| 883 v8::HandleScope scope(CcTest::isolate()); | 865 v8::HandleScope scope(CcTest::isolate()); |
| 884 Isolate* isolate = CcTest::i_isolate(); | 866 Isolate* isolate = CcTest::i_isolate(); |
| 885 Handle<FieldType> any_type = FieldType::Any(isolate); | 867 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 886 Handle<AccessorPair> pair = CreateAccessorPair(true, true); | 868 Handle<AccessorPair> pair = CreateAccessorPair(true, true); |
| 887 | 869 |
| 888 const int kAccessorProp = kPropCount / 2; | 870 const int kAccessorProp = kPropCount / 2; |
| 889 Expectations expectations(isolate); | 871 Expectations expectations(isolate); |
| 890 | 872 |
| 891 // Create a map, add required properties to it and initialize expectations. | 873 // Create a map, add required properties to it and initialize expectations. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 updated_map = Map::Update(maps[i]); | 918 updated_map = Map::Update(maps[i]); |
| 937 CHECK_EQ(*active_map, *updated_map); | 919 CHECK_EQ(*active_map, *updated_map); |
| 938 } | 920 } |
| 939 } | 921 } |
| 940 | 922 |
| 941 | 923 |
| 942 //////////////////////////////////////////////////////////////////////////////// | 924 //////////////////////////////////////////////////////////////////////////////// |
| 943 // A set of tests for attribute reconfiguration case. | 925 // A set of tests for attribute reconfiguration case. |
| 944 // | 926 // |
| 945 | 927 |
| 946 // This test ensures that representation/field type generalization is correctly | 928 // This test ensures that field generalization is correctly propagated from one |
| 947 // propagated from one branch of transition tree (|map2|) to another (|map|). | 929 // branch of transition tree (|map2|) to another (|map|). |
| 948 // | 930 // |
| 949 // + - p2B - p3 - p4: |map2| | 931 // + - p2B - p3 - p4: |map2| |
| 950 // | | 932 // | |
| 951 // {} - p0 - p1 - p2A - p3 - p4: |map| | 933 // {} - p0 - p1 - p2A - p3 - p4: |map| |
| 952 // | 934 // |
| 953 // where "p2A" and "p2B" differ only in the attributes. | 935 // where "p2A" and "p2B" differ only in the attributes. |
| 954 // | 936 // |
| 955 static void TestReconfigureDataFieldAttribute_GeneralizeRepresentation( | 937 static void TestReconfigureDataFieldAttribute_GeneralizeField( |
| 956 const CRFTData& from, const CRFTData& to, const CRFTData& expected) { | 938 const CRFTData& from, const CRFTData& to, const CRFTData& expected) { |
| 957 Isolate* isolate = CcTest::i_isolate(); | 939 Isolate* isolate = CcTest::i_isolate(); |
| 958 | 940 |
| 959 Expectations expectations(isolate); | 941 Expectations expectations(isolate); |
| 960 | 942 |
| 961 // Create a map, add required properties to it and initialize expectations. | 943 // Create a map, add required properties to it and initialize expectations. |
| 962 Handle<Map> initial_map = Map::Create(isolate, 0); | 944 Handle<Map> initial_map = Map::Create(isolate, 0); |
| 963 Handle<Map> map = initial_map; | 945 Handle<Map> map = initial_map; |
| 964 for (int i = 0; i < kPropCount; i++) { | 946 for (int i = 0; i < kPropCount; i++) { |
| 965 map = expectations.AddDataField(map, NONE, from.constness, | 947 map = expectations.AddDataField(map, NONE, from.constness, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1019 CHECK_NE(*map, *new_map); | 1001 CHECK_NE(*map, *new_map); |
| 1020 | 1002 |
| 1021 CHECK(!new_map->is_deprecated()); | 1003 CHECK(!new_map->is_deprecated()); |
| 1022 CHECK(expectations.Check(*new_map)); | 1004 CHECK(expectations.Check(*new_map)); |
| 1023 | 1005 |
| 1024 // Update deprecated |map|, it should become |new_map|. | 1006 // Update deprecated |map|, it should become |new_map|. |
| 1025 Handle<Map> updated_map = Map::Update(map); | 1007 Handle<Map> updated_map = Map::Update(map); |
| 1026 CHECK_EQ(*new_map, *updated_map); | 1008 CHECK_EQ(*new_map, *updated_map); |
| 1027 } | 1009 } |
| 1028 | 1010 |
| 1029 | 1011 // This test ensures that trivial field generalization (from HeapObject to |
| 1030 // This test ensures that trivial representation/field type generalization | 1012 // HeapObject) is correctly propagated from one branch of transition tree |
| 1031 // (from HeapObject to HeapObject) is correctly propagated from one branch of | 1013 // (|map2|) to another (|map|). |
| 1032 // transition tree (|map2|) to another (|map|). | |
| 1033 // | 1014 // |
| 1034 // + - p2B - p3 - p4: |map2| | 1015 // + - p2B - p3 - p4: |map2| |
| 1035 // | | 1016 // | |
| 1036 // {} - p0 - p1 - p2A - p3 - p4: |map| | 1017 // {} - p0 - p1 - p2A - p3 - p4: |map| |
| 1037 // | 1018 // |
| 1038 // where "p2A" and "p2B" differ only in the attributes. | 1019 // where "p2A" and "p2B" differ only in the attributes. |
| 1039 // | 1020 // |
| 1040 static void TestReconfigureDataFieldAttribute_GeneralizeRepresentationTrivial( | 1021 static void TestReconfigureDataFieldAttribute_GeneralizeFieldTrivial( |
| 1041 const CRFTData& from, const CRFTData& to, const CRFTData& expected, | 1022 const CRFTData& from, const CRFTData& to, const CRFTData& expected, |
| 1042 bool expected_field_type_dependency = true) { | 1023 bool expected_field_type_dependency = true) { |
| 1043 Isolate* isolate = CcTest::i_isolate(); | 1024 Isolate* isolate = CcTest::i_isolate(); |
| 1044 | 1025 |
| 1045 Expectations expectations(isolate); | 1026 Expectations expectations(isolate); |
| 1046 | 1027 |
| 1047 // Create a map, add required properties to it and initialize expectations. | 1028 // Create a map, add required properties to it and initialize expectations. |
| 1048 Handle<Map> initial_map = Map::Create(isolate, 0); | 1029 Handle<Map> initial_map = Map::Create(isolate, 0); |
| 1049 Handle<Map> map = initial_map; | 1030 Handle<Map> map = initial_map; |
| 1050 for (int i = 0; i < kPropCount; i++) { | 1031 for (int i = 0; i < kPropCount; i++) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1107 CHECK_EQ(expected_field_type_dependency, dependencies.HasAborted()); | 1088 CHECK_EQ(expected_field_type_dependency, dependencies.HasAborted()); |
| 1108 dependencies.Rollback(); // Properly cleanup compilation info. | 1089 dependencies.Rollback(); // Properly cleanup compilation info. |
| 1109 | 1090 |
| 1110 CHECK(!new_map->is_deprecated()); | 1091 CHECK(!new_map->is_deprecated()); |
| 1111 CHECK(expectations.Check(*new_map)); | 1092 CHECK(expectations.Check(*new_map)); |
| 1112 | 1093 |
| 1113 Handle<Map> updated_map = Map::Update(map); | 1094 Handle<Map> updated_map = Map::Update(map); |
| 1114 CHECK_EQ(*new_map, *updated_map); | 1095 CHECK_EQ(*new_map, *updated_map); |
| 1115 } | 1096 } |
| 1116 | 1097 |
| 1117 | 1098 TEST(ReconfigureDataFieldAttribute_GeneralizeSmiFieldToDouble) { |
| 1118 TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationSmiToDouble) { | |
| 1119 CcTest::InitializeVM(); | 1099 CcTest::InitializeVM(); |
| 1120 v8::HandleScope scope(CcTest::isolate()); | 1100 v8::HandleScope scope(CcTest::isolate()); |
| 1121 Isolate* isolate = CcTest::i_isolate(); | 1101 Isolate* isolate = CcTest::i_isolate(); |
| 1122 Handle<FieldType> any_type = FieldType::Any(isolate); | 1102 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1123 | 1103 |
| 1124 TestReconfigureDataFieldAttribute_GeneralizeRepresentation( | 1104 TestReconfigureDataFieldAttribute_GeneralizeField( |
| 1125 {kMutable, Representation::Smi(), any_type}, | 1105 {kMutable, Representation::Smi(), any_type}, |
| 1126 {kMutable, Representation::Double(), any_type}, | 1106 {kMutable, Representation::Double(), any_type}, |
| 1127 {kMutable, Representation::Double(), any_type}); | 1107 {kMutable, Representation::Double(), any_type}); |
| 1128 } | 1108 } |
| 1129 | 1109 |
| 1130 | 1110 TEST(ReconfigureDataFieldAttribute_GeneralizeSmiFieldToTagged) { |
| 1131 TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationSmiToTagged) { | |
| 1132 CcTest::InitializeVM(); | 1111 CcTest::InitializeVM(); |
| 1133 v8::HandleScope scope(CcTest::isolate()); | 1112 v8::HandleScope scope(CcTest::isolate()); |
| 1134 Isolate* isolate = CcTest::i_isolate(); | 1113 Isolate* isolate = CcTest::i_isolate(); |
| 1135 Handle<FieldType> any_type = FieldType::Any(isolate); | 1114 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1136 Handle<FieldType> value_type = | 1115 Handle<FieldType> value_type = |
| 1137 FieldType::Class(Map::Create(isolate, 0), isolate); | 1116 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 1138 | 1117 |
| 1139 TestReconfigureDataFieldAttribute_GeneralizeRepresentation( | 1118 TestReconfigureDataFieldAttribute_GeneralizeField( |
| 1140 {kMutable, Representation::Smi(), any_type}, | 1119 {kMutable, Representation::Smi(), any_type}, |
| 1141 {kMutable, Representation::HeapObject(), value_type}, | 1120 {kMutable, Representation::HeapObject(), value_type}, |
| 1142 {kMutable, Representation::Tagged(), any_type}); | 1121 {kMutable, Representation::Tagged(), any_type}); |
| 1143 } | 1122 } |
| 1144 | 1123 |
| 1145 | 1124 TEST(ReconfigureDataFieldAttribute_GeneralizeDoubleFieldToTagged) { |
| 1146 TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationDoubleToTagged) { | |
| 1147 CcTest::InitializeVM(); | 1125 CcTest::InitializeVM(); |
| 1148 v8::HandleScope scope(CcTest::isolate()); | 1126 v8::HandleScope scope(CcTest::isolate()); |
| 1149 Isolate* isolate = CcTest::i_isolate(); | 1127 Isolate* isolate = CcTest::i_isolate(); |
| 1150 Handle<FieldType> any_type = FieldType::Any(isolate); | 1128 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1151 Handle<FieldType> value_type = | 1129 Handle<FieldType> value_type = |
| 1152 FieldType::Class(Map::Create(isolate, 0), isolate); | 1130 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 1153 | 1131 |
| 1154 TestReconfigureDataFieldAttribute_GeneralizeRepresentation( | 1132 TestReconfigureDataFieldAttribute_GeneralizeField( |
| 1155 {kMutable, Representation::Double(), any_type}, | 1133 {kMutable, Representation::Double(), any_type}, |
| 1156 {kMutable, Representation::HeapObject(), value_type}, | 1134 {kMutable, Representation::HeapObject(), value_type}, |
| 1157 {kMutable, Representation::Tagged(), any_type}); | 1135 {kMutable, Representation::Tagged(), any_type}); |
| 1158 } | 1136 } |
| 1159 | 1137 |
| 1160 | 1138 TEST(ReconfigureDataFieldAttribute_GeneralizeHeapObjFieldToHeapObj) { |
| 1161 TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationHeapObjToHeapObj) { | |
| 1162 CcTest::InitializeVM(); | 1139 CcTest::InitializeVM(); |
| 1163 v8::HandleScope scope(CcTest::isolate()); | 1140 v8::HandleScope scope(CcTest::isolate()); |
| 1164 Isolate* isolate = CcTest::i_isolate(); | 1141 Isolate* isolate = CcTest::i_isolate(); |
| 1165 Handle<FieldType> any_type = FieldType::Any(isolate); | 1142 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1166 | 1143 |
| 1167 Handle<FieldType> current_type = | 1144 Handle<FieldType> current_type = |
| 1168 FieldType::Class(Map::Create(isolate, 0), isolate); | 1145 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 1169 | 1146 |
| 1170 Handle<FieldType> new_type = | 1147 Handle<FieldType> new_type = |
| 1171 FieldType::Class(Map::Create(isolate, 0), isolate); | 1148 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 1172 | 1149 |
| 1173 Handle<FieldType> expected_type = any_type; | 1150 Handle<FieldType> expected_type = any_type; |
| 1174 | 1151 |
| 1175 TestReconfigureDataFieldAttribute_GeneralizeRepresentationTrivial( | 1152 TestReconfigureDataFieldAttribute_GeneralizeFieldTrivial( |
| 1176 {kMutable, Representation::HeapObject(), current_type}, | 1153 {kMutable, Representation::HeapObject(), current_type}, |
| 1177 {kMutable, Representation::HeapObject(), new_type}, | 1154 {kMutable, Representation::HeapObject(), new_type}, |
| 1178 {kMutable, Representation::HeapObject(), expected_type}); | 1155 {kMutable, Representation::HeapObject(), expected_type}); |
| 1179 current_type = expected_type; | 1156 current_type = expected_type; |
| 1180 | 1157 |
| 1181 new_type = FieldType::Class(Map::Create(isolate, 0), isolate); | 1158 new_type = FieldType::Class(Map::Create(isolate, 0), isolate); |
| 1182 | 1159 |
| 1183 TestReconfigureDataFieldAttribute_GeneralizeRepresentationTrivial( | 1160 TestReconfigureDataFieldAttribute_GeneralizeFieldTrivial( |
| 1184 {kMutable, Representation::HeapObject(), any_type}, | 1161 {kMutable, Representation::HeapObject(), any_type}, |
| 1185 {kMutable, Representation::HeapObject(), new_type}, | 1162 {kMutable, Representation::HeapObject(), new_type}, |
| 1186 {kMutable, Representation::HeapObject(), any_type}, false); | 1163 {kMutable, Representation::HeapObject(), any_type}, false); |
| 1187 } | 1164 } |
| 1188 | 1165 |
| 1189 | 1166 TEST(ReconfigureDataFieldAttribute_GeneralizeHeapObjectFieldToTagged) { |
| 1190 TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationHeapObjectToTagged) { | |
| 1191 CcTest::InitializeVM(); | 1167 CcTest::InitializeVM(); |
| 1192 v8::HandleScope scope(CcTest::isolate()); | 1168 v8::HandleScope scope(CcTest::isolate()); |
| 1193 Isolate* isolate = CcTest::i_isolate(); | 1169 Isolate* isolate = CcTest::i_isolate(); |
| 1194 Handle<FieldType> any_type = FieldType::Any(isolate); | 1170 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1195 Handle<FieldType> value_type = | 1171 Handle<FieldType> value_type = |
| 1196 FieldType::Class(Map::Create(isolate, 0), isolate); | 1172 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 1197 | 1173 |
| 1198 TestReconfigureDataFieldAttribute_GeneralizeRepresentation( | 1174 TestReconfigureDataFieldAttribute_GeneralizeField( |
| 1199 {kMutable, Representation::HeapObject(), value_type}, | 1175 {kMutable, Representation::HeapObject(), value_type}, |
| 1200 {kMutable, Representation::Smi(), any_type}, | 1176 {kMutable, Representation::Smi(), any_type}, |
| 1201 {kMutable, Representation::Tagged(), any_type}); | 1177 {kMutable, Representation::Tagged(), any_type}); |
| 1202 } | 1178 } |
| 1203 | 1179 |
| 1204 | 1180 |
| 1205 // Checks that given |map| is deprecated and that it updates to given |new_map| | 1181 // Checks that given |map| is deprecated and that it updates to given |new_map| |
| 1206 // which in turn should match expectations. | 1182 // which in turn should match expectations. |
| 1207 struct CheckDeprecated { | 1183 struct CheckDeprecated { |
| 1208 void Check(Handle<Map> map, Handle<Map> new_map, | 1184 void Check(Handle<Map> map, Handle<Map> new_map, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 | 1233 |
| 1258 // Checks that given |map| is NOT deprecated, and |new_map| is a result of | 1234 // Checks that given |map| is NOT deprecated, and |new_map| is a result of |
| 1259 // copy-generalize-all-representations. | 1235 // copy-generalize-all-representations. |
| 1260 struct CheckCopyGeneralizeAllFields { | 1236 struct CheckCopyGeneralizeAllFields { |
| 1261 void Check(Handle<Map> map, Handle<Map> new_map, Expectations& expectations) { | 1237 void Check(Handle<Map> map, Handle<Map> new_map, Expectations& expectations) { |
| 1262 CHECK(!map->is_deprecated()); | 1238 CHECK(!map->is_deprecated()); |
| 1263 CHECK_NE(*map, *new_map); | 1239 CHECK_NE(*map, *new_map); |
| 1264 | 1240 |
| 1265 CHECK(new_map->GetBackPointer()->IsUndefined(map->GetIsolate())); | 1241 CHECK(new_map->GetBackPointer()->IsUndefined(map->GetIsolate())); |
| 1266 for (int i = 0; i < kPropCount; i++) { | 1242 for (int i = 0; i < kPropCount; i++) { |
| 1267 expectations.GeneralizeRepresentation(i); | 1243 expectations.GeneralizeField(i); |
| 1268 } | 1244 } |
| 1269 | 1245 |
| 1270 CHECK(!new_map->is_deprecated()); | 1246 CHECK(!new_map->is_deprecated()); |
| 1271 CHECK(expectations.Check(*new_map)); | 1247 CHECK(expectations.Check(*new_map)); |
| 1272 } | 1248 } |
| 1273 }; | 1249 }; |
| 1274 | 1250 |
| 1275 | 1251 // This test ensures that field generalization is correctly propagated from one |
| 1276 // This test ensures that representation/field type generalization is correctly | 1252 // branch of transition tree (|map2|) to another (|map1|). |
| 1277 // propagated from one branch of transition tree (|map2|) to another (|map1|). | |
| 1278 // | 1253 // |
| 1279 // + - p2B - p3 - p4: |map2| | 1254 // + - p2B - p3 - p4: |map2| |
| 1280 // | | 1255 // | |
| 1281 // {} - p0 - p1: |map| | 1256 // {} - p0 - p1: |map| |
| 1282 // | | 1257 // | |
| 1283 // + - p2A - p3 - p4: |map1| | 1258 // + - p2A - p3 - p4: |map1| |
| 1284 // | | 1259 // | |
| 1285 // + - the property customized by the TestConfig provided | 1260 // + - the property customized by the TestConfig provided |
| 1286 // | 1261 // |
| 1287 // where "p2A" and "p2B" differ only in the attributes. | 1262 // where "p2A" and "p2B" differ only in the attributes. |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1574 // These are completely separate branches in transition tree. | 1549 // These are completely separate branches in transition tree. |
| 1575 CheckUnrelated checker; | 1550 CheckUnrelated checker; |
| 1576 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); | 1551 TestReconfigureProperty_CustomPropertyAfterTargetMap(config, checker); |
| 1577 } | 1552 } |
| 1578 | 1553 |
| 1579 | 1554 |
| 1580 //////////////////////////////////////////////////////////////////////////////// | 1555 //////////////////////////////////////////////////////////////////////////////// |
| 1581 // A set of tests for elements kind reconfiguration case. | 1556 // A set of tests for elements kind reconfiguration case. |
| 1582 // | 1557 // |
| 1583 | 1558 |
| 1584 // This test ensures that representation/field type generalization is correctly | 1559 // This test ensures that field generalization is correctly propagated from one |
| 1585 // propagated from one branch of transition tree (|map2) to another (|map|). | 1560 // branch of transition tree (|map2) to another (|map|). |
| 1586 // | 1561 // |
| 1587 // + - p0 - p1 - p2A - p3 - p4: |map| | 1562 // + - p0 - p1 - p2A - p3 - p4: |map| |
| 1588 // | | 1563 // | |
| 1589 // ek | 1564 // ek |
| 1590 // | | 1565 // | |
| 1591 // {} - p0 - p1 - p2B - p3 - p4: |map2| | 1566 // {} - p0 - p1 - p2B - p3 - p4: |map2| |
| 1592 // | 1567 // |
| 1593 // where "p2A" and "p2B" differ only in the representation/field type. | 1568 // where "p2A" and "p2B" differ only in the representation/field type. |
| 1594 // | 1569 // |
| 1595 static void TestReconfigureElementsKind_GeneralizeRepresentation( | 1570 static void TestReconfigureElementsKind_GeneralizeField( |
| 1596 const CRFTData& from, const CRFTData& to, const CRFTData& expected) { | 1571 const CRFTData& from, const CRFTData& to, const CRFTData& expected) { |
| 1597 Isolate* isolate = CcTest::i_isolate(); | 1572 Isolate* isolate = CcTest::i_isolate(); |
| 1598 | 1573 |
| 1599 Expectations expectations(isolate, FAST_SMI_ELEMENTS); | 1574 Expectations expectations(isolate, FAST_SMI_ELEMENTS); |
| 1600 | 1575 |
| 1601 // Create a map, add required properties to it and initialize expectations. | 1576 // Create a map, add required properties to it and initialize expectations. |
| 1602 Handle<Map> initial_map = Map::Create(isolate, 0); | 1577 Handle<Map> initial_map = Map::Create(isolate, 0); |
| 1603 initial_map->set_elements_kind(FAST_SMI_ELEMENTS); | 1578 initial_map->set_elements_kind(FAST_SMI_ELEMENTS); |
| 1604 | 1579 |
| 1605 Handle<Map> map = initial_map; | 1580 Handle<Map> map = initial_map; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1666 // Ensure Map::FindElementsKindTransitionedMap() is able to find the | 1641 // Ensure Map::FindElementsKindTransitionedMap() is able to find the |
| 1667 // transitioned map. | 1642 // transitioned map. |
| 1668 { | 1643 { |
| 1669 MapHandleList map_list; | 1644 MapHandleList map_list; |
| 1670 map_list.Add(updated_map); | 1645 map_list.Add(updated_map); |
| 1671 Map* transitioned_map = map2->FindElementsKindTransitionedMap(&map_list); | 1646 Map* transitioned_map = map2->FindElementsKindTransitionedMap(&map_list); |
| 1672 CHECK_EQ(*updated_map, transitioned_map); | 1647 CHECK_EQ(*updated_map, transitioned_map); |
| 1673 } | 1648 } |
| 1674 } | 1649 } |
| 1675 | 1650 |
| 1676 // This test ensures that trivial representation/field type generalization | 1651 // This test ensures that trivial field generalization (from HeapObject to |
| 1677 // (from HeapObject to HeapObject) is correctly propagated from one branch of | 1652 // HeapObject) is correctly propagated from one branch of transition tree |
| 1678 // transition tree (|map2|) to another (|map|). | 1653 // (|map2|) to another (|map|). |
| 1679 // | 1654 // |
| 1680 // + - p0 - p1 - p2A - p3 - p4: |map| | 1655 // + - p0 - p1 - p2A - p3 - p4: |map| |
| 1681 // | | 1656 // | |
| 1682 // ek | 1657 // ek |
| 1683 // | | 1658 // | |
| 1684 // {} - p0 - p1 - p2B - p3 - p4: |map2| | 1659 // {} - p0 - p1 - p2B - p3 - p4: |map2| |
| 1685 // | 1660 // |
| 1686 // where "p2A" and "p2B" differ only in the representation/field type. | 1661 // where "p2A" and "p2B" differ only in the representation/field type. |
| 1687 // | 1662 // |
| 1688 static void TestReconfigureElementsKind_GeneralizeRepresentationTrivial( | 1663 static void TestReconfigureElementsKind_GeneralizeFieldTrivial( |
| 1689 const CRFTData& from, const CRFTData& to, const CRFTData& expected, | 1664 const CRFTData& from, const CRFTData& to, const CRFTData& expected, |
| 1690 bool expected_field_type_dependency = true) { | 1665 bool expected_field_type_dependency = true) { |
| 1691 Isolate* isolate = CcTest::i_isolate(); | 1666 Isolate* isolate = CcTest::i_isolate(); |
| 1692 | 1667 |
| 1693 Expectations expectations(isolate, FAST_SMI_ELEMENTS); | 1668 Expectations expectations(isolate, FAST_SMI_ELEMENTS); |
| 1694 | 1669 |
| 1695 // Create a map, add required properties to it and initialize expectations. | 1670 // Create a map, add required properties to it and initialize expectations. |
| 1696 Handle<Map> initial_map = Map::Create(isolate, 0); | 1671 Handle<Map> initial_map = Map::Create(isolate, 0); |
| 1697 initial_map->set_elements_kind(FAST_SMI_ELEMENTS); | 1672 initial_map->set_elements_kind(FAST_SMI_ELEMENTS); |
| 1698 | 1673 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1761 // Ensure Map::FindElementsKindTransitionedMap() is able to find the | 1736 // Ensure Map::FindElementsKindTransitionedMap() is able to find the |
| 1762 // transitioned map. | 1737 // transitioned map. |
| 1763 { | 1738 { |
| 1764 MapHandleList map_list; | 1739 MapHandleList map_list; |
| 1765 map_list.Add(updated_map); | 1740 map_list.Add(updated_map); |
| 1766 Map* transitioned_map = map2->FindElementsKindTransitionedMap(&map_list); | 1741 Map* transitioned_map = map2->FindElementsKindTransitionedMap(&map_list); |
| 1767 CHECK_EQ(*updated_map, transitioned_map); | 1742 CHECK_EQ(*updated_map, transitioned_map); |
| 1768 } | 1743 } |
| 1769 } | 1744 } |
| 1770 | 1745 |
| 1771 TEST(ReconfigureElementsKind_GeneralizeRepresentationSmiToDouble) { | 1746 TEST(ReconfigureElementsKind_GeneralizeSmiFieldToDouble) { |
| 1772 CcTest::InitializeVM(); | 1747 CcTest::InitializeVM(); |
| 1773 v8::HandleScope scope(CcTest::isolate()); | 1748 v8::HandleScope scope(CcTest::isolate()); |
| 1774 Isolate* isolate = CcTest::i_isolate(); | 1749 Isolate* isolate = CcTest::i_isolate(); |
| 1775 Handle<FieldType> any_type = FieldType::Any(isolate); | 1750 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1776 | 1751 |
| 1777 TestReconfigureElementsKind_GeneralizeRepresentation( | 1752 TestReconfigureElementsKind_GeneralizeField( |
| 1778 {kMutable, Representation::Smi(), any_type}, | 1753 {kMutable, Representation::Smi(), any_type}, |
| 1779 {kMutable, Representation::Double(), any_type}, | 1754 {kMutable, Representation::Double(), any_type}, |
| 1780 {kMutable, Representation::Double(), any_type}); | 1755 {kMutable, Representation::Double(), any_type}); |
| 1781 } | 1756 } |
| 1782 | 1757 |
| 1783 TEST(ReconfigureElementsKind_GeneralizeRepresentationSmiToTagged) { | 1758 TEST(ReconfigureElementsKind_GeneralizeSmiFieldToTagged) { |
| 1784 CcTest::InitializeVM(); | 1759 CcTest::InitializeVM(); |
| 1785 v8::HandleScope scope(CcTest::isolate()); | 1760 v8::HandleScope scope(CcTest::isolate()); |
| 1786 Isolate* isolate = CcTest::i_isolate(); | 1761 Isolate* isolate = CcTest::i_isolate(); |
| 1787 Handle<FieldType> any_type = FieldType::Any(isolate); | 1762 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1788 Handle<FieldType> value_type = | 1763 Handle<FieldType> value_type = |
| 1789 FieldType::Class(Map::Create(isolate, 0), isolate); | 1764 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 1790 | 1765 |
| 1791 TestReconfigureElementsKind_GeneralizeRepresentation( | 1766 TestReconfigureElementsKind_GeneralizeField( |
| 1792 {kMutable, Representation::Smi(), any_type}, | 1767 {kMutable, Representation::Smi(), any_type}, |
| 1793 {kMutable, Representation::HeapObject(), value_type}, | 1768 {kMutable, Representation::HeapObject(), value_type}, |
| 1794 {kMutable, Representation::Tagged(), any_type}); | 1769 {kMutable, Representation::Tagged(), any_type}); |
| 1795 } | 1770 } |
| 1796 | 1771 |
| 1797 TEST(ReconfigureElementsKind_GeneralizeRepresentationDoubleToTagged) { | 1772 TEST(ReconfigureElementsKind_GeneralizeDoubleFieldToTagged) { |
| 1798 CcTest::InitializeVM(); | 1773 CcTest::InitializeVM(); |
| 1799 v8::HandleScope scope(CcTest::isolate()); | 1774 v8::HandleScope scope(CcTest::isolate()); |
| 1800 Isolate* isolate = CcTest::i_isolate(); | 1775 Isolate* isolate = CcTest::i_isolate(); |
| 1801 Handle<FieldType> any_type = FieldType::Any(isolate); | 1776 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1802 Handle<FieldType> value_type = | 1777 Handle<FieldType> value_type = |
| 1803 FieldType::Class(Map::Create(isolate, 0), isolate); | 1778 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 1804 | 1779 |
| 1805 TestReconfigureElementsKind_GeneralizeRepresentation( | 1780 TestReconfigureElementsKind_GeneralizeField( |
| 1806 {kMutable, Representation::Double(), any_type}, | 1781 {kMutable, Representation::Double(), any_type}, |
| 1807 {kMutable, Representation::HeapObject(), value_type}, | 1782 {kMutable, Representation::HeapObject(), value_type}, |
| 1808 {kMutable, Representation::Tagged(), any_type}); | 1783 {kMutable, Representation::Tagged(), any_type}); |
| 1809 } | 1784 } |
| 1810 | 1785 |
| 1811 TEST(ReconfigureElementsKind_GeneralizeRepresentationHeapObjToHeapObj) { | 1786 TEST(ReconfigureElementsKind_GeneralizeHeapObjFieldToHeapObj) { |
| 1812 CcTest::InitializeVM(); | 1787 CcTest::InitializeVM(); |
| 1813 v8::HandleScope scope(CcTest::isolate()); | 1788 v8::HandleScope scope(CcTest::isolate()); |
| 1814 Isolate* isolate = CcTest::i_isolate(); | 1789 Isolate* isolate = CcTest::i_isolate(); |
| 1815 Handle<FieldType> any_type = FieldType::Any(isolate); | 1790 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1816 | 1791 |
| 1817 Handle<FieldType> current_type = | 1792 Handle<FieldType> current_type = |
| 1818 FieldType::Class(Map::Create(isolate, 0), isolate); | 1793 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 1819 | 1794 |
| 1820 Handle<FieldType> new_type = | 1795 Handle<FieldType> new_type = |
| 1821 FieldType::Class(Map::Create(isolate, 0), isolate); | 1796 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 1822 | 1797 |
| 1823 Handle<FieldType> expected_type = any_type; | 1798 Handle<FieldType> expected_type = any_type; |
| 1824 | 1799 |
| 1825 TestReconfigureElementsKind_GeneralizeRepresentationTrivial( | 1800 TestReconfigureElementsKind_GeneralizeFieldTrivial( |
| 1826 {kMutable, Representation::HeapObject(), current_type}, | 1801 {kMutable, Representation::HeapObject(), current_type}, |
| 1827 {kMutable, Representation::HeapObject(), new_type}, | 1802 {kMutable, Representation::HeapObject(), new_type}, |
| 1828 {kMutable, Representation::HeapObject(), expected_type}); | 1803 {kMutable, Representation::HeapObject(), expected_type}); |
| 1829 current_type = expected_type; | 1804 current_type = expected_type; |
| 1830 | 1805 |
| 1831 new_type = FieldType::Class(Map::Create(isolate, 0), isolate); | 1806 new_type = FieldType::Class(Map::Create(isolate, 0), isolate); |
| 1832 | 1807 |
| 1833 TestReconfigureElementsKind_GeneralizeRepresentationTrivial( | 1808 TestReconfigureElementsKind_GeneralizeFieldTrivial( |
| 1834 {kMutable, Representation::HeapObject(), any_type}, | 1809 {kMutable, Representation::HeapObject(), any_type}, |
| 1835 {kMutable, Representation::HeapObject(), new_type}, | 1810 {kMutable, Representation::HeapObject(), new_type}, |
| 1836 {kMutable, Representation::HeapObject(), any_type}, false); | 1811 {kMutable, Representation::HeapObject(), any_type}, false); |
| 1837 } | 1812 } |
| 1838 | 1813 |
| 1839 TEST(ReconfigureElementsKind_GeneralizeRepresentationHeapObjectToTagged) { | 1814 TEST(ReconfigureElementsKind_GeneralizeHeapObjectFieldToTagged) { |
| 1840 CcTest::InitializeVM(); | 1815 CcTest::InitializeVM(); |
| 1841 v8::HandleScope scope(CcTest::isolate()); | 1816 v8::HandleScope scope(CcTest::isolate()); |
| 1842 Isolate* isolate = CcTest::i_isolate(); | 1817 Isolate* isolate = CcTest::i_isolate(); |
| 1843 Handle<FieldType> any_type = FieldType::Any(isolate); | 1818 Handle<FieldType> any_type = FieldType::Any(isolate); |
| 1844 Handle<FieldType> value_type = | 1819 Handle<FieldType> value_type = |
| 1845 FieldType::Class(Map::Create(isolate, 0), isolate); | 1820 FieldType::Class(Map::Create(isolate, 0), isolate); |
| 1846 | 1821 |
| 1847 TestReconfigureElementsKind_GeneralizeRepresentation( | 1822 TestReconfigureElementsKind_GeneralizeField( |
| 1848 {kMutable, Representation::HeapObject(), value_type}, | 1823 {kMutable, Representation::HeapObject(), value_type}, |
| 1849 {kMutable, Representation::Smi(), any_type}, | 1824 {kMutable, Representation::Smi(), any_type}, |
| 1850 {kMutable, Representation::Tagged(), any_type}); | 1825 {kMutable, Representation::Tagged(), any_type}); |
| 1851 } | 1826 } |
| 1852 | 1827 |
| 1853 //////////////////////////////////////////////////////////////////////////////// | 1828 //////////////////////////////////////////////////////////////////////////////// |
| 1854 // A set of tests checking split map deprecation. | 1829 // A set of tests checking split map deprecation. |
| 1855 // | 1830 // |
| 1856 | 1831 |
| 1857 TEST(ReconfigurePropertySplitMapTransitionsOverflow) { | 1832 TEST(ReconfigurePropertySplitMapTransitionsOverflow) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1925 } | 1900 } |
| 1926 CHECK(expectations.Check(*updated_map)); | 1901 CHECK(expectations.Check(*updated_map)); |
| 1927 } | 1902 } |
| 1928 | 1903 |
| 1929 | 1904 |
| 1930 //////////////////////////////////////////////////////////////////////////////// | 1905 //////////////////////////////////////////////////////////////////////////////// |
| 1931 // A set of tests involving special transitions (such as elements kind | 1906 // A set of tests involving special transitions (such as elements kind |
| 1932 // transition, observed transition or prototype transition). | 1907 // transition, observed transition or prototype transition). |
| 1933 // | 1908 // |
| 1934 | 1909 |
| 1935 // This test ensures that representation/field type generalization is correctly | 1910 // This test ensures that field generalization is correctly propagated from one |
| 1936 // propagated from one branch of transition tree (|map2|) to another (|map|). | 1911 // branch of transition tree (|map2|) to another (|map|). |
| 1937 // | 1912 // |
| 1938 // p4B: |map2| | 1913 // p4B: |map2| |
| 1939 // | | 1914 // | |
| 1940 // * - special transition | 1915 // * - special transition |
| 1941 // | | 1916 // | |
| 1942 // {} - p0 - p1 - p2A - p3 - p4A: |map| | 1917 // {} - p0 - p1 - p2A - p3 - p4A: |map| |
| 1943 // | 1918 // |
| 1944 // where "p4A" and "p4B" are exactly the same properties. | 1919 // where "p4A" and "p4B" are exactly the same properties. |
| 1945 // | 1920 // |
| 1946 // TODO(ishell): unify this test template with | 1921 // TODO(ishell): unify this test template with |
| 1947 // TestReconfigureDataFieldAttribute_GeneralizeRepresentation once | 1922 // TestReconfigureDataFieldAttribute_GeneralizeField once |
| 1948 // IS_PROTO_TRANS_ISSUE_FIXED and IS_NON_EQUIVALENT_TRANSITION_SUPPORTED are | 1923 // IS_PROTO_TRANS_ISSUE_FIXED and IS_NON_EQUIVALENT_TRANSITION_SUPPORTED are |
| 1949 // fixed. | 1924 // fixed. |
| 1950 template <typename TestConfig> | 1925 template <typename TestConfig> |
| 1951 static void TestGeneralizeRepresentationWithSpecialTransition( | 1926 static void TestGeneralizeFieldWithSpecialTransition(TestConfig& config, |
| 1952 TestConfig& config, const CRFTData& from, const CRFTData& to, | 1927 const CRFTData& from, |
| 1953 const CRFTData& expected) { | 1928 const CRFTData& to, |
| 1929 const CRFTData& expected) { |
| 1954 Isolate* isolate = CcTest::i_isolate(); | 1930 Isolate* isolate = CcTest::i_isolate(); |
| 1955 | 1931 |
| 1956 Expectations expectations(isolate); | 1932 Expectations expectations(isolate); |
| 1957 | 1933 |
| 1958 // Create a map, add required properties to it and initialize expectations. | 1934 // Create a map, add required properties to it and initialize expectations. |
| 1959 Handle<Map> initial_map = Map::Create(isolate, 0); | 1935 Handle<Map> initial_map = Map::Create(isolate, 0); |
| 1960 Handle<Map> map = initial_map; | 1936 Handle<Map> map = initial_map; |
| 1961 for (int i = 0; i < kPropCount; i++) { | 1937 for (int i = 0; i < kPropCount; i++) { |
| 1962 map = expectations.AddDataField(map, NONE, from.constness, | 1938 map = expectations.AddDataField(map, NONE, from.constness, |
| 1963 from.representation, from.type); | 1939 from.representation, from.type); |
| 1964 } | 1940 } |
| 1965 CHECK(!map->is_deprecated()); | 1941 CHECK(!map->is_deprecated()); |
| 1966 CHECK(map->is_stable()); | 1942 CHECK(map->is_stable()); |
| 1967 CHECK(expectations.Check(*map)); | 1943 CHECK(expectations.Check(*map)); |
| 1968 | 1944 |
| 1969 Expectations expectations2 = expectations; | 1945 Expectations expectations2 = expectations; |
| 1970 | 1946 |
| 1971 // Apply some special transition to |map|. | 1947 // Apply some special transition to |map|. |
| 1972 CHECK(map->owns_descriptors()); | 1948 CHECK(map->owns_descriptors()); |
| 1973 Handle<Map> map2 = config.Transition(map, expectations2); | 1949 Handle<Map> map2 = config.Transition(map, expectations2); |
| 1974 | 1950 |
| 1975 // |map| should still match expectations. | 1951 // |map| should still match expectations. |
| 1976 CHECK(!map->is_deprecated()); | 1952 CHECK(!map->is_deprecated()); |
| 1977 CHECK(expectations.Check(*map)); | 1953 CHECK(expectations.Check(*map)); |
| 1978 | 1954 |
| 1979 if (config.generalizes_representations()) { | 1955 if (config.generalizes_representations()) { |
| 1980 for (int i = 0; i < kPropCount; i++) { | 1956 for (int i = 0; i < kPropCount; i++) { |
| 1981 expectations2.GeneralizeRepresentation(i); | 1957 expectations2.GeneralizeField(i); |
| 1982 } | 1958 } |
| 1983 } | 1959 } |
| 1984 | 1960 |
| 1985 CHECK(!map2->is_deprecated()); | 1961 CHECK(!map2->is_deprecated()); |
| 1986 CHECK(map2->is_stable()); | 1962 CHECK(map2->is_stable()); |
| 1987 CHECK(expectations2.Check(*map2)); | 1963 CHECK(expectations2.Check(*map2)); |
| 1988 | 1964 |
| 1989 // Create new maps by generalizing representation of propX field. | 1965 // Create new maps by generalizing representation of propX field. |
| 1990 Handle<Map> maps[kPropCount]; | 1966 Handle<Map> maps[kPropCount]; |
| 1991 for (int i = 0; i < kPropCount; i++) { | 1967 for (int i = 0; i < kPropCount; i++) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2009 if (Map::TryUpdate(map2).ToHandle(&tmp_map)) { | 1985 if (Map::TryUpdate(map2).ToHandle(&tmp_map)) { |
| 2010 // If Map::TryUpdate() manages to succeed the result must match the result | 1986 // If Map::TryUpdate() manages to succeed the result must match the result |
| 2011 // of Map::Update(). | 1987 // of Map::Update(). |
| 2012 CHECK_EQ(*new_map2, *tmp_map); | 1988 CHECK_EQ(*new_map2, *tmp_map); |
| 2013 } | 1989 } |
| 2014 | 1990 |
| 2015 if (config.is_non_equevalent_transition()) { | 1991 if (config.is_non_equevalent_transition()) { |
| 2016 // In case of non-equivalent transition currently we generalize all | 1992 // In case of non-equivalent transition currently we generalize all |
| 2017 // representations. | 1993 // representations. |
| 2018 for (int i = 0; i < kPropCount; i++) { | 1994 for (int i = 0; i < kPropCount; i++) { |
| 2019 expectations2.GeneralizeRepresentation(i); | 1995 expectations2.GeneralizeField(i); |
| 2020 } | 1996 } |
| 2021 CHECK(new_map2->GetBackPointer()->IsUndefined(isolate)); | 1997 CHECK(new_map2->GetBackPointer()->IsUndefined(isolate)); |
| 2022 CHECK(expectations2.Check(*new_map2)); | 1998 CHECK(expectations2.Check(*new_map2)); |
| 2023 } else { | 1999 } else { |
| 2024 CHECK(!new_map2->GetBackPointer()->IsUndefined(isolate)); | 2000 CHECK(!new_map2->GetBackPointer()->IsUndefined(isolate)); |
| 2025 CHECK(expectations2.Check(*new_map2)); | 2001 CHECK(expectations2.Check(*new_map2)); |
| 2026 } | 2002 } |
| 2027 } | 2003 } |
| 2028 | 2004 |
| 2029 Handle<Map> active_map = maps[kPropCount - 1]; | 2005 Handle<Map> active_map = maps[kPropCount - 1]; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2052 Handle<Symbol> frozen_symbol(map->GetHeap()->frozen_symbol()); | 2028 Handle<Symbol> frozen_symbol(map->GetHeap()->frozen_symbol()); |
| 2053 expectations.SetElementsKind(DICTIONARY_ELEMENTS); | 2029 expectations.SetElementsKind(DICTIONARY_ELEMENTS); |
| 2054 return Map::CopyForPreventExtensions(map, NONE, frozen_symbol, | 2030 return Map::CopyForPreventExtensions(map, NONE, frozen_symbol, |
| 2055 "CopyForPreventExtensions"); | 2031 "CopyForPreventExtensions"); |
| 2056 } | 2032 } |
| 2057 // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. | 2033 // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. |
| 2058 bool generalizes_representations() const { return false; } | 2034 bool generalizes_representations() const { return false; } |
| 2059 bool is_non_equevalent_transition() const { return true; } | 2035 bool is_non_equevalent_transition() const { return true; } |
| 2060 }; | 2036 }; |
| 2061 TestConfig config; | 2037 TestConfig config; |
| 2062 TestGeneralizeRepresentationWithSpecialTransition( | 2038 TestGeneralizeFieldWithSpecialTransition( |
| 2063 config, {kMutable, Representation::Smi(), any_type}, | 2039 config, {kMutable, Representation::Smi(), any_type}, |
| 2064 {kMutable, Representation::HeapObject(), value_type}, | 2040 {kMutable, Representation::HeapObject(), value_type}, |
| 2065 {kMutable, Representation::Tagged(), any_type}); | 2041 {kMutable, Representation::Tagged(), any_type}); |
| 2066 } | 2042 } |
| 2067 | 2043 |
| 2068 | 2044 |
| 2069 TEST(ElementsKindTransitionFromMapNotOwningDescriptor) { | 2045 TEST(ElementsKindTransitionFromMapNotOwningDescriptor) { |
| 2070 CcTest::InitializeVM(); | 2046 CcTest::InitializeVM(); |
| 2071 v8::HandleScope scope(CcTest::isolate()); | 2047 v8::HandleScope scope(CcTest::isolate()); |
| 2072 Isolate* isolate = CcTest::i_isolate(); | 2048 Isolate* isolate = CcTest::i_isolate(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2090 Handle<Symbol> frozen_symbol(map->GetHeap()->frozen_symbol()); | 2066 Handle<Symbol> frozen_symbol(map->GetHeap()->frozen_symbol()); |
| 2091 expectations.SetElementsKind(DICTIONARY_ELEMENTS); | 2067 expectations.SetElementsKind(DICTIONARY_ELEMENTS); |
| 2092 return Map::CopyForPreventExtensions(map, NONE, frozen_symbol, | 2068 return Map::CopyForPreventExtensions(map, NONE, frozen_symbol, |
| 2093 "CopyForPreventExtensions"); | 2069 "CopyForPreventExtensions"); |
| 2094 } | 2070 } |
| 2095 // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. | 2071 // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. |
| 2096 bool generalizes_representations() const { return false; } | 2072 bool generalizes_representations() const { return false; } |
| 2097 bool is_non_equevalent_transition() const { return true; } | 2073 bool is_non_equevalent_transition() const { return true; } |
| 2098 }; | 2074 }; |
| 2099 TestConfig config; | 2075 TestConfig config; |
| 2100 TestGeneralizeRepresentationWithSpecialTransition( | 2076 TestGeneralizeFieldWithSpecialTransition( |
| 2101 config, {kMutable, Representation::Smi(), any_type}, | 2077 config, {kMutable, Representation::Smi(), any_type}, |
| 2102 {kMutable, Representation::HeapObject(), value_type}, | 2078 {kMutable, Representation::HeapObject(), value_type}, |
| 2103 {kMutable, Representation::Tagged(), any_type}); | 2079 {kMutable, Representation::Tagged(), any_type}); |
| 2104 } | 2080 } |
| 2105 | 2081 |
| 2106 | 2082 |
| 2107 TEST(PrototypeTransitionFromMapOwningDescriptor) { | 2083 TEST(PrototypeTransitionFromMapOwningDescriptor) { |
| 2108 CcTest::InitializeVM(); | 2084 CcTest::InitializeVM(); |
| 2109 v8::HandleScope scope(CcTest::isolate()); | 2085 v8::HandleScope scope(CcTest::isolate()); |
| 2110 Isolate* isolate = CcTest::i_isolate(); | 2086 Isolate* isolate = CcTest::i_isolate(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2125 Handle<Map> Transition(Handle<Map> map, Expectations& expectations) { | 2101 Handle<Map> Transition(Handle<Map> map, Expectations& expectations) { |
| 2126 return Map::TransitionToPrototype(map, prototype_, REGULAR_PROTOTYPE); | 2102 return Map::TransitionToPrototype(map, prototype_, REGULAR_PROTOTYPE); |
| 2127 } | 2103 } |
| 2128 // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. | 2104 // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. |
| 2129 bool generalizes_representations() const { | 2105 bool generalizes_representations() const { |
| 2130 return !IS_PROTO_TRANS_ISSUE_FIXED; | 2106 return !IS_PROTO_TRANS_ISSUE_FIXED; |
| 2131 } | 2107 } |
| 2132 bool is_non_equevalent_transition() const { return true; } | 2108 bool is_non_equevalent_transition() const { return true; } |
| 2133 }; | 2109 }; |
| 2134 TestConfig config; | 2110 TestConfig config; |
| 2135 TestGeneralizeRepresentationWithSpecialTransition( | 2111 TestGeneralizeFieldWithSpecialTransition( |
| 2136 config, {kMutable, Representation::Smi(), any_type}, | 2112 config, {kMutable, Representation::Smi(), any_type}, |
| 2137 {kMutable, Representation::HeapObject(), value_type}, | 2113 {kMutable, Representation::HeapObject(), value_type}, |
| 2138 {kMutable, Representation::Tagged(), any_type}); | 2114 {kMutable, Representation::Tagged(), any_type}); |
| 2139 } | 2115 } |
| 2140 | 2116 |
| 2141 | 2117 |
| 2142 TEST(PrototypeTransitionFromMapNotOwningDescriptor) { | 2118 TEST(PrototypeTransitionFromMapNotOwningDescriptor) { |
| 2143 CcTest::InitializeVM(); | 2119 CcTest::InitializeVM(); |
| 2144 v8::HandleScope scope(CcTest::isolate()); | 2120 v8::HandleScope scope(CcTest::isolate()); |
| 2145 Isolate* isolate = CcTest::i_isolate(); | 2121 Isolate* isolate = CcTest::i_isolate(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2171 | 2147 |
| 2172 return Map::TransitionToPrototype(map, prototype_, REGULAR_PROTOTYPE); | 2148 return Map::TransitionToPrototype(map, prototype_, REGULAR_PROTOTYPE); |
| 2173 } | 2149 } |
| 2174 // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. | 2150 // TODO(ishell): remove once IS_PROTO_TRANS_ISSUE_FIXED is removed. |
| 2175 bool generalizes_representations() const { | 2151 bool generalizes_representations() const { |
| 2176 return !IS_PROTO_TRANS_ISSUE_FIXED; | 2152 return !IS_PROTO_TRANS_ISSUE_FIXED; |
| 2177 } | 2153 } |
| 2178 bool is_non_equevalent_transition() const { return true; } | 2154 bool is_non_equevalent_transition() const { return true; } |
| 2179 }; | 2155 }; |
| 2180 TestConfig config; | 2156 TestConfig config; |
| 2181 TestGeneralizeRepresentationWithSpecialTransition( | 2157 TestGeneralizeFieldWithSpecialTransition( |
| 2182 config, {kMutable, Representation::Smi(), any_type}, | 2158 config, {kMutable, Representation::Smi(), any_type}, |
| 2183 {kMutable, Representation::HeapObject(), value_type}, | 2159 {kMutable, Representation::HeapObject(), value_type}, |
| 2184 {kMutable, Representation::Tagged(), any_type}); | 2160 {kMutable, Representation::Tagged(), any_type}); |
| 2185 } | 2161 } |
| 2186 | 2162 |
| 2187 | 2163 |
| 2188 //////////////////////////////////////////////////////////////////////////////// | 2164 //////////////////////////////////////////////////////////////////////////////// |
| 2189 // A set of tests for higher level transitioning mechanics. | 2165 // A set of tests for higher level transitioning mechanics. |
| 2190 // | 2166 // |
| 2191 | 2167 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2274 PropertyAttributes attributes = NONE) | 2250 PropertyAttributes attributes = NONE) |
| 2275 : descriptor_(descriptor), attributes_(attributes) {} | 2251 : descriptor_(descriptor), attributes_(attributes) {} |
| 2276 | 2252 |
| 2277 Handle<Map> DoTransition(Expectations& expectations, Handle<Map> map) { | 2253 Handle<Map> DoTransition(Expectations& expectations, Handle<Map> map) { |
| 2278 expectations.SetAccessorField(descriptor_); | 2254 expectations.SetAccessorField(descriptor_); |
| 2279 return Map::ReconfigureExistingProperty(map, descriptor_, kAccessor, | 2255 return Map::ReconfigureExistingProperty(map, descriptor_, kAccessor, |
| 2280 attributes_); | 2256 attributes_); |
| 2281 } | 2257 } |
| 2282 }; | 2258 }; |
| 2283 | 2259 |
| 2284 | 2260 // Checks that field generalization happened. |
| 2285 // Checks that representation/field type generalization happened. | |
| 2286 struct FieldGeneralizationChecker { | 2261 struct FieldGeneralizationChecker { |
| 2287 int descriptor_; | 2262 int descriptor_; |
| 2288 PropertyConstness constness_; | 2263 PropertyConstness constness_; |
| 2289 Representation representation_; | 2264 Representation representation_; |
| 2290 PropertyAttributes attributes_; | 2265 PropertyAttributes attributes_; |
| 2291 Handle<FieldType> heap_type_; | 2266 Handle<FieldType> heap_type_; |
| 2292 | 2267 |
| 2293 FieldGeneralizationChecker(int descriptor, PropertyConstness constness, | 2268 FieldGeneralizationChecker(int descriptor, PropertyConstness constness, |
| 2294 Representation representation, | 2269 Representation representation, |
| 2295 Handle<FieldType> heap_type, | 2270 Handle<FieldType> heap_type, |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2479 Isolate* isolate = CcTest::i_isolate(); | 2454 Isolate* isolate = CcTest::i_isolate(); |
| 2480 | 2455 |
| 2481 Zone zone(isolate->allocator(), ZONE_NAME); | 2456 Zone zone(isolate->allocator(), ZONE_NAME); |
| 2482 | 2457 |
| 2483 CHECK_EQ(FieldType::Any()->Convert(&zone), AstType::NonInternal()); | 2458 CHECK_EQ(FieldType::Any()->Convert(&zone), AstType::NonInternal()); |
| 2484 CHECK_EQ(FieldType::None()->Convert(&zone), AstType::None()); | 2459 CHECK_EQ(FieldType::None()->Convert(&zone), AstType::None()); |
| 2485 } | 2460 } |
| 2486 | 2461 |
| 2487 // TODO(ishell): add this test once IS_ACCESSOR_FIELD_SUPPORTED is supported. | 2462 // TODO(ishell): add this test once IS_ACCESSOR_FIELD_SUPPORTED is supported. |
| 2488 // TEST(TransitionAccessorConstantToAnotherAccessorConstant) | 2463 // TEST(TransitionAccessorConstantToAnotherAccessorConstant) |
| OLD | NEW |