Commit 2b9c99a8 authored by ulan's avatar ulan Committed by Commit bot

Trace events corresponding to GCTracer scopes.

BUG=chromium:597310
LOG=NO

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

Cr-Commit-Position: refs/heads/master@{#35233}
parent 4598356f
......@@ -44,6 +44,18 @@ GCTracer::Scope::~Scope() {
}
}
const char* GCTracer::Scope::Name(ScopeId id) {
#define CASE(scope) \
case Scope::scope: \
return "V8.GC_" #scope;
switch (id) {
TRACER_SCOPES(CASE)
case Scope::NUMBER_OF_SCOPES:
break;
}
#undef CASE
return "(unknown)";
}
GCTracer::Event::Event(Type type, const char* gc_reason,
const char* collector_reason)
......
......@@ -58,6 +58,63 @@ inline BytesAndDuration MakeBytesAndDuration(uint64_t bytes, double duration) {
enum ScavengeSpeedMode { kForAllObjects, kForSurvivedObjects };
#define TRACER_SCOPES(F) \
F(EXTERNAL_WEAK_GLOBAL_HANDLES) \
F(MC_CLEAR) \
F(MC_CLEAR_CODE_FLUSH) \
F(MC_CLEAR_DEPENDENT_CODE) \
F(MC_CLEAR_GLOBAL_HANDLES) \
F(MC_CLEAR_MAPS) \
F(MC_CLEAR_SLOTS_BUFFER) \
F(MC_CLEAR_STORE_BUFFER) \
F(MC_CLEAR_STRING_TABLE) \
F(MC_CLEAR_WEAK_CELLS) \
F(MC_CLEAR_WEAK_COLLECTIONS) \
F(MC_CLEAR_WEAK_LISTS) \
F(MC_EVACUATE) \
F(MC_EVACUATE_CANDIDATES) \
F(MC_EVACUATE_CLEAN_UP) \
F(MC_EVACUATE_COPY) \
F(MC_EVACUATE_UPDATE_POINTERS) \
F(MC_EVACUATE_UPDATE_POINTERS_BETWEEN_EVACUATED) \
F(MC_EVACUATE_UPDATE_POINTERS_TO_EVACUATED) \
F(MC_EVACUATE_UPDATE_POINTERS_TO_NEW) \
F(MC_EVACUATE_UPDATE_POINTERS_WEAK) \
F(MC_EXTERNAL_EPILOGUE) \
F(MC_EXTERNAL_PROLOGUE) \
F(MC_FINISH) \
F(MC_INCREMENTAL_FINALIZE) \
F(MC_INCREMENTAL_EXTERNAL_EPILOGUE) \
F(MC_INCREMENTAL_EXTERNAL_PROLOGUE) \
F(MC_MARK) \
F(MC_MARK_FINISH_INCREMENTAL) \
F(MC_MARK_PREPARE_CODE_FLUSH) \
F(MC_MARK_ROOTS) \
F(MC_MARK_WEAK_CLOSURE) \
F(MC_MARK_WEAK_CLOSURE_EPHEMERAL) \
F(MC_MARK_WEAK_CLOSURE_WEAK_HANDLES) \
F(MC_MARK_WEAK_CLOSURE_WEAK_ROOTS) \
F(MC_MARK_WEAK_CLOSURE_HARMONY) \
F(MC_SWEEP) \
F(MC_SWEEP_CODE) \
F(MC_SWEEP_MAP) \
F(MC_SWEEP_OLD) \
F(SCAVENGER_CODE_FLUSH_CANDIDATES) \
F(SCAVENGER_EXTERNAL_EPILOGUE) \
F(SCAVENGER_EXTERNAL_PROLOGUE) \
F(SCAVENGER_OBJECT_GROUPS) \
F(SCAVENGER_OLD_TO_NEW_POINTERS) \
F(SCAVENGER_ROOTS) \
F(SCAVENGER_SCAVENGE) \
F(SCAVENGER_SEMISPACE) \
F(SCAVENGER_WEAK)
#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); \
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8"), \
GCTracer::Scope::Name(gc_tracer_scope_id))
// GCTracer collects and prints ONE line after each garbage collector
// invocation IFF --trace_gc is used.
// TODO(ernstm): Unit tests.
......@@ -66,60 +123,15 @@ class GCTracer {
class Scope {
public:
enum ScopeId {
EXTERNAL_WEAK_GLOBAL_HANDLES,
MC_CLEAR,
MC_CLEAR_CODE_FLUSH,
MC_CLEAR_DEPENDENT_CODE,
MC_CLEAR_GLOBAL_HANDLES,
MC_CLEAR_MAPS,
MC_CLEAR_SLOTS_BUFFER,
MC_CLEAR_STORE_BUFFER,
MC_CLEAR_STRING_TABLE,
MC_CLEAR_WEAK_CELLS,
MC_CLEAR_WEAK_COLLECTIONS,
MC_CLEAR_WEAK_LISTS,
MC_EVACUATE,
MC_EVACUATE_CANDIDATES,
MC_EVACUATE_CLEAN_UP,
MC_EVACUATE_COPY,
MC_EVACUATE_UPDATE_POINTERS,
MC_EVACUATE_UPDATE_POINTERS_BETWEEN_EVACUATED,
MC_EVACUATE_UPDATE_POINTERS_TO_EVACUATED,
MC_EVACUATE_UPDATE_POINTERS_TO_NEW,
MC_EVACUATE_UPDATE_POINTERS_WEAK,
MC_EXTERNAL_EPILOGUE,
MC_EXTERNAL_PROLOGUE,
MC_FINISH,
MC_INCREMENTAL_FINALIZE,
MC_INCREMENTAL_EXTERNAL_EPILOGUE,
MC_INCREMENTAL_EXTERNAL_PROLOGUE,
MC_MARK,
MC_MARK_FINISH_INCREMENTAL,
MC_MARK_PREPARE_CODE_FLUSH,
MC_MARK_ROOTS,
MC_MARK_WEAK_CLOSURE,
MC_MARK_WEAK_CLOSURE_EPHEMERAL,
MC_MARK_WEAK_CLOSURE_WEAK_HANDLES,
MC_MARK_WEAK_CLOSURE_WEAK_ROOTS,
MC_MARK_WEAK_CLOSURE_HARMONY,
MC_SWEEP,
MC_SWEEP_CODE,
MC_SWEEP_MAP,
MC_SWEEP_OLD,
SCAVENGER_CODE_FLUSH_CANDIDATES,
SCAVENGER_EXTERNAL_EPILOGUE,
SCAVENGER_EXTERNAL_PROLOGUE,
SCAVENGER_OBJECT_GROUPS,
SCAVENGER_OLD_TO_NEW_POINTERS,
SCAVENGER_ROOTS,
SCAVENGER_SCAVENGE,
SCAVENGER_SEMISPACE,
SCAVENGER_WEAK,
NUMBER_OF_SCOPES
#define DEFINE_SCOPE(scope) scope,
TRACER_SCOPES(DEFINE_SCOPE)
#undef DEFINE_SCOPE
NUMBER_OF_SCOPES
};
Scope(GCTracer* tracer, ScopeId scope);
~Scope();
static const char* Name(ScopeId id);
private:
GCTracer* tracer_;
......
......@@ -819,7 +819,7 @@ void Heap::FinalizeIncrementalMarking(const char* gc_reason) {
PrintF("[IncrementalMarking] (%s).\n", gc_reason);
}
GCTracer::Scope gc_scope(tracer(), GCTracer::Scope::MC_INCREMENTAL_FINALIZE);
TRACE_GC(tracer(), GCTracer::Scope::MC_INCREMENTAL_FINALIZE);
HistogramTimerScope incremental_marking_scope(
isolate()->counters()->gc_incremental_marking_finalize());
TRACE_EVENT0("v8", "V8.GCIncrementalMarkingFinalize");
......@@ -828,8 +828,7 @@ void Heap::FinalizeIncrementalMarking(const char* gc_reason) {
GCCallbacksScope scope(this);
if (scope.CheckReenter()) {
AllowHeapAllocation allow_allocation;
GCTracer::Scope scope(tracer(),
GCTracer::Scope::MC_INCREMENTAL_EXTERNAL_PROLOGUE);
TRACE_GC(tracer(), GCTracer::Scope::MC_INCREMENTAL_EXTERNAL_PROLOGUE);
VMState<EXTERNAL> state(isolate_);
HandleScope handle_scope(isolate_);
CallGCPrologueCallbacks(kGCTypeIncrementalMarking, kNoGCCallbackFlags);
......@@ -840,8 +839,7 @@ void Heap::FinalizeIncrementalMarking(const char* gc_reason) {
GCCallbacksScope scope(this);
if (scope.CheckReenter()) {
AllowHeapAllocation allow_allocation;
GCTracer::Scope scope(tracer(),
GCTracer::Scope::MC_INCREMENTAL_EXTERNAL_EPILOGUE);
TRACE_GC(tracer(), GCTracer::Scope::MC_INCREMENTAL_EXTERNAL_EPILOGUE);
VMState<EXTERNAL> state(isolate_);
HandleScope handle_scope(isolate_);
CallGCEpilogueCallbacks(kGCTypeIncrementalMarking, kNoGCCallbackFlags);
......@@ -1285,10 +1283,9 @@ bool Heap::PerformGarbageCollection(
GCCallbacksScope scope(this);
if (scope.CheckReenter()) {
AllowHeapAllocation allow_allocation;
GCTracer::Scope scope(tracer(),
collector == MARK_COMPACTOR
? GCTracer::Scope::MC_EXTERNAL_PROLOGUE
: GCTracer::Scope::SCAVENGER_EXTERNAL_PROLOGUE);
TRACE_GC(tracer(), collector == MARK_COMPACTOR
? GCTracer::Scope::MC_EXTERNAL_PROLOGUE
: GCTracer::Scope::SCAVENGER_EXTERNAL_PROLOGUE);
VMState<EXTERNAL> state(isolate_);
HandleScope handle_scope(isolate_);
CallGCPrologueCallbacks(gc_type, kNoGCCallbackFlags);
......@@ -1335,8 +1332,7 @@ bool Heap::PerformGarbageCollection(
gc_post_processing_depth_++;
{
AllowHeapAllocation allow_allocation;
GCTracer::Scope scope(tracer(),
GCTracer::Scope::EXTERNAL_WEAK_GLOBAL_HANDLES);
TRACE_GC(tracer(), GCTracer::Scope::EXTERNAL_WEAK_GLOBAL_HANDLES);
freed_global_handles =
isolate_->global_handles()->PostGarbageCollectionProcessing(
collector, gc_callback_flags);
......@@ -1366,10 +1362,9 @@ bool Heap::PerformGarbageCollection(
GCCallbacksScope scope(this);
if (scope.CheckReenter()) {
AllowHeapAllocation allow_allocation;
GCTracer::Scope scope(tracer(),
collector == MARK_COMPACTOR
? GCTracer::Scope::MC_EXTERNAL_EPILOGUE
: GCTracer::Scope::SCAVENGER_EXTERNAL_EPILOGUE);
TRACE_GC(tracer(), collector == MARK_COMPACTOR
? GCTracer::Scope::MC_EXTERNAL_EPILOGUE
: GCTracer::Scope::SCAVENGER_EXTERNAL_EPILOGUE);
VMState<EXTERNAL> state(isolate_);
HandleScope handle_scope(isolate_);
CallGCEpilogueCallbacks(gc_type, gc_callback_flags);
......@@ -1622,7 +1617,7 @@ class ScavengeWeakObjectRetainer : public WeakObjectRetainer {
void Heap::Scavenge() {
GCTracer::Scope gc_scope(tracer(), GCTracer::Scope::SCAVENGER_SCAVENGE);
TRACE_GC(tracer(), GCTracer::Scope::SCAVENGER_SCAVENGE);
RelocationLock relocation_lock(this);
// There are soft limits in the allocation code, designed to trigger a mark
// sweep collection by failing allocations. There is no sense in trying to
......@@ -1683,20 +1678,19 @@ void Heap::Scavenge() {
{
// Copy roots.
GCTracer::Scope gc_scope(tracer(), GCTracer::Scope::SCAVENGER_ROOTS);
TRACE_GC(tracer(), GCTracer::Scope::SCAVENGER_ROOTS);
IterateRoots(&scavenge_visitor, VISIT_ALL_IN_SCAVENGE);
}
{
// Copy objects reachable from the old generation.
GCTracer::Scope gc_scope(tracer(),
GCTracer::Scope::SCAVENGER_OLD_TO_NEW_POINTERS);
TRACE_GC(tracer(), GCTracer::Scope::SCAVENGER_OLD_TO_NEW_POINTERS);
RememberedSet<OLD_TO_NEW>::IterateWithWrapper(this,
Scavenger::ScavengeObject);
}
{
GCTracer::Scope gc_scope(tracer(), GCTracer::Scope::SCAVENGER_WEAK);
TRACE_GC(tracer(), GCTracer::Scope::SCAVENGER_WEAK);
// Copy objects reachable from the encountered weak collections list.
scavenge_visitor.VisitPointer(&encountered_weak_collections_);
// Copy objects reachable from the encountered weak cells.
......@@ -1705,8 +1699,7 @@ void Heap::Scavenge() {
{
// Copy objects reachable from the code flushing candidates list.
GCTracer::Scope gc_scope(tracer(),
GCTracer::Scope::SCAVENGER_CODE_FLUSH_CANDIDATES);
TRACE_GC(tracer(), GCTracer::Scope::SCAVENGER_CODE_FLUSH_CANDIDATES);
MarkCompactCollector* collector = mark_compact_collector();
if (collector->is_code_flushing_enabled()) {
collector->code_flusher()->IteratePointersToFromSpace(&scavenge_visitor);
......@@ -1714,7 +1707,7 @@ void Heap::Scavenge() {
}
{
GCTracer::Scope gc_scope(tracer(), GCTracer::Scope::SCAVENGER_SEMISPACE);
TRACE_GC(tracer(), GCTracer::Scope::SCAVENGER_SEMISPACE);
new_space_front = DoScavenge(&scavenge_visitor, new_space_front);
}
......@@ -1726,8 +1719,7 @@ void Heap::Scavenge() {
&scavenge_visitor);
new_space_front = DoScavenge(&scavenge_visitor, new_space_front);
} else {
GCTracer::Scope gc_scope(tracer(),
GCTracer::Scope::SCAVENGER_OBJECT_GROUPS);
TRACE_GC(tracer(), GCTracer::Scope::SCAVENGER_OBJECT_GROUPS);
while (isolate()->global_handles()->IterateObjectGroups(
&scavenge_visitor, &IsUnscavengedHeapObject)) {
new_space_front = DoScavenge(&scavenge_visitor, new_space_front);
......
This diff is collapsed.
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