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