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 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 int area_size = space->AreaSize(); | 671 int area_size = space->AreaSize(); |
672 | 672 |
673 // Pairs of (live_bytes_in_page, page). | 673 // Pairs of (live_bytes_in_page, page). |
674 typedef std::pair<int, Page*> LiveBytesPagePair; | 674 typedef std::pair<int, Page*> LiveBytesPagePair; |
675 std::vector<LiveBytesPagePair> pages; | 675 std::vector<LiveBytesPagePair> pages; |
676 pages.reserve(number_of_pages); | 676 pages.reserve(number_of_pages); |
677 | 677 |
678 PageIterator it(space); | 678 PageIterator it(space); |
679 while (it.has_next()) { | 679 while (it.has_next()) { |
680 Page* p = it.next(); | 680 Page* p = it.next(); |
681 // Invariant: No page should be marked as aborted after a GC. | |
682 DCHECK(!p->IsFlagSet(Page::COMPACTION_WAS_ABORTED)); | |
683 if (p->NeverEvacuate()) continue; | 681 if (p->NeverEvacuate()) continue; |
684 if (p->IsFlagSet(Page::POPULAR_PAGE)) { | 682 if (p->IsFlagSet(Page::POPULAR_PAGE)) { |
685 // This page had slots buffer overflow on previous GC, skip it. | 683 // This page had slots buffer overflow on previous GC, skip it. |
686 p->ClearFlag(Page::POPULAR_PAGE); | 684 p->ClearFlag(Page::POPULAR_PAGE); |
687 continue; | 685 continue; |
688 } | 686 } |
689 // Invariant: Evacuation candidates are just created when marking is | 687 // Invariant: Evacuation candidates are just created when marking is |
690 // started. At the end of a GC all evacuation candidates are cleared and | 688 // started. At the end of a GC all evacuation candidates are cleared and |
691 // their slot buffers are released. | 689 // their slot buffers are released. |
692 CHECK(!p->IsEvacuationCandidate()); | 690 CHECK(!p->IsEvacuationCandidate()); |
(...skipping 2564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3257 // moved, others are still in place. | 3255 // moved, others are still in place. |
3258 // We need to: | 3256 // We need to: |
3259 // - Leave the evacuation candidate flag for later processing of | 3257 // - Leave the evacuation candidate flag for later processing of |
3260 // slots buffer entries. | 3258 // slots buffer entries. |
3261 // - Leave the slots buffer there for processing of entries added by | 3259 // - Leave the slots buffer there for processing of entries added by |
3262 // the write barrier. | 3260 // the write barrier. |
3263 // - Rescan the page as slot recording in the migration buffer only | 3261 // - Rescan the page as slot recording in the migration buffer only |
3264 // happens upon moving (which we potentially didn't do). | 3262 // happens upon moving (which we potentially didn't do). |
3265 // - Leave the page in the list of pages of a space since we could not | 3263 // - Leave the page in the list of pages of a space since we could not |
3266 // fully evacuate it. | 3264 // fully evacuate it. |
3267 // - Mark them for rescanning for store buffer entries as we otherwise | |
3268 // might have stale store buffer entries that become "valid" again | |
3269 // after reusing the memory. Note that all existing store buffer | |
3270 // entries of such pages are filtered before rescanning. | |
3271 DCHECK(p->IsEvacuationCandidate()); | 3265 DCHECK(p->IsEvacuationCandidate()); |
3272 p->SetFlag(Page::COMPACTION_WAS_ABORTED); | 3266 p->SetFlag(Page::COMPACTION_WAS_ABORTED); |
3273 p->set_scan_on_scavenge(true); | |
3274 abandoned_pages++; | 3267 abandoned_pages++; |
3275 break; | 3268 break; |
3276 case MemoryChunk::kCompactingFinalize: | 3269 case MemoryChunk::kCompactingFinalize: |
3277 DCHECK(p->IsEvacuationCandidate()); | 3270 DCHECK(p->IsEvacuationCandidate()); |
3278 p->SetWasSwept(); | 3271 p->SetWasSwept(); |
3279 p->Unlink(); | 3272 p->Unlink(); |
3280 break; | 3273 break; |
3281 case MemoryChunk::kCompactingDone: | 3274 case MemoryChunk::kCompactingDone: |
3282 DCHECK(p->IsFlagSet(Page::POPULAR_PAGE)); | 3275 DCHECK(p->IsFlagSet(Page::POPULAR_PAGE)); |
3283 DCHECK(p->IsFlagSet(Page::RESCAN_ON_EVACUATION)); | 3276 DCHECK(p->IsFlagSet(Page::RESCAN_ON_EVACUATION)); |
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4115 MarkBit mark_bit = Marking::MarkBitFrom(host); | 4108 MarkBit mark_bit = Marking::MarkBitFrom(host); |
4116 if (Marking::IsBlack(mark_bit)) { | 4109 if (Marking::IsBlack(mark_bit)) { |
4117 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); | 4110 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); |
4118 RecordRelocSlot(&rinfo, target); | 4111 RecordRelocSlot(&rinfo, target); |
4119 } | 4112 } |
4120 } | 4113 } |
4121 } | 4114 } |
4122 | 4115 |
4123 } // namespace internal | 4116 } // namespace internal |
4124 } // namespace v8 | 4117 } // namespace v8 |
OLD | NEW |