Commit 387c4658 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[heap] Cleanup: Replace List<> with std::vector<> in MC

Bug: v8:6333
Change-Id: Icc04b896a472ddb7bf38829547349df19db97002
Reviewed-on: https://chromium-review.googlesource.com/550217Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46270}
parent 4260f605
...@@ -429,7 +429,7 @@ void MinorMarkCompactCollector::TearDown() {} ...@@ -429,7 +429,7 @@ void MinorMarkCompactCollector::TearDown() {}
void MarkCompactCollector::AddEvacuationCandidate(Page* p) { void MarkCompactCollector::AddEvacuationCandidate(Page* p) {
DCHECK(!p->NeverEvacuate()); DCHECK(!p->NeverEvacuate());
p->MarkEvacuationCandidate(); p->MarkEvacuationCandidate();
evacuation_candidates_.Add(p); evacuation_candidates_.push_back(p);
} }
...@@ -444,7 +444,7 @@ static void TraceFragmentation(PagedSpace* space) { ...@@ -444,7 +444,7 @@ static void TraceFragmentation(PagedSpace* space) {
bool MarkCompactCollector::StartCompaction() { bool MarkCompactCollector::StartCompaction() {
if (!compacting_) { if (!compacting_) {
DCHECK(evacuation_candidates_.length() == 0); DCHECK(evacuation_candidates_.empty());
CollectEvacuationCandidates(heap()->old_space()); CollectEvacuationCandidates(heap()->old_space());
...@@ -458,7 +458,7 @@ bool MarkCompactCollector::StartCompaction() { ...@@ -458,7 +458,7 @@ bool MarkCompactCollector::StartCompaction() {
TraceFragmentation(heap()->map_space()); TraceFragmentation(heap()->map_space());
} }
compacting_ = evacuation_candidates_.length() > 0; compacting_ = !evacuation_candidates_.empty();
} }
return compacting_; return compacting_;
...@@ -904,9 +904,9 @@ void MarkCompactCollector::AbortCompaction() { ...@@ -904,9 +904,9 @@ void MarkCompactCollector::AbortCompaction() {
p->ClearEvacuationCandidate(); p->ClearEvacuationCandidate();
} }
compacting_ = false; compacting_ = false;
evacuation_candidates_.Rewind(0); evacuation_candidates_.clear();
} }
DCHECK_EQ(0, evacuation_candidates_.length()); DCHECK(evacuation_candidates_.empty());
} }
...@@ -2771,7 +2771,7 @@ void MinorMarkCompactCollector::EvacuatePrologue() { ...@@ -2771,7 +2771,7 @@ void MinorMarkCompactCollector::EvacuatePrologue() {
NewSpace* new_space = heap()->new_space(); NewSpace* new_space = heap()->new_space();
// Append the list of new space pages to be processed. // Append the list of new space pages to be processed.
for (Page* p : PageRange(new_space->bottom(), new_space->top())) { for (Page* p : PageRange(new_space->bottom(), new_space->top())) {
new_space_evacuation_pages_.Add(p); new_space_evacuation_pages_.push_back(p);
} }
new_space->Flip(); new_space->Flip();
new_space->ResetAllocationInfo(); new_space->ResetAllocationInfo();
...@@ -2818,7 +2818,7 @@ void MinorMarkCompactCollector::Evacuate() { ...@@ -2818,7 +2818,7 @@ void MinorMarkCompactCollector::Evacuate() {
sweep_to_iterate_pages_.push_back(p); sweep_to_iterate_pages_.push_back(p);
} }
} }
new_space_evacuation_pages_.Rewind(0); new_space_evacuation_pages_.clear();
} }
{ {
...@@ -3455,15 +3455,16 @@ void MarkCompactCollector::EvacuatePrologue() { ...@@ -3455,15 +3455,16 @@ void MarkCompactCollector::EvacuatePrologue() {
NewSpace* new_space = heap()->new_space(); NewSpace* new_space = heap()->new_space();
// Append the list of new space pages to be processed. // Append the list of new space pages to be processed.
for (Page* p : PageRange(new_space->bottom(), new_space->top())) { for (Page* p : PageRange(new_space->bottom(), new_space->top())) {
new_space_evacuation_pages_.Add(p); new_space_evacuation_pages_.push_back(p);
} }
new_space->Flip(); new_space->Flip();
new_space->ResetAllocationInfo(); new_space->ResetAllocationInfo();
// Old space. // Old space.
DCHECK(old_space_evacuation_pages_.is_empty()); DCHECK(old_space_evacuation_pages_.empty());
old_space_evacuation_pages_.Swap(&evacuation_candidates_); old_space_evacuation_pages_ = std::move(evacuation_candidates_);
DCHECK(evacuation_candidates_.is_empty()); evacuation_candidates_.clear();
DCHECK(evacuation_candidates_.empty());
} }
void MarkCompactCollector::EvacuateEpilogue() { void MarkCompactCollector::EvacuateEpilogue() {
...@@ -4173,7 +4174,7 @@ void MarkCompactCollector::Evacuate() { ...@@ -4173,7 +4174,7 @@ void MarkCompactCollector::Evacuate() {
sweeper().AddPage(p->owner()->identity(), p); sweeper().AddPage(p->owner()->identity(), p);
} }
} }
new_space_evacuation_pages_.Rewind(0); new_space_evacuation_pages_.clear();
for (Page* p : old_space_evacuation_pages_) { for (Page* p : old_space_evacuation_pages_) {
// Important: skip list should be cleared only after roots were updated // Important: skip list should be cleared only after roots were updated
...@@ -4662,7 +4663,7 @@ void MarkCompactCollector::ReleaseEvacuationCandidates() { ...@@ -4662,7 +4663,7 @@ void MarkCompactCollector::ReleaseEvacuationCandidates() {
CHECK(p->SweepingDone()); CHECK(p->SweepingDone());
space->ReleasePage(p); space->ReleasePage(p);
} }
old_space_evacuation_pages_.Rewind(0); old_space_evacuation_pages_.clear();
compacting_ = false; compacting_ = false;
heap()->memory_allocator()->unmapper()->FreeQueuedChunks(); heap()->memory_allocator()->unmapper()->FreeQueuedChunks();
} }
...@@ -4763,7 +4764,7 @@ void MarkCompactCollector::StartSweepSpace(PagedSpace* space) { ...@@ -4763,7 +4764,7 @@ void MarkCompactCollector::StartSweepSpace(PagedSpace* space) {
if (p->IsEvacuationCandidate()) { if (p->IsEvacuationCandidate()) {
// Will be processed in Evacuate. // Will be processed in Evacuate.
DCHECK(evacuation_candidates_.length() > 0); DCHECK(!evacuation_candidates_.empty());
continue; continue;
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define V8_HEAP_MARK_COMPACT_H_ #define V8_HEAP_MARK_COMPACT_H_
#include <deque> #include <deque>
#include <vector>
#include "src/base/bits.h" #include "src/base/bits.h"
#include "src/base/platform/condition-variable.h" #include "src/base/platform/condition-variable.h"
...@@ -382,7 +383,7 @@ class MinorMarkCompactCollector final : public MarkCompactCollectorBase { ...@@ -382,7 +383,7 @@ class MinorMarkCompactCollector final : public MarkCompactCollectorBase {
Worklist* worklist_; Worklist* worklist_;
YoungGenerationMarkingVisitor* main_marking_visitor_; YoungGenerationMarkingVisitor* main_marking_visitor_;
base::Semaphore page_parallel_job_semaphore_; base::Semaphore page_parallel_job_semaphore_;
List<Page*> new_space_evacuation_pages_; std::vector<Page*> new_space_evacuation_pages_;
std::vector<Page*> sweep_to_iterate_pages_; std::vector<Page*> sweep_to_iterate_pages_;
friend class MarkYoungGenerationJobTraits; friend class MarkYoungGenerationJobTraits;
...@@ -794,10 +795,10 @@ class MarkCompactCollector final : public MarkCompactCollectorBase { ...@@ -794,10 +795,10 @@ class MarkCompactCollector final : public MarkCompactCollectorBase {
MarkingWorklist marking_worklist_; MarkingWorklist marking_worklist_;
// Candidates for pages that should be evacuated. // Candidates for pages that should be evacuated.
List<Page*> evacuation_candidates_; std::vector<Page*> evacuation_candidates_;
// Pages that are actually processed during evacuation. // Pages that are actually processed during evacuation.
List<Page*> old_space_evacuation_pages_; std::vector<Page*> old_space_evacuation_pages_;
List<Page*> new_space_evacuation_pages_; std::vector<Page*> new_space_evacuation_pages_;
std::vector<std::pair<HeapObject*, Page*>> aborted_evacuation_candidates_; std::vector<std::pair<HeapObject*, Page*>> aborted_evacuation_candidates_;
Sweeper sweeper_; Sweeper sweeper_;
......
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