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 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 | 940 |
941 TEST(DescriptorArrayTrimming) { | 941 TEST(DescriptorArrayTrimming) { |
942 CcTest::InitializeVM(); | 942 CcTest::InitializeVM(); |
943 v8::HandleScope scope(CcTest::isolate()); | 943 v8::HandleScope scope(CcTest::isolate()); |
944 Isolate* isolate = CcTest::i_isolate(); | 944 Isolate* isolate = CcTest::i_isolate(); |
945 | 945 |
946 const int kFieldCount = 128; | 946 const int kFieldCount = 128; |
947 const int kSplitFieldIndex = 32; | 947 const int kSplitFieldIndex = 32; |
948 const int kTrimmedLayoutDescriptorLength = 64; | 948 const int kTrimmedLayoutDescriptorLength = 64; |
949 | 949 |
950 Handle<HeapType> any_type = HeapType::Any(isolate); | 950 Handle<FieldType> any_type = FieldType::Any(isolate); |
951 Handle<Map> map = Map::Create(isolate, kFieldCount); | 951 Handle<Map> map = Map::Create(isolate, kFieldCount); |
952 for (int i = 0; i < kSplitFieldIndex; i++) { | 952 for (int i = 0; i < kSplitFieldIndex; i++) { |
953 map = Map::CopyWithField(map, MakeName("prop", i), any_type, NONE, | 953 map = Map::CopyWithField(map, MakeName("prop", i), any_type, NONE, |
954 Representation::Smi(), | 954 Representation::Smi(), |
955 INSERT_TRANSITION).ToHandleChecked(); | 955 INSERT_TRANSITION).ToHandleChecked(); |
956 } | 956 } |
957 map = Map::CopyWithField(map, MakeName("dbl", kSplitFieldIndex), any_type, | 957 map = Map::CopyWithField(map, MakeName("dbl", kSplitFieldIndex), any_type, |
958 NONE, Representation::Double(), | 958 NONE, Representation::Double(), |
959 INSERT_TRANSITION).ToHandleChecked(); | 959 INSERT_TRANSITION).ToHandleChecked(); |
960 CHECK(map->layout_descriptor()->IsConsistentWithMap(*map, true)); | 960 CHECK(map->layout_descriptor()->IsConsistentWithMap(*map, true)); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 CcTest::InitializeVM(); | 1028 CcTest::InitializeVM(); |
1029 v8::HandleScope scope(CcTest::isolate()); | 1029 v8::HandleScope scope(CcTest::isolate()); |
1030 Isolate* isolate = CcTest::i_isolate(); | 1030 Isolate* isolate = CcTest::i_isolate(); |
1031 Factory* factory = isolate->factory(); | 1031 Factory* factory = isolate->factory(); |
1032 | 1032 |
1033 // The plan: create |obj| with double field in new space, do scanvenge so | 1033 // The plan: create |obj| with double field in new space, do scanvenge so |
1034 // that |obj| is moved to old space, construct a double value that looks like | 1034 // that |obj| is moved to old space, construct a double value that looks like |
1035 // a pointer to "from space" pointer. Do scavenge one more time and ensure | 1035 // a pointer to "from space" pointer. Do scavenge one more time and ensure |
1036 // that it didn't crash or corrupt the double value stored in the object. | 1036 // that it didn't crash or corrupt the double value stored in the object. |
1037 | 1037 |
1038 Handle<HeapType> any_type = HeapType::Any(isolate); | 1038 Handle<FieldType> any_type = FieldType::Any(isolate); |
1039 Handle<Map> map = Map::Create(isolate, 10); | 1039 Handle<Map> map = Map::Create(isolate, 10); |
1040 map = Map::CopyWithField(map, MakeName("prop", 0), any_type, NONE, | 1040 map = Map::CopyWithField(map, MakeName("prop", 0), any_type, NONE, |
1041 Representation::Double(), | 1041 Representation::Double(), |
1042 INSERT_TRANSITION).ToHandleChecked(); | 1042 INSERT_TRANSITION).ToHandleChecked(); |
1043 | 1043 |
1044 // Create object in new space. | 1044 // Create object in new space. |
1045 Handle<JSObject> obj = factory->NewJSObjectFromMap(map, NOT_TENURED); | 1045 Handle<JSObject> obj = factory->NewJSObjectFromMap(map, NOT_TENURED); |
1046 | 1046 |
1047 Handle<HeapNumber> heap_number = factory->NewHeapNumber(42.5); | 1047 Handle<HeapNumber> heap_number = factory->NewHeapNumber(42.5); |
1048 obj->WriteToField(0, *heap_number); | 1048 obj->WriteToField(0, *heap_number); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 Factory* factory = isolate->factory(); | 1090 Factory* factory = isolate->factory(); |
1091 Heap* heap = CcTest::heap(); | 1091 Heap* heap = CcTest::heap(); |
1092 PagedSpace* old_space = heap->old_space(); | 1092 PagedSpace* old_space = heap->old_space(); |
1093 | 1093 |
1094 // The plan: create |obj_value| in old space and ensure that it is allocated | 1094 // The plan: create |obj_value| in old space and ensure that it is allocated |
1095 // on evacuation candidate page, create |obj| with double and tagged fields | 1095 // on evacuation candidate page, create |obj| with double and tagged fields |
1096 // in new space and write |obj_value| to tagged field of |obj|, do two | 1096 // in new space and write |obj_value| to tagged field of |obj|, do two |
1097 // scavenges to promote |obj| to old space, a GC in old space and ensure that | 1097 // scavenges to promote |obj| to old space, a GC in old space and ensure that |
1098 // the tagged value was properly updated after candidates evacuation. | 1098 // the tagged value was properly updated after candidates evacuation. |
1099 | 1099 |
1100 Handle<HeapType> any_type = HeapType::Any(isolate); | 1100 Handle<FieldType> any_type = FieldType::Any(isolate); |
1101 Handle<Map> map = Map::Create(isolate, 10); | 1101 Handle<Map> map = Map::Create(isolate, 10); |
1102 map = Map::CopyWithField(map, MakeName("prop", 0), any_type, NONE, | 1102 map = Map::CopyWithField(map, MakeName("prop", 0), any_type, NONE, |
1103 Representation::Double(), | 1103 Representation::Double(), |
1104 INSERT_TRANSITION).ToHandleChecked(); | 1104 INSERT_TRANSITION).ToHandleChecked(); |
1105 map = Map::CopyWithField(map, MakeName("prop", 1), any_type, NONE, | 1105 map = Map::CopyWithField(map, MakeName("prop", 1), any_type, NONE, |
1106 Representation::Tagged(), | 1106 Representation::Tagged(), |
1107 INSERT_TRANSITION).ToHandleChecked(); | 1107 INSERT_TRANSITION).ToHandleChecked(); |
1108 | 1108 |
1109 // Create |obj_value| in old space. | 1109 // Create |obj_value| in old space. |
1110 Handle<HeapObject> obj_value; | 1110 Handle<HeapObject> obj_value; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1314 kPropsCount); | 1314 kPropsCount); |
1315 | 1315 |
1316 TestLayoutDescriptorHelper(isolate, kPropsCount, descriptors, kPropsCount); | 1316 TestLayoutDescriptorHelper(isolate, kPropsCount, descriptors, kPropsCount); |
1317 } | 1317 } |
1318 | 1318 |
1319 | 1319 |
1320 TEST(LayoutDescriptorSharing) { | 1320 TEST(LayoutDescriptorSharing) { |
1321 CcTest::InitializeVM(); | 1321 CcTest::InitializeVM(); |
1322 v8::HandleScope scope(CcTest::isolate()); | 1322 v8::HandleScope scope(CcTest::isolate()); |
1323 Isolate* isolate = CcTest::i_isolate(); | 1323 Isolate* isolate = CcTest::i_isolate(); |
1324 Handle<HeapType> any_type = HeapType::Any(isolate); | 1324 Handle<FieldType> any_type = FieldType::Any(isolate); |
1325 | 1325 |
1326 Handle<Map> split_map; | 1326 Handle<Map> split_map; |
1327 { | 1327 { |
1328 Handle<Map> map = Map::Create(isolate, 64); | 1328 Handle<Map> map = Map::Create(isolate, 64); |
1329 for (int i = 0; i < 32; i++) { | 1329 for (int i = 0; i < 32; i++) { |
1330 Handle<String> name = MakeName("prop", i); | 1330 Handle<String> name = MakeName("prop", i); |
1331 map = Map::CopyWithField(map, name, any_type, NONE, Representation::Smi(), | 1331 map = Map::CopyWithField(map, name, any_type, NONE, Representation::Smi(), |
1332 INSERT_TRANSITION).ToHandleChecked(); | 1332 INSERT_TRANSITION).ToHandleChecked(); |
1333 } | 1333 } |
1334 split_map = Map::CopyWithField(map, MakeString("dbl"), any_type, NONE, | 1334 split_map = Map::CopyWithField(map, MakeString("dbl"), any_type, NONE, |
(...skipping 27 matching lines...) Expand all Loading... |
1362 CHECK(map2->layout_descriptor()->IsConsistentWithMap(*map2, true)); | 1362 CHECK(map2->layout_descriptor()->IsConsistentWithMap(*map2, true)); |
1363 } | 1363 } |
1364 | 1364 |
1365 | 1365 |
1366 TEST(StoreBufferScanOnScavenge) { | 1366 TEST(StoreBufferScanOnScavenge) { |
1367 CcTest::InitializeVM(); | 1367 CcTest::InitializeVM(); |
1368 Isolate* isolate = CcTest::i_isolate(); | 1368 Isolate* isolate = CcTest::i_isolate(); |
1369 Factory* factory = isolate->factory(); | 1369 Factory* factory = isolate->factory(); |
1370 v8::HandleScope scope(CcTest::isolate()); | 1370 v8::HandleScope scope(CcTest::isolate()); |
1371 | 1371 |
1372 Handle<HeapType> any_type = HeapType::Any(isolate); | 1372 Handle<FieldType> any_type = FieldType::Any(isolate); |
1373 Handle<Map> map = Map::Create(isolate, 10); | 1373 Handle<Map> map = Map::Create(isolate, 10); |
1374 map = Map::CopyWithField(map, MakeName("prop", 0), any_type, NONE, | 1374 map = Map::CopyWithField(map, MakeName("prop", 0), any_type, NONE, |
1375 Representation::Double(), | 1375 Representation::Double(), |
1376 INSERT_TRANSITION).ToHandleChecked(); | 1376 INSERT_TRANSITION).ToHandleChecked(); |
1377 | 1377 |
1378 // Create object in new space. | 1378 // Create object in new space. |
1379 Handle<JSObject> obj = factory->NewJSObjectFromMap(map, NOT_TENURED); | 1379 Handle<JSObject> obj = factory->NewJSObjectFromMap(map, NOT_TENURED); |
1380 | 1380 |
1381 Handle<HeapNumber> heap_number = factory->NewHeapNumber(42.5); | 1381 Handle<HeapNumber> heap_number = factory->NewHeapNumber(42.5); |
1382 obj->WriteToField(0, *heap_number); | 1382 obj->WriteToField(0, *heap_number); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1573 } | 1573 } |
1574 | 1574 |
1575 | 1575 |
1576 enum WriteBarrierKind { OLD_TO_OLD_WRITE_BARRIER, OLD_TO_NEW_WRITE_BARRIER }; | 1576 enum WriteBarrierKind { OLD_TO_OLD_WRITE_BARRIER, OLD_TO_NEW_WRITE_BARRIER }; |
1577 static void TestWriteBarrierObjectShiftFieldsRight( | 1577 static void TestWriteBarrierObjectShiftFieldsRight( |
1578 WriteBarrierKind write_barrier_kind) { | 1578 WriteBarrierKind write_barrier_kind) { |
1579 CcTest::InitializeVM(); | 1579 CcTest::InitializeVM(); |
1580 Isolate* isolate = CcTest::i_isolate(); | 1580 Isolate* isolate = CcTest::i_isolate(); |
1581 v8::HandleScope scope(CcTest::isolate()); | 1581 v8::HandleScope scope(CcTest::isolate()); |
1582 | 1582 |
1583 Handle<HeapType> any_type = HeapType::Any(isolate); | 1583 Handle<FieldType> any_type = FieldType::Any(isolate); |
1584 | 1584 |
1585 CompileRun("function func() { return 1; }"); | 1585 CompileRun("function func() { return 1; }"); |
1586 | 1586 |
1587 Handle<JSObject> func = GetObject("func"); | 1587 Handle<JSObject> func = GetObject("func"); |
1588 | 1588 |
1589 Handle<Map> map = Map::Create(isolate, 10); | 1589 Handle<Map> map = Map::Create(isolate, 10); |
1590 map = Map::CopyWithConstant(map, MakeName("prop", 0), func, NONE, | 1590 map = Map::CopyWithConstant(map, MakeName("prop", 0), func, NONE, |
1591 INSERT_TRANSITION).ToHandleChecked(); | 1591 INSERT_TRANSITION).ToHandleChecked(); |
1592 map = Map::CopyWithField(map, MakeName("prop", 1), any_type, NONE, | 1592 map = Map::CopyWithField(map, MakeName("prop", 1), any_type, NONE, |
1593 Representation::Double(), | 1593 Representation::Double(), |
(...skipping 28 matching lines...) Expand all Loading... |
1622 | 1622 |
1623 // TODO(ishell): add respective tests for property kind reconfiguring from | 1623 // TODO(ishell): add respective tests for property kind reconfiguring from |
1624 // accessor field to double, once accessor fields are supported by | 1624 // accessor field to double, once accessor fields are supported by |
1625 // Map::ReconfigureProperty(). | 1625 // Map::ReconfigureProperty(). |
1626 | 1626 |
1627 | 1627 |
1628 // TODO(ishell): add respective tests for fast property removal case once | 1628 // TODO(ishell): add respective tests for fast property removal case once |
1629 // Map::ReconfigureProperty() supports that. | 1629 // Map::ReconfigureProperty() supports that. |
1630 | 1630 |
1631 #endif | 1631 #endif |
OLD | NEW |