[heap] Add tracing scope to parallel evacuation.

Bug: chromium:758183
Change-Id: I626be7a8f42662a657595c1147a6aa8cb53391fa
Reviewed-on: https://chromium-review.googlesource.com/808941
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49902}
This commit is contained in:
Ulan Degenbaev 2017-12-06 16:35:18 +01:00 committed by Commit Bot
parent 2b08723c53
commit 39c0d3991c
3 changed files with 49 additions and 25 deletions

View File

@ -357,13 +357,13 @@
F(SCAVENGER_SCAVENGE_WEAK) F(SCAVENGER_SCAVENGE_WEAK)
#define TRACER_BACKGROUND_SCOPES(F) \ #define TRACER_BACKGROUND_SCOPES(F) \
F(SCAVENGER_BACKGROUND_SCAVENGE_PARALLEL) \ F(MC_BACKGROUND_EVACUATE_COPY) \
F(MINOR_MC_BACKGROUND_MARKING) \ F(MC_BACKGROUND_EVACUATE_UPDATE_POINTERS) \
F(MINOR_MC_BACKGROUND_EVACUATE_COPY) \
F(MINOR_MC_BACKGROUND_EVACUATE_UPDATE_POINTERS) \
F(MC_BACKGROUND_MARKING) \ F(MC_BACKGROUND_MARKING) \
F(MC_BACKGROUND_SWEEPING) \ F(MC_BACKGROUND_SWEEPING) \
F(MC_BACKGROUND_EVACUATE_COPY) \ F(MINOR_MC_BACKGROUND_EVACUATE_COPY) \
F(MC_BACKGROUND_EVACUATE_UPDATE_POINTERS) F(MINOR_MC_BACKGROUND_EVACUATE_UPDATE_POINTERS) \
F(MINOR_MC_BACKGROUND_MARKING) \
F(SCAVENGER_BACKGROUND_SCAVENGE_PARALLEL)
#endif // V8_HEAP_SYMBOLS_H_ #endif // V8_HEAP_SYMBOLS_H_

View File

@ -70,11 +70,10 @@ class V8_EXPORT_PRIVATE GCTracer {
FIRST_SCOPE = MC_INCREMENTAL, FIRST_SCOPE = MC_INCREMENTAL,
NUMBER_OF_INCREMENTAL_SCOPES = NUMBER_OF_INCREMENTAL_SCOPES =
LAST_INCREMENTAL_SCOPE - FIRST_INCREMENTAL_SCOPE + 1, LAST_INCREMENTAL_SCOPE - FIRST_INCREMENTAL_SCOPE + 1,
FIRST_MC_BACKGROUND_SCOPE = MC_BACKGROUND_MARKING, FIRST_MC_BACKGROUND_SCOPE = MC_BACKGROUND_EVACUATE_COPY,
LAST_MC_BACKGROUND_SCOPE = MC_BACKGROUND_EVACUATE_UPDATE_POINTERS, LAST_MC_BACKGROUND_SCOPE = MC_BACKGROUND_SWEEPING,
FIRST_MINOR_GC_BACKGROUND_SCOPE = SCAVENGER_BACKGROUND_SCAVENGE_PARALLEL, FIRST_MINOR_GC_BACKGROUND_SCOPE = MINOR_MC_BACKGROUND_EVACUATE_COPY,
LAST_MINOR_GC_BACKGROUND_SCOPE = LAST_MINOR_GC_BACKGROUND_SCOPE = SCAVENGER_BACKGROUND_SCAVENGE_PARALLEL
MINOR_MC_BACKGROUND_EVACUATE_UPDATE_POINTERS
}; };
Scope(GCTracer* tracer, ScopeId scope); Scope(GCTracer* tracer, ScopeId scope);
@ -98,12 +97,10 @@ class V8_EXPORT_PRIVATE GCTracer {
TRACER_BACKGROUND_SCOPES(DEFINE_SCOPE) TRACER_BACKGROUND_SCOPES(DEFINE_SCOPE)
#undef DEFINE_SCOPE #undef DEFINE_SCOPE
NUMBER_OF_SCOPES, NUMBER_OF_SCOPES,
FIRST_MC_BACKGROUND_SCOPE = MC_BACKGROUND_EVACUATE_COPY,
FIRST_MC_BACKGROUND_SCOPE = MC_BACKGROUND_MARKING, LAST_MC_BACKGROUND_SCOPE = MC_BACKGROUND_SWEEPING,
LAST_MC_BACKGROUND_SCOPE = MC_BACKGROUND_EVACUATE_UPDATE_POINTERS, FIRST_MINOR_GC_BACKGROUND_SCOPE = MINOR_MC_BACKGROUND_EVACUATE_COPY,
FIRST_MINOR_GC_BACKGROUND_SCOPE = SCAVENGER_BACKGROUND_SCAVENGE_PARALLEL, LAST_MINOR_GC_BACKGROUND_SCOPE = SCAVENGER_BACKGROUND_SCAVENGE_PARALLEL
LAST_MINOR_GC_BACKGROUND_SCOPE =
MINOR_MC_BACKGROUND_EVACUATE_UPDATE_POINTERS
}; };
BackgroundScope(GCTracer* tracer, ScopeId scope); BackgroundScope(GCTracer* tracer, ScopeId scope);
~BackgroundScope(); ~BackgroundScope();

