Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: src/heap/mark-compact.cc

Issue 1301183002: [heap] Cleanup and fix GC flags / add testing infra (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed Hannes' comments Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap/mark-compact.h ('k') | src/heap/mark-compact-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/compilation-cache.h" 10 #include "src/compilation-cache.h"
(...skipping 24 matching lines...) Expand all
35 35
36 36
37 // ------------------------------------------------------------------------- 37 // -------------------------------------------------------------------------
38 // MarkCompactCollector 38 // MarkCompactCollector
39 39
40 MarkCompactCollector::MarkCompactCollector(Heap* heap) 40 MarkCompactCollector::MarkCompactCollector(Heap* heap)
41 : // NOLINT 41 : // NOLINT
42 #ifdef DEBUG 42 #ifdef DEBUG
43 state_(IDLE), 43 state_(IDLE),
44 #endif 44 #endif
45 reduce_memory_footprint_(false),
46 abort_incremental_marking_(false),
47 finalize_incremental_marking_(false),
48 marking_parity_(ODD_MARKING_PARITY), 45 marking_parity_(ODD_MARKING_PARITY),
49 compacting_(false), 46 compacting_(false),
50 was_marked_incrementally_(false), 47 was_marked_incrementally_(false),
51 sweeping_in_progress_(false), 48 sweeping_in_progress_(false),
52 pending_sweeper_jobs_semaphore_(0), 49 pending_sweeper_jobs_semaphore_(0),
53 evacuation_(false), 50 evacuation_(false),
54 migration_slots_buffer_(NULL), 51 migration_slots_buffer_(NULL),
55 heap_(heap), 52 heap_(heap),
56 marking_deque_memory_(NULL), 53 marking_deque_memory_(NULL),
57 marking_deque_memory_committed_(0), 54 marking_deque_memory_committed_(0),
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 DCHECK(p->area_size() == area_size); 656 DCHECK(p->area_size() == area_size);
660 int live_bytes = 657 int live_bytes =
661 p->WasSwept() ? p->LiveBytesFromFreeList() : p->LiveBytes(); 658 p->WasSwept() ? p->LiveBytesFromFreeList() : p->LiveBytes();
662 pages.push_back(std::make_pair(live_bytes, p)); 659 pages.push_back(std::make_pair(live_bytes, p));
663 } 660 }
664 661
665 int candidate_count = 0; 662 int candidate_count = 0;
666 int total_live_bytes = 0; 663 int total_live_bytes = 0;
667 664
668 bool reduce_memory = 665 bool reduce_memory =
669 reduce_memory_footprint_ || heap()->HasLowAllocationRate(); 666 heap()->ShouldReduceMemory() || heap()->HasLowAllocationRate();
670 if (FLAG_manual_evacuation_candidates_selection) { 667 if (FLAG_manual_evacuation_candidates_selection) {
671 for (size_t i = 0; i < pages.size(); i++) { 668 for (size_t i = 0; i < pages.size(); i++) {
672 Page* p = pages[i].second; 669 Page* p = pages[i].second;
673 if (p->IsFlagSet(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING)) { 670 if (p->IsFlagSet(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING)) {
674 candidate_count++; 671 candidate_count++;
675 total_live_bytes += pages[i].first; 672 total_live_bytes += pages[i].first;
676 p->ClearFlag(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING); 673 p->ClearFlag(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING);
677 AddEvacuationCandidate(p); 674 AddEvacuationCandidate(p);
678 } 675 }
679 } 676 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 #endif 778 #endif
782 779
783 DCHECK(!FLAG_never_compact || !FLAG_always_compact); 780 DCHECK(!FLAG_never_compact || !FLAG_always_compact);
784 781
785 if (sweeping_in_progress()) { 782 if (sweeping_in_progress()) {
786 // Instead of waiting we could also abort the sweeper threads here. 783 // Instead of waiting we could also abort the sweeper threads here.
787 EnsureSweepingCompleted(); 784 EnsureSweepingCompleted();
788 } 785 }
789 786
790 // Clear marking bits if incremental marking is aborted. 787 // Clear marking bits if incremental marking is aborted.
791 if (was_marked_incrementally_ && abort_incremental_marking_) { 788 if (was_marked_incrementally_ && heap_->ShouldAbortIncrementalMarking()) {
792 heap()->incremental_marking()->Stop(); 789 heap()->incremental_marking()->Stop();
793 ClearMarkbits(); 790 ClearMarkbits();
794 AbortWeakCollections(); 791 AbortWeakCollections();
795 AbortWeakCells(); 792 AbortWeakCells();
796 AbortCompaction(); 793 AbortCompaction();
797 was_marked_incrementally_ = false; 794 was_marked_incrementally_ = false;
798 } 795 }
799 796
800 // Don't start compaction if we are in the middle of incremental 797 // Don't start compaction if we are in the middle of incremental
801 // marking cycle. We did not collect any slots. 798 // marking cycle. We did not collect any slots.
(...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after
2053 code->CodeIterateBody(visitor); 2050 code->CodeIterateBody(visitor);
2054 } 2051 }
2055 ProcessMarkingDeque(); 2052 ProcessMarkingDeque();
2056 return; 2053 return;
2057 } 2054 }
2058 } 2055 }
2059 } 2056 }
2060 2057
2061 2058
2062 void MarkCompactCollector::RetainMaps() { 2059 void MarkCompactCollector::RetainMaps() {
2063 if (reduce_memory_footprint_ || abort_incremental_marking_ || 2060 if (heap()->ShouldReduceMemory() || heap()->ShouldAbortIncrementalMarking() ||
2064 FLAG_retain_maps_for_n_gc == 0) { 2061 FLAG_retain_maps_for_n_gc == 0) {
2065 // Do not retain dead maps if flag disables it or there is 2062 // Do not retain dead maps if flag disables it or there is
2066 // - memory pressure (reduce_memory_footprint_), 2063 // - memory pressure (reduce_memory_footprint_),
2067 // - GC is requested by tests or dev-tools (abort_incremental_marking_). 2064 // - GC is requested by tests or dev-tools (abort_incremental_marking_).
2068 return; 2065 return;
2069 } 2066 }
2070 2067
2071 ArrayList* retained_maps = heap()->retained_maps(); 2068 ArrayList* retained_maps = heap()->retained_maps();
2072 int length = retained_maps->Length(); 2069 int length = retained_maps->Length();
2073 int new_length = 0; 2070 int new_length = 0;
(...skipping 2639 matching lines...) Expand 10 before | Expand all | Expand 10 after
4713 SlotsBuffer* buffer = *buffer_address; 4710 SlotsBuffer* buffer = *buffer_address;
4714 while (buffer != NULL) { 4711 while (buffer != NULL) {
4715 SlotsBuffer* next_buffer = buffer->next(); 4712 SlotsBuffer* next_buffer = buffer->next();
4716 DeallocateBuffer(buffer); 4713 DeallocateBuffer(buffer);
4717 buffer = next_buffer; 4714 buffer = next_buffer;
4718 } 4715 }
4719 *buffer_address = NULL; 4716 *buffer_address = NULL;
4720 } 4717 }
4721 } // namespace internal 4718 } // namespace internal
4722 } // namespace v8 4719 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/mark-compact.h ('k') | src/heap/mark-compact-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698