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

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

Issue 1409363003: [heap] Add concurrency-safe refilling to compaction spaces (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 5 years, 2 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/spaces.h ('k') | 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 "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/base/platform/platform.h" 8 #include "src/base/platform/platform.h"
9 #include "src/full-codegen/full-codegen.h" 9 #include "src/full-codegen/full-codegen.h"
10 #include "src/heap/slots-buffer.h" 10 #include "src/heap/slots-buffer.h"
(...skipping 2695 matching lines...) Expand 10 before | Expand all | Expand 10 after
2706 int remaining = 2706 int remaining =
2707 static_cast<int>(allocation_info_.limit() - allocation_info_.top()); 2707 static_cast<int>(allocation_info_.limit() - allocation_info_.top());
2708 heap()->CreateFillerObjectAt(allocation_info_.top(), remaining); 2708 heap()->CreateFillerObjectAt(allocation_info_.top(), remaining);
2709 2709
2710 allocation_info_.set_top(nullptr); 2710 allocation_info_.set_top(nullptr);
2711 allocation_info_.set_limit(nullptr); 2711 allocation_info_.set_limit(nullptr);
2712 } 2712 }
2713 } 2713 }
2714 2714
2715 2715
2716 HeapObject* PagedSpace::WaitForSweeperThreadsAndRetryAllocation( 2716 HeapObject* PagedSpace::SweepAndRetryAllocation(int size_in_bytes) {
2717 int size_in_bytes) {
2718 MarkCompactCollector* collector = heap()->mark_compact_collector(); 2717 MarkCompactCollector* collector = heap()->mark_compact_collector();
2719 if (collector->sweeping_in_progress()) { 2718 if (collector->sweeping_in_progress()) {
2720 // Wait for the sweeper threads here and complete the sweeping phase. 2719 // Wait for the sweeper threads here and complete the sweeping phase.
2721 collector->EnsureSweepingCompleted(); 2720 collector->EnsureSweepingCompleted();
2722 2721
2723 // After waiting for the sweeper threads, there may be new free-list 2722 // After waiting for the sweeper threads, there may be new free-list
2724 // entries. 2723 // entries.
2725 return free_list_.Allocate(size_in_bytes); 2724 return free_list_.Allocate(size_in_bytes);
2726 } 2725 }
2727 return NULL; 2726 return nullptr;
2728 } 2727 }
2729 2728
2730 2729
2730 HeapObject* CompactionSpace::SweepAndRetryAllocation(int size_in_bytes) {
2731 MarkCompactCollector* collector = heap()->mark_compact_collector();
2732 if (collector->sweeping_in_progress()) {
2733 collector->SweepAndRefill(this);
2734 return free_list_.Allocate(size_in_bytes);
2735 }
2736 return nullptr;
2737 }
2738
2739
2731 HeapObject* PagedSpace::SlowAllocateRaw(int size_in_bytes) { 2740 HeapObject* PagedSpace::SlowAllocateRaw(int size_in_bytes) {
2732 // Allocation in this space has failed. 2741 // Allocation in this space has failed.
2733 2742
2734 MarkCompactCollector* collector = heap()->mark_compact_collector(); 2743 MarkCompactCollector* collector = heap()->mark_compact_collector();
2735 // Sweeping is still in progress. 2744 // Sweeping is still in progress.
2736 if (collector->sweeping_in_progress()) { 2745 if (collector->sweeping_in_progress()) {
2737 // First try to refill the free-list, concurrent sweeper threads 2746 // First try to refill the free-list, concurrent sweeper threads
2738 // may have freed some objects in the meantime. 2747 // may have freed some objects in the meantime.
2739 RefillFreeList(); 2748 RefillFreeList();
2740 2749
(...skipping 13 matching lines...) Expand all
2754 } 2763 }
2755 } 2764 }
2756 2765
2757 // Free list allocation failed and there is no next page. Fail if we have 2766 // Free list allocation failed and there is no next page. Fail if we have
2758 // hit the old generation size limit that should cause a garbage 2767 // hit the old generation size limit that should cause a garbage
2759 // collection. 2768 // collection.
2760 if (!heap()->always_allocate() && 2769 if (!heap()->always_allocate() &&
2761 heap()->OldGenerationAllocationLimitReached()) { 2770 heap()->OldGenerationAllocationLimitReached()) {
2762 // If sweeper threads are active, wait for them at that point and steal 2771 // If sweeper threads are active, wait for them at that point and steal
2763 // elements form their free-lists. 2772 // elements form their free-lists.
2764 HeapObject* object = WaitForSweeperThreadsAndRetryAllocation(size_in_bytes); 2773 HeapObject* object = SweepAndRetryAllocation(size_in_bytes);
2765 return object; 2774 return object;
2766 } 2775 }
2767 2776
2768 // Try to expand the space and allocate in the new next page. 2777 // Try to expand the space and allocate in the new next page.
2769 if (Expand()) { 2778 if (Expand()) {
2770 DCHECK((CountTotalPages() > 1) || 2779 DCHECK((CountTotalPages() > 1) ||
2771 (size_in_bytes <= free_list_.Available())); 2780 (size_in_bytes <= free_list_.Available()));
2772 return free_list_.Allocate(size_in_bytes); 2781 return free_list_.Allocate(size_in_bytes);
2773 } 2782 }
2774 2783
2775 // If sweeper threads are active, wait for them at that point and steal 2784 // If sweeper threads are active, wait for them at that point and steal
2776 // elements form their free-lists. Allocation may still fail their which 2785 // elements form their free-lists. Allocation may still fail their which
2777 // would indicate that there is not enough memory for the given allocation. 2786 // would indicate that there is not enough memory for the given allocation.
2778 return WaitForSweeperThreadsAndRetryAllocation(size_in_bytes); 2787 return SweepAndRetryAllocation(size_in_bytes);
2779 } 2788 }
2780 2789
2781 2790
2782 #ifdef DEBUG 2791 #ifdef DEBUG
2783 void PagedSpace::ReportCodeStatistics(Isolate* isolate) { 2792 void PagedSpace::ReportCodeStatistics(Isolate* isolate) {
2784 CommentStatistic* comments_statistics = 2793 CommentStatistic* comments_statistics =
2785 isolate->paged_space_comments_statistics(); 2794 isolate->paged_space_comments_statistics();
2786 ReportCodeKindStatistics(isolate->code_kind_statistics()); 2795 ReportCodeKindStatistics(isolate->code_kind_statistics());
2787 PrintF( 2796 PrintF(
2788 "Code comment statistics (\" [ comment-txt : size/ " 2797 "Code comment statistics (\" [ comment-txt : size/ "
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
3267 object->ShortPrint(); 3276 object->ShortPrint();
3268 PrintF("\n"); 3277 PrintF("\n");
3269 } 3278 }
3270 printf(" --------------------------------------\n"); 3279 printf(" --------------------------------------\n");
3271 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); 3280 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
3272 } 3281 }
3273 3282
3274 #endif // DEBUG 3283 #endif // DEBUG
3275 } // namespace internal 3284 } // namespace internal
3276 } // namespace v8 3285 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/spaces.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698