OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <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/compilation-cache.h" | 10 #include "src/compilation-cache.h" |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 layout_descriptor = TestLayoutDescriptorAppend(isolate, kPropsCount, props, | 734 layout_descriptor = TestLayoutDescriptorAppend(isolate, kPropsCount, props, |
735 kSmiValueSize + 1); | 735 kSmiValueSize + 1); |
736 CHECK(layout_descriptor->IsSlowLayout()); | 736 CHECK(layout_descriptor->IsSlowLayout()); |
737 } | 737 } |
738 } | 738 } |
739 | 739 |
740 | 740 |
741 static Handle<LayoutDescriptor> TestLayoutDescriptorAppendIfFastOrUseFull( | 741 static Handle<LayoutDescriptor> TestLayoutDescriptorAppendIfFastOrUseFull( |
742 Isolate* isolate, int inobject_properties, | 742 Isolate* isolate, int inobject_properties, |
743 Handle<DescriptorArray> descriptors, int number_of_descriptors) { | 743 Handle<DescriptorArray> descriptors, int number_of_descriptors) { |
744 Handle<Map> map = Map::Create(isolate, inobject_properties); | 744 Handle<Map> initial_map = Map::Create(isolate, inobject_properties); |
745 | 745 |
746 Handle<LayoutDescriptor> full_layout_descriptor = LayoutDescriptor::New( | 746 Handle<LayoutDescriptor> full_layout_descriptor = LayoutDescriptor::New( |
747 map, descriptors, descriptors->number_of_descriptors()); | 747 initial_map, descriptors, descriptors->number_of_descriptors()); |
748 | 748 |
749 int nof = 0; | 749 int nof = 0; |
750 bool switched_to_slow_mode = false; | 750 bool switched_to_slow_mode = false; |
751 | 751 |
| 752 // This method calls LayoutDescriptor::AppendIfFastOrUseFull() internally |
| 753 // and does all the required map-descriptors related book keeping. |
| 754 Handle<Map> last_map = Map::AddMissingTransitionsForTesting( |
| 755 initial_map, descriptors, full_layout_descriptor); |
| 756 |
| 757 // Follow back pointers to construct a sequence of maps from |map| |
| 758 // to |last_map|. |
| 759 int descriptors_length = descriptors->number_of_descriptors(); |
| 760 std::vector<Handle<Map>> maps(descriptors_length); |
| 761 { |
| 762 Map* map = *last_map; |
| 763 for (int i = 0; i < descriptors_length; i++) { |
| 764 maps[descriptors_length - 1 - i] = handle(map, isolate); |
| 765 Object* maybe_map = map->GetBackPointer(); |
| 766 CHECK(maybe_map->IsMap()); |
| 767 map = Map::cast(maybe_map); |
| 768 } |
| 769 CHECK_EQ(1, maps[0]->NumberOfOwnDescriptors()); |
| 770 } |
| 771 |
| 772 Handle<Map> map; |
| 773 // Now check layout descriptors of all intermediate maps. |
752 for (int i = 0; i < number_of_descriptors; i++) { | 774 for (int i = 0; i < number_of_descriptors; i++) { |
753 PropertyDetails details = descriptors->GetDetails(i); | 775 PropertyDetails details = descriptors->GetDetails(i); |
754 | 776 map = maps[i]; |
755 // This method calls LayoutDescriptor::AppendIfFastOrUseFull() internally | |
756 // and does all the required map-descriptors related book keeping. | |
757 map = Map::CopyInstallDescriptorsForTesting(map, i, descriptors, | |
758 full_layout_descriptor); | |
759 | |
760 LayoutDescriptor* layout_desc = map->layout_descriptor(); | 777 LayoutDescriptor* layout_desc = map->layout_descriptor(); |
761 | 778 |
762 if (layout_desc->IsSlowLayout()) { | 779 if (layout_desc->IsSlowLayout()) { |
763 switched_to_slow_mode = true; | 780 switched_to_slow_mode = true; |
764 CHECK_EQ(*full_layout_descriptor, layout_desc); | 781 CHECK_EQ(*full_layout_descriptor, layout_desc); |
765 } else { | 782 } else { |
766 CHECK(!switched_to_slow_mode); | 783 CHECK(!switched_to_slow_mode); |
767 if (details.type() == DATA) { | 784 if (details.type() == DATA) { |
768 nof++; | 785 nof++; |
769 int field_index = details.field_index(); | 786 int field_index = details.field_index(); |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1603 | 1620 |
1604 // TODO(ishell): add respective tests for property kind reconfiguring from | 1621 // TODO(ishell): add respective tests for property kind reconfiguring from |
1605 // accessor field to double, once accessor fields are supported by | 1622 // accessor field to double, once accessor fields are supported by |
1606 // Map::ReconfigureProperty(). | 1623 // Map::ReconfigureProperty(). |
1607 | 1624 |
1608 | 1625 |
1609 // TODO(ishell): add respective tests for fast property removal case once | 1626 // TODO(ishell): add respective tests for fast property removal case once |
1610 // Map::ReconfigureProperty() supports that. | 1627 // Map::ReconfigureProperty() supports that. |
1611 | 1628 |
1612 #endif | 1629 #endif |
OLD | NEW |