Commit 38d889ec authored by mlippautz's avatar mlippautz Committed by Commit bot

[heap] Remove SweeperType and clean up SweepSpace a bit.

R=hpayer@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1521573002

Cr-Commit-Position: refs/heads/master@{#32793}
parent 69cf31f0
......@@ -3722,7 +3722,7 @@ int MarkCompactCollector::SweepInParallel(Page* page, PagedSpace* space) {
}
void MarkCompactCollector::SweepSpace(PagedSpace* space, SweeperType sweeper) {
void MarkCompactCollector::StartSweepSpace(PagedSpace* space) {
space->ClearStats();
// We defensively initialize end_of_unswept_pages_ here with the first page
......@@ -3753,8 +3753,7 @@ void MarkCompactCollector::SweepSpace(PagedSpace* space, SweeperType sweeper) {
if (p->LiveBytes() == 0) {
if (unused_page_present) {
if (FLAG_gc_verbose) {
PrintF("Sweeping 0x%" V8PRIxPTR " released page.\n",
reinterpret_cast<intptr_t>(p));
PrintIsolate(isolate(), "sweeping: released page: %p", p);
}
space->ReleasePage(p);
continue;
......@@ -3762,64 +3761,38 @@ void MarkCompactCollector::SweepSpace(PagedSpace* space, SweeperType sweeper) {
unused_page_present = true;
}
switch (sweeper) {
case CONCURRENT_SWEEPING:
if (!parallel_sweeping_active) {
if (FLAG_gc_verbose) {
PrintF("Sweeping 0x%" V8PRIxPTR ".\n",
reinterpret_cast<intptr_t>(p));
}
if (space->identity() == CODE_SPACE) {
if (FLAG_zap_code_space) {
Sweep<SWEEP_ONLY, SWEEP_ON_MAIN_THREAD, REBUILD_SKIP_LIST,
ZAP_FREE_SPACE>(space, NULL, p, NULL);
} else {
Sweep<SWEEP_ONLY, SWEEP_ON_MAIN_THREAD, REBUILD_SKIP_LIST,
IGNORE_FREE_SPACE>(space, NULL, p, NULL);
}
} else {
Sweep<SWEEP_ONLY, SWEEP_ON_MAIN_THREAD, IGNORE_SKIP_LIST,
IGNORE_FREE_SPACE>(space, NULL, p, NULL);
}
pages_swept++;
parallel_sweeping_active = true;
} else {
if (FLAG_gc_verbose) {
PrintF("Sweeping 0x%" V8PRIxPTR " in parallel.\n",
reinterpret_cast<intptr_t>(p));
}
p->parallel_sweeping_state().SetValue(MemoryChunk::kSweepingPending);
int to_sweep = p->area_size() - p->LiveBytes();
space->accounting_stats_.ShrinkSpace(to_sweep);
}
space->set_end_of_unswept_pages(p);
break;
case SEQUENTIAL_SWEEPING: {
if (FLAG_gc_verbose) {
PrintF("Sweeping 0x%" V8PRIxPTR ".\n", reinterpret_cast<intptr_t>(p));
}
if (space->identity() == CODE_SPACE) {
if (FLAG_zap_code_space) {
Sweep<SWEEP_ONLY, SWEEP_ON_MAIN_THREAD, REBUILD_SKIP_LIST,
ZAP_FREE_SPACE>(space, NULL, p, NULL);
} else {
Sweep<SWEEP_ONLY, SWEEP_ON_MAIN_THREAD, REBUILD_SKIP_LIST,
IGNORE_FREE_SPACE>(space, NULL, p, NULL);
}
if (!parallel_sweeping_active) {
if (FLAG_gc_verbose) {
PrintIsolate(isolate(), "sweeping: %p", p);
}
if (space->identity() == CODE_SPACE) {
if (FLAG_zap_code_space) {
Sweep<SWEEP_ONLY, SWEEP_ON_MAIN_THREAD, REBUILD_SKIP_LIST,
ZAP_FREE_SPACE>(space, NULL, p, NULL);
} else {
Sweep<SWEEP_ONLY, SWEEP_ON_MAIN_THREAD, IGNORE_SKIP_LIST,
Sweep<SWEEP_ONLY, SWEEP_ON_MAIN_THREAD, REBUILD_SKIP_LIST,
IGNORE_FREE_SPACE>(space, NULL, p, NULL);
}
pages_swept++;
break;
} else {
Sweep<SWEEP_ONLY, SWEEP_ON_MAIN_THREAD, IGNORE_SKIP_LIST,
IGNORE_FREE_SPACE>(space, NULL, p, NULL);
}
pages_swept++;
parallel_sweeping_active = true;
} else {
if (FLAG_gc_verbose) {
PrintIsolate(isolate(), "sweeping: initialized for parallel: %p", p);
}
default: { UNREACHABLE(); }
p->parallel_sweeping_state().SetValue(MemoryChunk::kSweepingPending);
int to_sweep = p->area_size() - p->LiveBytes();
space->accounting_stats_.ShrinkSpace(to_sweep);
}
space->set_end_of_unswept_pages(p);
}
if (FLAG_gc_verbose) {
PrintF("SweepSpace: %s (%d pages swept)\n",
AllocationSpaceName(space->identity()), pages_swept);
PrintIsolate(isolate(), "sweeping: space=%s pages_swept=%d",
AllocationSpaceName(space->identity()), pages_swept);
}
}
......@@ -3841,17 +3814,17 @@ void MarkCompactCollector::SweepSpaces() {
{
GCTracer::Scope sweep_scope(heap()->tracer(),
GCTracer::Scope::MC_SWEEP_OLD);
SweepSpace(heap()->old_space(), CONCURRENT_SWEEPING);
StartSweepSpace(heap()->old_space());
}
{
GCTracer::Scope sweep_scope(heap()->tracer(),
GCTracer::Scope::MC_SWEEP_CODE);
SweepSpace(heap()->code_space(), CONCURRENT_SWEEPING);
StartSweepSpace(heap()->code_space());
}
{
GCTracer::Scope sweep_scope(heap()->tracer(),
GCTracer::Scope::MC_SWEEP_MAP);
SweepSpace(heap()->map_space(), CONCURRENT_SWEEPING);
StartSweepSpace(heap()->map_space());
}
sweeping_in_progress_ = true;
if (FLAG_concurrent_sweeping) {
......
......@@ -365,11 +365,6 @@ class MarkCompactCollector {
CodeFlusher* code_flusher() { return code_flusher_; }
inline bool is_code_flushing_enabled() const { return code_flusher_ != NULL; }
enum SweeperType {
CONCURRENT_SWEEPING,
SEQUENTIAL_SWEEPING
};
enum SweepingParallelism { SWEEP_ON_MAIN_THREAD, SWEEP_IN_PARALLEL };
#ifdef VERIFY_HEAP
......@@ -693,7 +688,6 @@ class MarkCompactCollector {
// regions to each space's free list.
void SweepSpaces();
void EvacuateNewSpace();
void AddEvacuationSlotsBufferSynchronized(
......@@ -731,7 +725,9 @@ class MarkCompactCollector {
// corresponding space pages list.
void MoveEvacuationCandidatesToEndOfPagesList();
void SweepSpace(PagedSpace* space, SweeperType sweeper);
// Starts sweeping of a space by contributing on the main thread and setting
// up other pages for sweeping.
void StartSweepSpace(PagedSpace* space);
// Finalizes the parallel sweeping phase. Marks all the pages that were
// swept in parallel.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment