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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 } | 574 } |
575 InitializeVerifiedMapDescriptors(*map, *descriptors, *layout_descriptor); | 575 InitializeVerifiedMapDescriptors(*map, *descriptors, *layout_descriptor); |
576 | 576 |
577 // Now test LayoutDescriptor::cast_gc_safe(). | 577 // Now test LayoutDescriptor::cast_gc_safe(). |
578 Handle<LayoutDescriptor> layout_descriptor_copy = | 578 Handle<LayoutDescriptor> layout_descriptor_copy = |
579 LayoutDescriptor::New(map, descriptors, kPropsCount); | 579 LayoutDescriptor::New(map, descriptors, kPropsCount); |
580 | 580 |
581 LayoutDescriptor* layout_desc = *layout_descriptor; | 581 LayoutDescriptor* layout_desc = *layout_descriptor; |
582 CHECK_EQ(layout_desc, LayoutDescriptor::cast(layout_desc)); | 582 CHECK_EQ(layout_desc, LayoutDescriptor::cast(layout_desc)); |
583 CHECK_EQ(layout_desc, LayoutDescriptor::cast_gc_safe(layout_desc)); | 583 CHECK_EQ(layout_desc, LayoutDescriptor::cast_gc_safe(layout_desc)); |
584 CHECK(layout_descriptor->IsFixedTypedArrayBase()); | 584 CHECK(layout_descriptor->IsJSTypedArray()); |
585 // Now make it look like a forwarding pointer to layout_descriptor_copy. | 585 // Now make it look like a forwarding pointer to layout_descriptor_copy. |
586 MapWord map_word = layout_desc->map_word(); | 586 MapWord map_word = layout_desc->map_word(); |
587 CHECK(!map_word.IsForwardingAddress()); | 587 CHECK(!map_word.IsForwardingAddress()); |
588 layout_desc->set_map_word( | 588 layout_desc->set_map_word( |
589 MapWord::FromForwardingAddress(*layout_descriptor_copy)); | 589 MapWord::FromForwardingAddress(*layout_descriptor_copy)); |
590 CHECK(layout_desc->map_word().IsForwardingAddress()); | 590 CHECK(layout_desc->map_word().IsForwardingAddress()); |
591 CHECK_EQ(*layout_descriptor_copy, | 591 CHECK_EQ(*layout_descriptor_copy, |
592 LayoutDescriptor::cast_gc_safe(layout_desc)); | 592 LayoutDescriptor::cast_gc_safe(layout_desc)); |
593 | 593 |
594 // Restore it back. | 594 // Restore it back. |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 map = Map::CopyWithField(map, MakeName("prop", i), any_type, NONE, | 928 map = Map::CopyWithField(map, MakeName("prop", i), any_type, NONE, |
929 Representation::Smi(), | 929 Representation::Smi(), |
930 INSERT_TRANSITION).ToHandleChecked(); | 930 INSERT_TRANSITION).ToHandleChecked(); |
931 } | 931 } |
932 map = Map::CopyWithField(map, MakeName("dbl", kSplitFieldIndex), any_type, | 932 map = Map::CopyWithField(map, MakeName("dbl", kSplitFieldIndex), any_type, |
933 NONE, Representation::Double(), | 933 NONE, Representation::Double(), |
934 INSERT_TRANSITION).ToHandleChecked(); | 934 INSERT_TRANSITION).ToHandleChecked(); |
935 CHECK(map->layout_descriptor()->IsConsistentWithMap(*map, true)); | 935 CHECK(map->layout_descriptor()->IsConsistentWithMap(*map, true)); |
936 CHECK(map->layout_descriptor()->IsSlowLayout()); | 936 CHECK(map->layout_descriptor()->IsSlowLayout()); |
937 CHECK(map->owns_descriptors()); | 937 CHECK(map->owns_descriptors()); |
938 CHECK_EQ(2, map->layout_descriptor()->length()); | 938 CHECK_EQ(2, Smi::cast(map->layout_descriptor()->length())->value()); |
939 | 939 |
940 { | 940 { |
941 // Add transitions to double fields. | 941 // Add transitions to double fields. |
942 v8::HandleScope scope(CcTest::isolate()); | 942 v8::HandleScope scope(CcTest::isolate()); |
943 | 943 |
944 Handle<Map> tmp_map = map; | 944 Handle<Map> tmp_map = map; |
945 for (int i = kSplitFieldIndex + 1; i < kFieldCount; i++) { | 945 for (int i = kSplitFieldIndex + 1; i < kFieldCount; i++) { |
946 tmp_map = Map::CopyWithField(tmp_map, MakeName("dbl", i), any_type, NONE, | 946 tmp_map = Map::CopyWithField(tmp_map, MakeName("dbl", i), any_type, NONE, |
947 Representation::Double(), | 947 Representation::Double(), |
948 INSERT_TRANSITION).ToHandleChecked(); | 948 INSERT_TRANSITION).ToHandleChecked(); |
949 CHECK(tmp_map->layout_descriptor()->IsConsistentWithMap(*tmp_map, true)); | 949 CHECK(tmp_map->layout_descriptor()->IsConsistentWithMap(*tmp_map, true)); |
950 } | 950 } |
951 // Check that descriptors are shared. | 951 // Check that descriptors are shared. |
952 CHECK(tmp_map->owns_descriptors()); | 952 CHECK(tmp_map->owns_descriptors()); |
953 CHECK_EQ(map->instance_descriptors(), tmp_map->instance_descriptors()); | 953 CHECK_EQ(map->instance_descriptors(), tmp_map->instance_descriptors()); |
954 CHECK_EQ(map->layout_descriptor(), tmp_map->layout_descriptor()); | 954 CHECK_EQ(map->layout_descriptor(), tmp_map->layout_descriptor()); |
955 } | 955 } |
956 CHECK(map->layout_descriptor()->IsSlowLayout()); | 956 CHECK(map->layout_descriptor()->IsSlowLayout()); |
957 CHECK_EQ(4, map->layout_descriptor()->length()); | 957 CHECK_EQ(4, Smi::cast(map->layout_descriptor()->length())->value()); |
958 | 958 |
959 // The unused tail of the layout descriptor is now "durty" because of sharing. | 959 // The unused tail of the layout descriptor is now "durty" because of sharing. |
960 CHECK(map->layout_descriptor()->IsConsistentWithMap(*map)); | 960 CHECK(map->layout_descriptor()->IsConsistentWithMap(*map)); |
961 for (int i = kSplitFieldIndex + 1; i < kTrimmedLayoutDescriptorLength; i++) { | 961 for (int i = kSplitFieldIndex + 1; i < kTrimmedLayoutDescriptorLength; i++) { |
962 CHECK(!map->layout_descriptor()->IsTagged(i)); | 962 CHECK(!map->layout_descriptor()->IsTagged(i)); |
963 } | 963 } |
964 CHECK_LT(map->NumberOfOwnDescriptors(), | 964 CHECK_LT(map->NumberOfOwnDescriptors(), |
965 map->instance_descriptors()->number_of_descriptors()); | 965 map->instance_descriptors()->number_of_descriptors()); |
966 | 966 |
967 // Call GC that should trim both |map|'s descriptor array and layout | 967 // Call GC that should trim both |map|'s descriptor array and layout |
968 // descriptor. | 968 // descriptor. |
969 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); | 969 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); |
970 | 970 |
971 // The unused tail of the layout descriptor is now "clean" again. | 971 // The unused tail of the layout descriptor is now "clean" again. |
972 CHECK(map->layout_descriptor()->IsConsistentWithMap(*map, true)); | 972 CHECK(map->layout_descriptor()->IsConsistentWithMap(*map, true)); |
973 CHECK(map->owns_descriptors()); | 973 CHECK(map->owns_descriptors()); |
974 CHECK_EQ(map->NumberOfOwnDescriptors(), | 974 CHECK_EQ(map->NumberOfOwnDescriptors(), |
975 map->instance_descriptors()->number_of_descriptors()); | 975 map->instance_descriptors()->number_of_descriptors()); |
976 CHECK(map->layout_descriptor()->IsSlowLayout()); | 976 CHECK(map->layout_descriptor()->IsSlowLayout()); |
977 CHECK_EQ(2, map->layout_descriptor()->length()); | 977 CHECK_EQ(2, Smi::cast(map->layout_descriptor()->length())->value()); |
978 | 978 |
979 { | 979 { |
980 // Add transitions to tagged fields. | 980 // Add transitions to tagged fields. |
981 v8::HandleScope scope(CcTest::isolate()); | 981 v8::HandleScope scope(CcTest::isolate()); |
982 | 982 |
983 Handle<Map> tmp_map = map; | 983 Handle<Map> tmp_map = map; |
984 for (int i = kSplitFieldIndex + 1; i < kFieldCount - 1; i++) { | 984 for (int i = kSplitFieldIndex + 1; i < kFieldCount - 1; i++) { |
985 tmp_map = Map::CopyWithField(tmp_map, MakeName("tagged", i), any_type, | 985 tmp_map = Map::CopyWithField(tmp_map, MakeName("tagged", i), any_type, |
986 NONE, Representation::Tagged(), | 986 NONE, Representation::Tagged(), |
987 INSERT_TRANSITION).ToHandleChecked(); | 987 INSERT_TRANSITION).ToHandleChecked(); |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1681 | 1681 |
1682 // TODO(ishell): add respective tests for property kind reconfiguring from | 1682 // TODO(ishell): add respective tests for property kind reconfiguring from |
1683 // accessor field to double, once accessor fields are supported by | 1683 // accessor field to double, once accessor fields are supported by |
1684 // Map::ReconfigureProperty(). | 1684 // Map::ReconfigureProperty(). |
1685 | 1685 |
1686 | 1686 |
1687 // TODO(ishell): add respective tests for fast property removal case once | 1687 // TODO(ishell): add respective tests for fast property removal case once |
1688 // Map::ReconfigureProperty() supports that. | 1688 // Map::ReconfigureProperty() supports that. |
1689 | 1689 |
1690 #endif | 1690 #endif |
OLD | NEW |