| 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 267 |
| 268 static void TraceFragmentation(PagedSpace* space) { | 268 static void TraceFragmentation(PagedSpace* space) { |
| 269 int number_of_pages = space->CountTotalPages(); | 269 int number_of_pages = space->CountTotalPages(); |
| 270 intptr_t reserved = (number_of_pages * space->AreaSize()); | 270 intptr_t reserved = (number_of_pages * space->AreaSize()); |
| 271 intptr_t free = reserved - space->SizeOfObjects(); | 271 intptr_t free = reserved - space->SizeOfObjects(); |
| 272 PrintF("[%s]: %d pages, %d (%.1f%%) free\n", | 272 PrintF("[%s]: %d pages, %d (%.1f%%) free\n", |
| 273 AllocationSpaceName(space->identity()), number_of_pages, | 273 AllocationSpaceName(space->identity()), number_of_pages, |
| 274 static_cast<int>(free), static_cast<double>(free) * 100 / reserved); | 274 static_cast<int>(free), static_cast<double>(free) * 100 / reserved); |
| 275 } | 275 } |
| 276 | 276 |
| 277 | 277 bool MarkCompactCollector::StartCompaction() { |
| 278 bool MarkCompactCollector::StartCompaction(CompactionMode mode) { | |
| 279 if (!compacting_) { | 278 if (!compacting_) { |
| 280 DCHECK(evacuation_candidates_.length() == 0); | 279 DCHECK(evacuation_candidates_.length() == 0); |
| 281 | 280 |
| 282 CollectEvacuationCandidates(heap()->old_space()); | 281 CollectEvacuationCandidates(heap()->old_space()); |
| 283 | 282 |
| 284 if (FLAG_compact_code_space) { | 283 if (FLAG_compact_code_space) { |
| 285 CollectEvacuationCandidates(heap()->code_space()); | 284 CollectEvacuationCandidates(heap()->code_space()); |
| 286 } else if (FLAG_trace_fragmentation) { | 285 } else if (FLAG_trace_fragmentation) { |
| 287 TraceFragmentation(heap()->code_space()); | 286 TraceFragmentation(heap()->code_space()); |
| 288 } | 287 } |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 } | 815 } |
| 817 } | 816 } |
| 818 | 817 |
| 819 if (heap_->UsingEmbedderHeapTracer()) { | 818 if (heap_->UsingEmbedderHeapTracer()) { |
| 820 heap_->embedder_heap_tracer()->EnterFinalPause(); | 819 heap_->embedder_heap_tracer()->EnterFinalPause(); |
| 821 } | 820 } |
| 822 | 821 |
| 823 // Don't start compaction if we are in the middle of incremental | 822 // Don't start compaction if we are in the middle of incremental |
| 824 // marking cycle. We did not collect any slots. | 823 // marking cycle. We did not collect any slots. |
| 825 if (!FLAG_never_compact && !was_marked_incrementally_) { | 824 if (!FLAG_never_compact && !was_marked_incrementally_) { |
| 826 StartCompaction(NON_INCREMENTAL_COMPACTION); | 825 StartCompaction(); |
| 827 } | 826 } |
| 828 | 827 |
| 829 PagedSpaces spaces(heap()); | 828 PagedSpaces spaces(heap()); |
| 830 for (PagedSpace* space = spaces.next(); space != NULL; | 829 for (PagedSpace* space = spaces.next(); space != NULL; |
| 831 space = spaces.next()) { | 830 space = spaces.next()) { |
| 832 space->PrepareForMarkCompact(); | 831 space->PrepareForMarkCompact(); |
| 833 } | 832 } |
| 834 heap()->account_external_memory_concurrently_freed(); | 833 heap()->account_external_memory_concurrently_freed(); |
| 835 | 834 |
| 836 #ifdef VERIFY_HEAP | 835 #ifdef VERIFY_HEAP |
| (...skipping 3099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3936 // The target is always in old space, we don't have to record the slot in | 3935 // The target is always in old space, we don't have to record the slot in |
| 3937 // the old-to-new remembered set. | 3936 // the old-to-new remembered set. |
| 3938 DCHECK(!heap()->InNewSpace(target)); | 3937 DCHECK(!heap()->InNewSpace(target)); |
| 3939 RecordRelocSlot(host, &rinfo, target); | 3938 RecordRelocSlot(host, &rinfo, target); |
| 3940 } | 3939 } |
| 3941 } | 3940 } |
| 3942 } | 3941 } |
| 3943 | 3942 |
| 3944 } // namespace internal | 3943 } // namespace internal |
| 3945 } // namespace v8 | 3944 } // namespace v8 |
| OLD | NEW |