| 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 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 CHECK(field_index.is_inobject() && field_index.is_double()); | 1028 CHECK(field_index.is_inobject() && field_index.is_double()); |
| 1029 CHECK_EQ(FLAG_unbox_double_fields, map->IsUnboxedDoubleField(field_index)); | 1029 CHECK_EQ(FLAG_unbox_double_fields, map->IsUnboxedDoubleField(field_index)); |
| 1030 CHECK_EQ(42.5, GetDoubleFieldValue(*obj, field_index)); | 1030 CHECK_EQ(42.5, GetDoubleFieldValue(*obj, field_index)); |
| 1031 } | 1031 } |
| 1032 CHECK(isolate->heap()->new_space()->Contains(*obj)); | 1032 CHECK(isolate->heap()->new_space()->Contains(*obj)); |
| 1033 | 1033 |
| 1034 // Do scavenge so that |obj| is moved to survivor space. | 1034 // Do scavenge so that |obj| is moved to survivor space. |
| 1035 CcTest::heap()->CollectGarbage(i::NEW_SPACE); | 1035 CcTest::heap()->CollectGarbage(i::NEW_SPACE); |
| 1036 | 1036 |
| 1037 // Create temp object in the new space. | 1037 // Create temp object in the new space. |
| 1038 Handle<JSArray> temp = factory->NewJSArray(FAST_ELEMENTS, NOT_TENURED); | 1038 Handle<JSArray> temp = factory->NewJSArray(FAST_ELEMENTS, WEAK, NOT_TENURED); |
| 1039 CHECK(isolate->heap()->new_space()->Contains(*temp)); | 1039 CHECK(isolate->heap()->new_space()->Contains(*temp)); |
| 1040 | 1040 |
| 1041 // Construct a double value that looks like a pointer to the new space object | 1041 // Construct a double value that looks like a pointer to the new space object |
| 1042 // and store it into the obj. | 1042 // and store it into the obj. |
| 1043 Address fake_object = reinterpret_cast<Address>(*temp) + kPointerSize; | 1043 Address fake_object = reinterpret_cast<Address>(*temp) + kPointerSize; |
| 1044 double boom_value = bit_cast<double>(fake_object); | 1044 double boom_value = bit_cast<double>(fake_object); |
| 1045 | 1045 |
| 1046 FieldIndex field_index = FieldIndex::ForDescriptor(obj->map(), 0); | 1046 FieldIndex field_index = FieldIndex::ForDescriptor(obj->map(), 0); |
| 1047 Handle<HeapNumber> boom_number = factory->NewHeapNumber(boom_value, MUTABLE); | 1047 Handle<HeapNumber> boom_number = factory->NewHeapNumber(boom_value, MUTABLE); |
| 1048 obj->FastPropertyAtPut(field_index, *boom_number); | 1048 obj->FastPropertyAtPut(field_index, *boom_number); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1081 Representation::Tagged(), | 1081 Representation::Tagged(), |
| 1082 INSERT_TRANSITION).ToHandleChecked(); | 1082 INSERT_TRANSITION).ToHandleChecked(); |
| 1083 | 1083 |
| 1084 // Create |obj_value| in old space. | 1084 // Create |obj_value| in old space. |
| 1085 Handle<HeapObject> obj_value; | 1085 Handle<HeapObject> obj_value; |
| 1086 Page* ec_page; | 1086 Page* ec_page; |
| 1087 { | 1087 { |
| 1088 AlwaysAllocateScope always_allocate(isolate); | 1088 AlwaysAllocateScope always_allocate(isolate); |
| 1089 // Make sure |obj_value| is placed on an old-space evacuation candidate. | 1089 // Make sure |obj_value| is placed on an old-space evacuation candidate. |
| 1090 SimulateFullSpace(old_space); | 1090 SimulateFullSpace(old_space); |
| 1091 obj_value = factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED); | 1091 obj_value = |
| 1092 factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, WEAK, TENURED); |
| 1092 ec_page = Page::FromAddress(obj_value->address()); | 1093 ec_page = Page::FromAddress(obj_value->address()); |
| 1093 } | 1094 } |
| 1094 | 1095 |
| 1095 // Create object in new space. | 1096 // Create object in new space. |
| 1096 Handle<JSObject> obj = factory->NewJSObjectFromMap(map, NOT_TENURED, false); | 1097 Handle<JSObject> obj = factory->NewJSObjectFromMap(map, NOT_TENURED, false); |
| 1097 | 1098 |
| 1098 Handle<HeapNumber> heap_number = factory->NewHeapNumber(42.5); | 1099 Handle<HeapNumber> heap_number = factory->NewHeapNumber(42.5); |
| 1099 obj->WriteToField(0, *heap_number); | 1100 obj->WriteToField(0, *heap_number); |
| 1100 obj->WriteToField(1, *obj_value); | 1101 obj->WriteToField(1, *obj_value); |
| 1101 | 1102 |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1366 } | 1367 } |
| 1367 CHECK(isolate->heap()->new_space()->Contains(*obj)); | 1368 CHECK(isolate->heap()->new_space()->Contains(*obj)); |
| 1368 | 1369 |
| 1369 // Trigger GCs so that the newly allocated object moves to old gen. | 1370 // Trigger GCs so that the newly allocated object moves to old gen. |
| 1370 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now | 1371 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now |
| 1371 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now | 1372 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now |
| 1372 | 1373 |
| 1373 CHECK(isolate->heap()->old_space()->Contains(*obj)); | 1374 CHECK(isolate->heap()->old_space()->Contains(*obj)); |
| 1374 | 1375 |
| 1375 // Create temp object in the new space. | 1376 // Create temp object in the new space. |
| 1376 Handle<JSArray> temp = factory->NewJSArray(FAST_ELEMENTS, NOT_TENURED); | 1377 Handle<JSArray> temp = factory->NewJSArray(FAST_ELEMENTS, WEAK, NOT_TENURED); |
| 1377 CHECK(isolate->heap()->new_space()->Contains(*temp)); | 1378 CHECK(isolate->heap()->new_space()->Contains(*temp)); |
| 1378 | 1379 |
| 1379 // Construct a double value that looks like a pointer to the new space object | 1380 // Construct a double value that looks like a pointer to the new space object |
| 1380 // and store it into the obj. | 1381 // and store it into the obj. |
| 1381 Address fake_object = reinterpret_cast<Address>(*temp) + kPointerSize; | 1382 Address fake_object = reinterpret_cast<Address>(*temp) + kPointerSize; |
| 1382 double boom_value = bit_cast<double>(fake_object); | 1383 double boom_value = bit_cast<double>(fake_object); |
| 1383 | 1384 |
| 1384 FieldIndex field_index = FieldIndex::ForDescriptor(obj->map(), 0); | 1385 FieldIndex field_index = FieldIndex::ForDescriptor(obj->map(), 0); |
| 1385 Handle<HeapNumber> boom_number = factory->NewHeapNumber(boom_value, MUTABLE); | 1386 Handle<HeapNumber> boom_number = factory->NewHeapNumber(boom_value, MUTABLE); |
| 1386 obj->FastPropertyAtPut(field_index, *boom_number); | 1387 obj->FastPropertyAtPut(field_index, *boom_number); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 Handle<JSObject> obj; | 1566 Handle<JSObject> obj; |
| 1566 Handle<HeapObject> obj_value; | 1567 Handle<HeapObject> obj_value; |
| 1567 Page* ec_page; | 1568 Page* ec_page; |
| 1568 { | 1569 { |
| 1569 AlwaysAllocateScope always_allocate(isolate); | 1570 AlwaysAllocateScope always_allocate(isolate); |
| 1570 obj = factory->NewJSObjectFromMap(map, TENURED, false); | 1571 obj = factory->NewJSObjectFromMap(map, TENURED, false); |
| 1571 CHECK(old_space->Contains(*obj)); | 1572 CHECK(old_space->Contains(*obj)); |
| 1572 | 1573 |
| 1573 // Make sure |obj_value| is placed on an old-space evacuation candidate. | 1574 // Make sure |obj_value| is placed on an old-space evacuation candidate. |
| 1574 SimulateFullSpace(old_space); | 1575 SimulateFullSpace(old_space); |
| 1575 obj_value = factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED); | 1576 obj_value = |
| 1577 factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, WEAK, TENURED); |
| 1576 ec_page = Page::FromAddress(obj_value->address()); | 1578 ec_page = Page::FromAddress(obj_value->address()); |
| 1577 CHECK_NE(ec_page, Page::FromAddress(obj->address())); | 1579 CHECK_NE(ec_page, Page::FromAddress(obj->address())); |
| 1578 } | 1580 } |
| 1579 | 1581 |
| 1580 // Heap is ready, force |ec_page| to become an evacuation candidate and | 1582 // Heap is ready, force |ec_page| to become an evacuation candidate and |
| 1581 // simulate incremental marking. | 1583 // simulate incremental marking. |
| 1582 ec_page->SetFlag(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING); | 1584 ec_page->SetFlag(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING); |
| 1583 SimulateIncrementalMarking(heap); | 1585 SimulateIncrementalMarking(heap); |
| 1584 | 1586 |
| 1585 // Check that everything is ready for triggering incremental write barrier | 1587 // Check that everything is ready for triggering incremental write barrier |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1681 | 1683 |
| 1682 // TODO(ishell): add respective tests for property kind reconfiguring from | 1684 // TODO(ishell): add respective tests for property kind reconfiguring from |
| 1683 // accessor field to double, once accessor fields are supported by | 1685 // accessor field to double, once accessor fields are supported by |
| 1684 // Map::ReconfigureProperty(). | 1686 // Map::ReconfigureProperty(). |
| 1685 | 1687 |
| 1686 | 1688 |
| 1687 // TODO(ishell): add respective tests for fast property removal case once | 1689 // TODO(ishell): add respective tests for fast property removal case once |
| 1688 // Map::ReconfigureProperty() supports that. | 1690 // Map::ReconfigureProperty() supports that. |
| 1689 | 1691 |
| 1690 #endif | 1692 #endif |
| OLD | NEW |