| OLD | NEW |
| 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/heap/mark-compact.h" | 5 #include "src/heap/mark-compact.h" |
| 6 | 6 |
| 7 #include "src/base/atomicops.h" | 7 #include "src/base/atomicops.h" |
| 8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
| 9 #include "src/base/sys-info.h" | 9 #include "src/base/sys-info.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 CHECK(Marking::IsBlack(Marking::MarkBitFrom(object))); | 115 CHECK(Marking::IsBlack(Marking::MarkBitFrom(object))); |
| 116 CHECK(current >= next_object_must_be_here_or_later); | 116 CHECK(current >= next_object_must_be_here_or_later); |
| 117 object->Iterate(&visitor); | 117 object->Iterate(&visitor); |
| 118 next_object_must_be_here_or_later = current + object->Size(); | 118 next_object_must_be_here_or_later = current + object->Size(); |
| 119 // The next word for sure belongs to the current object, jump over it. | 119 // The next word for sure belongs to the current object, jump over it. |
| 120 current += kPointerSize; | 120 current += kPointerSize; |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 | 124 |
| 125 static void VerifyMarkingBlackPage(Heap* heap, Page* page) { |
| 126 CHECK(page->IsFlagSet(Page::BLACK_PAGE)); |
| 127 VerifyMarkingVisitor visitor(heap); |
| 128 HeapObjectIterator it(page); |
| 129 for (HeapObject* object = it.Next(); object != NULL; object = it.Next()) { |
| 130 CHECK(Marking::IsBlack(Marking::MarkBitFrom(object))); |
| 131 object->Iterate(&visitor); |
| 132 } |
| 133 } |
| 125 | 134 |
| 126 static void VerifyMarking(NewSpace* space) { | 135 static void VerifyMarking(NewSpace* space) { |
| 127 Address end = space->top(); | 136 Address end = space->top(); |
| 128 NewSpacePageIterator it(space->bottom(), end); | 137 NewSpacePageIterator it(space->bottom(), end); |
| 129 // The bottom position is at the start of its page. Allows us to use | 138 // The bottom position is at the start of its page. Allows us to use |
| 130 // page->area_start() as start of range on all pages. | 139 // page->area_start() as start of range on all pages. |
| 131 CHECK_EQ(space->bottom(), | 140 CHECK_EQ(space->bottom(), |
| 132 NewSpacePage::FromAddress(space->bottom())->area_start()); | 141 NewSpacePage::FromAddress(space->bottom())->area_start()); |
| 133 while (it.has_next()) { | 142 while (it.has_next()) { |
| 134 NewSpacePage* page = it.next(); | 143 NewSpacePage* page = it.next(); |
| 135 Address limit = it.has_next() ? page->area_end() : end; | 144 Address limit = it.has_next() ? page->area_end() : end; |
| 136 CHECK(limit == end || !page->Contains(end)); | 145 CHECK(limit == end || !page->Contains(end)); |
| 137 VerifyMarking(space->heap(), page->area_start(), limit); | 146 VerifyMarking(space->heap(), page->area_start(), limit); |
| 138 } | 147 } |
| 139 } | 148 } |
| 140 | 149 |
| 141 | 150 |
| 142 static void VerifyMarking(PagedSpace* space) { | 151 static void VerifyMarking(PagedSpace* space) { |
| 143 PageIterator it(space); | 152 PageIterator it(space); |
| 144 | 153 |
| 145 while (it.has_next()) { | 154 while (it.has_next()) { |
| 146 Page* p = it.next(); | 155 Page* p = it.next(); |
| 147 VerifyMarking(space->heap(), p->area_start(), p->area_end()); | 156 if (p->IsFlagSet(Page::BLACK_PAGE)) { |
| 157 VerifyMarkingBlackPage(space->heap(), p); |
| 158 } else { |
| 159 VerifyMarking(space->heap(), p->area_start(), p->area_end()); |
| 160 } |
| 148 } | 161 } |
| 149 } | 162 } |
| 150 | 163 |
| 151 | 164 |
| 152 static void VerifyMarking(Heap* heap) { | 165 static void VerifyMarking(Heap* heap) { |
| 153 VerifyMarking(heap->old_space()); | 166 VerifyMarking(heap->old_space()); |
| 154 VerifyMarking(heap->code_space()); | 167 VerifyMarking(heap->code_space()); |
| 155 VerifyMarking(heap->map_space()); | 168 VerifyMarking(heap->map_space()); |
| 156 VerifyMarking(heap->new_space()); | 169 VerifyMarking(heap->new_space()); |
| 157 | 170 |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 map->VerifyOmittedMapChecks(); | 454 map->VerifyOmittedMapChecks(); |
| 442 } | 455 } |
| 443 } | 456 } |
| 444 #endif // VERIFY_HEAP | 457 #endif // VERIFY_HEAP |
| 445 | 458 |
| 446 | 459 |
| 447 static void ClearMarkbitsInPagedSpace(PagedSpace* space) { | 460 static void ClearMarkbitsInPagedSpace(PagedSpace* space) { |
| 448 PageIterator it(space); | 461 PageIterator it(space); |
| 449 | 462 |
| 450 while (it.has_next()) { | 463 while (it.has_next()) { |
| 451 Bitmap::Clear(it.next()); | 464 Page* p = it.next(); |
| 465 Bitmap::Clear(p); |
| 466 if (p->IsFlagSet(Page::BLACK_PAGE)) { |
| 467 p->ClearFlag(Page::BLACK_PAGE); |
| 468 } |
| 452 } | 469 } |
| 453 } | 470 } |
| 454 | 471 |
| 455 | 472 |
| 456 static void ClearMarkbitsInNewSpace(NewSpace* space) { | 473 static void ClearMarkbitsInNewSpace(NewSpace* space) { |
| 457 NewSpacePageIterator it(space->ToSpaceStart(), space->ToSpaceEnd()); | 474 NewSpacePageIterator it(space->ToSpaceStart(), space->ToSpaceEnd()); |
| 458 | 475 |
| 459 while (it.has_next()) { | 476 while (it.has_next()) { |
| 460 Bitmap::Clear(it.next()); | 477 Bitmap::Clear(it.next()); |
| 461 } | 478 } |
| 462 } | 479 } |
| 463 | 480 |
| 464 | 481 |
| 465 void MarkCompactCollector::ClearMarkbits() { | 482 void MarkCompactCollector::ClearMarkbits() { |
| 466 ClearMarkbitsInPagedSpace(heap_->code_space()); | 483 ClearMarkbitsInPagedSpace(heap_->code_space()); |
| 467 ClearMarkbitsInPagedSpace(heap_->map_space()); | 484 ClearMarkbitsInPagedSpace(heap_->map_space()); |
| 468 ClearMarkbitsInPagedSpace(heap_->old_space()); | 485 ClearMarkbitsInPagedSpace(heap_->old_space()); |
| 469 ClearMarkbitsInNewSpace(heap_->new_space()); | 486 ClearMarkbitsInNewSpace(heap_->new_space()); |
| 470 | 487 |
| 471 LargeObjectIterator it(heap_->lo_space()); | 488 LargeObjectIterator it(heap_->lo_space()); |
| 472 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { | 489 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { |
| 473 Marking::MarkWhite(Marking::MarkBitFrom(obj)); | 490 Marking::MarkWhite(Marking::MarkBitFrom(obj)); |
| 474 Page::FromAddress(obj->address())->ResetProgressBar(); | 491 MemoryChunk* chunk = MemoryChunk::FromAddress(obj->address()); |
| 475 Page::FromAddress(obj->address())->ResetLiveBytes(); | 492 chunk->ResetProgressBar(); |
| 493 chunk->ResetLiveBytes(); |
| 494 if (chunk->IsFlagSet(Page::BLACK_PAGE)) { |
| 495 chunk->ClearFlag(Page::BLACK_PAGE); |
| 496 } |
| 476 } | 497 } |
| 477 } | 498 } |
| 478 | 499 |
| 479 | 500 |
| 480 class MarkCompactCollector::SweeperTask : public v8::Task { | 501 class MarkCompactCollector::SweeperTask : public v8::Task { |
| 481 public: | 502 public: |
| 482 SweeperTask(Heap* heap, AllocationSpace space_to_start) | 503 SweeperTask(Heap* heap, AllocationSpace space_to_start) |
| 483 : heap_(heap), space_to_start_(space_to_start) {} | 504 : heap_(heap), space_to_start_(space_to_start) {} |
| 484 | 505 |
| 485 virtual ~SweeperTask() {} | 506 virtual ~SweeperTask() {} |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 pending_sweeper_tasks_semaphore_.Signal(); | 603 pending_sweeper_tasks_semaphore_.Signal(); |
| 583 return true; | 604 return true; |
| 584 } | 605 } |
| 585 | 606 |
| 586 | 607 |
| 587 void Marking::TransferMark(Heap* heap, Address old_start, Address new_start) { | 608 void Marking::TransferMark(Heap* heap, Address old_start, Address new_start) { |
| 588 // This is only used when resizing an object. | 609 // This is only used when resizing an object. |
| 589 DCHECK(MemoryChunk::FromAddress(old_start) == | 610 DCHECK(MemoryChunk::FromAddress(old_start) == |
| 590 MemoryChunk::FromAddress(new_start)); | 611 MemoryChunk::FromAddress(new_start)); |
| 591 | 612 |
| 592 if (!heap->incremental_marking()->IsMarking()) return; | 613 if (!heap->incremental_marking()->IsMarking() || |
| 614 Page::FromAddress(old_start)->IsFlagSet(Page::BLACK_PAGE)) |
| 615 return; |
| 593 | 616 |
| 594 // If the mark doesn't move, we don't check the color of the object. | 617 // If the mark doesn't move, we don't check the color of the object. |
| 595 // It doesn't matter whether the object is black, since it hasn't changed | 618 // It doesn't matter whether the object is black, since it hasn't changed |
| 596 // size, so the adjustment to the live data count will be zero anyway. | 619 // size, so the adjustment to the live data count will be zero anyway. |
| 597 if (old_start == new_start) return; | 620 if (old_start == new_start) return; |
| 598 | 621 |
| 599 MarkBit new_mark_bit = MarkBitFrom(new_start); | 622 MarkBit new_mark_bit = MarkBitFrom(new_start); |
| 600 MarkBit old_mark_bit = MarkBitFrom(old_start); | 623 MarkBit old_mark_bit = MarkBitFrom(old_start); |
| 601 | 624 |
| 602 #ifdef DEBUG | 625 #ifdef DEBUG |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 | 714 |
| 692 // Pairs of (live_bytes_in_page, page). | 715 // Pairs of (live_bytes_in_page, page). |
| 693 typedef std::pair<int, Page*> LiveBytesPagePair; | 716 typedef std::pair<int, Page*> LiveBytesPagePair; |
| 694 std::vector<LiveBytesPagePair> pages; | 717 std::vector<LiveBytesPagePair> pages; |
| 695 pages.reserve(number_of_pages); | 718 pages.reserve(number_of_pages); |
| 696 | 719 |
| 697 PageIterator it(space); | 720 PageIterator it(space); |
| 698 while (it.has_next()) { | 721 while (it.has_next()) { |
| 699 Page* p = it.next(); | 722 Page* p = it.next(); |
| 700 if (p->NeverEvacuate()) continue; | 723 if (p->NeverEvacuate()) continue; |
| 724 if (p->IsFlagSet(Page::BLACK_PAGE)) continue; |
| 701 if (p->IsFlagSet(Page::POPULAR_PAGE)) { | 725 if (p->IsFlagSet(Page::POPULAR_PAGE)) { |
| 702 // This page had slots buffer overflow on previous GC, skip it. | 726 // This page had slots buffer overflow on previous GC, skip it. |
| 703 p->ClearFlag(Page::POPULAR_PAGE); | 727 p->ClearFlag(Page::POPULAR_PAGE); |
| 704 continue; | 728 continue; |
| 705 } | 729 } |
| 706 // Invariant: Evacuation candidates are just created when marking is | 730 // Invariant: Evacuation candidates are just created when marking is |
| 707 // started. This means that sweeping has finished. Furthermore, at the end | 731 // started. This means that sweeping has finished. Furthermore, at the end |
| 708 // of a GC all evacuation candidates are cleared and their slot buffers are | 732 // of a GC all evacuation candidates are cleared and their slot buffers are |
| 709 // released. | 733 // released. |
| 710 CHECK(!p->IsEvacuationCandidate()); | 734 CHECK(!p->IsEvacuationCandidate()); |
| (...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1734 } | 1758 } |
| 1735 return false; | 1759 return false; |
| 1736 } | 1760 } |
| 1737 }; | 1761 }; |
| 1738 | 1762 |
| 1739 | 1763 |
| 1740 void MarkCompactCollector::DiscoverGreyObjectsInSpace(PagedSpace* space) { | 1764 void MarkCompactCollector::DiscoverGreyObjectsInSpace(PagedSpace* space) { |
| 1741 PageIterator it(space); | 1765 PageIterator it(space); |
| 1742 while (it.has_next()) { | 1766 while (it.has_next()) { |
| 1743 Page* p = it.next(); | 1767 Page* p = it.next(); |
| 1744 DiscoverGreyObjectsOnPage(p); | 1768 if (!p->IsFlagSet(Page::BLACK_PAGE)) { |
| 1745 if (marking_deque()->IsFull()) return; | 1769 DiscoverGreyObjectsOnPage(p); |
| 1770 if (marking_deque()->IsFull()) return; |
| 1771 } |
| 1746 } | 1772 } |
| 1747 } | 1773 } |
| 1748 | 1774 |
| 1749 | 1775 |
| 1750 void MarkCompactCollector::DiscoverGreyObjectsInNewSpace() { | 1776 void MarkCompactCollector::DiscoverGreyObjectsInNewSpace() { |
| 1751 NewSpace* space = heap()->new_space(); | 1777 NewSpace* space = heap()->new_space(); |
| 1752 NewSpacePageIterator it(space->bottom(), space->top()); | 1778 NewSpacePageIterator it(space->bottom(), space->top()); |
| 1753 while (it.has_next()) { | 1779 while (it.has_next()) { |
| 1754 NewSpacePage* page = it.next(); | 1780 NewSpacePage* page = it.next(); |
| 1755 DiscoverGreyObjectsOnPage(page); | 1781 DiscoverGreyObjectsOnPage(page); |
| (...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2915 // for it. | 2941 // for it. |
| 2916 CHECK(large_object->IsHeapObject()); | 2942 CHECK(large_object->IsHeapObject()); |
| 2917 HeapObject* large_heap_object = HeapObject::cast(large_object); | 2943 HeapObject* large_heap_object = HeapObject::cast(large_object); |
| 2918 if (IsMarked(large_heap_object)) { | 2944 if (IsMarked(large_heap_object)) { |
| 2919 *out_object = large_heap_object; | 2945 *out_object = large_heap_object; |
| 2920 return true; | 2946 return true; |
| 2921 } | 2947 } |
| 2922 return false; | 2948 return false; |
| 2923 } | 2949 } |
| 2924 | 2950 |
| 2951 // If we are on a black page, we cannot find the actual object start |
| 2952 // easiliy. We just return true but do not set the out_object. |
| 2953 if (p->IsFlagSet(Page::BLACK_PAGE)) { |
| 2954 return true; |
| 2955 } |
| 2956 |
| 2925 uint32_t mark_bit_index = p->AddressToMarkbitIndex(slot); | 2957 uint32_t mark_bit_index = p->AddressToMarkbitIndex(slot); |
| 2926 unsigned int cell_index = mark_bit_index >> Bitmap::kBitsPerCellLog2; | 2958 unsigned int cell_index = mark_bit_index >> Bitmap::kBitsPerCellLog2; |
| 2927 MarkBit::CellType index_mask = 1u << Bitmap::IndexInCell(mark_bit_index); | 2959 MarkBit::CellType index_mask = 1u << Bitmap::IndexInCell(mark_bit_index); |
| 2928 MarkBit::CellType* cells = p->markbits()->cells(); | 2960 MarkBit::CellType* cells = p->markbits()->cells(); |
| 2929 Address base_address = p->area_start(); | 2961 Address base_address = p->area_start(); |
| 2930 unsigned int base_address_cell_index = Bitmap::IndexToCell( | 2962 unsigned int base_address_cell_index = Bitmap::IndexToCell( |
| 2931 Bitmap::CellAlignIndex(p->AddressToMarkbitIndex(base_address))); | 2963 Bitmap::CellAlignIndex(p->AddressToMarkbitIndex(base_address))); |
| 2932 | 2964 |
| 2933 // Check if the slot points to the start of an object. This can happen e.g. | 2965 // Check if the slot points to the start of an object. This can happen e.g. |
| 2934 // when we left trim a fixed array. Such slots are invalid and we can remove | 2966 // when we left trim a fixed array. Such slots are invalid and we can remove |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2995 // Slots pointing to the first word of an object are invalid and removed. | 3027 // Slots pointing to the first word of an object are invalid and removed. |
| 2996 // This can happen when we move the object header while left trimming. | 3028 // This can happen when we move the object header while left trimming. |
| 2997 *out_object = object; | 3029 *out_object = object; |
| 2998 return true; | 3030 return true; |
| 2999 } | 3031 } |
| 3000 return false; | 3032 return false; |
| 3001 } | 3033 } |
| 3002 | 3034 |
| 3003 | 3035 |
| 3004 bool MarkCompactCollector::IsSlotInBlackObjectSlow(Page* p, Address slot) { | 3036 bool MarkCompactCollector::IsSlotInBlackObjectSlow(Page* p, Address slot) { |
| 3005 // This function does not support large objects right now. | |
| 3006 Space* owner = p->owner(); | 3037 Space* owner = p->owner(); |
| 3007 if (owner == heap_->lo_space() || owner == NULL) { | 3038 if (owner == heap_->lo_space() || owner == NULL) { |
| 3008 Object* large_object = heap_->lo_space()->FindObject(slot); | 3039 Object* large_object = heap_->lo_space()->FindObject(slot); |
| 3009 // This object has to exist, otherwise we would not have recorded a slot | 3040 // This object has to exist, otherwise we would not have recorded a slot |
| 3010 // for it. | 3041 // for it. |
| 3011 CHECK(large_object->IsHeapObject()); | 3042 CHECK(large_object->IsHeapObject()); |
| 3012 HeapObject* large_heap_object = HeapObject::cast(large_object); | 3043 HeapObject* large_heap_object = HeapObject::cast(large_object); |
| 3013 if (IsMarked(large_heap_object)) { | 3044 if (IsMarked(large_heap_object)) { |
| 3014 return true; | 3045 return true; |
| 3015 } | 3046 } |
| 3016 return false; | 3047 return false; |
| 3017 } | 3048 } |
| 3018 | 3049 |
| 3050 if (p->IsFlagSet(Page::BLACK_PAGE)) return true; |
| 3051 |
| 3019 LiveObjectIterator<kBlackObjects> it(p); | 3052 LiveObjectIterator<kBlackObjects> it(p); |
| 3020 HeapObject* object = NULL; | 3053 HeapObject* object = NULL; |
| 3021 while ((object = it.Next()) != NULL) { | 3054 while ((object = it.Next()) != NULL) { |
| 3022 int size = object->Size(); | 3055 int size = object->Size(); |
| 3023 | 3056 |
| 3024 if (object->address() > slot) return false; | 3057 if (object->address() > slot) return false; |
| 3025 if (object->address() <= slot && slot < (object->address() + size)) { | 3058 if (object->address() <= slot && slot < (object->address() + size)) { |
| 3026 return true; | 3059 return true; |
| 3027 } | 3060 } |
| 3028 } | 3061 } |
| 3029 return false; | 3062 return false; |
| 3030 } | 3063 } |
| 3031 | 3064 |
| 3032 | 3065 |
| 3033 bool MarkCompactCollector::IsSlotInLiveObject(Address slot) { | 3066 bool MarkCompactCollector::IsSlotInLiveObject(Address slot) { |
| 3034 HeapObject* object = NULL; | |
| 3035 // The target object is black but we don't know if the source slot is black. | 3067 // The target object is black but we don't know if the source slot is black. |
| 3036 // The source object could have died and the slot could be part of a free | 3068 // The source object could have died and the slot could be part of a free |
| 3037 // space. Find out based on mark bits if the slot is part of a live object. | 3069 // space. Find out based on mark bits if the slot is part of a live object. |
| 3038 if (!IsSlotInBlackObject(Page::FromAddress(slot), slot, &object)) { | 3070 Page* page = Page::FromAddress(slot); |
| 3071 HeapObject* object = NULL; |
| 3072 if (!IsSlotInBlackObject(page, slot, &object)) { |
| 3039 return false; | 3073 return false; |
| 3040 } | 3074 } |
| 3041 | 3075 |
| 3042 DCHECK(object != NULL); | 3076 // If the slot is on a black page, the object will be live. |
| 3077 DCHECK(object != NULL || page->IsFlagSet(Page::BLACK_PAGE)); |
| 3078 if (page->IsFlagSet(Page::BLACK_PAGE)) { |
| 3079 return true; |
| 3080 } |
| 3081 |
| 3043 int offset = static_cast<int>(slot - object->address()); | 3082 int offset = static_cast<int>(slot - object->address()); |
| 3044 return object->IsValidSlot(offset); | 3083 return object->IsValidSlot(offset); |
| 3045 } | 3084 } |
| 3046 | 3085 |
| 3047 | 3086 |
| 3048 void MarkCompactCollector::VerifyIsSlotInLiveObject(Address slot, | 3087 void MarkCompactCollector::VerifyIsSlotInLiveObject(Address slot, |
| 3049 HeapObject* object) { | 3088 HeapObject* object) { |
| 3050 // The target object has to be black. | 3089 // The target object has to be black. |
| 3051 CHECK(Marking::IsBlack(Marking::MarkBitFrom(object))); | 3090 CHECK(Marking::IsBlack(Marking::MarkBitFrom(object))); |
| 3052 | 3091 |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3434 // Slots in live objects pointing into evacuation candidates are updated | 3473 // Slots in live objects pointing into evacuation candidates are updated |
| 3435 // if requested. | 3474 // if requested. |
| 3436 // Returns the size of the biggest continuous freed memory chunk in bytes. | 3475 // Returns the size of the biggest continuous freed memory chunk in bytes. |
| 3437 template <SweepingMode sweeping_mode, | 3476 template <SweepingMode sweeping_mode, |
| 3438 MarkCompactCollector::SweepingParallelism parallelism, | 3477 MarkCompactCollector::SweepingParallelism parallelism, |
| 3439 SkipListRebuildingMode skip_list_mode, | 3478 SkipListRebuildingMode skip_list_mode, |
| 3440 FreeSpaceTreatmentMode free_space_mode> | 3479 FreeSpaceTreatmentMode free_space_mode> |
| 3441 static int Sweep(PagedSpace* space, FreeList* free_list, Page* p, | 3480 static int Sweep(PagedSpace* space, FreeList* free_list, Page* p, |
| 3442 ObjectVisitor* v) { | 3481 ObjectVisitor* v) { |
| 3443 DCHECK(!p->IsEvacuationCandidate() && !p->SweepingDone()); | 3482 DCHECK(!p->IsEvacuationCandidate() && !p->SweepingDone()); |
| 3483 DCHECK(!p->IsFlagSet(Page::BLACK_PAGE)); |
| 3444 DCHECK_EQ(skip_list_mode == REBUILD_SKIP_LIST, | 3484 DCHECK_EQ(skip_list_mode == REBUILD_SKIP_LIST, |
| 3445 space->identity() == CODE_SPACE); | 3485 space->identity() == CODE_SPACE); |
| 3446 DCHECK((p->skip_list() == NULL) || (skip_list_mode == REBUILD_SKIP_LIST)); | 3486 DCHECK((p->skip_list() == NULL) || (skip_list_mode == REBUILD_SKIP_LIST)); |
| 3447 DCHECK(parallelism == MarkCompactCollector::SWEEP_ON_MAIN_THREAD || | 3487 DCHECK(parallelism == MarkCompactCollector::SWEEP_ON_MAIN_THREAD || |
| 3448 sweeping_mode == SWEEP_ONLY); | 3488 sweeping_mode == SWEEP_ONLY); |
| 3449 | 3489 |
| 3450 Address free_start = p->area_start(); | 3490 Address free_start = p->area_start(); |
| 3451 DCHECK(reinterpret_cast<intptr_t>(free_start) % (32 * kPointerSize) == 0); | 3491 DCHECK(reinterpret_cast<intptr_t>(free_start) % (32 * kPointerSize) == 0); |
| 3452 | 3492 |
| 3453 // If we use the skip list for code space pages, we have to lock the skip | 3493 // If we use the skip list for code space pages, we have to lock the skip |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3896 | 3936 |
| 3897 PageIterator it(space); | 3937 PageIterator it(space); |
| 3898 | 3938 |
| 3899 int will_be_swept = 0; | 3939 int will_be_swept = 0; |
| 3900 bool unused_page_present = false; | 3940 bool unused_page_present = false; |
| 3901 | 3941 |
| 3902 while (it.has_next()) { | 3942 while (it.has_next()) { |
| 3903 Page* p = it.next(); | 3943 Page* p = it.next(); |
| 3904 DCHECK(p->SweepingDone()); | 3944 DCHECK(p->SweepingDone()); |
| 3905 | 3945 |
| 3946 // We can not sweep black pages, since all mark bits are set for these |
| 3947 // pages. |
| 3948 if (p->IsFlagSet(Page::BLACK_PAGE)) { |
| 3949 Bitmap::Clear(p); |
| 3950 p->concurrent_sweeping_state().SetValue(Page::kSweepingDone); |
| 3951 p->ClearFlag(Page::BLACK_PAGE); |
| 3952 // TODO(hpayer): Free unused memory of last black page. |
| 3953 continue; |
| 3954 } |
| 3955 |
| 3906 if (p->IsFlagSet(Page::RESCAN_ON_EVACUATION) || | 3956 if (p->IsFlagSet(Page::RESCAN_ON_EVACUATION) || |
| 3907 p->IsEvacuationCandidate()) { | 3957 p->IsEvacuationCandidate()) { |
| 3908 // Will be processed in EvacuateNewSpaceAndCandidates. | 3958 // Will be processed in EvacuateNewSpaceAndCandidates. |
| 3909 DCHECK(evacuation_candidates_.length() > 0); | 3959 DCHECK(evacuation_candidates_.length() > 0); |
| 3910 continue; | 3960 continue; |
| 3911 } | 3961 } |
| 3912 | 3962 |
| 3913 if (p->IsFlagSet(Page::NEVER_ALLOCATE_ON_PAGE)) { | 3963 if (p->IsFlagSet(Page::NEVER_ALLOCATE_ON_PAGE)) { |
| 3914 // We need to sweep the page to get it into an iterable state again. Note | 3964 // We need to sweep the page to get it into an iterable state again. Note |
| 3915 // that this adds unusable memory into the free list that is later on | 3965 // that this adds unusable memory into the free list that is later on |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4066 MarkBit mark_bit = Marking::MarkBitFrom(host); | 4116 MarkBit mark_bit = Marking::MarkBitFrom(host); |
| 4067 if (Marking::IsBlack(mark_bit)) { | 4117 if (Marking::IsBlack(mark_bit)) { |
| 4068 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); | 4118 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); |
| 4069 RecordRelocSlot(&rinfo, target); | 4119 RecordRelocSlot(&rinfo, target); |
| 4070 } | 4120 } |
| 4071 } | 4121 } |
| 4072 } | 4122 } |
| 4073 | 4123 |
| 4074 } // namespace internal | 4124 } // namespace internal |
| 4075 } // namespace v8 | 4125 } // namespace v8 |
| OLD | NEW |