Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2654 } | 2654 } |
| 2655 // Clear marking bits for current cell. | 2655 // Clear marking bits for current cell. |
| 2656 cells[cell_index] = 0; | 2656 cells[cell_index] = 0; |
| 2657 } | 2657 } |
| 2658 if (free_start != p->ObjectAreaEnd()) { | 2658 if (free_start != p->ObjectAreaEnd()) { |
| 2659 space->Free(free_start, static_cast<int>(p->ObjectAreaEnd() - free_start)); | 2659 space->Free(free_start, static_cast<int>(p->ObjectAreaEnd() - free_start)); |
| 2660 } | 2660 } |
| 2661 } | 2661 } |
| 2662 | 2662 |
| 2663 | 2663 |
| 2664 // Sweep a page of a space which contains objects of fixed size. This is used | |
| 2665 // for map space and cell space, it always sweeps those spaces precisely. | |
| 2666 template<int size> | |
| 2667 static void SweepSpecialized(PagedSpace* space, Page* p) { | |
| 2668 ASSERT(!p->IsEvacuationCandidate() && !p->WasSwept()); | |
| 2669 MarkBit::CellType* cells = p->markbits()->cells(); | |
| 2670 p->MarkSweptPrecisely(); | |
| 2671 | |
| 2672 int last_cell_index = | |
| 2673 Bitmap::IndexToCell( | |
| 2674 Bitmap::CellAlignIndex( | |
| 2675 p->AddressToMarkbitIndex(p->ObjectAreaEnd()))); | |
| 2676 | |
| 2677 int cell_index = Page::kFirstUsedCell; | |
| 2678 Address free_start = p->ObjectAreaStart(); | |
| 2679 Address free_end = p->ObjectAreaStart(); | |
| 2680 uint32_t mark_mask = 0; | |
| 2681 uint32_t mark_bits; | |
| 2682 | |
| 2683 ASSERT(size % kPointerSize == 0); | |
| 2684 int bits_per_object = size / kPointerSize; | |
| 2685 | |
| 2686 for (cell_index = Page::kFirstUsedCell; | |
| 2687 cell_index < last_cell_index || mark_mask != 0; | |
| 2688 free_end += size, mark_mask <<= bits_per_object) { | |
| 2689 if (mark_mask == 0) { | |
| 2690 mark_mask = 1 << (p->AddressToMarkbitIndex(free_end) % 32); | |
| 2691 mark_bits = cells[cell_index]; | |
| 2692 cells[cell_index] = 0; | |
| 2693 cell_index++; | |
| 2694 } | |
| 2695 printf("cell:0x%08x mask:0x%08x, idx=%d\n", mark_bits, mark_mask, cell_index ); | |
|
Erik Corry
2011/08/29 20:09:14
You don't want this printf.
Michael Starzinger
2011/08/30 07:33:07
Done (ooops).
| |
| 2696 if ((mark_bits & mark_mask) != 0) { | |
| 2697 if (free_end != free_start) { | |
| 2698 space->Free(free_start, static_cast<int>(free_end - free_start)); | |
| 2699 } | |
| 2700 free_start = free_end + size; | |
| 2701 } | |
| 2702 } | |
| 2703 if (free_start != p->ObjectAreaEnd()) { | |
| 2704 space->Free(free_start, static_cast<int>(p->ObjectAreaEnd() - free_start)); | |
| 2705 } | |
| 2706 } | |
| 2707 | |
| 2708 | |
| 2664 void MarkCompactCollector::EvacuateNewSpaceAndCandidates() { | 2709 void MarkCompactCollector::EvacuateNewSpaceAndCandidates() { |
| 2665 EvacuateNewSpace(); | 2710 EvacuateNewSpace(); |
| 2666 EvacuatePages(); | 2711 EvacuatePages(); |
| 2667 | 2712 |
| 2668 // Second pass: find pointers to new space and update them. | 2713 // Second pass: find pointers to new space and update them. |
| 2669 PointersUpdatingVisitor updating_visitor(heap()); | 2714 PointersUpdatingVisitor updating_visitor(heap()); |
| 2670 | 2715 |
| 2671 // Update pointers in to space. | 2716 // Update pointers in to space. |
| 2672 SemiSpaceIterator to_it(heap()->new_space()->bottom(), | 2717 SemiSpaceIterator to_it(heap()->new_space()->bottom(), |
| 2673 heap()->new_space()->top()); | 2718 heap()->new_space()->top()); |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3234 if (freed_bytes >= newspace_size && p != space->LastPage()) { | 3279 if (freed_bytes >= newspace_size && p != space->LastPage()) { |
| 3235 space->SetPagesToSweep(p->next_page(), space->LastPage()); | 3280 space->SetPagesToSweep(p->next_page(), space->LastPage()); |
| 3236 lazy_sweeping_active = true; | 3281 lazy_sweeping_active = true; |
| 3237 } | 3282 } |
| 3238 break; | 3283 break; |
| 3239 } | 3284 } |
| 3240 case PRECISE: { | 3285 case PRECISE: { |
| 3241 SweepPrecisely(space, p, SWEEP_ONLY); | 3286 SweepPrecisely(space, p, SWEEP_ONLY); |
| 3242 break; | 3287 break; |
| 3243 } | 3288 } |
| 3289 case PRECISE_CELLS: { | |
| 3290 SweepSpecialized<JSGlobalPropertyCell::kSize>(space, p); | |
| 3291 break; | |
| 3292 } | |
| 3293 case PRECISE_MAPS: { | |
| 3294 SweepSpecialized<Map::kSize>(space, p); | |
| 3295 break; | |
| 3296 } | |
| 3244 default: { | 3297 default: { |
| 3245 UNREACHABLE(); | 3298 UNREACHABLE(); |
| 3246 } | 3299 } |
| 3247 } | 3300 } |
| 3248 } | 3301 } |
| 3249 } | 3302 } |
| 3250 | 3303 |
| 3251 | 3304 |
| 3252 void MarkCompactCollector::SweepSpaces() { | 3305 void MarkCompactCollector::SweepSpaces() { |
| 3253 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_SWEEP); | 3306 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_SWEEP); |
| 3254 #ifdef DEBUG | 3307 #ifdef DEBUG |
| 3255 state_ = SWEEP_SPACES; | 3308 state_ = SWEEP_SPACES; |
| 3256 #endif | 3309 #endif |
| 3257 SweeperType how_to_sweep = | 3310 SweeperType how_to_sweep = |
| 3258 FLAG_lazy_sweeping ? LAZY_CONSERVATIVE : CONSERVATIVE; | 3311 FLAG_lazy_sweeping ? LAZY_CONSERVATIVE : CONSERVATIVE; |
| 3259 if (sweep_precisely_) how_to_sweep = PRECISE; | 3312 if (sweep_precisely_) how_to_sweep = PRECISE; |
| 3260 // Noncompacting collections simply sweep the spaces to clear the mark | 3313 // Noncompacting collections simply sweep the spaces to clear the mark |
| 3261 // bits and free the nonlive blocks (for old and map spaces). We sweep | 3314 // bits and free the nonlive blocks (for old and map spaces). We sweep |
| 3262 // the map space last because freeing non-live maps overwrites them and | 3315 // the map space last because freeing non-live maps overwrites them and |
| 3263 // the other spaces rely on possibly non-live maps to get the sizes for | 3316 // the other spaces rely on possibly non-live maps to get the sizes for |
| 3264 // non-live objects. | 3317 // non-live objects. |
| 3265 SweepSpace(heap()->old_pointer_space(), how_to_sweep); | 3318 SweepSpace(heap()->old_pointer_space(), how_to_sweep); |
| 3266 SweepSpace(heap()->old_data_space(), how_to_sweep); | 3319 SweepSpace(heap()->old_data_space(), how_to_sweep); |
| 3267 SweepSpace(heap()->code_space(), PRECISE); | 3320 SweepSpace(heap()->code_space(), PRECISE); |
| 3268 SweepSpace(heap()->cell_space(), PRECISE); | 3321 SweepSpace(heap()->cell_space(), PRECISE_CELLS); |
| 3269 { GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_SWEEP_NEWSPACE); | 3322 { GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_SWEEP_NEWSPACE); |
| 3270 EvacuateNewSpaceAndCandidates(); | 3323 EvacuateNewSpaceAndCandidates(); |
| 3271 } | 3324 } |
| 3272 // ClearNonLiveTransitions depends on precise sweeping of map space to | 3325 // ClearNonLiveTransitions depends on precise sweeping of map space to |
| 3273 // detect whether unmarked map became dead in this collection or in one | 3326 // detect whether unmarked map became dead in this collection or in one |
| 3274 // of the previous ones. | 3327 // of the previous ones. |
| 3275 SweepSpace(heap()->map_space(), PRECISE); | 3328 SweepSpace(heap()->map_space(), PRECISE_MAPS); |
| 3276 | 3329 |
| 3277 ASSERT(live_map_objects_size_ <= heap()->map_space()->Size()); | 3330 ASSERT(live_map_objects_size_ <= heap()->map_space()->Size()); |
| 3278 | 3331 |
| 3279 // Deallocate unmarked objects and clear marked bits for marked objects. | 3332 // Deallocate unmarked objects and clear marked bits for marked objects. |
| 3280 heap_->lo_space()->FreeUnmarkedObjects(); | 3333 heap_->lo_space()->FreeUnmarkedObjects(); |
| 3281 } | 3334 } |
| 3282 | 3335 |
| 3283 | 3336 |
| 3284 // TODO(1466) ReportDeleteIfNeeded is not called currently. | 3337 // TODO(1466) ReportDeleteIfNeeded is not called currently. |
| 3285 // Our profiling tools do not expect intersections between | 3338 // Our profiling tools do not expect intersections between |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3336 while (buffer != NULL) { | 3389 while (buffer != NULL) { |
| 3337 SlotsBuffer* next_buffer = buffer->next(); | 3390 SlotsBuffer* next_buffer = buffer->next(); |
| 3338 DeallocateBuffer(buffer); | 3391 DeallocateBuffer(buffer); |
| 3339 buffer = next_buffer; | 3392 buffer = next_buffer; |
| 3340 } | 3393 } |
| 3341 *buffer_address = NULL; | 3394 *buffer_address = NULL; |
| 3342 } | 3395 } |
| 3343 | 3396 |
| 3344 | 3397 |
| 3345 } } // namespace v8::internal | 3398 } } // namespace v8::internal |
| OLD | NEW |