Commit c1b9e690 authored by Dominik Inführ's avatar Dominik Inführ Committed by Commit Bot

[heap] Replace TRACE_BACKGROUND_GC macro with TRACE_GC1

Remove TRACE_BACKGROUND_GC which was used to emit events on the
background thread. It is replaced by TRACE_GC1, which uses the ThreadKind
argument to work both on main and background threads.

This CL also removes the dedicated BackgroundScope enum, all scopes
are now in GCTracer::Scope.

Change-Id: Ie377082d6a278dd46f2fa359611fdd99a08afcea
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2560203Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71458}
parent ec71d2b9
......@@ -150,9 +150,8 @@ void ArrayBufferSweeper::RequestSweep(SweepingScope scope) {
Prepare(scope);
auto task = MakeCancelableTask(heap_->isolate(), [this] {
TRACE_BACKGROUND_GC(
heap_->tracer(),
GCTracer::BackgroundScope::BACKGROUND_ARRAY_BUFFER_SWEEP);
TRACE_GC1(heap_->tracer(), GCTracer::Scope::BACKGROUND_ARRAY_BUFFER_SWEEP,
ThreadKind::kBackground);
base::MutexGuard guard(&sweeping_mutex_);
job_->Sweep();
job_finished_.NotifyAll();
......
......@@ -5,6 +5,7 @@
#include "src/heap/collection-barrier.h"
#include "src/base/platform/time.h"
#include "src/common/globals.h"
#include "src/heap/gc-tracer.h"
#include "src/heap/heap-inl.h"
#include "src/heap/heap.h"
......@@ -87,8 +88,8 @@ void CollectionBarrier::ActivateStackGuardAndPostTask() {
}
void CollectionBarrier::BlockUntilCollected() {
TRACE_BACKGROUND_GC(heap_->tracer(),
GCTracer::BackgroundScope::BACKGROUND_COLLECTION);
TRACE_GC1(heap_->tracer(), GCTracer::Scope::BACKGROUND_COLLECTION,
ThreadKind::kBackground);
base::MutexGuard guard(&mutex_);
while (CollectionRequested()) {
......
......@@ -398,8 +398,8 @@ ConcurrentMarking::ConcurrentMarking(Heap* heap,
void ConcurrentMarking::Run(JobDelegate* delegate, unsigned mark_compact_epoch,
bool is_forced_gc) {
TRACE_BACKGROUND_GC(heap_->tracer(),
GCTracer::BackgroundScope::MC_BACKGROUND_MARKING);
TRACE_GC1(heap_->tracer(), GCTracer::Scope::MC_BACKGROUND_MARKING,
ThreadKind::kBackground);
size_t kBytesUntilInterruptCheck = 64 * KB;
int kObjectsUntilInterrupCheck = 1000;
uint8_t task_id = delegate->GetTaskId() + 1;
......
......@@ -7,7 +7,9 @@
#include <cstdarg>
#include "src/base/atomic-utils.h"
#include "src/common/globals.h"
#include "src/execution/isolate.h"
#include "src/execution/thread-id.h"
#include "src/heap/heap-inl.h"
#include "src/heap/incremental-marking.h"
#include "src/heap/spaces.h"
......@@ -37,17 +39,6 @@ RuntimeCallCounterId GCTracer::RCSCounterFromScope(Scope::ScopeId id) {
static_cast<int>(id));
}
RuntimeCallCounterId GCTracer::RCSCounterFromBackgroundScope(
BackgroundScope::ScopeId id) {
STATIC_ASSERT(Scope::FIRST_BACKGROUND_SCOPE ==
Scope::BACKGROUND_ARRAY_BUFFER_SWEEP);
STATIC_ASSERT(
0 == static_cast<int>(BackgroundScope::BACKGROUND_ARRAY_BUFFER_SWEEP));
return static_cast<RuntimeCallCounterId>(
static_cast<int>(RCSCounterFromScope(Scope::FIRST_BACKGROUND_SCOPE)) +
static_cast<int>(id));
}
double GCTracer::MonotonicallyIncreasingTimeInMs() {
if (V8_UNLIKELY(FLAG_predictable)) {
return heap_->MonotonicallyIncreasingTimeInMs();
......@@ -57,33 +48,34 @@ double GCTracer::MonotonicallyIncreasingTimeInMs() {
}
}
GCTracer::Scope::Scope(GCTracer* tracer, ScopeId scope)
: tracer_(tracer), scope_(scope) {
GCTracer::Scope::Scope(GCTracer* tracer, ScopeId scope, ThreadKind thread_kind)
: tracer_(tracer), scope_(scope), thread_kind_(thread_kind) {
start_time_ = tracer_->MonotonicallyIncreasingTimeInMs();
if (V8_LIKELY(!TracingFlags::is_runtime_stats_enabled())) return;
runtime_stats_ = tracer_->heap_->isolate()->counters()->runtime_call_stats();
runtime_stats_->Enter(&timer_, GCTracer::RCSCounterFromScope(scope));
if (thread_kind_ == ThreadKind::kMain) {
DCHECK_EQ(tracer_->heap_->isolate()->thread_id(), ThreadId::Current());
runtime_stats_ =
tracer_->heap_->isolate()->counters()->runtime_call_stats();
runtime_stats_->Enter(&timer_, GCTracer::RCSCounterFromScope(scope));
} else {
runtime_call_stats_scope_.emplace(
tracer->worker_thread_runtime_call_stats());
runtime_stats_ = runtime_call_stats_scope_->Get();
runtime_stats_->Enter(&timer_, GCTracer::RCSCounterFromScope(scope));
}
}
GCTracer::Scope::~Scope() {
double delta = tracer_->MonotonicallyIncreasingTimeInMs() - start_time_;
tracer_->AddScopeSample(scope_, delta);
if (V8_LIKELY(runtime_stats_ == nullptr)) return;
runtime_stats_->Leave(&timer_);
}
double duration_ms = tracer_->MonotonicallyIncreasingTimeInMs() - start_time_;
GCTracer::BackgroundScope::BackgroundScope(GCTracer* tracer, ScopeId scope,
RuntimeCallStats* runtime_stats)
: tracer_(tracer), scope_(scope), runtime_stats_(runtime_stats) {
start_time_ = tracer_->MonotonicallyIncreasingTimeInMs();
if (V8_LIKELY(!TracingFlags::is_runtime_stats_enabled())) return;
runtime_stats_->Enter(&timer_,
GCTracer::RCSCounterFromBackgroundScope(scope));
}
if (thread_kind_ == ThreadKind::kMain) {
DCHECK_EQ(tracer_->heap_->isolate()->thread_id(), ThreadId::Current());
tracer_->AddScopeSample(scope_, duration_ms);
} else {
tracer_->AddScopeSampleBackground(scope_, duration_ms);
}
GCTracer::BackgroundScope::~BackgroundScope() {
double delta = tracer_->MonotonicallyIncreasingTimeInMs() - start_time_;
tracer_->AddBackgroundScopeSample(scope_, delta);
if (V8_LIKELY(runtime_stats_ == nullptr)) return;
runtime_stats_->Leave(&timer_);
}
......@@ -103,20 +95,6 @@ const char* GCTracer::Scope::Name(ScopeId id) {
return nullptr;
}
const char* GCTracer::BackgroundScope::Name(ScopeId id) {
#define CASE(scope) \
case BackgroundScope::scope: \
return "V8.GC_" #scope;
switch (id) {
TRACER_BACKGROUND_SCOPES(CASE)
case BackgroundScope::NUMBER_OF_SCOPES:
break;
}
#undef CASE
UNREACHABLE();
return nullptr;
}
GCTracer::Event::Event(Type type, GarbageCollectionReason gc_reason,
const char* collector_reason)
: type(type),
......@@ -184,7 +162,7 @@ GCTracer::GCTracer(Heap* heap)
// map it to RuntimeCallStats.
STATIC_ASSERT(0 == Scope::MC_INCREMENTAL);
current_.end_time = MonotonicallyIncreasingTimeInMs();
for (int i = 0; i < BackgroundScope::NUMBER_OF_SCOPES; i++) {
for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) {
background_counter_[i].total_duration_ms = 0;
}
}
......@@ -217,7 +195,7 @@ void GCTracer::ResetForTesting() {
current_mark_compact_mutator_utilization_ = 1.0;
previous_mark_compact_end_time_ = 0;
base::MutexGuard guard(&background_counter_mutex_);
for (int i = 0; i < BackgroundScope::NUMBER_OF_SCOPES; i++) {
for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) {
background_counter_[i].total_duration_ms = 0;
}
}
......@@ -1146,9 +1124,7 @@ void GCTracer::NotifyIncrementalMarkingStart() {
void GCTracer::FetchBackgroundMarkCompactCounters() {
FetchBackgroundCounters(Scope::FIRST_MC_BACKGROUND_SCOPE,
Scope::LAST_MC_BACKGROUND_SCOPE,
BackgroundScope::FIRST_MC_BACKGROUND_SCOPE,
BackgroundScope::LAST_MC_BACKGROUND_SCOPE);
Scope::LAST_MC_BACKGROUND_SCOPE);
heap_->isolate()->counters()->background_marking()->AddSample(
static_cast<int>(current_.scopes[Scope::MC_BACKGROUND_MARKING]));
heap_->isolate()->counters()->background_sweeping()->AddSample(
......@@ -1157,9 +1133,7 @@ void GCTracer::FetchBackgroundMarkCompactCounters() {
void GCTracer::FetchBackgroundMinorGCCounters() {
FetchBackgroundCounters(Scope::FIRST_MINOR_GC_BACKGROUND_SCOPE,
Scope::LAST_MINOR_GC_BACKGROUND_SCOPE,
BackgroundScope::FIRST_MINOR_GC_BACKGROUND_SCOPE,
BackgroundScope::LAST_MINOR_GC_BACKGROUND_SCOPE);
Scope::LAST_MINOR_GC_BACKGROUND_SCOPE);
heap_->isolate()->counters()->background_scavenger()->AddSample(
static_cast<int>(
current_.scopes[Scope::SCAVENGER_BACKGROUND_SCAVENGE_PARALLEL]));
......@@ -1167,28 +1141,18 @@ void GCTracer::FetchBackgroundMinorGCCounters() {
void GCTracer::FetchBackgroundGeneralCounters() {
FetchBackgroundCounters(Scope::FIRST_GENERAL_BACKGROUND_SCOPE,
Scope::LAST_GENERAL_BACKGROUND_SCOPE,
BackgroundScope::FIRST_GENERAL_BACKGROUND_SCOPE,
BackgroundScope::LAST_GENERAL_BACKGROUND_SCOPE);
Scope::LAST_GENERAL_BACKGROUND_SCOPE);
}
void GCTracer::FetchBackgroundCounters(int first_global_scope,
int last_global_scope,
int first_background_scope,
int last_background_scope) {
DCHECK_EQ(last_global_scope - first_global_scope,
last_background_scope - first_background_scope);
void GCTracer::FetchBackgroundCounters(int first_scope, int last_scope) {
base::MutexGuard guard(&background_counter_mutex_);
int background_mc_scopes = last_background_scope - first_background_scope + 1;
for (int i = 0; i < background_mc_scopes; i++) {
current_.scopes[first_global_scope + i] +=
background_counter_[first_background_scope + i].total_duration_ms;
background_counter_[first_background_scope + i].total_duration_ms = 0;
for (int i = first_scope; i <= last_scope; i++) {
current_.scopes[i] += background_counter_[i].total_duration_ms;
background_counter_[i].total_duration_ms = 0;
}
}
void GCTracer::AddBackgroundScopeSample(BackgroundScope::ScopeId scope,
double duration) {
void GCTracer::AddScopeSampleBackground(Scope::ScopeId scope, double duration) {
base::MutexGuard guard(&background_counter_mutex_);
BackgroundCounter& counter = background_counter_[scope];
counter.total_duration_ms += duration;
......@@ -1268,15 +1232,12 @@ void GCTracer::RecordGCSumCounters(double atomic_pause_duration) {
.duration +
atomic_pause_duration;
const double background_duration =
background_counter_[BackgroundScope::MC_BACKGROUND_EVACUATE_COPY]
background_counter_[Scope::MC_BACKGROUND_EVACUATE_COPY]
.total_duration_ms +
background_counter_
[BackgroundScope::MC_BACKGROUND_EVACUATE_UPDATE_POINTERS]
.total_duration_ms +
background_counter_[BackgroundScope::MC_BACKGROUND_MARKING]
background_counter_[Scope::MC_BACKGROUND_EVACUATE_UPDATE_POINTERS]
.total_duration_ms +
background_counter_[BackgroundScope::MC_BACKGROUND_SWEEPING]
.total_duration_ms;
background_counter_[Scope::MC_BACKGROUND_MARKING].total_duration_ms +
background_counter_[Scope::MC_BACKGROUND_SWEEPING].total_duration_ms;
const double marking_duration =
current_.incremental_marking_scopes[Scope::MC_INCREMENTAL_LAYOUT_CHANGE]
......@@ -1288,8 +1249,7 @@ void GCTracer::RecordGCSumCounters(double atomic_pause_duration) {
.duration +
current_.scopes[Scope::MC_MARK];
const double marking_background_duration =
background_counter_[BackgroundScope::MC_BACKGROUND_MARKING]
.total_duration_ms;
background_counter_[Scope::MC_BACKGROUND_MARKING].total_duration_ms;
// UMA.
heap_->isolate()->counters()->gc_mark_compactor()->AddSample(
......
......@@ -6,6 +6,7 @@
#define V8_HEAP_GC_TRACER_H_
#include "src/base/compiler-specific.h"
#include "src/base/optional.h"
#include "src/base/platform/platform.h"
#include "src/base/platform/time.h"
#include "src/base/ring-buffer.h"
......@@ -29,17 +30,16 @@ enum ScavengeSpeedMode { kForAllObjects, kForSurvivedObjects };
#define TRACE_GC_CATEGORIES \
"devtools.timeline," TRACE_DISABLED_BY_DEFAULT("v8.gc")
#define TRACE_GC(tracer, scope_id) \
GCTracer::Scope::ScopeId gc_tracer_scope_id(scope_id); \
GCTracer::Scope gc_tracer_scope(tracer, gc_tracer_scope_id); \
#define TRACE_GC(tracer, scope_id) \
GCTracer::Scope::ScopeId gc_tracer_scope_id(scope_id); \
GCTracer::Scope gc_tracer_scope(tracer, gc_tracer_scope_id, \
ThreadKind::kMain); \
TRACE_EVENT0(TRACE_GC_CATEGORIES, GCTracer::Scope::Name(gc_tracer_scope_id))
#define TRACE_BACKGROUND_GC(tracer, scope_id) \
WorkerThreadRuntimeCallStatsScope runtime_call_stats_scope( \
tracer->worker_thread_runtime_call_stats()); \
GCTracer::BackgroundScope background_scope(tracer, scope_id, \
runtime_call_stats_scope.Get()); \
TRACE_EVENT0(TRACE_GC_CATEGORIES, GCTracer::BackgroundScope::Name(scope_id))
#define TRACE_GC1(tracer, scope_id, thread_kind) \
GCTracer::Scope::ScopeId gc_tracer_scope_id(scope_id); \
GCTracer::Scope gc_tracer_scope(tracer, gc_tracer_scope_id, thread_kind); \
TRACE_EVENT0(TRACE_GC_CATEGORIES, GCTracer::Scope::Name(gc_tracer_scope_id))
// GCTracer collects and prints ONE line after each garbage collector
// invocation IFF --trace_gc is used.
......@@ -67,7 +67,7 @@ class V8_EXPORT_PRIVATE GCTracer {
int steps;
};
class V8_NODISCARD Scope {
class V8_EXPORT_PRIVATE V8_NODISCARD Scope {
public:
enum ScopeId {
#define DEFINE_SCOPE(scope) scope,
......@@ -91,49 +91,22 @@ class V8_EXPORT_PRIVATE GCTracer {
FIRST_BACKGROUND_SCOPE = FIRST_GENERAL_BACKGROUND_SCOPE
};
Scope(GCTracer* tracer, ScopeId scope);
Scope(GCTracer* tracer, ScopeId scope, ThreadKind thread_kind);
~Scope();
static const char* Name(ScopeId id);
private:
GCTracer* tracer_;
ScopeId scope_;
ThreadKind thread_kind_;
double start_time_;
RuntimeCallTimer timer_;
RuntimeCallStats* runtime_stats_ = nullptr;
base::Optional<WorkerThreadRuntimeCallStatsScope> runtime_call_stats_scope_;
DISALLOW_COPY_AND_ASSIGN(Scope);
};
class V8_EXPORT_PRIVATE V8_NODISCARD BackgroundScope {
public:
enum ScopeId {
#define DEFINE_SCOPE(scope) scope,
TRACER_BACKGROUND_SCOPES(DEFINE_SCOPE)
#undef DEFINE_SCOPE
NUMBER_OF_SCOPES,
FIRST_GENERAL_BACKGROUND_SCOPE = BACKGROUND_ARRAY_BUFFER_SWEEP,
LAST_GENERAL_BACKGROUND_SCOPE = BACKGROUND_UNMAPPER,
FIRST_MC_BACKGROUND_SCOPE = MC_BACKGROUND_EVACUATE_COPY,
LAST_MC_BACKGROUND_SCOPE = MC_BACKGROUND_SWEEPING,
FIRST_MINOR_GC_BACKGROUND_SCOPE = MINOR_MC_BACKGROUND_EVACUATE_COPY,
LAST_MINOR_GC_BACKGROUND_SCOPE = SCAVENGER_BACKGROUND_SCAVENGE_PARALLEL
};
BackgroundScope(GCTracer* tracer, ScopeId scope,
RuntimeCallStats* runtime_stats);
~BackgroundScope();
static const char* Name(ScopeId id);
private:
GCTracer* tracer_;
ScopeId scope_;
double start_time_;
RuntimeCallTimer timer_;
RuntimeCallStats* runtime_stats_;
DISALLOW_COPY_AND_ASSIGN(BackgroundScope);
};
class Event {
public:
enum Type {
......@@ -212,8 +185,6 @@ class V8_EXPORT_PRIVATE GCTracer {
double optional_speed);
static RuntimeCallCounterId RCSCounterFromScope(Scope::ScopeId id);
static RuntimeCallCounterId RCSCounterFromBackgroundScope(
BackgroundScope::ScopeId id);
explicit GCTracer(Heap* heap);
......@@ -350,8 +321,7 @@ class V8_EXPORT_PRIVATE GCTracer {
}
}
void AddBackgroundScopeSample(BackgroundScope::ScopeId scope,
double duration);
void AddScopeSampleBackground(Scope::ScopeId scope, double duration);
void RecordGCPhasesHistograms(TimedHistogram* gc_timer);
......@@ -428,9 +398,7 @@ class V8_EXPORT_PRIVATE GCTracer {
current_.scopes[Scope::MC_INCREMENTAL_EXTERNAL_PROLOGUE];
}
void FetchBackgroundCounters(int first_global_scope, int last_global_scope,
int first_background_scope,
int last_background_scope);
void FetchBackgroundCounters(int first_scope, int last_scope);
void FetchBackgroundMinorGCCounters();
void FetchBackgroundMarkCompactCounters();
void FetchBackgroundGeneralCounters();
......@@ -502,7 +470,7 @@ class V8_EXPORT_PRIVATE GCTracer {
base::RingBuffer<double> recorded_survival_ratios_;
base::Mutex background_counter_mutex_;
BackgroundCounter background_counter_[BackgroundScope::NUMBER_OF_SCOPES];
BackgroundCounter background_counter_[Scope::NUMBER_OF_SCOPES];
DISALLOW_COPY_AND_ASSIGN(GCTracer);
};
......
......@@ -9,6 +9,7 @@
#include "src/base/optional.h"
#include "src/base/utils/random-number-generator.h"
#include "src/codegen/compilation-cache.h"
#include "src/common/globals.h"
#include "src/deoptimizer/deoptimizer.h"
#include "src/execution/execution.h"
#include "src/execution/frames-inl.h"
......@@ -2934,7 +2935,7 @@ class Evacuator : public Malloced {
// to be called from the main thread.
virtual void Finalize();
virtual GCTracer::BackgroundScope::ScopeId GetBackgroundTracingScope() = 0;
virtual GCTracer::Scope::ScopeId GetBackgroundTracingScope() = 0;
virtual GCTracer::Scope::ScopeId GetTracingScope() = 0;
protected:
......@@ -3023,8 +3024,8 @@ class FullEvacuator : public Evacuator {
local_allocator_(heap_, LocalSpaceKind::kCompactionSpaceForMarkCompact),
collector_(collector) {}
GCTracer::BackgroundScope::ScopeId GetBackgroundTracingScope() override {
return GCTracer::BackgroundScope::MC_BACKGROUND_EVACUATE_COPY;
GCTracer::Scope::ScopeId GetBackgroundTracingScope() override {
return GCTracer::Scope::MC_BACKGROUND_EVACUATE_COPY;
}
GCTracer::Scope::ScopeId GetTracingScope() override {
......@@ -3117,7 +3118,8 @@ class PageEvacuationJob : public v8::JobTask {
TRACE_GC(tracer_, evacuator->GetTracingScope());
ProcessItems(delegate, evacuator);
} else {
TRACE_BACKGROUND_GC(tracer_, evacuator->GetBackgroundTracingScope());
TRACE_GC1(tracer_, evacuator->GetBackgroundTracingScope(),
ThreadKind::kBackground);
ProcessItems(delegate, evacuator);
}
}
......@@ -3476,8 +3478,7 @@ class PointersUpdatingJob : public v8::JobTask {
explicit PointersUpdatingJob(
Isolate* isolate,
std::vector<std::unique_ptr<UpdatingItem>> updating_items, int slots,
GCTracer::Scope::ScopeId scope,
GCTracer::BackgroundScope::ScopeId background_scope)
GCTracer::Scope::ScopeId scope, GCTracer::Scope::ScopeId background_scope)
: updating_items_(std::move(updating_items)),
remaining_updating_items_(updating_items_.size()),
generator_(updating_items_.size()),
......@@ -3491,7 +3492,7 @@ class PointersUpdatingJob : public v8::JobTask {
TRACE_GC(tracer_, scope_);
UpdatePointers(delegate);
} else {
TRACE_BACKGROUND_GC(tracer_, background_scope_);
TRACE_GC1(tracer_, background_scope_, ThreadKind::kBackground);
UpdatePointers(delegate);
}
}
......@@ -3536,7 +3537,7 @@ class PointersUpdatingJob : public v8::JobTask {
GCTracer* tracer_;
GCTracer::Scope::ScopeId scope_;
GCTracer::BackgroundScope::ScopeId background_scope_;
GCTracer::Scope::ScopeId background_scope_;
};
template <typename MarkingState>
......@@ -3932,8 +3933,7 @@ void MarkCompactCollector::UpdatePointersAfterEvacuation() {
std::make_unique<PointersUpdatingJob>(
isolate(), std::move(updating_items), old_to_new_slots_,
GCTracer::Scope::MC_EVACUATE_UPDATE_POINTERS_PARALLEL,
GCTracer::BackgroundScope::
MC_BACKGROUND_EVACUATE_UPDATE_POINTERS))
GCTracer::Scope::MC_BACKGROUND_EVACUATE_UPDATE_POINTERS))
->Join();
}
......@@ -3950,12 +3950,12 @@ void MarkCompactCollector::UpdatePointersAfterEvacuation() {
RememberedSetUpdatingMode::ALL);
if (!updating_items.empty()) {
V8::GetCurrentPlatform()
->PostJob(v8::TaskPriority::kUserBlocking,
std::make_unique<PointersUpdatingJob>(
isolate(), std::move(updating_items), old_to_new_slots_,
GCTracer::Scope::MC_EVACUATE_UPDATE_POINTERS_PARALLEL,
GCTracer::BackgroundScope::
MC_BACKGROUND_EVACUATE_UPDATE_POINTERS))
->PostJob(
v8::TaskPriority::kUserBlocking,
std::make_unique<PointersUpdatingJob>(
isolate(), std::move(updating_items), old_to_new_slots_,
GCTracer::Scope::MC_EVACUATE_UPDATE_POINTERS_PARALLEL,
GCTracer::Scope::MC_BACKGROUND_EVACUATE_UPDATE_POINTERS))
->Join();
}
}
......@@ -4097,18 +4097,18 @@ void MarkCompactCollector::StartSweepSpaces() {
{
{
GCTracer::Scope sweep_scope(heap()->tracer(),
GCTracer::Scope::MC_SWEEP_OLD);
GCTracer::Scope sweep_scope(
heap()->tracer(), GCTracer::Scope::MC_SWEEP_OLD, ThreadKind::kMain);
StartSweepSpace(heap()->old_space());
}
{
GCTracer::Scope sweep_scope(heap()->tracer(),
GCTracer::Scope::MC_SWEEP_CODE);
GCTracer::Scope sweep_scope(
heap()->tracer(), GCTracer::Scope::MC_SWEEP_CODE, ThreadKind::kMain);
StartSweepSpace(heap()->code_space());
}
{
GCTracer::Scope sweep_scope(heap()->tracer(),
GCTracer::Scope::MC_SWEEP_MAP);
GCTracer::Scope sweep_scope(
heap()->tracer(), GCTracer::Scope::MC_SWEEP_MAP, ThreadKind::kMain);
StartSweepSpace(heap()->map_space());
}
sweeper()->StartSweeping();
......@@ -4454,8 +4454,7 @@ void MinorMarkCompactCollector::UpdatePointersAfterEvacuation() {
std::make_unique<PointersUpdatingJob>(
isolate(), std::move(updating_items), old_to_new_slots_,
GCTracer::Scope::MINOR_MC_EVACUATE_UPDATE_POINTERS_PARALLEL,
GCTracer::BackgroundScope::
MINOR_MC_BACKGROUND_EVACUATE_UPDATE_POINTERS))
GCTracer::Scope::MINOR_MC_BACKGROUND_EVACUATE_UPDATE_POINTERS))
->Join();
}
......@@ -4866,9 +4865,9 @@ class YoungGenerationMarkingJob : public v8::JobTask {
GCTracer::Scope::MINOR_MC_MARK_PARALLEL);
ProcessItems(delegate);
} else {
TRACE_BACKGROUND_GC(
collector_->heap()->tracer(),
GCTracer::BackgroundScope::MINOR_MC_BACKGROUND_MARKING);
TRACE_GC1(collector_->heap()->tracer(),
GCTracer::Scope::MINOR_MC_BACKGROUND_MARKING,
ThreadKind::kBackground);
ProcessItems(delegate);
}
}
......@@ -5125,8 +5124,8 @@ class YoungGenerationEvacuator : public Evacuator {
LocalSpaceKind::kCompactionSpaceForMinorMarkCompact),
collector_(collector) {}
GCTracer::BackgroundScope::ScopeId GetBackgroundTracingScope() override {
return GCTracer::BackgroundScope::MINOR_MC_BACKGROUND_EVACUATE_COPY;
GCTracer::Scope::ScopeId GetBackgroundTracingScope() override {
return GCTracer::Scope::MINOR_MC_BACKGROUND_EVACUATE_COPY;
}
GCTracer::Scope::ScopeId GetTracingScope() override {
......
......@@ -160,8 +160,8 @@ class MemoryAllocator::Unmapper::UnmapFreeMemoryJob : public JobTask {
: unmapper_(unmapper), tracer_(isolate->heap()->tracer()) {}
void Run(JobDelegate* delegate) override {
TRACE_BACKGROUND_GC(tracer_,
GCTracer::BackgroundScope::BACKGROUND_UNMAPPER);
TRACE_GC1(tracer_, GCTracer::Scope::BACKGROUND_UNMAPPER,
ThreadKind::kBackground);
unmapper_->PerformFreeMemoryOnQueuedChunks<FreeMode::kUncommitPooled>(
delegate);
if (FLAG_trace_unmapper) {
......
......@@ -182,9 +182,9 @@ void ScavengerCollector::JobTask::Run(JobDelegate* delegate) {
GCTracer::Scope::SCAVENGER_SCAVENGE_PARALLEL);
ProcessItems(delegate, scavenger);
} else {
TRACE_BACKGROUND_GC(
outer_->heap_->tracer(),
GCTracer::BackgroundScope::SCAVENGER_BACKGROUND_SCAVENGE_PARALLEL);
TRACE_GC1(outer_->heap_->tracer(),
GCTracer::Scope::SCAVENGER_BACKGROUND_SCAVENGE_PARALLEL,
ThreadKind::kBackground);
ProcessItems(delegate, scavenger);
}
}
......
......@@ -4,6 +4,7 @@
#include "src/heap/sweeper.h"
#include "src/common/globals.h"
#include "src/execution/vm-state-inl.h"
#include "src/heap/code-object-registry.h"
#include "src/heap/free-list-inl.h"
......@@ -95,8 +96,8 @@ class Sweeper::SweeperTask final : public CancelableTask {
private:
void RunInternal() final {
TRACE_BACKGROUND_GC(tracer_,
GCTracer::BackgroundScope::MC_BACKGROUND_SWEEPING);
TRACE_GC1(tracer_, GCTracer::Scope::MC_BACKGROUND_SWEEPING,
ThreadKind::kBackground);
DCHECK(IsValidSweepingSpace(space_to_start_));
const int offset = space_to_start_ - FIRST_GROWABLE_PAGED_SPACE;
for (int i = 0; i < kNumberOfSweepingSpaces; i++) {
......@@ -608,8 +609,8 @@ class Sweeper::IterabilityTask final : public CancelableTask {
private:
void RunInternal() final {
TRACE_BACKGROUND_GC(tracer_,
GCTracer::BackgroundScope::MC_BACKGROUND_SWEEPING);
TRACE_GC1(tracer_, GCTracer::Scope::MC_BACKGROUND_SWEEPING,
ThreadKind::kBackground);
for (Page* page : sweeper_->iterability_list_) {
sweeper_->MakeIterable(page);
}
......
......@@ -354,10 +354,10 @@ TEST_F(GCTracerTest, BackgroundScavengerScope) {
tracer->ResetForTesting();
tracer->Start(SCAVENGER, GarbageCollectionReason::kTesting,
"collector unittest");
tracer->AddBackgroundScopeSample(
GCTracer::BackgroundScope::SCAVENGER_BACKGROUND_SCAVENGE_PARALLEL, 10);
tracer->AddBackgroundScopeSample(
GCTracer::BackgroundScope::SCAVENGER_BACKGROUND_SCAVENGE_PARALLEL, 1);
tracer->AddScopeSampleBackground(
GCTracer::Scope::SCAVENGER_BACKGROUND_SCAVENGE_PARALLEL, 10);
tracer->AddScopeSampleBackground(
GCTracer::Scope::SCAVENGER_BACKGROUND_SCAVENGE_PARALLEL, 1);
tracer->Stop(SCAVENGER);
EXPECT_DOUBLE_EQ(
11, tracer->current_
......@@ -369,20 +369,18 @@ TEST_F(GCTracerTest, BackgroundMinorMCScope) {
tracer->ResetForTesting();
tracer->Start(MINOR_MARK_COMPACTOR, GarbageCollectionReason::kTesting,
"collector unittest");
tracer->AddBackgroundScopeSample(
GCTracer::BackgroundScope::MINOR_MC_BACKGROUND_MARKING, 10);
tracer->AddBackgroundScopeSample(
GCTracer::BackgroundScope::MINOR_MC_BACKGROUND_MARKING, 1);
tracer->AddBackgroundScopeSample(
GCTracer::BackgroundScope::MINOR_MC_BACKGROUND_EVACUATE_COPY, 20);
tracer->AddBackgroundScopeSample(
GCTracer::BackgroundScope::MINOR_MC_BACKGROUND_EVACUATE_COPY, 2);
tracer->AddBackgroundScopeSample(
GCTracer::BackgroundScope::MINOR_MC_BACKGROUND_EVACUATE_UPDATE_POINTERS,
30);
tracer->AddBackgroundScopeSample(
GCTracer::BackgroundScope::MINOR_MC_BACKGROUND_EVACUATE_UPDATE_POINTERS,
3);
tracer->AddScopeSampleBackground(GCTracer::Scope::MINOR_MC_BACKGROUND_MARKING,
10);
tracer->AddScopeSampleBackground(GCTracer::Scope::MINOR_MC_BACKGROUND_MARKING,
1);
tracer->AddScopeSampleBackground(
GCTracer::Scope::MINOR_MC_BACKGROUND_EVACUATE_COPY, 20);
tracer->AddScopeSampleBackground(
GCTracer::Scope::MINOR_MC_BACKGROUND_EVACUATE_COPY, 2);
tracer->AddScopeSampleBackground(
GCTracer::Scope::MINOR_MC_BACKGROUND_EVACUATE_UPDATE_POINTERS, 30);
tracer->AddScopeSampleBackground(
GCTracer::Scope::MINOR_MC_BACKGROUND_EVACUATE_UPDATE_POINTERS, 3);
tracer->Stop(MINOR_MARK_COMPACTOR);
EXPECT_DOUBLE_EQ(
11,
......@@ -398,32 +396,27 @@ TEST_F(GCTracerTest, BackgroundMinorMCScope) {
TEST_F(GCTracerTest, BackgroundMajorMCScope) {
GCTracer* tracer = i_isolate()->heap()->tracer();
tracer->ResetForTesting();
tracer->AddBackgroundScopeSample(
GCTracer::BackgroundScope::MC_BACKGROUND_MARKING, 100);
tracer->AddBackgroundScopeSample(
GCTracer::BackgroundScope::MC_BACKGROUND_SWEEPING, 200);
tracer->AddBackgroundScopeSample(
GCTracer::BackgroundScope::MC_BACKGROUND_MARKING, 10);
tracer->AddScopeSampleBackground(GCTracer::Scope::MC_BACKGROUND_MARKING, 100);
tracer->AddScopeSampleBackground(GCTracer::Scope::MC_BACKGROUND_SWEEPING,
200);
tracer->AddScopeSampleBackground(GCTracer::Scope::MC_BACKGROUND_MARKING, 10);
// Scavenger should not affect the major mark-compact scopes.
tracer->Start(SCAVENGER, GarbageCollectionReason::kTesting,
"collector unittest");
tracer->Stop(SCAVENGER);
tracer->AddBackgroundScopeSample(
GCTracer::BackgroundScope::MC_BACKGROUND_SWEEPING, 20);
tracer->AddBackgroundScopeSample(
GCTracer::BackgroundScope::MC_BACKGROUND_MARKING, 1);
tracer->AddBackgroundScopeSample(
GCTracer::BackgroundScope::MC_BACKGROUND_SWEEPING, 2);
tracer->AddScopeSampleBackground(GCTracer::Scope::MC_BACKGROUND_SWEEPING, 20);
tracer->AddScopeSampleBackground(GCTracer::Scope::MC_BACKGROUND_MARKING, 1);
tracer->AddScopeSampleBackground(GCTracer::Scope::MC_BACKGROUND_SWEEPING, 2);
tracer->Start(MARK_COMPACTOR, GarbageCollectionReason::kTesting,
"collector unittest");
tracer->AddBackgroundScopeSample(
GCTracer::BackgroundScope::MC_BACKGROUND_EVACUATE_COPY, 30);
tracer->AddBackgroundScopeSample(
GCTracer::BackgroundScope::MC_BACKGROUND_EVACUATE_COPY, 3);
tracer->AddBackgroundScopeSample(
GCTracer::BackgroundScope::MC_BACKGROUND_EVACUATE_UPDATE_POINTERS, 40);
tracer->AddBackgroundScopeSample(
GCTracer::BackgroundScope::MC_BACKGROUND_EVACUATE_UPDATE_POINTERS, 4);
tracer->AddScopeSampleBackground(GCTracer::Scope::MC_BACKGROUND_EVACUATE_COPY,
30);
tracer->AddScopeSampleBackground(GCTracer::Scope::MC_BACKGROUND_EVACUATE_COPY,
3);
tracer->AddScopeSampleBackground(
GCTracer::Scope::MC_BACKGROUND_EVACUATE_UPDATE_POINTERS, 40);
tracer->AddScopeSampleBackground(
GCTracer::Scope::MC_BACKGROUND_EVACUATE_UPDATE_POINTERS, 4);
tracer->Stop(MARK_COMPACTOR);
EXPECT_DOUBLE_EQ(
111, tracer->current_.scopes[GCTracer::Scope::MC_BACKGROUND_MARKING]);
......@@ -442,8 +435,8 @@ class ThreadWithBackgroundScope final : public base::Thread {
explicit ThreadWithBackgroundScope(GCTracer* tracer)
: Thread(Options("ThreadWithBackgroundScope")), tracer_(tracer) {}
void Run() override {
GCTracer::BackgroundScope scope(
tracer_, GCTracer::BackgroundScope::MC_BACKGROUND_MARKING, nullptr);
GCTracer::Scope scope(tracer_, GCTracer::Scope::MC_BACKGROUND_MARKING,
ThreadKind::kBackground);
}
private:
......
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