OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 "src/heap/slots-buffer.h" | 5 #include "src/heap/slots-buffer.h" |
6 #include "test/cctest/cctest.h" | 6 #include "test/cctest/cctest.h" |
7 #include "test/cctest/heap/utils-inl.h" | 7 #include "test/cctest/heap/heap-utils.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
11 | 11 |
12 TEST(SlotsBufferObjectSlotsRemoval) { | 12 TEST(SlotsBufferObjectSlotsRemoval) { |
13 CcTest::InitializeVM(); | 13 CcTest::InitializeVM(); |
14 v8::HandleScope scope(CcTest::isolate()); | 14 v8::HandleScope scope(CcTest::isolate()); |
15 Isolate* isolate = CcTest::i_isolate(); | 15 Isolate* isolate = CcTest::i_isolate(); |
16 Heap* heap = isolate->heap(); | 16 Heap* heap = isolate->heap(); |
17 Factory* factory = isolate->factory(); | 17 Factory* factory = isolate->factory(); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 factory->NewFixedArray(23, TENURED); | 94 factory->NewFixedArray(23, TENURED); |
95 mark_bit = Marking::MarkBitFrom(*old_space_object_non_evacuation); | 95 mark_bit = Marking::MarkBitFrom(*old_space_object_non_evacuation); |
96 Marking::MarkBlack(mark_bit); | 96 Marking::MarkBlack(mark_bit); |
97 Object** field_old_space_object_non_evacuation = | 97 Object** field_old_space_object_non_evacuation = |
98 fake_object->RawFieldOfElementAt(2); | 98 fake_object->RawFieldOfElementAt(2); |
99 *field_old_space_object_non_evacuation = *old_space_object_non_evacuation; | 99 *field_old_space_object_non_evacuation = *old_space_object_non_evacuation; |
100 buffer->Add(field_old_space_object_non_evacuation); | 100 buffer->Add(field_old_space_object_non_evacuation); |
101 | 101 |
102 // Write an old space reference into field 4 which points to an object on an | 102 // Write an old space reference into field 4 which points to an object on an |
103 // evacuation candidate. | 103 // evacuation candidate. |
104 SimulateFullSpace(heap->old_space()); | 104 heap::SimulateFullSpace(heap->old_space()); |
105 Handle<FixedArray> valid_object = | 105 Handle<FixedArray> valid_object = |
106 isolate->factory()->NewFixedArray(23, TENURED); | 106 isolate->factory()->NewFixedArray(23, TENURED); |
107 Page* page = Page::FromAddress(valid_object->address()); | 107 Page* page = Page::FromAddress(valid_object->address()); |
108 page->SetFlag(MemoryChunk::EVACUATION_CANDIDATE); | 108 page->SetFlag(MemoryChunk::EVACUATION_CANDIDATE); |
109 Object** valid_field = fake_object->RawFieldOfElementAt(3); | 109 Object** valid_field = fake_object->RawFieldOfElementAt(3); |
110 *valid_field = *valid_object; | 110 *valid_field = *valid_object; |
111 buffer->Add(valid_field); | 111 buffer->Add(valid_field); |
112 | 112 |
113 SlotsBuffer::RemoveInvalidSlots(heap, buffer); | 113 SlotsBuffer::RemoveInvalidSlots(heap, buffer); |
114 Object** kRemovedEntry = HeapObject::RawField(heap->empty_fixed_array(), | 114 Object** kRemovedEntry = HeapObject::RawField(heap->empty_fixed_array(), |
115 FixedArrayBase::kLengthOffset); | 115 FixedArrayBase::kLengthOffset); |
116 CHECK_EQ(buffer->Get(0), kRemovedEntry); | 116 CHECK_EQ(buffer->Get(0), kRemovedEntry); |
117 CHECK_EQ(buffer->Get(1), kRemovedEntry); | 117 CHECK_EQ(buffer->Get(1), kRemovedEntry); |
118 CHECK_EQ(buffer->Get(2), kRemovedEntry); | 118 CHECK_EQ(buffer->Get(2), kRemovedEntry); |
119 CHECK_EQ(buffer->Get(3), valid_field); | 119 CHECK_EQ(buffer->Get(3), valid_field); |
120 | 120 |
121 // Clean-up to make verify heap happy. | 121 // Clean-up to make verify heap happy. |
122 mark_bit = Marking::MarkBitFrom(*fake_object); | 122 mark_bit = Marking::MarkBitFrom(*fake_object); |
123 Marking::MarkWhite(mark_bit); | 123 Marking::MarkWhite(mark_bit); |
124 mark_bit = Marking::MarkBitFrom(*new_space_object); | 124 mark_bit = Marking::MarkBitFrom(*new_space_object); |
125 Marking::MarkWhite(mark_bit); | 125 Marking::MarkWhite(mark_bit); |
126 mark_bit = Marking::MarkBitFrom(*old_space_object_non_evacuation); | 126 mark_bit = Marking::MarkBitFrom(*old_space_object_non_evacuation); |
127 Marking::MarkWhite(mark_bit); | 127 Marking::MarkWhite(mark_bit); |
128 | 128 |
129 delete buffer; | 129 delete buffer; |
130 } | 130 } |
131 | 131 |
132 } // namespace internal | 132 } // namespace internal |
133 } // namespace v8 | 133 } // namespace v8 |
OLD | NEW |