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 "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 case ACCESSOR_CONSTANT: | 138 case ACCESSOR_CONSTANT: |
139 os << "immutable "; | 139 os << "immutable "; |
140 // Fall through. | 140 // Fall through. |
141 case ACCESSOR: | 141 case ACCESSOR: |
142 os << "accessor"; | 142 os << "accessor"; |
143 break; | 143 break; |
144 } | 144 } |
145 os << ": " << representations_[i].Mnemonic(); | 145 os << ": " << representations_[i].Mnemonic(); |
146 os << ", attrs: " << attributes_[i] << ")\n"; | 146 os << ", attrs: " << attributes_[i] << ")\n"; |
147 } | 147 } |
| 148 os << "\n"; |
148 } | 149 } |
149 | 150 |
150 Handle<HeapType> GetFieldType(int index) { | 151 Handle<HeapType> GetFieldType(int index) { |
151 CHECK(index < MAX_PROPERTIES); | 152 CHECK(index < MAX_PROPERTIES); |
152 CHECK(types_[index] == DATA || types_[index] == ACCESSOR); | 153 CHECK(types_[index] == DATA || types_[index] == ACCESSOR); |
153 return Handle<HeapType>::cast(values_[index]); | 154 return Handle<HeapType>::cast(values_[index]); |
154 } | 155 } |
155 | 156 |
156 void SetDataField(int index, PropertyAttributes attrs, | 157 void SetDataField(int index, PropertyAttributes attrs, |
157 Representation representation, Handle<HeapType> value) { | 158 Representation representation, Handle<HeapType> value) { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 bool Check(Map* map, int expected_nof) const { | 257 bool Check(Map* map, int expected_nof) const { |
257 CHECK(number_of_properties_ <= MAX_PROPERTIES); | 258 CHECK(number_of_properties_ <= MAX_PROPERTIES); |
258 CHECK_EQ(expected_nof, map->NumberOfOwnDescriptors()); | 259 CHECK_EQ(expected_nof, map->NumberOfOwnDescriptors()); |
259 CHECK(!map->is_dictionary_map()); | 260 CHECK(!map->is_dictionary_map()); |
260 | 261 |
261 DescriptorArray* descriptors = map->instance_descriptors(); | 262 DescriptorArray* descriptors = map->instance_descriptors(); |
262 CHECK(expected_nof <= number_of_properties_); | 263 CHECK(expected_nof <= number_of_properties_); |
263 for (int i = 0; i < expected_nof; i++) { | 264 for (int i = 0; i < expected_nof; i++) { |
264 if (!Check(descriptors, i)) { | 265 if (!Check(descriptors, i)) { |
265 Print(); | 266 Print(); |
| 267 #ifdef OBJECT_PRINT |
| 268 descriptors->Print(); |
| 269 #endif |
266 Check(descriptors, i); | 270 Check(descriptors, i); |
267 return false; | 271 return false; |
268 } | 272 } |
269 } | 273 } |
270 return true; | 274 return true; |
271 } | 275 } |
272 | 276 |
273 bool Check(Map* map) const { return Check(map, number_of_properties_); } | 277 bool Check(Map* map) const { return Check(map, number_of_properties_); } |
274 | 278 |
275 | 279 |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 Object* the_value = obj->RawFastPropertyAt(index); | 514 Object* the_value = obj->RawFastPropertyAt(index); |
511 CHECK(the_value->IsSmi()); | 515 CHECK(the_value->IsSmi()); |
512 CHECK_EQ(42, Smi::cast(the_value)->value()); | 516 CHECK_EQ(42, Smi::cast(the_value)->value()); |
513 } | 517 } |
514 | 518 |
515 | 519 |
516 //////////////////////////////////////////////////////////////////////////////// | 520 //////////////////////////////////////////////////////////////////////////////// |
517 // A set of tests for representation generalization case. | 521 // A set of tests for representation generalization case. |
518 // | 522 // |
519 | 523 |
520 static void TestGeneralizeRepresentation(Representation from_representation, | 524 // This test ensures that representation/field type generalization at |
521 Handle<HeapType> from_type, | 525 // |property_index| is done correctly independently of the fact that the |map| |
522 Representation to_representation, | 526 // is detached from transition tree or not. |
523 Handle<HeapType> to_type, | 527 // |
524 Representation expected_representation, | 528 // {} - p0 - p1 - p2: |detach_point_map| |
525 Handle<HeapType> expected_type) { | 529 // | |
| 530 // X - detached at |detach_property_at_index| |
| 531 // | |
| 532 // + - p3 - p4: |map| |
| 533 // |
| 534 // Detaching does not happen if |detach_property_at_index| is -1. |
| 535 // |
| 536 static void TestGeneralizeRepresentation( |
| 537 int detach_property_at_index, int property_index, |
| 538 Representation from_representation, Handle<HeapType> from_type, |
| 539 Representation to_representation, Handle<HeapType> to_type, |
| 540 Representation expected_representation, Handle<HeapType> expected_type, |
| 541 bool expected_deprecation, bool expected_field_type_dependency) { |
526 Isolate* isolate = CcTest::i_isolate(); | 542 Isolate* isolate = CcTest::i_isolate(); |
| 543 Handle<HeapType> any_type = HeapType::Any(isolate); |
| 544 |
| 545 CHECK(detach_property_at_index >= -1 && |
| 546 detach_property_at_index < kPropCount); |
| 547 CHECK(property_index < kPropCount); |
| 548 CHECK_NE(detach_property_at_index, property_index); |
| 549 |
| 550 const bool is_detached_map = detach_property_at_index >= 0; |
527 | 551 |
528 Expectations expectations(isolate); | 552 Expectations expectations(isolate); |
529 | 553 |
530 // Create a map, add required properties to it and initialize expectations. | 554 // Create a map, add required properties to it and initialize expectations. |
531 Handle<Map> initial_map = Map::Create(isolate, 0); | 555 Handle<Map> initial_map = Map::Create(isolate, 0); |
532 Handle<Map> map = initial_map; | 556 Handle<Map> map = initial_map; |
| 557 Handle<Map> detach_point_map; |
533 for (int i = 0; i < kPropCount; i++) { | 558 for (int i = 0; i < kPropCount; i++) { |
534 map = expectations.AddDataField(map, NONE, from_representation, from_type); | 559 if (i == property_index) { |
| 560 map = |
| 561 expectations.AddDataField(map, NONE, from_representation, from_type); |
| 562 } else { |
| 563 map = |
| 564 expectations.AddDataField(map, NONE, Representation::Smi(), any_type); |
| 565 if (i == detach_property_at_index) { |
| 566 detach_point_map = map; |
| 567 } |
| 568 } |
535 } | 569 } |
536 CHECK(!map->is_deprecated()); | 570 CHECK(!map->is_deprecated()); |
537 CHECK(map->is_stable()); | 571 CHECK(map->is_stable()); |
538 CHECK(expectations.Check(*map)); | 572 CHECK(expectations.Check(*map)); |
539 | 573 |
540 Zone zone; | 574 Zone zone; |
541 FakeStubForTesting stub(isolate); | 575 FakeStubForTesting stub(isolate); |
542 | 576 |
| 577 if (is_detached_map) { |
| 578 detach_point_map = Map::ReconfigureProperty( |
| 579 detach_point_map, detach_property_at_index, kData, NONE, |
| 580 Representation::Tagged(), any_type, FORCE_FIELD); |
| 581 expectations.SetDataField(detach_property_at_index, |
| 582 Representation::Tagged(), any_type); |
| 583 CHECK(map->is_deprecated()); |
| 584 CHECK(expectations.Check(*detach_point_map, |
| 585 detach_point_map->NumberOfOwnDescriptors())); |
| 586 } |
| 587 |
543 // Create new maps by generalizing representation of propX field. | 588 // Create new maps by generalizing representation of propX field. |
544 Handle<Map> maps[kPropCount]; | 589 Handle<Map> field_owner(map->FindFieldOwner(property_index), isolate); |
545 for (int i = 0; i < kPropCount; i++) { | 590 CompilationInfo info(&stub, isolate, &zone); |
546 Handle<Map> field_owner(map->FindFieldOwner(i), isolate); | 591 CHECK(!info.HasAbortedDueToDependencyChange()); |
547 CompilationInfo info(&stub, isolate, &zone); | 592 |
| 593 Map::AddDependentCompilationInfo(field_owner, DependentCode::kFieldTypeGroup, |
| 594 &info); |
| 595 |
| 596 Handle<Map> new_map = |
| 597 Map::ReconfigureProperty(map, property_index, kData, NONE, |
| 598 to_representation, to_type, FORCE_FIELD); |
| 599 |
| 600 expectations.SetDataField(property_index, expected_representation, |
| 601 expected_type); |
| 602 |
| 603 CHECK(!new_map->is_deprecated()); |
| 604 CHECK(expectations.Check(*new_map)); |
| 605 |
| 606 if (is_detached_map) { |
| 607 CHECK(map->is_deprecated()); |
| 608 CHECK_NE(*map, *new_map); |
| 609 CHECK_EQ(expected_field_type_dependency && !field_owner->is_deprecated(), |
| 610 info.HasAbortedDueToDependencyChange()); |
| 611 |
| 612 } else if (expected_deprecation) { |
| 613 CHECK(map->is_deprecated()); |
| 614 CHECK(field_owner->is_deprecated()); |
| 615 CHECK_NE(*map, *new_map); |
548 CHECK(!info.HasAbortedDueToDependencyChange()); | 616 CHECK(!info.HasAbortedDueToDependencyChange()); |
549 | 617 |
550 Map::AddDependentCompilationInfo(field_owner, | 618 } else { |
551 DependentCode::kFieldTypeGroup, &info); | 619 CHECK(!field_owner->is_deprecated()); |
| 620 CHECK_EQ(*map, *new_map); |
552 | 621 |
553 Handle<Map> new_map = Map::ReconfigureProperty( | 622 CHECK_EQ(expected_field_type_dependency, |
554 map, i, kData, NONE, to_representation, to_type, FORCE_FIELD); | 623 info.HasAbortedDueToDependencyChange()); |
555 maps[i] = new_map; | |
556 | |
557 expectations.SetDataField(i, expected_representation, expected_type); | |
558 | |
559 CHECK(map->is_deprecated()); | |
560 CHECK(!info.HasAbortedDueToDependencyChange()); | |
561 info.RollbackDependencies(); // Properly cleanup compilation info. | |
562 | |
563 CHECK_NE(*map, *new_map); | |
564 CHECK(i == 0 || maps[i - 1]->is_deprecated()); | |
565 | |
566 CHECK(!new_map->is_deprecated()); | |
567 CHECK(!new_map->is_dictionary_map()); | |
568 CHECK(expectations.Check(*new_map)); | |
569 } | 624 } |
570 | 625 |
571 Handle<Map> active_map = maps[kPropCount - 1]; | 626 info.RollbackDependencies(); // Properly cleanup compilation info. |
572 CHECK(!active_map->is_deprecated()); | |
573 | 627 |
574 // Update all deprecated maps and check that they are now the same. | 628 // Update all deprecated maps and check that they are now the same. |
575 Handle<Map> updated_map = Map::Update(map); | 629 Handle<Map> updated_map = Map::Update(map); |
576 CHECK_EQ(*active_map, *updated_map); | 630 CHECK_EQ(*new_map, *updated_map); |
577 for (int i = 0; i < kPropCount; i++) { | 631 } |
578 updated_map = Map::Update(maps[i]); | 632 |
579 CHECK_EQ(*active_map, *updated_map); | 633 |
| 634 static void TestGeneralizeRepresentation( |
| 635 Representation from_representation, Handle<HeapType> from_type, |
| 636 Representation to_representation, Handle<HeapType> to_type, |
| 637 Representation expected_representation, Handle<HeapType> expected_type, |
| 638 bool expected_deprecation, bool expected_field_type_dependency) { |
| 639 // Check the cases when the map being reconfigured is a part of the |
| 640 // transition tree. |
| 641 STATIC_ASSERT(kPropCount > 4); |
| 642 int indices[] = {0, 2, kPropCount - 1}; |
| 643 for (int i = 0; i < static_cast<int>(arraysize(indices)); i++) { |
| 644 TestGeneralizeRepresentation( |
| 645 -1, indices[i], from_representation, from_type, to_representation, |
| 646 to_type, expected_representation, expected_type, expected_deprecation, |
| 647 expected_field_type_dependency); |
580 } | 648 } |
| 649 |
| 650 if (!from_representation.IsNone()) { |
| 651 // Check the cases when the map being reconfigured is NOT a part of the |
| 652 // transition tree. "None -> anything" representation changes make sense |
| 653 // only for "attached" maps. |
| 654 int indices[] = {0, kPropCount - 1}; |
| 655 for (int i = 0; i < static_cast<int>(arraysize(indices)); i++) { |
| 656 TestGeneralizeRepresentation( |
| 657 indices[i], 2, from_representation, from_type, to_representation, |
| 658 to_type, expected_representation, expected_type, expected_deprecation, |
| 659 expected_field_type_dependency); |
| 660 } |
| 661 } |
| 662 } |
| 663 |
| 664 |
| 665 static void TestGeneralizeRepresentation(Representation from_representation, |
| 666 Handle<HeapType> from_type, |
| 667 Representation to_representation, |
| 668 Handle<HeapType> to_type, |
| 669 Representation expected_representation, |
| 670 Handle<HeapType> expected_type) { |
| 671 const bool expected_deprecation = true; |
| 672 const bool expected_field_type_dependency = false; |
| 673 |
| 674 TestGeneralizeRepresentation( |
| 675 from_representation, from_type, to_representation, to_type, |
| 676 expected_representation, expected_type, expected_deprecation, |
| 677 expected_field_type_dependency); |
581 } | 678 } |
582 | 679 |
583 | 680 |
584 static void TestGeneralizeRepresentationTrivial( | 681 static void TestGeneralizeRepresentationTrivial( |
585 Representation from_representation, Handle<HeapType> from_type, | 682 Representation from_representation, Handle<HeapType> from_type, |
586 Representation to_representation, Handle<HeapType> to_type, | 683 Representation to_representation, Handle<HeapType> to_type, |
587 Representation expected_representation, Handle<HeapType> expected_type, | 684 Representation expected_representation, Handle<HeapType> expected_type, |
588 bool expected_field_type_dependency = true) { | 685 bool expected_field_type_dependency = true) { |
589 Isolate* isolate = CcTest::i_isolate(); | 686 const bool expected_deprecation = false; |
590 | 687 |
591 Expectations expectations(isolate); | 688 TestGeneralizeRepresentation( |
592 | 689 from_representation, from_type, to_representation, to_type, |
593 // Create a map, add required properties to it and initialize expectations. | 690 expected_representation, expected_type, expected_deprecation, |
594 Handle<Map> initial_map = Map::Create(isolate, 0); | 691 expected_field_type_dependency); |
595 Handle<Map> map = initial_map; | |
596 for (int i = 0; i < kPropCount; i++) { | |
597 map = expectations.AddDataField(map, NONE, from_representation, from_type); | |
598 } | |
599 CHECK(!map->is_deprecated()); | |
600 CHECK(map->is_stable()); | |
601 CHECK(expectations.Check(*map)); | |
602 | |
603 Zone zone; | |
604 FakeStubForTesting stub(isolate); | |
605 | |
606 // Create new maps by generalizing representation of propX field. | |
607 for (int i = 0; i < kPropCount; i++) { | |
608 Handle<Map> field_owner(map->FindFieldOwner(i), isolate); | |
609 CompilationInfo info(&stub, isolate, &zone); | |
610 CHECK(!info.HasAbortedDueToDependencyChange()); | |
611 | |
612 Map::AddDependentCompilationInfo(field_owner, | |
613 DependentCode::kFieldTypeGroup, &info); | |
614 | |
615 Handle<Map> new_map = Map::ReconfigureProperty( | |
616 map, i, kData, NONE, to_representation, to_type, FORCE_FIELD); | |
617 | |
618 expectations.SetDataField(i, expected_representation, expected_type); | |
619 | |
620 CHECK_EQ(*map, *new_map); | |
621 CHECK_EQ(expected_field_type_dependency, | |
622 info.HasAbortedDueToDependencyChange()); | |
623 | |
624 info.RollbackDependencies(); // Properly cleanup compilation info. | |
625 | |
626 CHECK_EQ(*map, *new_map); | |
627 CHECK(!new_map->is_deprecated()); | |
628 CHECK(!new_map->is_dictionary_map()); | |
629 CHECK(expectations.Check(*new_map)); | |
630 } | |
631 | |
632 Handle<Map> updated_map = Map::Update(map); | |
633 CHECK_EQ(*map, *updated_map); | |
634 } | 692 } |
635 | 693 |
636 | 694 |
637 TEST(GeneralizeRepresentationSmiToDouble) { | 695 TEST(GeneralizeRepresentationSmiToDouble) { |
638 CcTest::InitializeVM(); | 696 CcTest::InitializeVM(); |
639 v8::HandleScope scope(CcTest::isolate()); | 697 v8::HandleScope scope(CcTest::isolate()); |
640 Isolate* isolate = CcTest::i_isolate(); | 698 Isolate* isolate = CcTest::i_isolate(); |
641 Handle<HeapType> any_type = HeapType::Any(isolate); | 699 Handle<HeapType> any_type = HeapType::Any(isolate); |
642 | 700 |
643 TestGeneralizeRepresentation(Representation::Smi(), any_type, | 701 TestGeneralizeRepresentation(Representation::Smi(), any_type, |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 map, i, kData, NONE, Representation::Double(), any_type, FORCE_FIELD); | 879 map, i, kData, NONE, Representation::Double(), any_type, FORCE_FIELD); |
822 maps[i] = new_map; | 880 maps[i] = new_map; |
823 | 881 |
824 expectations.SetDataField(i, Representation::Double(), any_type); | 882 expectations.SetDataField(i, Representation::Double(), any_type); |
825 | 883 |
826 CHECK(map->is_deprecated()); | 884 CHECK(map->is_deprecated()); |
827 CHECK_NE(*map, *new_map); | 885 CHECK_NE(*map, *new_map); |
828 CHECK(i == 0 || maps[i - 1]->is_deprecated()); | 886 CHECK(i == 0 || maps[i - 1]->is_deprecated()); |
829 | 887 |
830 CHECK(!new_map->is_deprecated()); | 888 CHECK(!new_map->is_deprecated()); |
831 CHECK(!new_map->is_dictionary_map()); | |
832 CHECK(expectations.Check(*new_map)); | 889 CHECK(expectations.Check(*new_map)); |
833 } | 890 } |
834 | 891 |
835 Handle<Map> active_map = maps[kPropCount - 1]; | 892 Handle<Map> active_map = maps[kPropCount - 1]; |
836 CHECK(!active_map->is_deprecated()); | 893 CHECK(!active_map->is_deprecated()); |
837 | 894 |
838 // Update all deprecated maps and check that they are now the same. | 895 // Update all deprecated maps and check that they are now the same. |
839 Handle<Map> updated_map = Map::Update(map); | 896 Handle<Map> updated_map = Map::Update(map); |
840 CHECK_EQ(*active_map, *updated_map); | 897 CHECK_EQ(*active_map, *updated_map); |
841 for (int i = 0; i < kPropCount; i++) { | 898 for (int i = 0; i < kPropCount; i++) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 // |map| should be deprecated and |new_map| should match new expectations. | 975 // |map| should be deprecated and |new_map| should match new expectations. |
919 for (int i = kSplitProp; i < kPropCount; i++) { | 976 for (int i = kSplitProp; i < kPropCount; i++) { |
920 expectations.SetDataField(i, expected_representation, expected_type); | 977 expectations.SetDataField(i, expected_representation, expected_type); |
921 } | 978 } |
922 CHECK(map->is_deprecated()); | 979 CHECK(map->is_deprecated()); |
923 CHECK(!info.HasAbortedDueToDependencyChange()); | 980 CHECK(!info.HasAbortedDueToDependencyChange()); |
924 info.RollbackDependencies(); // Properly cleanup compilation info. | 981 info.RollbackDependencies(); // Properly cleanup compilation info. |
925 CHECK_NE(*map, *new_map); | 982 CHECK_NE(*map, *new_map); |
926 | 983 |
927 CHECK(!new_map->is_deprecated()); | 984 CHECK(!new_map->is_deprecated()); |
928 CHECK(!new_map->is_dictionary_map()); | |
929 CHECK(expectations.Check(*new_map)); | 985 CHECK(expectations.Check(*new_map)); |
930 | 986 |
931 // Update deprecated |map|, it should become |new_map|. | 987 // Update deprecated |map|, it should become |new_map|. |
932 Handle<Map> updated_map = Map::Update(map); | 988 Handle<Map> updated_map = Map::Update(map); |
933 CHECK_EQ(*new_map, *updated_map); | 989 CHECK_EQ(*new_map, *updated_map); |
934 } | 990 } |
935 | 991 |
936 | 992 |
937 // This test ensures that trivial representation/field type generalization | 993 // This test ensures that trivial representation/field type generalization |
938 // (from HeapObject to HeapObject) is correctly propagated from one branch of | 994 // (from HeapObject to HeapObject) is correctly propagated from one branch of |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1009 for (int i = kSplitProp; i < kPropCount; i++) { | 1065 for (int i = kSplitProp; i < kPropCount; i++) { |
1010 expectations.SetDataField(i, expected_representation, expected_type); | 1066 expectations.SetDataField(i, expected_representation, expected_type); |
1011 } | 1067 } |
1012 CHECK(!map->is_deprecated()); | 1068 CHECK(!map->is_deprecated()); |
1013 CHECK_EQ(*map, *new_map); | 1069 CHECK_EQ(*map, *new_map); |
1014 CHECK_EQ(expected_field_type_dependency, | 1070 CHECK_EQ(expected_field_type_dependency, |
1015 info.HasAbortedDueToDependencyChange()); | 1071 info.HasAbortedDueToDependencyChange()); |
1016 info.RollbackDependencies(); // Properly cleanup compilation info. | 1072 info.RollbackDependencies(); // Properly cleanup compilation info. |
1017 | 1073 |
1018 CHECK(!new_map->is_deprecated()); | 1074 CHECK(!new_map->is_deprecated()); |
1019 CHECK(!new_map->is_dictionary_map()); | |
1020 CHECK(expectations.Check(*new_map)); | 1075 CHECK(expectations.Check(*new_map)); |
1021 | 1076 |
1022 Handle<Map> updated_map = Map::Update(map); | 1077 Handle<Map> updated_map = Map::Update(map); |
1023 CHECK_EQ(*new_map, *updated_map); | 1078 CHECK_EQ(*new_map, *updated_map); |
1024 } | 1079 } |
1025 | 1080 |
1026 | 1081 |
1027 TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationSmiToDouble) { | 1082 TEST(ReconfigureDataFieldAttribute_GeneralizeRepresentationSmiToDouble) { |
1028 CcTest::InitializeVM(); | 1083 CcTest::InitializeVM(); |
1029 v8::HandleScope scope(CcTest::isolate()); | 1084 v8::HandleScope scope(CcTest::isolate()); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1114 | 1169 |
1115 // Checks that given |map| is deprecated and that it updates to given |new_map| | 1170 // Checks that given |map| is deprecated and that it updates to given |new_map| |
1116 // which in turn should match expectations. | 1171 // which in turn should match expectations. |
1117 struct CheckDeprecated { | 1172 struct CheckDeprecated { |
1118 void Check(Handle<Map> map, Handle<Map> new_map, | 1173 void Check(Handle<Map> map, Handle<Map> new_map, |
1119 const Expectations& expectations) { | 1174 const Expectations& expectations) { |
1120 CHECK(map->is_deprecated()); | 1175 CHECK(map->is_deprecated()); |
1121 CHECK_NE(*map, *new_map); | 1176 CHECK_NE(*map, *new_map); |
1122 | 1177 |
1123 CHECK(!new_map->is_deprecated()); | 1178 CHECK(!new_map->is_deprecated()); |
1124 CHECK(!new_map->is_dictionary_map()); | |
1125 CHECK(expectations.Check(*new_map)); | 1179 CHECK(expectations.Check(*new_map)); |
1126 | 1180 |
1127 // Update deprecated |map|, it should become |new_map|. | 1181 // Update deprecated |map|, it should become |new_map|. |
1128 Handle<Map> updated_map = Map::Update(map); | 1182 Handle<Map> updated_map = Map::Update(map); |
1129 CHECK_EQ(*new_map, *updated_map); | 1183 CHECK_EQ(*new_map, *updated_map); |
1130 } | 1184 } |
1131 }; | 1185 }; |
1132 | 1186 |
1133 | 1187 |
1134 // Checks that given |map| is NOT deprecated, equals to given |new_map| and | 1188 // Checks that given |map| is NOT deprecated, equals to given |new_map| and |
1135 // matches expectations. | 1189 // matches expectations. |
1136 struct CheckSameMap { | 1190 struct CheckSameMap { |
1137 void Check(Handle<Map> map, Handle<Map> new_map, | 1191 void Check(Handle<Map> map, Handle<Map> new_map, |
1138 const Expectations& expectations) { | 1192 const Expectations& expectations) { |
1139 CHECK(!map->is_deprecated()); | 1193 CHECK(!map->is_deprecated()); |
1140 CHECK_EQ(*map, *new_map); | 1194 CHECK_EQ(*map, *new_map); |
1141 | 1195 |
1142 CHECK(!new_map->is_deprecated()); | 1196 CHECK(!new_map->is_deprecated()); |
1143 CHECK(!new_map->is_dictionary_map()); | |
1144 CHECK(expectations.Check(*new_map)); | 1197 CHECK(expectations.Check(*new_map)); |
1145 | 1198 |
1146 // Update deprecated |map|, it should become |new_map|. | 1199 // Update deprecated |map|, it should become |new_map|. |
1147 Handle<Map> updated_map = Map::Update(map); | 1200 Handle<Map> updated_map = Map::Update(map); |
1148 CHECK_EQ(*new_map, *updated_map); | 1201 CHECK_EQ(*new_map, *updated_map); |
1149 } | 1202 } |
1150 }; | 1203 }; |
1151 | 1204 |
1152 | 1205 |
1153 // Checks that given |map| is NOT deprecated, and |new_map| is a result of | 1206 // Checks that given |map| is NOT deprecated, and |new_map| is a result of |
1154 // copy-generalize-all-representations. | 1207 // copy-generalize-all-representations. |
1155 struct CheckCopyGeneralizeAllRepresentations { | 1208 struct CheckCopyGeneralizeAllRepresentations { |
1156 void Check(Handle<Map> map, Handle<Map> new_map, Expectations& expectations) { | 1209 void Check(Handle<Map> map, Handle<Map> new_map, Expectations& expectations) { |
1157 CHECK(!map->is_deprecated()); | 1210 CHECK(!map->is_deprecated()); |
1158 CHECK_NE(*map, *new_map); | 1211 CHECK_NE(*map, *new_map); |
1159 | 1212 |
1160 CHECK(new_map->GetBackPointer()->IsUndefined()); | 1213 CHECK(new_map->GetBackPointer()->IsUndefined()); |
1161 for (int i = 0; i < kPropCount; i++) { | 1214 for (int i = 0; i < kPropCount; i++) { |
1162 expectations.GeneralizeRepresentation(i); | 1215 expectations.GeneralizeRepresentation(i); |
1163 } | 1216 } |
1164 | 1217 |
1165 CHECK(!new_map->is_deprecated()); | 1218 CHECK(!new_map->is_deprecated()); |
1166 CHECK(!new_map->is_dictionary_map()); | |
1167 CHECK(expectations.Check(*new_map)); | 1219 CHECK(expectations.Check(*new_map)); |
1168 } | 1220 } |
1169 }; | 1221 }; |
1170 | 1222 |
1171 | 1223 |
1172 // This test ensures that representation/field type generalization is correctly | 1224 // This test ensures that representation/field type generalization is correctly |
1173 // propagated from one branch of transition tree (|map2|) to another (|map1|). | 1225 // propagated from one branch of transition tree (|map2|) to another (|map1|). |
1174 // | 1226 // |
1175 // + - p2B - p3 - p4: |map2| | 1227 // + - p2B - p3 - p4: |map2| |
1176 // | | 1228 // | |
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2023 Handle<AccessorPair> pair = CreateAccessorPair(true, true); | 2075 Handle<AccessorPair> pair = CreateAccessorPair(true, true); |
2024 TransitionToAccessorConstantOperator transition_op(pair); | 2076 TransitionToAccessorConstantOperator transition_op(pair); |
2025 | 2077 |
2026 SameMapChecker checker; | 2078 SameMapChecker checker; |
2027 TestTransitionTo(transition_op, transition_op, checker); | 2079 TestTransitionTo(transition_op, transition_op, checker); |
2028 } | 2080 } |
2029 | 2081 |
2030 | 2082 |
2031 // TODO(ishell): add this test once IS_ACCESSOR_FIELD_SUPPORTED is supported. | 2083 // TODO(ishell): add this test once IS_ACCESSOR_FIELD_SUPPORTED is supported. |
2032 // TEST(TransitionAccessorConstantToAnotherAccessorConstant) | 2084 // TEST(TransitionAccessorConstantToAnotherAccessorConstant) |
OLD | NEW |