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

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

Issue 16631002: Separate Cell and PropertyCell spaces (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove Mips changes Created 7 years, 6 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 | « src/incremental-marking.cc ('k') | src/mksnapshot.cc » ('j') | 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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 VerifyMarking(p->area_start(), p->area_end()); 141 VerifyMarking(p->area_start(), p->area_end());
142 } 142 }
143 } 143 }
144 144
145 145
146 static void VerifyMarking(Heap* heap) { 146 static void VerifyMarking(Heap* heap) {
147 VerifyMarking(heap->old_pointer_space()); 147 VerifyMarking(heap->old_pointer_space());
148 VerifyMarking(heap->old_data_space()); 148 VerifyMarking(heap->old_data_space());
149 VerifyMarking(heap->code_space()); 149 VerifyMarking(heap->code_space());
150 VerifyMarking(heap->cell_space()); 150 VerifyMarking(heap->cell_space());
151 VerifyMarking(heap->property_cell_space());
151 VerifyMarking(heap->map_space()); 152 VerifyMarking(heap->map_space());
152 VerifyMarking(heap->new_space()); 153 VerifyMarking(heap->new_space());
153 154
154 VerifyMarkingVisitor visitor; 155 VerifyMarkingVisitor visitor;
155 156
156 LargeObjectIterator it(heap->lo_space()); 157 LargeObjectIterator it(heap->lo_space());
157 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { 158 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) {
158 if (MarkCompactCollector::IsMarked(obj)) { 159 if (MarkCompactCollector::IsMarked(obj)) {
159 obj->Iterate(&visitor); 160 obj->Iterate(&visitor);
160 } 161 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 VerifyEvacuation(p->area_start(), p->area_end()); 223 VerifyEvacuation(p->area_start(), p->area_end());
223 } 224 }
224 } 225 }
225 226
226 227
227 static void VerifyEvacuation(Heap* heap) { 228 static void VerifyEvacuation(Heap* heap) {
228 VerifyEvacuation(heap->old_pointer_space()); 229 VerifyEvacuation(heap->old_pointer_space());
229 VerifyEvacuation(heap->old_data_space()); 230 VerifyEvacuation(heap->old_data_space());
230 VerifyEvacuation(heap->code_space()); 231 VerifyEvacuation(heap->code_space());
231 VerifyEvacuation(heap->cell_space()); 232 VerifyEvacuation(heap->cell_space());
233 VerifyEvacuation(heap->property_cell_space());
232 VerifyEvacuation(heap->map_space()); 234 VerifyEvacuation(heap->map_space());
233 VerifyEvacuation(heap->new_space()); 235 VerifyEvacuation(heap->new_space());
234 236
235 VerifyEvacuationVisitor visitor; 237 VerifyEvacuationVisitor visitor;
236 heap->IterateStrongRoots(&visitor, VISIT_ALL); 238 heap->IterateStrongRoots(&visitor, VISIT_ALL);
237 } 239 }
238 #endif // VERIFY_HEAP 240 #endif // VERIFY_HEAP
239 241
240 242
241 #ifdef DEBUG 243 #ifdef DEBUG
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 FixedArray* array = FixedArray::cast(object); 278 FixedArray* array = FixedArray::cast(object);
277 int length = array->length(); 279 int length = array->length();
278 // Set array length to zero to prevent cycles while iterating 280 // Set array length to zero to prevent cycles while iterating
279 // over array bodies, this is easier than intrusive marking. 281 // over array bodies, this is easier than intrusive marking.
280 array->set_length(0); 282 array->set_length(0);
281 array->IterateBody( 283 array->IterateBody(
282 FIXED_ARRAY_TYPE, FixedArray::SizeFor(length), this); 284 FIXED_ARRAY_TYPE, FixedArray::SizeFor(length), this);
283 array->set_length(length); 285 array->set_length(length);
284 } 286 }
285 break; 287 break;
286 case JS_GLOBAL_PROPERTY_CELL_TYPE: 288 case CELL_TYPE:
287 case JS_PROXY_TYPE: 289 case JS_PROXY_TYPE:
288 case JS_VALUE_TYPE: 290 case JS_VALUE_TYPE:
289 case TYPE_FEEDBACK_INFO_TYPE: 291 case TYPE_FEEDBACK_INFO_TYPE:
290 object->Iterate(this); 292 object->Iterate(this);
291 break; 293 break;
292 case DECLARED_ACCESSOR_INFO_TYPE: 294 case DECLARED_ACCESSOR_INFO_TYPE:
293 case EXECUTABLE_ACCESSOR_INFO_TYPE: 295 case EXECUTABLE_ACCESSOR_INFO_TYPE:
294 case BYTE_ARRAY_TYPE: 296 case BYTE_ARRAY_TYPE:
295 case CALL_HANDLER_INFO_TYPE: 297 case CALL_HANDLER_INFO_TYPE:
296 case CODE_TYPE: 298 case CODE_TYPE:
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 (mode == NON_INCREMENTAL_COMPACTION || 370 (mode == NON_INCREMENTAL_COMPACTION ||
369 FLAG_incremental_code_compaction)) { 371 FLAG_incremental_code_compaction)) {
370 CollectEvacuationCandidates(heap()->code_space()); 372 CollectEvacuationCandidates(heap()->code_space());
371 } else if (FLAG_trace_fragmentation) { 373 } else if (FLAG_trace_fragmentation) {
372 TraceFragmentation(heap()->code_space()); 374 TraceFragmentation(heap()->code_space());
373 } 375 }
374 376
375 if (FLAG_trace_fragmentation) { 377 if (FLAG_trace_fragmentation) {
376 TraceFragmentation(heap()->map_space()); 378 TraceFragmentation(heap()->map_space());
377 TraceFragmentation(heap()->cell_space()); 379 TraceFragmentation(heap()->cell_space());
380 TraceFragmentation(heap()->property_cell_space());
378 } 381 }
379 382
380 heap()->old_pointer_space()->EvictEvacuationCandidatesFromFreeLists(); 383 heap()->old_pointer_space()->EvictEvacuationCandidatesFromFreeLists();
381 heap()->old_data_space()->EvictEvacuationCandidatesFromFreeLists(); 384 heap()->old_data_space()->EvictEvacuationCandidatesFromFreeLists();
382 heap()->code_space()->EvictEvacuationCandidatesFromFreeLists(); 385 heap()->code_space()->EvictEvacuationCandidatesFromFreeLists();
383 386
384 compacting_ = evacuation_candidates_.length() > 0; 387 compacting_ = evacuation_candidates_.length() > 0;
385 } 388 }
386 389
387 return compacting_; 390 return compacting_;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 CHECK_EQ(0, p->LiveBytes()); 464 CHECK_EQ(0, p->LiveBytes());
462 } 465 }
463 } 466 }
464 467
465 468
466 void MarkCompactCollector::VerifyMarkbitsAreClean() { 469 void MarkCompactCollector::VerifyMarkbitsAreClean() {
467 VerifyMarkbitsAreClean(heap_->old_pointer_space()); 470 VerifyMarkbitsAreClean(heap_->old_pointer_space());
468 VerifyMarkbitsAreClean(heap_->old_data_space()); 471 VerifyMarkbitsAreClean(heap_->old_data_space());
469 VerifyMarkbitsAreClean(heap_->code_space()); 472 VerifyMarkbitsAreClean(heap_->code_space());
470 VerifyMarkbitsAreClean(heap_->cell_space()); 473 VerifyMarkbitsAreClean(heap_->cell_space());
474 VerifyMarkbitsAreClean(heap_->property_cell_space());
471 VerifyMarkbitsAreClean(heap_->map_space()); 475 VerifyMarkbitsAreClean(heap_->map_space());
472 VerifyMarkbitsAreClean(heap_->new_space()); 476 VerifyMarkbitsAreClean(heap_->new_space());
473 477
474 LargeObjectIterator it(heap_->lo_space()); 478 LargeObjectIterator it(heap_->lo_space());
475 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { 479 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) {
476 MarkBit mark_bit = Marking::MarkBitFrom(obj); 480 MarkBit mark_bit = Marking::MarkBitFrom(obj);
477 CHECK(Marking::IsWhite(mark_bit)); 481 CHECK(Marking::IsWhite(mark_bit));
478 CHECK_EQ(0, Page::FromAddress(obj->address())->LiveBytes()); 482 CHECK_EQ(0, Page::FromAddress(obj->address())->LiveBytes());
479 } 483 }
480 } 484 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 } 526 }
523 } 527 }
524 528
525 529
526 void MarkCompactCollector::ClearMarkbits() { 530 void MarkCompactCollector::ClearMarkbits() {
527 ClearMarkbitsInPagedSpace(heap_->code_space()); 531 ClearMarkbitsInPagedSpace(heap_->code_space());
528 ClearMarkbitsInPagedSpace(heap_->map_space()); 532 ClearMarkbitsInPagedSpace(heap_->map_space());
529 ClearMarkbitsInPagedSpace(heap_->old_pointer_space()); 533 ClearMarkbitsInPagedSpace(heap_->old_pointer_space());
530 ClearMarkbitsInPagedSpace(heap_->old_data_space()); 534 ClearMarkbitsInPagedSpace(heap_->old_data_space());
531 ClearMarkbitsInPagedSpace(heap_->cell_space()); 535 ClearMarkbitsInPagedSpace(heap_->cell_space());
536 ClearMarkbitsInPagedSpace(heap_->property_cell_space());
532 ClearMarkbitsInNewSpace(heap_->new_space()); 537 ClearMarkbitsInNewSpace(heap_->new_space());
533 538
534 LargeObjectIterator it(heap_->lo_space()); 539 LargeObjectIterator it(heap_->lo_space());
535 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { 540 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) {
536 MarkBit mark_bit = Marking::MarkBitFrom(obj); 541 MarkBit mark_bit = Marking::MarkBitFrom(obj);
537 mark_bit.Clear(); 542 mark_bit.Clear();
538 mark_bit.Next().Clear(); 543 mark_bit.Next().Clear();
539 Page::FromAddress(obj->address())->ResetProgressBar(); 544 Page::FromAddress(obj->address())->ResetProgressBar();
540 Page::FromAddress(obj->address())->ResetLiveBytes(); 545 Page::FromAddress(obj->address())->ResetLiveBytes();
541 } 546 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 646
642 647
643 const char* AllocationSpaceName(AllocationSpace space) { 648 const char* AllocationSpaceName(AllocationSpace space) {
644 switch (space) { 649 switch (space) {
645 case NEW_SPACE: return "NEW_SPACE"; 650 case NEW_SPACE: return "NEW_SPACE";
646 case OLD_POINTER_SPACE: return "OLD_POINTER_SPACE"; 651 case OLD_POINTER_SPACE: return "OLD_POINTER_SPACE";
647 case OLD_DATA_SPACE: return "OLD_DATA_SPACE"; 652 case OLD_DATA_SPACE: return "OLD_DATA_SPACE";
648 case CODE_SPACE: return "CODE_SPACE"; 653 case CODE_SPACE: return "CODE_SPACE";
649 case MAP_SPACE: return "MAP_SPACE"; 654 case MAP_SPACE: return "MAP_SPACE";
650 case CELL_SPACE: return "CELL_SPACE"; 655 case CELL_SPACE: return "CELL_SPACE";
656 case PROPERTY_CELL_SPACE:
657 return "PROPERTY_CELL_SPACE";
651 case LO_SPACE: return "LO_SPACE"; 658 case LO_SPACE: return "LO_SPACE";
652 default: 659 default:
653 UNREACHABLE(); 660 UNREACHABLE();
654 } 661 }
655 662
656 return NULL; 663 return NULL;
657 } 664 }
658 665
659 666
660 // Returns zero for pages that have so little fragmentation that it is not 667 // Returns zero for pages that have so little fragmentation that it is not
(...skipping 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after
2118 DiscoverGreyObjectsInSpace(heap(), 2125 DiscoverGreyObjectsInSpace(heap(),
2119 &marking_deque_, 2126 &marking_deque_,
2120 heap()->map_space()); 2127 heap()->map_space());
2121 if (marking_deque_.IsFull()) return; 2128 if (marking_deque_.IsFull()) return;
2122 2129
2123 DiscoverGreyObjectsInSpace(heap(), 2130 DiscoverGreyObjectsInSpace(heap(),
2124 &marking_deque_, 2131 &marking_deque_,
2125 heap()->cell_space()); 2132 heap()->cell_space());
2126 if (marking_deque_.IsFull()) return; 2133 if (marking_deque_.IsFull()) return;
2127 2134
2135 DiscoverGreyObjectsInSpace(heap(),
2136 &marking_deque_,
2137 heap()->property_cell_space());
2138 if (marking_deque_.IsFull()) return;
2139
2128 LargeObjectIterator lo_it(heap()->lo_space()); 2140 LargeObjectIterator lo_it(heap()->lo_space());
2129 DiscoverGreyObjectsWithIterator(heap(), 2141 DiscoverGreyObjectsWithIterator(heap(),
2130 &marking_deque_, 2142 &marking_deque_,
2131 &lo_it); 2143 &lo_it);
2132 if (marking_deque_.IsFull()) return; 2144 if (marking_deque_.IsFull()) return;
2133 2145
2134 marking_deque_.ClearOverflowed(); 2146 marking_deque_.ClearOverflowed();
2135 } 2147 }
2136 2148
2137 2149
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2211 2223
2212 PrepareForCodeFlushing(); 2224 PrepareForCodeFlushing();
2213 2225
2214 if (was_marked_incrementally_) { 2226 if (was_marked_incrementally_) {
2215 // There is no write barrier on cells so we have to scan them now at the end 2227 // There is no write barrier on cells so we have to scan them now at the end
2216 // of the incremental marking. 2228 // of the incremental marking.
2217 { 2229 {
2218 HeapObjectIterator cell_iterator(heap()->cell_space()); 2230 HeapObjectIterator cell_iterator(heap()->cell_space());
2219 HeapObject* cell; 2231 HeapObject* cell;
2220 while ((cell = cell_iterator.Next()) != NULL) { 2232 while ((cell = cell_iterator.Next()) != NULL) {
2233 ASSERT(cell->IsCell());
2234 if (IsMarked(cell)) {
2235 int offset = Cell::kValueOffset;
2236 MarkCompactMarkingVisitor::VisitPointer(
2237 heap(),
2238 reinterpret_cast<Object**>(cell->address() + offset));
2239 }
2240 }
2241 }
2242 {
2243 HeapObjectIterator js_global_property_cell_iterator(
2244 heap()->property_cell_space());
2245 HeapObject* cell;
2246 while ((cell = js_global_property_cell_iterator.Next()) != NULL) {
2221 ASSERT(cell->IsJSGlobalPropertyCell()); 2247 ASSERT(cell->IsJSGlobalPropertyCell());
2222 if (IsMarked(cell)) { 2248 if (IsMarked(cell)) {
2223 int offset = JSGlobalPropertyCell::kValueOffset; 2249 int offset = JSGlobalPropertyCell::kValueOffset;
2224 MarkCompactMarkingVisitor::VisitPointer( 2250 MarkCompactMarkingVisitor::VisitPointer(
2225 heap(), 2251 heap(),
2226 reinterpret_cast<Object**>(cell->address() + offset)); 2252 reinterpret_cast<Object**>(cell->address() + offset));
2253 offset = JSGlobalPropertyCell::kTypeOffset;
2254 MarkCompactMarkingVisitor::VisitPointer(
2255 heap(),
2256 reinterpret_cast<Object**>(cell->address() + offset));
2227 } 2257 }
2228 } 2258 }
2229 } 2259 }
2230 } 2260 }
2231 2261
2232 RootMarkingVisitor root_visitor(heap()); 2262 RootMarkingVisitor root_visitor(heap());
2233 MarkRoots(&root_visitor); 2263 MarkRoots(&root_visitor);
2234 2264
2235 // The objects reachable from the roots are marked, yet unreachable 2265 // The objects reachable from the roots are marked, yet unreachable
2236 // objects are unmarked. Mark objects reachable due to host 2266 // objects are unmarked. Mark objects reachable due to host
(...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after
3356 } 3386 }
3357 } 3387 }
3358 3388
3359 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_UPDATE_MISC_POINTERS); 3389 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_UPDATE_MISC_POINTERS);
3360 3390
3361 // Update pointers from cells. 3391 // Update pointers from cells.
3362 HeapObjectIterator cell_iterator(heap_->cell_space()); 3392 HeapObjectIterator cell_iterator(heap_->cell_space());
3363 for (HeapObject* cell = cell_iterator.Next(); 3393 for (HeapObject* cell = cell_iterator.Next();
3364 cell != NULL; 3394 cell != NULL;
3365 cell = cell_iterator.Next()) { 3395 cell = cell_iterator.Next()) {
3396 if (cell->IsCell()) {
3397 Address value_address = reinterpret_cast<Address>(cell) +
3398 (Cell::kValueOffset - kHeapObjectTag);
3399 updating_visitor.VisitPointer(reinterpret_cast<Object**>(value_address));
3400 }
3401 }
3402
3403 HeapObjectIterator js_global_property_cell_iterator(
3404 heap_->property_cell_space());
3405 for (HeapObject* cell = js_global_property_cell_iterator.Next();
3406 cell != NULL;
3407 cell = js_global_property_cell_iterator.Next()) {
3366 if (cell->IsJSGlobalPropertyCell()) { 3408 if (cell->IsJSGlobalPropertyCell()) {
3367 Address value_address = 3409 Address value_address =
3368 reinterpret_cast<Address>(cell) + 3410 reinterpret_cast<Address>(cell) +
3369 (JSGlobalPropertyCell::kValueOffset - kHeapObjectTag); 3411 (JSGlobalPropertyCell::kValueOffset - kHeapObjectTag);
3370 updating_visitor.VisitPointer(reinterpret_cast<Object**>(value_address)); 3412 updating_visitor.VisitPointer(reinterpret_cast<Object**>(value_address));
3413 Address type_address =
3414 reinterpret_cast<Address>(cell) +
3415 (JSGlobalPropertyCell::kTypeOffset - kHeapObjectTag);
3416 updating_visitor.VisitPointer(reinterpret_cast<Object**>(type_address));
3371 } 3417 }
3372 } 3418 }
3373 3419
3374 // Update pointer from the native contexts list. 3420 // Update pointer from the native contexts list.
3375 updating_visitor.VisitPointer(heap_->native_contexts_list_address()); 3421 updating_visitor.VisitPointer(heap_->native_contexts_list_address());
3376 3422
3377 heap_->string_table()->Iterate(&updating_visitor); 3423 heap_->string_table()->Iterate(&updating_visitor);
3378 3424
3379 // Update pointers from external string table. 3425 // Update pointers from external string table.
3380 heap_->UpdateReferencesInExternalStringTable( 3426 heap_->UpdateReferencesInExternalStringTable(
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
4022 } 4068 }
4023 4069
4024 if (how_to_sweep == PARALLEL_CONSERVATIVE) { 4070 if (how_to_sweep == PARALLEL_CONSERVATIVE) {
4025 WaitUntilSweepingCompleted(); 4071 WaitUntilSweepingCompleted();
4026 } 4072 }
4027 4073
4028 RemoveDeadInvalidatedCode(); 4074 RemoveDeadInvalidatedCode();
4029 SweepSpace(heap()->code_space(), PRECISE); 4075 SweepSpace(heap()->code_space(), PRECISE);
4030 4076
4031 SweepSpace(heap()->cell_space(), PRECISE); 4077 SweepSpace(heap()->cell_space(), PRECISE);
4078 SweepSpace(heap()->property_cell_space(), PRECISE);
4032 4079
4033 EvacuateNewSpaceAndCandidates(); 4080 EvacuateNewSpaceAndCandidates();
4034 4081
4035 // ClearNonLiveTransitions depends on precise sweeping of map space to 4082 // ClearNonLiveTransitions depends on precise sweeping of map space to
4036 // detect whether unmarked map became dead in this collection or in one 4083 // detect whether unmarked map became dead in this collection or in one
4037 // of the previous ones. 4084 // of the previous ones.
4038 SweepSpace(heap()->map_space(), PRECISE); 4085 SweepSpace(heap()->map_space(), PRECISE);
4039 4086
4040 // Deallocate unmarked objects and clear marked bits for marked objects. 4087 // Deallocate unmarked objects and clear marked bits for marked objects.
4041 heap_->lo_space()->FreeUnmarkedObjects(); 4088 heap_->lo_space()->FreeUnmarkedObjects();
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
4244 while (buffer != NULL) { 4291 while (buffer != NULL) {
4245 SlotsBuffer* next_buffer = buffer->next(); 4292 SlotsBuffer* next_buffer = buffer->next();
4246 DeallocateBuffer(buffer); 4293 DeallocateBuffer(buffer);
4247 buffer = next_buffer; 4294 buffer = next_buffer;
4248 } 4295 }
4249 *buffer_address = NULL; 4296 *buffer_address = NULL;
4250 } 4297 }
4251 4298
4252 4299
4253 } } // namespace v8::internal 4300 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/incremental-marking.cc ('k') | src/mksnapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698