| Index: src/heap/mark-compact.cc
|
| diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc
|
| index 3a88eebdccb79d1f98b3c1e32c24a01aaf693ab0..ce7d8782a8601c1a9f8be61b04f51631f173f8f2 100644
|
| --- a/src/heap/mark-compact.cc
|
| +++ b/src/heap/mark-compact.cc
|
| @@ -25,6 +25,7 @@
|
| #include "src/heap/spaces-inl.h"
|
| #include "src/ic/ic.h"
|
| #include "src/ic/stub-cache.h"
|
| +#include "src/tracing/tracing-category-observer.h"
|
| #include "src/utils-inl.h"
|
| #include "src/v8.h"
|
|
|
| @@ -2236,17 +2237,21 @@ void MarkCompactCollector::VisitAllObjects(HeapObjectVisitor* visitor) {
|
| }
|
|
|
| void MarkCompactCollector::RecordObjectStats() {
|
| - if (FLAG_track_gc_object_stats) {
|
| + if (V8_UNLIKELY(FLAG_gc_stats)) {
|
| + heap()->CreateObjectStats();
|
| ObjectStatsVisitor visitor(heap(), heap()->live_object_stats_,
|
| heap()->dead_object_stats_);
|
| VisitAllObjects(&visitor);
|
| - std::stringstream live, dead;
|
| - heap()->live_object_stats_->Dump(live);
|
| - heap()->dead_object_stats_->Dump(dead);
|
| - TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("v8.gc_stats"),
|
| - "V8.GC_Objects_Stats", TRACE_EVENT_SCOPE_THREAD,
|
| - "live", TRACE_STR_COPY(live.str().c_str()), "dead",
|
| - TRACE_STR_COPY(dead.str().c_str()));
|
| + if (V8_UNLIKELY(FLAG_gc_stats &
|
| + v8::tracing::TracingCategoryObserver::ENABLED_BY_TRACING)) {
|
| + std::stringstream live, dead;
|
| + heap()->live_object_stats_->Dump(live);
|
| + heap()->dead_object_stats_->Dump(dead);
|
| + TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("v8.gc_stats"),
|
| + "V8.GC_Objects_Stats", TRACE_EVENT_SCOPE_THREAD,
|
| + "live", TRACE_STR_COPY(live.str().c_str()), "dead",
|
| + TRACE_STR_COPY(dead.str().c_str()));
|
| + }
|
| if (FLAG_trace_gc_object_stats) {
|
| heap()->live_object_stats_->PrintJSON("live");
|
| heap()->dead_object_stats_->PrintJSON("dead");
|
|
|