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

Side by Side Diff: src/heap/spaces.cc

Issue 2806463002: Fix free space repairing after deserialization. (Closed)
Patch Set: Fix issues after review. Created 3 years, 8 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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/spaces.h" 5 #include "src/heap/spaces.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 2816 matching lines...) Expand 10 before | Expand all | Expand 10 after
2827 } 2827 }
2828 2828
2829 2829
2830 // After we have booted, we have created a map which represents free space 2830 // After we have booted, we have created a map which represents free space
2831 // on the heap. If there was already a free list then the elements on it 2831 // on the heap. If there was already a free list then the elements on it
2832 // were created with the wrong FreeSpaceMap (normally NULL), so we need to 2832 // were created with the wrong FreeSpaceMap (normally NULL), so we need to
2833 // fix them. 2833 // fix them.
2834 void PagedSpace::RepairFreeListsAfterDeserialization() { 2834 void PagedSpace::RepairFreeListsAfterDeserialization() {
2835 free_list_.RepairLists(heap()); 2835 free_list_.RepairLists(heap());
2836 // Each page may have a small free space that is not tracked by a free list. 2836 // Each page may have a small free space that is not tracked by a free list.
2837 // Update the maps for those free space objects. 2837 // Those free spaces still contain null as their map pointer.
2838 // Overwrite them with new fillers.
2838 for (Page* page : *this) { 2839 for (Page* page : *this) {
2839 size_t size = page->wasted_memory(); 2840 int size = static_cast<int>(page->wasted_memory());
2840 if (size == 0) continue; 2841 if (size == 0) {
2841 DCHECK_GE(static_cast<size_t>(Page::kPageSize), size); 2842 // If there is no wasted memory then all free space is in the free list.
2842 Address address = page->OffsetToAddress(Page::kPageSize - size); 2843 continue;
2843 heap()->CreateFillerObjectAt(address, static_cast<int>(size), 2844 }
2844 ClearRecordedSlots::kNo); 2845 Address start = page->HighWaterMark();
2846 Address end = page->area_end();
2847 CHECK_EQ(size, static_cast<int>(end - start));
2848 heap()->CreateFillerObjectAt(start, size, ClearRecordedSlots::kNo);
2845 } 2849 }
2846 } 2850 }
2847 2851
2848 HeapObject* PagedSpace::SweepAndRetryAllocation(int size_in_bytes) { 2852 HeapObject* PagedSpace::SweepAndRetryAllocation(int size_in_bytes) {
2849 MarkCompactCollector* collector = heap()->mark_compact_collector(); 2853 MarkCompactCollector* collector = heap()->mark_compact_collector();
2850 if (collector->sweeping_in_progress()) { 2854 if (collector->sweeping_in_progress()) {
2851 // Wait for the sweeper threads here and complete the sweeping phase. 2855 // Wait for the sweeper threads here and complete the sweeping phase.
2852 collector->EnsureSweepingCompleted(); 2856 collector->EnsureSweepingCompleted();
2853 2857
2854 // After waiting for the sweeper threads, there may be new free-list 2858 // After waiting for the sweeper threads, there may be new free-list
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
3294 PrintF("\n"); 3298 PrintF("\n");
3295 } 3299 }
3296 printf(" --------------------------------------\n"); 3300 printf(" --------------------------------------\n");
3297 printf(" Marked: %x, LiveCount: %" V8PRIdPTR "\n", mark_size, 3301 printf(" Marked: %x, LiveCount: %" V8PRIdPTR "\n", mark_size,
3298 MarkingState::Internal(this).live_bytes()); 3302 MarkingState::Internal(this).live_bytes());
3299 } 3303 }
3300 3304
3301 #endif // DEBUG 3305 #endif // DEBUG
3302 } // namespace internal 3306 } // namespace internal
3303 } // namespace v8 3307 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698