Commit 1da7c49c authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[heap] MinorMC: Cleanup dead code and reshuffle visitor allocation

- Visitors are now part of the tasks.
- There's one visitor extra for the main thread.

Bug: chromium:651354
Change-Id: I6c1d109e9d2a2092c0f06fee5a158d101ac6bc2a
Reviewed-on: https://chromium-review.googlesource.com/512302Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45480}
parent e8757382
...@@ -2288,7 +2288,7 @@ class MinorMarkCompactCollector::RootMarkingVisitor : public RootVisitor { ...@@ -2288,7 +2288,7 @@ class MinorMarkCompactCollector::RootMarkingVisitor : public RootVisitor {
if (ObjectMarking::WhiteToBlack<MarkBit::NON_ATOMIC>( if (ObjectMarking::WhiteToBlack<MarkBit::NON_ATOMIC>(
object, marking_state(object))) { object, marking_state(object))) {
collector_->marking_visitor(kMainMarker)->Visit(object); collector_->main_marking_visitor()->Visit(object);
collector_->EmptyMarkingDeque(); collector_->EmptyMarkingDeque();
} }
} }
...@@ -2313,12 +2313,11 @@ class YoungGenerationMarkingTask : public ItemParallelJob::Task { ...@@ -2313,12 +2313,11 @@ class YoungGenerationMarkingTask : public ItemParallelJob::Task {
YoungGenerationMarkingTask(Isolate* isolate, YoungGenerationMarkingTask(Isolate* isolate,
MinorMarkCompactCollector* collector, MinorMarkCompactCollector* collector,
WorkStealingMarkingDeque* marking_deque, WorkStealingMarkingDeque* marking_deque,
YoungGenerationMarkingVisitor* visitor,
int task_id) int task_id)
: ItemParallelJob::Task(isolate), : ItemParallelJob::Task(isolate),
collector_(collector), collector_(collector),
marking_deque_(marking_deque, task_id), marking_deque_(marking_deque, task_id),
visitor_(visitor) {} visitor_(isolate->heap(), marking_deque, task_id) {}
void RunInParallel() override { void RunInParallel() override {
double marking_time = 0.0; double marking_time = 0.0;
...@@ -2344,7 +2343,7 @@ class YoungGenerationMarkingTask : public ItemParallelJob::Task { ...@@ -2344,7 +2343,7 @@ class YoungGenerationMarkingTask : public ItemParallelJob::Task {
HeapObject* heap_object = HeapObject::cast(object); HeapObject* heap_object = HeapObject::cast(object);
if (ObjectMarking::WhiteToBlack<MarkBit::ATOMIC>( if (ObjectMarking::WhiteToBlack<MarkBit::ATOMIC>(
heap_object, collector_->marking_state(heap_object))) { heap_object, collector_->marking_state(heap_object))) {
visitor_->Visit(heap_object); visitor_.Visit(heap_object);
} }
} }
...@@ -2352,7 +2351,7 @@ class YoungGenerationMarkingTask : public ItemParallelJob::Task { ...@@ -2352,7 +2351,7 @@ class YoungGenerationMarkingTask : public ItemParallelJob::Task {
void EmptyLocalMarkingDeque() { void EmptyLocalMarkingDeque() {
HeapObject* object = nullptr; HeapObject* object = nullptr;
while (marking_deque_.Pop(&object)) { while (marking_deque_.Pop(&object)) {
visitor_->Visit(object); visitor_.Visit(object);
} }
} }
...@@ -2360,14 +2359,14 @@ class YoungGenerationMarkingTask : public ItemParallelJob::Task { ...@@ -2360,14 +2359,14 @@ class YoungGenerationMarkingTask : public ItemParallelJob::Task {
HeapObject* object = nullptr; HeapObject* object = nullptr;
while (marking_deque_.WaitForMoreObjects()) { while (marking_deque_.WaitForMoreObjects()) {
while (marking_deque_.Pop(&object)) { while (marking_deque_.Pop(&object)) {
visitor_->Visit(object); visitor_.Visit(object);
} }
} }
} }
MinorMarkCompactCollector* collector_; MinorMarkCompactCollector* collector_;
LocalWorkStealingMarkingDeque marking_deque_; LocalWorkStealingMarkingDeque marking_deque_;
YoungGenerationMarkingVisitor* visitor_; YoungGenerationMarkingVisitor visitor_;
}; };
class BatchedRootMarkingItem : public MarkingItem { class BatchedRootMarkingItem : public MarkingItem {
...@@ -2523,39 +2522,15 @@ class MinorMarkCompactCollector::RootMarkingVisitorSeedOnly ...@@ -2523,39 +2522,15 @@ class MinorMarkCompactCollector::RootMarkingVisitorSeedOnly
}; };
MinorMarkCompactCollector::MinorMarkCompactCollector(Heap* heap) MinorMarkCompactCollector::MinorMarkCompactCollector(Heap* heap)
: MarkCompactCollectorBase(heap), page_parallel_job_semaphore_(0) { : MarkCompactCollectorBase(heap),
marking_deque_ = new WorkStealingMarkingDeque(); marking_deque_(new WorkStealingMarkingDeque()),
for (int i = 0; i < kNumMarkers; i++) { main_marking_visitor_(
marking_visitor_[i] = new YoungGenerationMarkingVisitor(heap, marking_deque_, kMainMarker)),
new YoungGenerationMarkingVisitor(heap, marking_deque_, i); page_parallel_job_semaphore_(0) {}
}
}
MinorMarkCompactCollector::~MinorMarkCompactCollector() { MinorMarkCompactCollector::~MinorMarkCompactCollector() {
for (int i = 0; i < kNumMarkers; i++) {
DCHECK_NOT_NULL(marking_visitor_[i]);
delete marking_visitor_[i];
}
delete marking_deque_; delete marking_deque_;
} delete main_marking_visitor_;
SlotCallbackResult MinorMarkCompactCollector::CheckAndMarkObject(
Heap* heap, Address slot_address) {
Object* object = *reinterpret_cast<Object**>(slot_address);
if (heap->InNewSpace(object)) {
// Marking happens before flipping the young generation, so the object
// has to be in ToSpace.
DCHECK(heap->InToSpace(object));
HeapObject* heap_object = reinterpret_cast<HeapObject*>(object);
const MarkingState state = MarkingState::External(heap_object);
if (ObjectMarking::WhiteToBlack<MarkBit::NON_ATOMIC>(heap_object, state)) {
heap->minor_mark_compact_collector()
->marking_visitor(kMainMarker)
->Visit(heap_object);
}
return KEEP_SLOT;
}
return REMOVE_SLOT;
} }
static bool IsUnmarkedObjectForYoungGeneration(Heap* heap, Object** p) { static bool IsUnmarkedObjectForYoungGeneration(Heap* heap, Object** p) {
...@@ -2600,8 +2575,8 @@ void MinorMarkCompactCollector::MarkRootSetInParallel() { ...@@ -2600,8 +2575,8 @@ void MinorMarkCompactCollector::MarkRootSetInParallel() {
TRACE_GC(heap()->tracer(), GCTracer::Scope::MINOR_MC_MARK_ROOTS); TRACE_GC(heap()->tracer(), GCTracer::Scope::MINOR_MC_MARK_ROOTS);
const int num_tasks = NumberOfMarkingTasks(); const int num_tasks = NumberOfMarkingTasks();
for (int i = 0; i < num_tasks; i++) { for (int i = 0; i < num_tasks; i++) {
job.AddTask(new YoungGenerationMarkingTask( job.AddTask(
isolate(), this, marking_deque(), marking_visitor(i), i)); new YoungGenerationMarkingTask(isolate(), this, marking_deque(), i));
} }
job.Run(); job.Run();
} }
...@@ -2649,7 +2624,7 @@ void MinorMarkCompactCollector::EmptyMarkingDeque() { ...@@ -2649,7 +2624,7 @@ void MinorMarkCompactCollector::EmptyMarkingDeque() {
object, marking_state(object)))); object, marking_state(object))));
DCHECK((ObjectMarking::IsBlack<MarkBit::NON_ATOMIC>( DCHECK((ObjectMarking::IsBlack<MarkBit::NON_ATOMIC>(
object, marking_state(object)))); object, marking_state(object))));
marking_visitor(kMainMarker)->Visit(object); main_marking_visitor()->Visit(object);
} }
DCHECK(local_marking_deque.IsEmpty()); DCHECK(local_marking_deque.IsEmpty());
} }
......
...@@ -313,12 +313,10 @@ class MinorMarkCompactCollector final : public MarkCompactCollectorBase { ...@@ -313,12 +313,10 @@ class MinorMarkCompactCollector final : public MarkCompactCollectorBase {
inline WorkStealingMarkingDeque* marking_deque() { return marking_deque_; } inline WorkStealingMarkingDeque* marking_deque() { return marking_deque_; }
inline YoungGenerationMarkingVisitor* marking_visitor(int index) { inline YoungGenerationMarkingVisitor* main_marking_visitor() {
DCHECK_LT(index, kNumMarkers); return main_marking_visitor_;
return marking_visitor_[index];
} }
SlotCallbackResult CheckAndMarkObject(Heap* heap, Address slot_address);
void MarkLiveObjects() override; void MarkLiveObjects() override;
void MarkRootSetInParallel(); void MarkRootSetInParallel();
void ProcessMarkingDeque() override; void ProcessMarkingDeque() override;
...@@ -334,7 +332,7 @@ class MinorMarkCompactCollector final : public MarkCompactCollectorBase { ...@@ -334,7 +332,7 @@ class MinorMarkCompactCollector final : public MarkCompactCollectorBase {
int NumberOfMarkingTasks(); int NumberOfMarkingTasks();
WorkStealingMarkingDeque* marking_deque_; WorkStealingMarkingDeque* marking_deque_;
YoungGenerationMarkingVisitor* marking_visitor_[kNumMarkers]; YoungGenerationMarkingVisitor* main_marking_visitor_;
base::Semaphore page_parallel_job_semaphore_; base::Semaphore page_parallel_job_semaphore_;
List<Page*> new_space_evacuation_pages_; List<Page*> new_space_evacuation_pages_;
std::vector<Page*> sweep_to_iterate_pages_; std::vector<Page*> sweep_to_iterate_pages_;
......
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