From c0d3a6224408f9e806ebe495fe99f6321018d687 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Fri, 18 Sep 2015 12:49:09 -0700 Subject: [PATCH] Bug 1204169 - Push SPS pseudo frame entries when GCing; r=terrence --- js/src/gc/GCInternals.h | 1 + js/src/jsgc.cpp | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/js/src/gc/GCInternals.h b/js/src/gc/GCInternals.h index 79cab1b3f35d..03124f86fdff 100644 --- a/js/src/gc/GCInternals.h +++ b/js/src/gc/GCInternals.h @@ -56,6 +56,7 @@ class MOZ_RAII AutoTraceSession void operator=(const AutoTraceSession&) = delete; JS::HeapState prevState; + AutoSPSEntry pseudoFrame; }; struct MOZ_RAII AutoPrepareForTracing diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index 1f6e3d9fc3b3..6ff3c9616831 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -5580,11 +5580,29 @@ GCRuntime::finishCollection(JS::gcreason::Reason reason) } } +static const char* +HeapStateToLabel(JS::HeapState heapState) +{ + switch (heapState) { + case JS::HeapState::MinorCollecting: + return "js::Nursery::collect"; + case JS::HeapState::MajorCollecting: + return "js::GCRuntime::collect"; + case JS::HeapState::Tracing: + return "JS_IterateCompartments"; + case JS::HeapState::Idle: + MOZ_CRASH("Should never have an Idle heap state when pushing GC pseudo frames!"); + } + MOZ_ASSERT_UNREACHABLE("Should have exhausted every JS::HeapState variant!"); + return nullptr; +} + /* Start a new heap session. */ AutoTraceSession::AutoTraceSession(JSRuntime* rt, JS::HeapState heapState) : lock(rt), runtime(rt), - prevState(rt->heapState_) + prevState(rt->heapState_), + pseudoFrame(rt, HeapStateToLabel(heapState), ProfileEntry::Category::GC) { MOZ_ASSERT(rt->heapState_ == JS::HeapState::Idle); MOZ_ASSERT(heapState != JS::HeapState::Idle);