View File

@ -3031,6 +3031,8 @@ class Evacuator : public Malloced {
// to be called from the main thread. // to be called from the main thread.
inline void Finalize(); inline void Finalize();
virtual GCTracer::BackgroundScope::ScopeId GetBackgroundTracingScope() = 0;
protected: protected:
static const int kInitialLocalPretenuringFeedbackCapacity = 256; static const int kInitialLocalPretenuringFeedbackCapacity = 256;
@ -3110,6 +3112,10 @@ class FullEvacuator : public Evacuator {
RecordMigratedSlotVisitor* record_visitor) RecordMigratedSlotVisitor* record_visitor)
: Evacuator(collector->heap(), record_visitor), collector_(collector) {} : Evacuator(collector->heap(), record_visitor), collector_(collector) {}
GCTracer::BackgroundScope::ScopeId GetBackgroundTracingScope() override {
return GCTracer::BackgroundScope::MC_BACKGROUND_EVACUATE_COPY;
}
protected: protected:
void RawEvacuatePage(Page* page, intptr_t* live_bytes) override; void RawEvacuatePage(Page* page, intptr_t* live_bytes) override;
@ -3166,6 +3172,10 @@ class YoungGenerationEvacuator : public Evacuator {
RecordMigratedSlotVisitor* record_visitor) RecordMigratedSlotVisitor* record_visitor)
: Evacuator(collector->heap(), record_visitor), collector_(collector) {} : Evacuator(collector->heap(), record_visitor), collector_(collector) {}
GCTracer::BackgroundScope::ScopeId GetBackgroundTracingScope() override {
return GCTracer::BackgroundScope::MINOR_MC_BACKGROUND_EVACUATE_COPY;
}
protected: protected:
void RawEvacuatePage(Page* page, intptr_t* live_bytes) override; void RawEvacuatePage(Page* page, intptr_t* live_bytes) override;
@ -3243,10 +3253,13 @@ class PageEvacuationItem : public ItemParallelJob::Item {
class PageEvacuationTask : public ItemParallelJob::Task { class PageEvacuationTask : public ItemParallelJob::Task {
public: public:
PageEvacuationTask(Isolate* isolate, Evacuator* evacuator) PageEvacuationTask(Isolate* isolate, Evacuator* evacuator)
: ItemParallelJob::Task(isolate), evacuator_(evacuator) {} : ItemParallelJob::Task(isolate),
evacuator_(evacuator),
tracer_(isolate->heap()->tracer()) {}
void RunInParallel() override { void RunInParallel() override {
// TODO(ulan): add GCTracer background scope. GCTracer::BackgroundScope scope(tracer_,
evacuator_->GetBackgroundTracingScope());
PageEvacuationItem* item = nullptr; PageEvacuationItem* item = nullptr;
while ((item = GetItem<PageEvacuationItem>()) != nullptr) { while ((item = GetItem<PageEvacuationItem>()) != nullptr) {
evacuator_->EvacuatePage(item->page()); evacuator_->EvacuatePage(item->page());
@ -3256,6 +3269,7 @@ class PageEvacuationTask : public ItemParallelJob::Task {
private: private:
Evacuator* evacuator_; Evacuator* evacuator_;
GCTracer* tracer_;
}; };
template <class Evacuator, class Collector> template <class Evacuator, class Collector>
@ -3554,17 +3568,24 @@ class UpdatingItem : public ItemParallelJob::Item {
class PointersUpdatingTask : public ItemParallelJob::Task { class PointersUpdatingTask : public ItemParallelJob::Task {
public: public:
explicit PointersUpdatingTask(Isolate* isolate) explicit PointersUpdatingTask(Isolate* isolate,
: ItemParallelJob::Task(isolate) {} GCTracer::BackgroundScope::ScopeId scope)
: ItemParallelJob::Task(isolate),
tracer_(isolate->heap()->tracer()),
scope_(scope) {}
void RunInParallel() override { void RunInParallel() override {
// TODO(ulan): add GCTracer background scope. GCTracer::BackgroundScope scope(tracer_, scope_);
UpdatingItem* item = nullptr; UpdatingItem* item = nullptr;
while ((item = GetItem<UpdatingItem>()) != nullptr) { while ((item = GetItem<UpdatingItem>()) != nullptr) {
item->Process(); item->Process();
item->MarkFinished(); item->MarkFinished();
} }
}; };
private:
GCTracer* tracer_;
GCTracer::BackgroundScope::ScopeId scope_;
}; };
template <typename MarkingState> template <typename MarkingState>
@ -3955,7 +3976,9 @@ void MarkCompactCollector::UpdatePointersAfterEvacuation() {
const int to_space_tasks = CollectToSpaceUpdatingItems(&updating_job); const int to_space_tasks = CollectToSpaceUpdatingItems(&updating_job);
const int num_tasks = Max(to_space_tasks, remembered_set_tasks); const int num_tasks = Max(to_space_tasks, remembered_set_tasks);
for (int i = 0; i < num_tasks; i++) { for (int i = 0; i < num_tasks; i++) {
updating_job.AddTask(new PointersUpdatingTask(isolate())); updating_job.AddTask(new PointersUpdatingTask(
isolate(),
GCTracer::BackgroundScope::MC_BACKGROUND_EVACUATE_UPDATE_POINTERS));
} }
updating_job.Run(); updating_job.Run();
} }
@ -3985,7 +4008,9 @@ void MarkCompactCollector::UpdatePointersAfterEvacuation() {
const int num_tasks = Max(array_buffer_pages, remembered_set_tasks); const int num_tasks = Max(array_buffer_pages, remembered_set_tasks);
if (num_tasks > 0) { if (num_tasks > 0) {
for (int i = 0; i < num_tasks; i++) { for (int i = 0; i < num_tasks; i++) {
updating_job.AddTask(new PointersUpdatingTask(isolate())); updating_job.AddTask(new PointersUpdatingTask(
isolate(),
GCTracer::BackgroundScope::MC_BACKGROUND_EVACUATE_UPDATE_POINTERS));
} }
updating_job.Run(); updating_job.Run();
heap()->array_buffer_collector()->FreeAllocationsOnBackgroundThread(); heap()->array_buffer_collector()->FreeAllocationsOnBackgroundThread();
@ -4036,7 +4061,9 @@ void MinorMarkCompactCollector::UpdatePointersAfterEvacuation() {
remembered_set_pages, old_to_new_slots_); remembered_set_pages, old_to_new_slots_);
const int num_tasks = Max(to_space_tasks, remembered_set_tasks); const int num_tasks = Max(to_space_tasks, remembered_set_tasks);
for (int i = 0; i < num_tasks; i++) { for (int i = 0; i < num_tasks; i++) {
updating_job.AddTask(new PointersUpdatingTask(isolate())); updating_job.AddTask(new PointersUpdatingTask(
isolate(), GCTracer::BackgroundScope::
MINOR_MC_BACKGROUND_EVACUATE_UPDATE_POINTERS));
} }
{ {