| 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 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 CHECK(object->HasFastProperties()); | 902 CHECK(object->HasFastProperties()); |
| 903 CHECK(!object->map()->HasFastPointerLayout()); | 903 CHECK(!object->map()->HasFastPointerLayout()); |
| 904 | 904 |
| 905 Handle<Map> normalized_map = | 905 Handle<Map> normalized_map = |
| 906 Map::Normalize(map, KEEP_INOBJECT_PROPERTIES, "testing"); | 906 Map::Normalize(map, KEEP_INOBJECT_PROPERTIES, "testing"); |
| 907 JSObject::MigrateToMap(object, normalized_map); | 907 JSObject::MigrateToMap(object, normalized_map); |
| 908 CHECK(!object->HasFastProperties()); | 908 CHECK(!object->HasFastProperties()); |
| 909 CHECK(object->map()->HasFastPointerLayout()); | 909 CHECK(object->map()->HasFastPointerLayout()); |
| 910 | 910 |
| 911 // Trigger GCs and heap verification. | 911 // Trigger GCs and heap verification. |
| 912 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 912 CcTest::heap()->CollectAllGarbage(); |
| 913 } | 913 } |
| 914 | 914 |
| 915 | 915 |
| 916 TEST(DescriptorArrayTrimming) { | 916 TEST(DescriptorArrayTrimming) { |
| 917 CcTest::InitializeVM(); | 917 CcTest::InitializeVM(); |
| 918 v8::HandleScope scope(CcTest::isolate()); | 918 v8::HandleScope scope(CcTest::isolate()); |
| 919 Isolate* isolate = CcTest::i_isolate(); | 919 Isolate* isolate = CcTest::i_isolate(); |
| 920 | 920 |
| 921 const int kFieldCount = 128; | 921 const int kFieldCount = 128; |
| 922 const int kSplitFieldIndex = 32; | 922 const int kSplitFieldIndex = 32; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(); |
| 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, map->layout_descriptor()->length()); |
| 978 | 978 |
| 979 { | 979 { |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1383 | 1383 |
| 1384 FieldIndex field_index = FieldIndex::ForDescriptor(obj->map(), 0); | 1384 FieldIndex field_index = FieldIndex::ForDescriptor(obj->map(), 0); |
| 1385 Handle<HeapNumber> boom_number = factory->NewHeapNumber(boom_value, MUTABLE); | 1385 Handle<HeapNumber> boom_number = factory->NewHeapNumber(boom_value, MUTABLE); |
| 1386 obj->FastPropertyAtPut(field_index, *boom_number); | 1386 obj->FastPropertyAtPut(field_index, *boom_number); |
| 1387 | 1387 |
| 1388 // Enforce scan on scavenge for the obj's page. | 1388 // Enforce scan on scavenge for the obj's page. |
| 1389 MemoryChunk* chunk = MemoryChunk::FromAddress(obj->address()); | 1389 MemoryChunk* chunk = MemoryChunk::FromAddress(obj->address()); |
| 1390 chunk->set_scan_on_scavenge(true); | 1390 chunk->set_scan_on_scavenge(true); |
| 1391 | 1391 |
| 1392 // Trigger GCs and force evacuation. Should not crash there. | 1392 // Trigger GCs and force evacuation. Should not crash there. |
| 1393 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 1393 CcTest::heap()->CollectAllGarbage(); |
| 1394 | 1394 |
| 1395 CHECK_EQ(boom_value, GetDoubleFieldValue(*obj, field_index)); | 1395 CHECK_EQ(boom_value, GetDoubleFieldValue(*obj, field_index)); |
| 1396 } | 1396 } |
| 1397 | 1397 |
| 1398 | 1398 |
| 1399 static int LenFromSize(int size) { | 1399 static int LenFromSize(int size) { |
| 1400 return (size - FixedArray::kHeaderSize) / kPointerSize; | 1400 return (size - FixedArray::kHeaderSize) / kPointerSize; |
| 1401 } | 1401 } |
| 1402 | 1402 |
| 1403 | 1403 |
| (...skipping 277 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 |