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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 if (FLAG_compact_code_space) { | 283 if (FLAG_compact_code_space) { |
284 CollectEvacuationCandidates(heap()->code_space()); | 284 CollectEvacuationCandidates(heap()->code_space()); |
285 } else if (FLAG_trace_fragmentation) { | 285 } else if (FLAG_trace_fragmentation) { |
286 TraceFragmentation(heap()->code_space()); | 286 TraceFragmentation(heap()->code_space()); |
287 } | 287 } |
288 | 288 |
289 if (FLAG_trace_fragmentation) { | 289 if (FLAG_trace_fragmentation) { |
290 TraceFragmentation(heap()->map_space()); | 290 TraceFragmentation(heap()->map_space()); |
291 } | 291 } |
292 | 292 |
293 heap()->old_space()->EvictEvacuationCandidatesFromLinearAllocationArea(); | |
294 heap()->code_space()->EvictEvacuationCandidatesFromLinearAllocationArea(); | |
295 | |
296 compacting_ = evacuation_candidates_.length() > 0; | 293 compacting_ = evacuation_candidates_.length() > 0; |
297 } | 294 } |
298 | 295 |
299 return compacting_; | 296 return compacting_; |
300 } | 297 } |
301 | 298 |
302 void MarkCompactCollector::CollectGarbage() { | 299 void MarkCompactCollector::CollectGarbage() { |
303 // Make sure that Prepare() has been called. The individual steps below will | 300 // Make sure that Prepare() has been called. The individual steps below will |
304 // update the state as they proceed. | 301 // update the state as they proceed. |
305 DCHECK(state_ == PREPARE_GC); | 302 DCHECK(state_ == PREPARE_GC); |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 size_t area_size = space->AreaSize(); | 631 size_t area_size = space->AreaSize(); |
635 | 632 |
636 // Pairs of (live_bytes_in_page, page). | 633 // Pairs of (live_bytes_in_page, page). |
637 typedef std::pair<size_t, Page*> LiveBytesPagePair; | 634 typedef std::pair<size_t, Page*> LiveBytesPagePair; |
638 std::vector<LiveBytesPagePair> pages; | 635 std::vector<LiveBytesPagePair> pages; |
639 pages.reserve(number_of_pages); | 636 pages.reserve(number_of_pages); |
640 | 637 |
641 DCHECK(!sweeping_in_progress()); | 638 DCHECK(!sweeping_in_progress()); |
642 DCHECK(!FLAG_concurrent_sweeping || | 639 DCHECK(!FLAG_concurrent_sweeping || |
643 sweeper().IsSweepingCompleted(space->identity())); | 640 sweeper().IsSweepingCompleted(space->identity())); |
| 641 Page* owner_of_linear_allocation_area = |
| 642 space->top() == space->limit() |
| 643 ? nullptr |
| 644 : Page::FromAllocationAreaAddress(space->top()); |
644 for (Page* p : *space) { | 645 for (Page* p : *space) { |
645 if (p->NeverEvacuate()) continue; | 646 if (p->NeverEvacuate() || p == owner_of_linear_allocation_area) continue; |
646 // Invariant: Evacuation candidates are just created when marking is | 647 // Invariant: Evacuation candidates are just created when marking is |
647 // started. This means that sweeping has finished. Furthermore, at the end | 648 // started. This means that sweeping has finished. Furthermore, at the end |
648 // of a GC all evacuation candidates are cleared and their slot buffers are | 649 // of a GC all evacuation candidates are cleared and their slot buffers are |
649 // released. | 650 // released. |
650 CHECK(!p->IsEvacuationCandidate()); | 651 CHECK(!p->IsEvacuationCandidate()); |
651 CHECK_NULL(p->old_to_old_slots()); | 652 CHECK_NULL(p->old_to_old_slots()); |
652 CHECK_NULL(p->typed_old_to_old_slots()); | 653 CHECK_NULL(p->typed_old_to_old_slots()); |
653 CHECK(p->SweepingDone()); | 654 CHECK(p->SweepingDone()); |
654 DCHECK(p->area_size() == area_size); | 655 DCHECK(p->area_size() == area_size); |
655 pages.push_back(std::make_pair(p->LiveBytesFromFreeList(), p)); | 656 pages.push_back(std::make_pair(p->LiveBytesFromFreeList(), p)); |
(...skipping 3259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3915 // The target is always in old space, we don't have to record the slot in | 3916 // The target is always in old space, we don't have to record the slot in |
3916 // the old-to-new remembered set. | 3917 // the old-to-new remembered set. |
3917 DCHECK(!heap()->InNewSpace(target)); | 3918 DCHECK(!heap()->InNewSpace(target)); |
3918 RecordRelocSlot(host, &rinfo, target); | 3919 RecordRelocSlot(host, &rinfo, target); |
3919 } | 3920 } |
3920 } | 3921 } |
3921 } | 3922 } |
3922 | 3923 |
3923 } // namespace internal | 3924 } // namespace internal |
3924 } // namespace v8 | 3925 } // namespace v8 |
OLD | NEW |