Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: src/mark-compact.cc

Issue 407893004: Enable object evacuation verifier. Perform verification of evacuation candidates when sweeping is d… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/base/atomicops.h" 7 #include "src/base/atomicops.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/compilation-cache.h" 9 #include "src/compilation-cache.h"
10 #include "src/cpu-profiler.h" 10 #include "src/cpu-profiler.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 105 }
106 } 106 }
107 107
108 108
109 static void VerifyMarking(NewSpace* space) { 109 static void VerifyMarking(NewSpace* space) {
110 Address end = space->top(); 110 Address end = space->top();
111 NewSpacePageIterator it(space->bottom(), end); 111 NewSpacePageIterator it(space->bottom(), end);
112 // The bottom position is at the start of its page. Allows us to use 112 // The bottom position is at the start of its page. Allows us to use
113 // page->area_start() as start of range on all pages. 113 // page->area_start() as start of range on all pages.
114 CHECK_EQ(space->bottom(), 114 CHECK_EQ(space->bottom(),
115 NewSpacePage::FromAddress(space->bottom())->area_start()); 115 NewSpacePage::FromAddress(space->bottom())->area_start());
116 while (it.has_next()) { 116 while (it.has_next()) {
117 NewSpacePage* page = it.next(); 117 NewSpacePage* page = it.next();
118 Address limit = it.has_next() ? page->area_end() : end; 118 Address limit = it.has_next() ? page->area_end() : end;
119 CHECK(limit == end || !page->Contains(end)); 119 CHECK(limit == end || !page->Contains(end));
120 VerifyMarking(space->heap(), page->area_start(), limit); 120 VerifyMarking(space->heap(), page->area_start(), limit);
121 } 121 }
122 } 122 }
123 123
124 124
125 static void VerifyMarking(PagedSpace* space) { 125 static void VerifyMarking(PagedSpace* space) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 for (Object** current = start; current < end; current++) { 160 for (Object** current = start; current < end; current++) {
161 if ((*current)->IsHeapObject()) { 161 if ((*current)->IsHeapObject()) {
162 HeapObject* object = HeapObject::cast(*current); 162 HeapObject* object = HeapObject::cast(*current);
163 CHECK(!MarkCompactCollector::IsOnEvacuationCandidate(object)); 163 CHECK(!MarkCompactCollector::IsOnEvacuationCandidate(object));
164 } 164 }
165 } 165 }
166 } 166 }
167 }; 167 };
168 168
169 169
170 static void VerifyEvacuation(Address bottom, Address top) { 170 static void VerifyEvacuation(Page* page) {
171 VerifyEvacuationVisitor visitor; 171 VerifyEvacuationVisitor visitor;
172 HeapObject* object; 172 HeapObjectIterator iterator(page, NULL);
173 Address next_object_must_be_here_or_later = bottom; 173 for (HeapObject* heap_object = iterator.Next(); heap_object != NULL;
174 174 heap_object = iterator.Next()) {
Michael Starzinger 2014/07/21 14:58:55 nit: Indentation looks off.
Hannes Payer (out of office) 2014/07/21 15:11:42 nope, 4 spaces
175 for (Address current = bottom; 175 // We skip free space objects.
176 current < top; 176 if (!heap_object->IsFiller()) {
177 current += kPointerSize) { 177 heap_object->Iterate(&visitor);
178 object = HeapObject::FromAddress(current);
179 if (MarkCompactCollector::IsMarked(object)) {
180 CHECK(current >= next_object_must_be_here_or_later);
181 object->Iterate(&visitor);
182 next_object_must_be_here_or_later = current + object->Size();
183 } 178 }
184 } 179 }
185 } 180 }
186 181
187 182
188 static void VerifyEvacuation(NewSpace* space) { 183 static void VerifyEvacuation(NewSpace* space) {
189 NewSpacePageIterator it(space->bottom(), space->top()); 184 NewSpacePageIterator it(space->bottom(), space->top());
190 VerifyEvacuationVisitor visitor; 185 VerifyEvacuationVisitor visitor;
191 186
192 while (it.has_next()) { 187 while (it.has_next()) {
193 NewSpacePage* page = it.next(); 188 NewSpacePage* page = it.next();
194 Address current = page->area_start(); 189 Address current = page->area_start();
195 Address limit = it.has_next() ? page->area_end() : space->top(); 190 Address limit = it.has_next() ? page->area_end() : space->top();
196 CHECK(limit == space->top() || !page->Contains(space->top())); 191 CHECK(limit == space->top() || !page->Contains(space->top()));
197 while (current < limit) { 192 while (current < limit) {
198 HeapObject* object = HeapObject::FromAddress(current); 193 HeapObject* object = HeapObject::FromAddress(current);
199 object->Iterate(&visitor); 194 object->Iterate(&visitor);
200 current += object->Size(); 195 current += object->Size();
201 } 196 }
202 } 197 }
203 } 198 }
204 199
205 200
206 static void VerifyEvacuation(PagedSpace* space) { 201 static void VerifyEvacuation(Heap* heap, PagedSpace* space) {
207 // TODO(hpayer): Bring back VerifyEvacuation for parallel-concurrently 202 if (!space->swept_precisely()) return;
208 // swept pages. 203 if (FLAG_use_allocation_folding &&
209 if ((FLAG_concurrent_sweeping || FLAG_parallel_sweeping) && 204 (space == heap->old_pointer_space() || space == heap->old_data_space())) {
210 !space->swept_precisely()) return; 205 return;
206 }
211 PageIterator it(space); 207 PageIterator it(space);
212 208
213 while (it.has_next()) { 209 while (it.has_next()) {
214 Page* p = it.next(); 210 Page* p = it.next();
215 if (p->IsEvacuationCandidate()) continue; 211 if (p->IsEvacuationCandidate()) continue;
216 VerifyEvacuation(p->area_start(), p->area_end()); 212 VerifyEvacuation(p);
217 } 213 }
218 } 214 }
219 215
220 216
221 static void VerifyEvacuation(Heap* heap) { 217 static void VerifyEvacuation(Heap* heap) {
222 VerifyEvacuation(heap->old_pointer_space()); 218 VerifyEvacuation(heap, heap->old_pointer_space());
223 VerifyEvacuation(heap->old_data_space()); 219 VerifyEvacuation(heap, heap->old_data_space());
224 VerifyEvacuation(heap->code_space()); 220 VerifyEvacuation(heap, heap->code_space());
225 VerifyEvacuation(heap->cell_space()); 221 VerifyEvacuation(heap, heap->cell_space());
226 VerifyEvacuation(heap->property_cell_space()); 222 VerifyEvacuation(heap, heap->property_cell_space());
227 VerifyEvacuation(heap->map_space()); 223 VerifyEvacuation(heap, heap->map_space());
228 VerifyEvacuation(heap->new_space()); 224 VerifyEvacuation(heap->new_space());
229 225
230 VerifyEvacuationVisitor visitor; 226 VerifyEvacuationVisitor visitor;
231 heap->IterateStrongRoots(&visitor, VISIT_ALL); 227 heap->IterateStrongRoots(&visitor, VISIT_ALL);
232 } 228 }
233 #endif // VERIFY_HEAP 229 #endif // VERIFY_HEAP
234 230
235 231
236 #ifdef DEBUG 232 #ifdef DEBUG
237 class VerifyNativeContextSeparationVisitor: public ObjectVisitor { 233 class VerifyNativeContextSeparationVisitor: public ObjectVisitor {
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 // Wait twice for both jobs. 599 // Wait twice for both jobs.
604 pending_sweeper_jobs_semaphore_.Wait(); 600 pending_sweeper_jobs_semaphore_.Wait();
605 pending_sweeper_jobs_semaphore_.Wait(); 601 pending_sweeper_jobs_semaphore_.Wait();
606 } 602 }
607 ParallelSweepSpacesComplete(); 603 ParallelSweepSpacesComplete();
608 sweeping_in_progress_ = false; 604 sweeping_in_progress_ = false;
609 RefillFreeList(heap()->paged_space(OLD_DATA_SPACE)); 605 RefillFreeList(heap()->paged_space(OLD_DATA_SPACE));
610 RefillFreeList(heap()->paged_space(OLD_POINTER_SPACE)); 606 RefillFreeList(heap()->paged_space(OLD_POINTER_SPACE));
611 heap()->paged_space(OLD_DATA_SPACE)->ResetUnsweptFreeBytes(); 607 heap()->paged_space(OLD_DATA_SPACE)->ResetUnsweptFreeBytes();
612 heap()->paged_space(OLD_POINTER_SPACE)->ResetUnsweptFreeBytes(); 608 heap()->paged_space(OLD_POINTER_SPACE)->ResetUnsweptFreeBytes();
609
610 #ifdef VERIFY_HEAP
611 if (FLAG_verify_heap) {
612 VerifyEvacuation(heap_);
613 }
614 #endif
613 } 615 }
614 616
615 617
616 bool MarkCompactCollector::IsSweepingCompleted() { 618 bool MarkCompactCollector::IsSweepingCompleted() {
617 for (int i = 0; i < isolate()->num_sweeper_threads(); i++) { 619 for (int i = 0; i < isolate()->num_sweeper_threads(); i++) {
618 if (!isolate()->sweeper_threads()[i]->SweepingCompleted()) { 620 if (!isolate()->sweeper_threads()[i]->SweepingCompleted()) {
619 return false; 621 return false;
620 } 622 }
621 } 623 }
622 624
(...skipping 3025 matching lines...) Expand 10 before | Expand all | Expand 10 after
3648 3650
3649 EvacuationWeakObjectRetainer evacuation_object_retainer; 3651 EvacuationWeakObjectRetainer evacuation_object_retainer;
3650 heap()->ProcessWeakReferences(&evacuation_object_retainer); 3652 heap()->ProcessWeakReferences(&evacuation_object_retainer);
3651 3653
3652 // Visit invalidated code (we ignored all slots on it) and clear mark-bits 3654 // Visit invalidated code (we ignored all slots on it) and clear mark-bits
3653 // under it. 3655 // under it.
3654 ProcessInvalidatedCode(&updating_visitor); 3656 ProcessInvalidatedCode(&updating_visitor);
3655 3657
3656 heap_->isolate()->inner_pointer_to_code_cache()->Flush(); 3658 heap_->isolate()->inner_pointer_to_code_cache()->Flush();
3657 3659
3658 #ifdef VERIFY_HEAP
3659 if (FLAG_verify_heap) {
3660 VerifyEvacuation(heap_);
3661 }
3662 #endif
3663
3664 slots_buffer_allocator_.DeallocateChain(&migration_slots_buffer_); 3660 slots_buffer_allocator_.DeallocateChain(&migration_slots_buffer_);
3665 ASSERT(migration_slots_buffer_ == NULL); 3661 ASSERT(migration_slots_buffer_ == NULL);
3666 } 3662 }
3667 3663
3668 3664
3669 void MarkCompactCollector::MoveEvacuationCandidatesToEndOfPagesList() { 3665 void MarkCompactCollector::MoveEvacuationCandidatesToEndOfPagesList() {
3670 int npages = evacuation_candidates_.length(); 3666 int npages = evacuation_candidates_.length();
3671 for (int i = 0; i < npages; i++) { 3667 for (int i = 0; i < npages; i++) {
3672 Page* p = evacuation_candidates_[i]; 3668 Page* p = evacuation_candidates_[i];
3673 if (!p->IsEvacuationCandidate()) continue; 3669 if (!p->IsEvacuationCandidate()) continue;
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
4580 while (buffer != NULL) { 4576 while (buffer != NULL) {
4581 SlotsBuffer* next_buffer = buffer->next(); 4577 SlotsBuffer* next_buffer = buffer->next();
4582 DeallocateBuffer(buffer); 4578 DeallocateBuffer(buffer);
4583 buffer = next_buffer; 4579 buffer = next_buffer;
4584 } 4580 }
4585 *buffer_address = NULL; 4581 *buffer_address = NULL;
4586 } 4582 }
4587 4583
4588 4584
4589 } } // namespace v8::internal 4585 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698