Backed out 3 changesets (bug 1417976) for causing devtools failures in builds/worker/workspace/build/src/tools/profiler/core/platform.cpp

Backed out changeset e70a24d50f20 (bug 1417976)
Backed out changeset 01ca16ef0b25 (bug 1417976)
Backed out changeset ede2fbe20d14 (bug 1417976)
This commit is contained in:
Noemi Erli 2018-11-03 01:40:27 +02:00
Родитель 890cf8bcf7
Коммит e8db1dcf1f
18 изменённых файлов: 71 добавлений и 604 удалений

Просмотреть файл

@ -424,10 +424,6 @@ nsDocShell::~nsDocShell()
// Avoid notifying observers while we're in the dtor.
mIsBeingDestroyed = true;
#ifdef MOZ_GECKO_PROFILER
profiler_unregister_pages(mHistoryID);
#endif
Destroy();
if (mSessionHistory) {
@ -11326,18 +11322,6 @@ nsDocShell::OnNewURI(nsIURI* aURI, nsIChannel* aChannel,
}
}
#ifdef MOZ_GECKO_PROFILER
if (updateGHistory) {
uint32_t id = 0;
nsAutoCString spec;
if (mLSHE) {
mLSHE->GetID(&id);
}
aURI->GetSpec(spec);
profiler_register_page(mHistoryID, id, spec, IsFrame());
}
#endif
// If this is a POST request, we do not want to include this in global
// history.
if (updateGHistory && aAddToGlobalHistory && !ChannelIsPost(aChannel)) {
@ -11648,12 +11632,6 @@ nsDocShell::AddState(JS::Handle<JS::Value> aData, const nsAString& aTitle,
// we'll just set mOSHE here.
mOSHE = newSHEntry;
#ifdef MOZ_GECKO_PROFILER
uint32_t id = 0;
GetOSHEId(&id);
profiler_register_page(mHistoryID, id, NS_ConvertUTF16toUTF8(aURL), IsFrame());
#endif
} else {
newSHEntry = mOSHE;
newSHEntry->SetURI(newURI);
@ -13740,17 +13718,6 @@ nsDocShell::SetOriginAttributes(JS::Handle<JS::Value> aOriginAttributes,
return SetOriginAttributes(attrs);
}
NS_IMETHODIMP
nsDocShell::GetOSHEId(uint32_t* aSHEntryId)
{
if (mOSHE) {
mOSHE->GetID(aSHEntryId);
return NS_OK;
} else {
return NS_ERROR_FAILURE;
}
}
NS_IMETHODIMP
nsDocShell::GetAsyncPanZoomEnabled(bool* aOut)
{

Просмотреть файл

@ -1091,8 +1091,6 @@ interface nsIDocShell : nsIDocShellTreeItem
in string asyncCause);
[noscript,notxpcom,nostdcall] void notifyJSRunToCompletionStop();
[noscript] void GetOSHEId(out uint32_t aSHEntryId);
/**
* This attribute determines whether a document which is not about:blank has
* already be loaded by this docShell.

Просмотреть файл

@ -102,16 +102,14 @@ void
nsDOMNavigationTiming::NotifyUnloadEventStart()
{
mUnloadStart = TimeStamp::Now();
PROFILER_TRACING_DOCSHELL(
"Navigation", "Unload", TRACING_INTERVAL_START, mDocShell);
PROFILER_TRACING("Navigation", "Unload", TRACING_INTERVAL_START);
}
void
nsDOMNavigationTiming::NotifyUnloadEventEnd()
{
mUnloadEnd = TimeStamp::Now();
PROFILER_TRACING_DOCSHELL(
"Navigation", "Unload", TRACING_INTERVAL_END, mDocShell);
PROFILER_TRACING("Navigation", "Unload", TRACING_INTERVAL_END);
}
void
@ -122,8 +120,7 @@ nsDOMNavigationTiming::NotifyLoadEventStart()
}
mLoadEventStart = TimeStamp::Now();
PROFILER_TRACING_DOCSHELL(
"Navigation", "Load", TRACING_INTERVAL_START, mDocShell);
PROFILER_TRACING("Navigation", "Load", TRACING_INTERVAL_START);
if (IsTopLevelContentDocumentInContentProcess()) {
TimeStamp now = TimeStamp::Now();
@ -154,8 +151,7 @@ nsDOMNavigationTiming::NotifyLoadEventEnd()
}
mLoadEventEnd = TimeStamp::Now();
PROFILER_TRACING_DOCSHELL(
"Navigation", "Load", TRACING_INTERVAL_END, mDocShell);
PROFILER_TRACING("Navigation", "Load", TRACING_INTERVAL_END);
if (IsTopLevelContentDocumentInContentProcess()) {
Telemetry::AccumulateTimeDelta(Telemetry::TIME_TO_LOAD_EVENT_END_MS,
@ -219,8 +215,7 @@ nsDOMNavigationTiming::NotifyDOMContentLoadedStart(nsIURI* aURI)
mLoadedURI = aURI;
mDOMContentLoadedEventStart = TimeStamp::Now();
PROFILER_TRACING_DOCSHELL(
"Navigation", "DOMContentLoaded", TRACING_INTERVAL_START, mDocShell);
PROFILER_TRACING("Navigation", "DOMContentLoaded", TRACING_INTERVAL_START);
if (IsTopLevelContentDocumentInContentProcess()) {
TimeStamp now = TimeStamp::Now();
@ -253,8 +248,7 @@ nsDOMNavigationTiming::NotifyDOMContentLoadedEnd(nsIURI* aURI)
mLoadedURI = aURI;
mDOMContentLoadedEventEnd = TimeStamp::Now();
PROFILER_TRACING_DOCSHELL(
"Navigation", "DOMContentLoaded", TRACING_INTERVAL_END, mDocShell);
PROFILER_TRACING("Navigation", "DOMContentLoaded", TRACING_INTERVAL_END);
if (IsTopLevelContentDocumentInContentProcess()) {
Telemetry::AccumulateTimeDelta(Telemetry::TIME_TO_DOM_CONTENT_LOADED_END_MS,
@ -362,12 +356,8 @@ nsDOMNavigationTiming::TTITimeout(nsITimer* aTimer)
int(elapsed.ToMilliseconds()),
int(elapsedLongTask.ToMilliseconds()),spec.get());
DECLARE_DOCSHELL_AND_HISTORY_ID(mDocShell);
profiler_add_marker(
"TTI", MakeUnique<UserTimingMarkerPayload>(NS_ConvertASCIItoUTF16(marker),
mTTFI,
docShellId,
docShellHistoryId));
"TTI", MakeUnique<UserTimingMarkerPayload>(NS_ConvertASCIItoUTF16(marker), mTTFI));
}
#endif
return;

Просмотреть файл

@ -6,7 +6,6 @@
#include "nsPresContext.h"
#include "nsContentUtils.h"
#include "nsDocShell.h"
#include "nsError.h"
#include <new>
#include "nsIContent.h"
@ -1135,17 +1134,12 @@ EventDispatcher::Dispatch(nsISupports* aTarget,
AUTO_PROFILER_LABEL_DYNAMIC_LOSSY_NSSTRING(
"EventDispatcher::Dispatch", OTHER, typeStr);
nsCOMPtr<nsIDocShell> docShell;
docShell = nsContentUtils::GetDocShellForEventTarget(aEvent->mTarget);
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell);
profiler_add_marker(
"DOMEvent",
MakeUnique<DOMEventMarkerPayload>(typeStr,
aEvent->mTimeStamp,
"DOMEvent",
TRACING_INTERVAL_START,
docShellId,
docShellHistoryId));
TRACING_INTERVAL_START));
EventTargetChainItem::HandleEventTargetChain(chain, postVisitor,
aCallback, cd);
@ -1155,9 +1149,7 @@ EventDispatcher::Dispatch(nsISupports* aTarget,
MakeUnique<DOMEventMarkerPayload>(typeStr,
aEvent->mTimeStamp,
"DOMEvent",
TRACING_INTERVAL_END,
docShellId,
docShellHistoryId));
TRACING_INTERVAL_END));
} else
#endif
{

Просмотреть файл

@ -7,7 +7,6 @@
#include "Performance.h"
#include "GeckoProfiler.h"
#include "nsIDocShell.h"
#include "nsRFPService.h"
#include "PerformanceEntry.h"
#include "PerformanceMainThread.h"
@ -250,14 +249,9 @@ Performance::Mark(const nsAString& aName, ErrorResult& aRv)
#ifdef MOZ_GECKO_PROFILER
if (profiler_is_active()) {
nsCOMPtr<EventTarget> et = do_QueryInterface(GetOwner());
nsCOMPtr<nsIDocShell> docShell =
nsContentUtils::GetDocShellForEventTarget(et);
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell);
profiler_add_marker(
"UserTiming",
MakeUnique<UserTimingMarkerPayload>(
aName, TimeStamp::Now(), docShellId, docShellHistoryId));
MakeUnique<UserTimingMarkerPayload>(aName, TimeStamp::Now()));
}
#endif
}
@ -353,18 +347,10 @@ Performance::Measure(const nsAString& aName,
endMark.emplace(aEndMark.Value());
}
nsCOMPtr<EventTarget> et = do_QueryInterface(GetOwner());
nsCOMPtr<nsIDocShell> docShell =
nsContentUtils::GetDocShellForEventTarget(et);
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell);
profiler_add_marker("UserTiming",
MakeUnique<UserTimingMarkerPayload>(aName,
startMark,
endMark,
startTimeStamp,
endTimeStamp,
docShellId,
docShellHistoryId));
profiler_add_marker(
"UserTiming",
MakeUnique<UserTimingMarkerPayload>(aName, startMark, endMark,
startTimeStamp, endTimeStamp));
}
#endif
}

Просмотреть файл

@ -18,14 +18,10 @@ namespace mozilla {
class MOZ_RAII AutoProfilerStyleMarker
{
public:
explicit AutoProfilerStyleMarker(UniqueProfilerBacktrace aCause,
const Maybe<nsID>& aDocShellId,
const Maybe<uint32_t>& aDocShellHistoryId)
explicit AutoProfilerStyleMarker(UniqueProfilerBacktrace aCause)
: mActive(profiler_is_active())
, mStartTime(TimeStamp::Now())
, mCause(std::move(aCause))
, mDocShellId(aDocShellId)
, mDocShellHistoryId(aDocShellHistoryId)
{
if (!mActive) {
return;
@ -42,22 +38,15 @@ public:
return;
}
ServoTraversalStatistics::sActive = false;
profiler_add_marker(
"Styles",
MakeUnique<StyleMarkerPayload>(mStartTime,
TimeStamp::Now(),
std::move(mCause),
ServoTraversalStatistics::sSingleton,
mDocShellId,
mDocShellHistoryId));
profiler_add_marker("Styles", MakeUnique<StyleMarkerPayload>(
mStartTime, TimeStamp::Now(), std::move(mCause),
ServoTraversalStatistics::sSingleton));
}
private:
bool mActive;
TimeStamp mStartTime;
UniqueProfilerBacktrace mCause;
Maybe<nsID> mDocShellId;
Maybe<uint32_t> mDocShellHistoryId;
};
} // namespace mozilla

Просмотреть файл

@ -3850,8 +3850,7 @@ PresShell::ScheduleViewManagerFlush(PaintType aType)
void
nsIPresShell::DispatchSynthMouseMove(WidgetGUIEvent* aEvent)
{
AUTO_PROFILER_TRACING_DOCSHELL(
"Paint", "DispatchSynthMouseMove", mPresContext->GetDocShell());
AUTO_PROFILER_TRACING("Paint", "DispatchSynthMouseMove");
nsEventStatus status = nsEventStatus_eIgnore;
nsView* targetView = nsView::GetViewFor(aEvent->mWidget);
if (!targetView)
@ -4321,10 +4320,7 @@ PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush aFlush)
if (MOZ_LIKELY(!mIsDestroying)) {
nsAutoScriptBlocker scriptBlocker;
#ifdef MOZ_GECKO_PROFILER
nsCOMPtr<nsIDocShell> docShell = mPresContext->GetDocShell();
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell);
AutoProfilerStyleMarker tracingStyleFlush(
std::move(mStyleCause), docShellId, docShellHistoryId);
AutoProfilerStyleMarker tracingStyleFlush(std::move(mStyleCause));
#endif
mPresContext->RestyleManager()->ProcessPendingRestyles();
@ -4347,10 +4343,7 @@ PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush aFlush)
if (MOZ_LIKELY(!mIsDestroying)) {
nsAutoScriptBlocker scriptBlocker;
#ifdef MOZ_GECKO_PROFILER
nsCOMPtr<nsIDocShell> docShell = mPresContext->GetDocShell();
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell);
AutoProfilerStyleMarker tracingStyleFlush(
std::move(mStyleCause), docShellId, docShellHistoryId);
AutoProfilerStyleMarker tracingStyleFlush(std::move(mStyleCause));
#endif
mPresContext->RestyleManager()->ProcessPendingRestyles();
@ -8959,12 +8952,8 @@ PresShell::DoReflow(nsIFrame* target, bool aInterruptible)
}
#ifdef MOZ_GECKO_PROFILER
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell);
AutoProfilerTracing tracingLayoutFlush("Paint",
"Reflow",
std::move(mReflowCause),
docShellId,
docShellHistoryId);
AutoProfilerTracing tracingLayoutFlush("Paint", "Reflow",
std::move(mReflowCause));
mReflowCause = nullptr;
#endif

Просмотреть файл

@ -1701,8 +1701,7 @@ nsRefreshDriver::RunFrameRequestCallbacks(TimeStamp aNowTime)
mFrameRequestCallbackDocs.Clear();
if (!frameRequestCallbacks.IsEmpty()) {
AUTO_PROFILER_TRACING_DOCSHELL(
"Paint", "Scripts", GetDocShell(mPresContext));
AUTO_PROFILER_TRACING("Paint", "Scripts");
for (const DocumentFrameCallbacks& docCallbacks : frameRequestCallbacks) {
// XXXbz Bug 863140: GetInnerWindow can return the outer
// window in some cases.

Просмотреть файл

@ -5139,13 +5139,7 @@ ScrollFrameHelper::ScrollEndEvent::Run()
void
ScrollFrameHelper::FireScrollEvent()
{
nsIContent* content = mOuter->GetContent();
nsPresContext* prescontext = mOuter->PresContext();
#ifdef MOZ_GECKO_PROFILER
nsCOMPtr<nsIDocShell> docShell = prescontext->GetDocShell();
AUTO_PROFILER_TRACING_DOCSHELL("Paint", "FireScrollEvent", docShell);
#endif
AUTO_PROFILER_TRACING("Paint", "FireScrollEvent");
MOZ_ASSERT(mScrollEvent);
mScrollEvent->Revoke();
mScrollEvent = nullptr;
@ -5153,6 +5147,8 @@ ScrollFrameHelper::FireScrollEvent()
ActiveLayerTracker::SetCurrentScrollHandlerFrame(mOuter);
WidgetGUIEvent event(true, eScroll, nullptr);
nsEventStatus status = nsEventStatus_eIgnore;
nsIContent* content = mOuter->GetContent();
nsPresContext* prescontext = mOuter->PresContext();
// Fire viewport scroll events at the document (where they
// will bubble to the window)
mozilla::layers::ScrollLinkedEffectDetector detector(content->GetComposedDoc());

Просмотреть файл

@ -2560,10 +2560,7 @@ nsDisplayList::BuildLayers(nsDisplayListBuilder* aBuilder,
RefPtr<ContainerLayer> root;
{
#ifdef MOZ_GECKO_PROFILER
nsCOMPtr<nsIDocShell> docShell = presContext->GetDocShell();
AUTO_PROFILER_TRACING_DOCSHELL("Paint", "LayerBuilding", docShell);
#endif
AUTO_PROFILER_TRACING("Paint", "LayerBuilding");
if (XRE_IsContentProcess() && gfxPrefs::AlwaysPaint()) {
FrameLayerBuilder::InvalidateAllLayers(aLayerManager);

Просмотреть файл

@ -1,44 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "PageInformation.h"
PageInformation::PageInformation(const nsID& aDocShellId,
uint32_t aDocShellHistoryId,
const nsCString& aUrl,
bool aIsSubFrame)
: mDocShellId(aDocShellId)
, mDocShellHistoryId(aDocShellHistoryId)
, mUrl(aUrl)
, mIsSubFrame(aIsSubFrame)
{
}
bool
PageInformation::Equals(PageInformation* aOtherPageInfo)
{
return DocShellHistoryId() == aOtherPageInfo->DocShellHistoryId() &&
DocShellId().Equals(aOtherPageInfo->DocShellId()) &&
IsSubFrame() == aOtherPageInfo->IsSubFrame();
}
void
PageInformation::StreamJSON(SpliceableJSONWriter& aWriter)
{
aWriter.StartObjectElement();
aWriter.StringProperty("docshellId", nsIDToCString(DocShellId()).get());
aWriter.DoubleProperty("historyId", DocShellHistoryId());
aWriter.StringProperty("url", Url().get());
aWriter.BoolProperty("isSubFrame", IsSubFrame());
aWriter.EndObject();
}
size_t
PageInformation::SizeOfIncludingThis(
mozilla::MallocSizeOf aMallocSizeOf) const
{
return aMallocSizeOf(this);
}

Просмотреть файл

@ -1,64 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef PageInformation_h
#define PageInformation_h
#include "nsID.h"
#include "nsString.h"
#include "platform.h"
#include "ProfileJSONWriter.h"
// This class contains information that's relevant to a single page only
// while the page information is important and registered with the profiler,
// but regardless of whether the profiler is running. All accesses to it are
// protected by the profiler state lock.
// When the page gets unregistered, we keep the profiler buffer position
// to determine if we are still using this page. If not, we unregister
// it in the next page registration.
class PageInformation final
{
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(PageInformation)
PageInformation(const nsID& aDocShellId,
uint32_t aDocShellHistoryId,
const nsCString& aUrl,
bool aIsSubFrame);
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
bool Equals(PageInformation* aOtherDocShellInfo);
void StreamJSON(SpliceableJSONWriter& aWriter);
uint32_t DocShellHistoryId() { return mDocShellHistoryId; }
const nsID& DocShellId() { return mDocShellId; }
const nsCString& Url() { return mUrl; }
bool IsSubFrame() { return mIsSubFrame; }
mozilla::Maybe<uint64_t> BufferPositionWhenUnregistered()
{
return mBufferPositionWhenUnregistered;
}
void NotifyUnregistered(uint64_t aBufferPosition)
{
mBufferPositionWhenUnregistered = mozilla::Some(aBufferPosition);
}
private:
const nsID mDocShellId;
const uint32_t mDocShellHistoryId;
const nsCString mUrl;
const bool mIsSubFrame;
// Holds the buffer position when DocShell is unregistered.
// It's used to determine if we still use this DocShell in the profiler or
// not.
mozilla::Maybe<uint64_t> mBufferPositionWhenUnregistered;
virtual ~PageInformation() = default;
};
#endif // PageInformation_h

Просмотреть файл

@ -43,12 +43,6 @@ ProfilerMarkerPayload::StreamCommonProps(const char* aMarkerType,
StreamType(aMarkerType, aWriter);
WriteTime(aWriter, aProcessStartTime, mStartTime, "startTime");
WriteTime(aWriter, aProcessStartTime, mEndTime, "endTime");
if (mDocShellId) {
aWriter.StringProperty("docShellId", nsIDToCString(*mDocShellId).get());
}
if (mDocShellHistoryId) {
aWriter.DoubleProperty("docshellHistoryId", mDocShellHistoryId.ref());
}
if (mStack) {
aWriter.StartObjectProperty("stack");
{

Просмотреть файл

@ -264,16 +264,10 @@ public:
aProfSize += registeredThread->SizeOfIncludingThis(aMallocSizeOf);
}
for (auto& registeredPage : sInstance->mRegisteredPages) {
aProfSize += registeredPage->SizeOfIncludingThis(aMallocSizeOf);
}
// Measurement of the following things may be added later if DMD finds it
// is worthwhile:
// - CorePS::mRegisteredThreads itself (its elements' children are
// measured above)
// - CorePS::mRegisteredPages itself (its elements' children are
// measured above)
// - CorePS::mRegisteredThreads itself (its elements' children are measured
// above)
// - CorePS::mInterposeObserver
#if defined(USE_LUL_STACKWALK)
@ -302,38 +296,6 @@ public:
[&](UniquePtr<RegisteredThread>& rt) { return rt.get() == aRegisteredThread; });
}
PS_GET(nsTArray<RefPtr<PageInformation>>&, RegisteredPages)
static void AppendRegisteredPage(
PSLockRef,
RefPtr<PageInformation>&& aRegisteredPage)
{
#ifdef DEBUG
struct RegisteredPageComparator
{
bool Equals(PageInformation* aA,
PageInformation* aB) const
{
return aA->Equals(aB);
}
};
MOZ_ASSERT(!sInstance->mRegisteredPages.Contains(
aRegisteredPage, RegisteredPageComparator()));
#endif
sInstance->mRegisteredPages.AppendElement(
std::move(aRegisteredPage));
}
static void RemoveRegisteredPages(PSLockRef,
const nsID& aRegisteredDocShellId)
{
// Remove RegisteredPage from mRegisteredPages by given DocShell Id.
sInstance->mRegisteredPages.RemoveElementsBy(
[&](RefPtr<PageInformation>& rd) {
return rd->DocShellId().Equals(aRegisteredDocShellId);
});
}
PS_GET(const nsTArray<BaseProfilerCount*>&, Counters)
static void AppendCounter(PSLockRef, BaseProfilerCount* aCounter)
@ -370,10 +332,6 @@ private:
// ThreadIds in mRegisteredThreads are unique.
nsTArray<UniquePtr<RegisteredThread>> mRegisteredThreads;
// Info on all the registered pages.
// DocShellId and DocShellHistoryId pairs in mRegisteredPages are unique.
nsTArray<RefPtr<PageInformation>> mRegisteredPages;
// Non-owning pointers to all active counters
nsTArray<BaseProfilerCount*> mCounters;
@ -648,20 +606,6 @@ public:
return array;
}
static nsTArray<RefPtr<PageInformation>> ProfiledPages(PSLockRef aLock)
{
nsTArray<RefPtr<PageInformation>> array;
for (auto& d : CorePS::RegisteredPages(aLock)) {
array.AppendElement(d);
}
for (auto& d : sInstance->mDeadProfiledPages) {
array.AppendElement(d);
}
// We don't need to sort the DocShells like threads since we won't show them
// as a list.
return array;
}
// Do a linear search through mLiveProfiledThreads to find the
// ProfiledThreadData object for a RegisteredThread.
static ProfiledThreadData* GetProfiledThreadData(PSLockRef,
@ -725,35 +669,6 @@ public:
});
}
static void UnregisterPages(PSLockRef aLock,
const nsID& aRegisteredDocShellId)
{
auto& registeredPages = CorePS::RegisteredPages(aLock);
for (size_t i = 0; i < registeredPages.Length(); i++) {
RefPtr<PageInformation>& page = registeredPages[i];
if (page->DocShellId().Equals(aRegisteredDocShellId)) {
page->NotifyUnregistered(sInstance->mBuffer->mRangeEnd);
sInstance->mDeadProfiledPages.AppendElement(std::move(page));
registeredPages.RemoveElementAt(i--);
}
}
}
static void DiscardExpiredPages(PSLockRef)
{
uint64_t bufferRangeStart = sInstance->mBuffer->mRangeStart;
// Discard any dead pages that were unregistered before
// bufferRangeStart.
sInstance->mDeadProfiledPages.RemoveElementsBy(
[bufferRangeStart](RefPtr<PageInformation>& aProfiledPage) {
Maybe<uint64_t> bufferPosition =
aProfiledPage->BufferPositionWhenUnregistered();
MOZ_RELEASE_ASSERT(bufferPosition,
"should have unregistered this page");
return *bufferPosition < bufferRangeStart;
});
}
private:
// The singleton instance.
static ActivePS* sInstance;
@ -802,12 +717,6 @@ private:
nsTArray<LiveProfiledThreadData> mLiveProfiledThreads;
nsTArray<UniquePtr<ProfiledThreadData>> mDeadProfiledThreads;
// Info on all the dead pages.
// Registered pages are being moved to this array after unregistration.
// We are keeping them in case we need them in the profile data.
// We are removing them when we ensure that we won't need them anymore.
nsTArray<RefPtr<PageInformation>> mDeadProfiledPages;
// The current sampler thread. This class is not responsible for destroying
// the SamplerThread object; the Destroy() method returns it so the caller
// can destroy it.
@ -1890,16 +1799,6 @@ StreamMetaJSCustomObject(PSLockRef aLock, SpliceableJSONWriter& aWriter,
}
}
static void
StreamPages(PSLockRef aLock, SpliceableJSONWriter& aWriter)
{
MOZ_RELEASE_ASSERT(CorePS::Exists());
ActivePS::DiscardExpiredPages(aLock);
for (const auto& page : ActivePS::ProfiledPages(aLock)) {
page->StreamJSON(aWriter);
}
}
#if defined(GP_OS_android)
static UniquePtr<ProfileBuffer>
CollectJavaThreadProfileData()
@ -1976,13 +1875,6 @@ locked_profiler_stream_json_for_this_process(PSLockRef aLock,
}
aWriter.EndObject();
// Put page data
aWriter.StartArrayProperty("pages");
{
StreamPages(aLock, aWriter);
}
aWriter.EndArray();
buffer.StreamCountersToJSON(aWriter, CorePS::ProcessStartTime(), aSinceTime);
buffer.StreamMemoryToJSON(aWriter, CorePS::ProcessStartTime(), aSinceTime);
@ -3551,60 +3443,6 @@ profiler_unregister_thread()
}
}
void
profiler_register_page(const nsID& aDocShellId,
uint32_t aHistoryId,
const nsCString& aUrl,
bool aIsSubFrame)
{
DEBUG_LOG("profiler_register_page(%s, %u, %s, %d)",
aDocShellId.ToString(),
aHistoryId,
aUrl.get(),
aIsSubFrame);
MOZ_RELEASE_ASSERT(CorePS::Exists());
PSAutoLock lock(gPSMutex);
// If profiler is not active, delete all the previous page entries of the
// given DocShell since we won't need those.
if (!ActivePS::Exists(lock)) {
CorePS::RemoveRegisteredPages(lock, aDocShellId);
}
RefPtr<PageInformation> pageInfo =
new PageInformation(aDocShellId, aHistoryId, aUrl, aIsSubFrame);
CorePS::AppendRegisteredPage(lock, std::move(pageInfo));
// After appending the given page to CorePS, look for the expired
// pages and remove them if there are any.
if (ActivePS::Exists(lock)) {
ActivePS::DiscardExpiredPages(lock);
}
}
void
profiler_unregister_pages(const nsID& aRegisteredDocShellId)
{
if (!CorePS::Exists()) {
// This function can be called after the main thread has already shut down.
return;
}
PSAutoLock lock(gPSMutex);
// During unregistration, if the profiler is active, we have to keep the
// page information since there may be some markers associated with the given
// page. But if profiler is not active. we have no reason to keep the
// page information here because there can't be any marker associated with it.
if (ActivePS::Exists(lock)) {
ActivePS::UnregisterPages(lock, aRegisteredDocShellId);
} else {
CorePS::RemoveRegisteredPages(lock, aRegisteredDocShellId);
}
}
void
profiler_thread_sleep()
{
@ -3842,11 +3680,8 @@ profiler_add_marker_for_thread(int aThreadId,
}
void
profiler_tracing(const char* aCategory,
const char* aMarkerName,
TracingKind aKind,
const Maybe<nsID>& aDocShellId,
const Maybe<uint32_t>& aDocShellHistoryId)
profiler_tracing(const char* aCategory, const char* aMarkerName,
TracingKind aKind)
{
MOZ_RELEASE_ASSERT(CorePS::Exists());
@ -3857,18 +3692,13 @@ profiler_tracing(const char* aCategory,
return;
}
auto payload = MakeUnique<TracingMarkerPayload>(
aCategory, aKind, aDocShellId, aDocShellHistoryId);
auto payload = MakeUnique<TracingMarkerPayload>(aCategory, aKind);
racy_profiler_add_marker(aMarkerName, std::move(payload));
}
void
profiler_tracing(const char* aCategory,
const char* aMarkerName,
TracingKind aKind,
UniqueProfilerBacktrace aCause,
const Maybe<nsID>& aDocShellId,
const Maybe<uint32_t>& aDocShellHistoryId)
profiler_tracing(const char* aCategory, const char* aMarkerName,
TracingKind aKind, UniqueProfilerBacktrace aCause)
{
MOZ_RELEASE_ASSERT(CorePS::Exists());
@ -3879,8 +3709,8 @@ profiler_tracing(const char* aCategory,
return;
}
auto payload = MakeUnique<TracingMarkerPayload>(
aCategory, aKind, aDocShellId, aDocShellHistoryId, std::move(aCause));
auto payload =
MakeUnique<TracingMarkerPayload>(aCategory, aKind, std::move(aCause));
racy_profiler_add_marker(aMarkerName, std::move(payload));
}

Просмотреть файл

@ -20,7 +20,6 @@ if CONFIG['MOZ_GECKO_PROFILER']:
'public/shared-libraries.h',
]
UNIFIED_SOURCES += [
'core/PageInformation.cpp',
'core/platform.cpp',
'core/ProfileBuffer.cpp',
'core/ProfileBufferEntry.cpp',

Просмотреть файл

@ -50,11 +50,8 @@
#define PROFILER_ADD_MARKER(markerName)
#define PROFILER_ADD_NETWORK_MARKER(uri, pri, channel, type, start, end, count, timings, redirect)
#define DECLARE_DOCSHELL_AND_HISTORY_ID(docShell)
#define PROFILER_TRACING(category, markerName, kind)
#define PROFILER_TRACING_DOCSHELL(category, markerName, kind, docshell)
#define AUTO_PROFILER_TRACING(category, markerName)
#define AUTO_PROFILER_TRACING_DOCSHELL(category, markerName, docShell)
#else // !MOZ_GECKO_PROFILER
@ -77,8 +74,6 @@
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "nscore.h"
#include "nsID.h"
#include "nsString.h"
// Make sure that we can use std::min here without the Windows headers messing
// with us.
@ -298,33 +293,6 @@ void profiler_ensure_started(uint32_t aCapacity, double aInterval,
ProfilingStack* profiler_register_thread(const char* name, void* guessStackTop);
void profiler_unregister_thread();
// Register pages with the profiler.
//
// The `page` means every new history entry for docShells.
// DocShellId + HistoryID is a unique pair to identify these pages.
// We also keep these pairs inside markers to associate with the pages.
// That allows us to see which markers belong to a specific page and filter the
// markers by a page.
// We register pages in these cases:
// - If there is a navigation through a link or URL bar.
// - If there is a navigation through `location.replace` or `history.pushState`.
// We do not register pages in these cases:
// - If there is a history navigation through the back and forward buttons.
// - If there is a navigation through `history.replaceState` or anchor scrolls.
//
// "aDocShellId" is the ID of the docShell that page belongs to.
// "aHistoryId" is the ID of the history entry on the given docShell.
// "aUrl" is the URL of the page.
// "aIsSubFrame" is true if the page is a sub frame.
void profiler_register_page(const nsID& aDocShellId,
uint32_t aHistoryId,
const nsCString& aUrl,
bool aIsSubFrame);
// Unregister pages with the profiler.
//
// Take a docShellId and unregister all the page entries that have the given ID.
void profiler_unregister_pages(const nsID& aRegisteredDocShellId);
class BaseProfilerCount;
void profiler_add_sampled_counter(BaseProfilerCount* aCounter);
void profiler_remove_sampled_counter(BaseProfilerCount* aCounter);
@ -618,55 +586,18 @@ enum TracingKind {
TRACING_INTERVAL_END,
};
// Helper macro to retrieve DocShellId and DocShellHistoryId from docShell
#define DECLARE_DOCSHELL_AND_HISTORY_ID(docShell) \
mozilla::Maybe<nsID> docShellId; \
mozilla::Maybe<uint32_t> docShellHistoryId; \
if (docShell) { \
docShellId = Some(docShell->HistoryID()); \
uint32_t id; \
nsresult rv = docShell->GetOSHEId(&id); \
if (NS_SUCCEEDED(rv)) { \
docShellHistoryId = Some(id); \
} else { \
docShellHistoryId = Nothing(); \
} \
} else { \
docShellId = Nothing(); \
docShellHistoryId = Nothing(); \
}
// Adds a tracing marker to the profile. A no-op if the profiler is inactive or
// in privacy mode.
#define PROFILER_TRACING(category, markerName, kind) \
profiler_tracing(category, markerName, kind)
#define PROFILER_TRACING_DOCSHELL(category, markerName, kind, docShell) \
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell); \
profiler_tracing(category, markerName, kind, docShellId, docShellHistoryId)
void
profiler_tracing(
const char* aCategory,
const char* aMarkerName,
TracingKind aKind,
const mozilla::Maybe<nsID>& aDocShellId = mozilla::Nothing(),
const mozilla::Maybe<uint32_t>& aDocShellHistoryId = mozilla::Nothing());
void
profiler_tracing(
const char* aCategory,
const char* aMarkerName,
TracingKind aKind,
UniqueProfilerBacktrace aCause,
const mozilla::Maybe<nsID>& aDocShellId = mozilla::Nothing(),
const mozilla::Maybe<uint32_t>& aDocShellHistoryId = mozilla::Nothing());
void profiler_tracing(const char* aCategory, const char* aMarkerName,
TracingKind aKind);
void profiler_tracing(const char* aCategory, const char* aMarkerName,
TracingKind aKind, UniqueProfilerBacktrace aCause);
// Adds a START/END pair of tracing markers.
#define AUTO_PROFILER_TRACING(category, markerName) \
mozilla::AutoProfilerTracing PROFILER_RAII( \
category, markerName, mozilla::Nothing(), mozilla::Nothing())
#define AUTO_PROFILER_TRACING_DOCSHELL(category, markerName, docShell) \
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell); \
mozilla::AutoProfilerTracing PROFILER_RAII( \
category, markerName, docShellId, docShellHistoryId)
mozilla::AutoProfilerTracing PROFILER_RAII(category, markerName)
//---------------------------------------------------------------------------
// Output profiles
@ -850,59 +781,35 @@ public:
class MOZ_RAII AutoProfilerTracing
{
public:
AutoProfilerTracing(const char* aCategory,
const char* aMarkerName,
const mozilla::Maybe<nsID>& aDocShellId,
const mozilla::Maybe<uint32_t>& aDocShellHistoryId
AutoProfilerTracing(const char* aCategory, const char* aMarkerName
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: mCategory(aCategory)
, mMarkerName(aMarkerName)
, mDocShellId(aDocShellId)
, mDocShellHistoryId(aDocShellHistoryId)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
profiler_tracing(mCategory,
mMarkerName,
TRACING_INTERVAL_START,
mDocShellId,
mDocShellHistoryId);
profiler_tracing(mCategory, mMarkerName, TRACING_INTERVAL_START);
}
AutoProfilerTracing(const char* aCategory,
const char* aMarkerName,
UniqueProfilerBacktrace aBacktrace,
const mozilla::Maybe<nsID>& aDocShellId,
const mozilla::Maybe<uint32_t>& aDocShellHistoryId
AutoProfilerTracing(const char* aCategory, const char* aMarkerName,
UniqueProfilerBacktrace aBacktrace
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: mCategory(aCategory)
, mMarkerName(aMarkerName)
, mDocShellId(aDocShellId)
, mDocShellHistoryId(aDocShellHistoryId)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
profiler_tracing(mCategory,
mMarkerName,
TRACING_INTERVAL_START,
std::move(aBacktrace),
mDocShellId,
mDocShellHistoryId);
profiler_tracing(mCategory, mMarkerName, TRACING_INTERVAL_START,
std::move(aBacktrace));
}
~AutoProfilerTracing()
{
profiler_tracing(mCategory,
mMarkerName,
TRACING_INTERVAL_END,
mDocShellId,
mDocShellHistoryId);
profiler_tracing(mCategory, mMarkerName, TRACING_INTERVAL_END);
}
protected:
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
const char* mCategory;
const char* mMarkerName;
const mozilla::Maybe<nsID> mDocShellId;
const mozilla::Maybe<uint32_t> mDocShellHistoryId;
};
// Set MOZ_PROFILER_STARTUP* environment variables that will be inherited into

Просмотреть файл

@ -38,26 +38,16 @@ class UniqueStacks;
class ProfilerMarkerPayload
{
public:
explicit ProfilerMarkerPayload(
const mozilla::Maybe<nsID>& aDocShellId = mozilla::Nothing(),
const mozilla::Maybe<uint32_t>& aDocShellHistoryId = mozilla::Nothing(),
UniqueProfilerBacktrace aStack = nullptr)
explicit ProfilerMarkerPayload(UniqueProfilerBacktrace aStack = nullptr)
: mStack(std::move(aStack))
, mDocShellId(aDocShellId)
, mDocShellHistoryId(aDocShellHistoryId)
{}
ProfilerMarkerPayload(
const mozilla::TimeStamp& aStartTime,
ProfilerMarkerPayload(const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime,
const mozilla::Maybe<nsID>& aDocShellId = mozilla::Nothing(),
const mozilla::Maybe<uint32_t>& aDocShellHistoryId = mozilla::Nothing(),
UniqueProfilerBacktrace aStack = nullptr)
: mStartTime(aStartTime)
, mEndTime(aEndTime)
, mStack(std::move(aStack))
, mDocShellId(aDocShellId)
, mDocShellHistoryId(aDocShellHistoryId)
{}
virtual ~ProfilerMarkerPayload() {}
@ -80,22 +70,10 @@ protected:
mStack = std::move(aStack);
}
void SetDocShellHistoryId(const mozilla::Maybe<uint32_t>& aDocShellHistoryId)
{
mDocShellHistoryId = aDocShellHistoryId;
}
void SetDocShellId(const mozilla::Maybe<nsID>& aDocShellId)
{
mDocShellId = aDocShellId;
}
private:
mozilla::TimeStamp mStartTime;
mozilla::TimeStamp mEndTime;
UniqueProfilerBacktrace mStack;
mozilla::Maybe<nsID> mDocShellId;
mozilla::Maybe<uint32_t> mDocShellHistoryId;
};
#define DECL_STREAM_PAYLOAD \
@ -103,15 +81,10 @@ private:
const mozilla::TimeStamp& aProcessStartTime, \
UniqueStacks& aUniqueStacks) override;
// TODO: Increase the coverage of tracing markers that include DocShell information
class TracingMarkerPayload : public ProfilerMarkerPayload
{
public:
TracingMarkerPayload(
const char* aCategory,
TracingKind aKind,
const mozilla::Maybe<nsID>& aDocShellId = mozilla::Nothing(),
const mozilla::Maybe<uint32_t>& aDocShellHistoryId = mozilla::Nothing(),
TracingMarkerPayload(const char* aCategory, TracingKind aKind,
UniqueProfilerBacktrace aCause = nullptr)
: mCategory(aCategory)
, mKind(aKind)
@ -119,8 +92,6 @@ public:
if (aCause) {
SetStack(std::move(aCause));
}
SetDocShellId(aDocShellId);
SetDocShellHistoryId(aDocShellHistoryId);
}
DECL_STREAM_PAYLOAD
@ -133,16 +104,11 @@ private:
class IOMarkerPayload : public ProfilerMarkerPayload
{
public:
IOMarkerPayload(const char* aSource,
const char* aFilename,
IOMarkerPayload(const char* aSource, const char* aFilename,
const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime,
UniqueProfilerBacktrace aStack)
: ProfilerMarkerPayload(aStartTime,
aEndTime,
mozilla::Nothing(),
mozilla::Nothing(),
std::move(aStack))
: ProfilerMarkerPayload(aStartTime, aEndTime, std::move(aStack))
, mSource(aSource)
, mFilename(aFilename ? strdup(aFilename) : nullptr)
{
@ -161,11 +127,8 @@ class DOMEventMarkerPayload : public TracingMarkerPayload
public:
DOMEventMarkerPayload(const nsAString& aEventType,
const mozilla::TimeStamp& aTimeStamp,
const char* aCategory,
TracingKind aKind,
const mozilla::Maybe<nsID>& aDocShellId,
const mozilla::Maybe<uint32_t>& aDocShellHistoryId)
: TracingMarkerPayload(aCategory, aKind, aDocShellId, aDocShellHistoryId)
const char* aCategory, TracingKind aKind)
: TracingMarkerPayload(aCategory, aKind)
, mTimeStamp(aTimeStamp)
, mEventType(aEventType)
{}
@ -181,13 +144,8 @@ class UserTimingMarkerPayload : public ProfilerMarkerPayload
{
public:
UserTimingMarkerPayload(const nsAString& aName,
const mozilla::TimeStamp& aStartTime,
const mozilla::Maybe<nsID>& aDocShellId,
const mozilla::Maybe<uint32_t>& aDocShellHistoryId)
: ProfilerMarkerPayload(aStartTime,
aStartTime,
aDocShellId,
aDocShellHistoryId)
const mozilla::TimeStamp& aStartTime)
: ProfilerMarkerPayload(aStartTime, aStartTime)
, mEntryType("mark")
, mName(aName)
{}
@ -196,13 +154,8 @@ public:
const mozilla::Maybe<nsString>& aStartMark,
const mozilla::Maybe<nsString>& aEndMark,
const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime,
const mozilla::Maybe<nsID>& aDocShellId,
const mozilla::Maybe<uint32_t>& aDocShellHistoryId)
: ProfilerMarkerPayload(aStartTime,
aEndTime,
aDocShellId,
aDocShellHistoryId)
const mozilla::TimeStamp& aEndTime)
: ProfilerMarkerPayload(aStartTime, aEndTime)
, mEntryType("measure")
, mName(aName)
, mStartMark(aStartMark)
@ -255,8 +208,7 @@ public:
class NetworkMarkerPayload : public ProfilerMarkerPayload
{
public:
NetworkMarkerPayload(int64_t aID,
const char* aURI,
NetworkMarkerPayload(int64_t aID, const char* aURI,
NetworkLoadType aType,
const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime,
@ -264,12 +216,10 @@ public:
int64_t aCount,
const mozilla::net::TimingStruct* aTimings = nullptr,
const char* aRedirectURI = nullptr)
: ProfilerMarkerPayload(aStartTime, aEndTime, mozilla::Nothing())
: ProfilerMarkerPayload(aStartTime, aEndTime)
, mID(aID)
, mURI(aURI ? strdup(aURI) : nullptr)
, mRedirectURI(aRedirectURI && (strlen(aRedirectURI) > 0)
? strdup(aRedirectURI)
: nullptr)
, mRedirectURI(aRedirectURI && (strlen(aRedirectURI) > 0) ? strdup(aRedirectURI) : nullptr)
, mType(aType)
, mPri(aPri)
, mCount(aCount)
@ -378,13 +328,8 @@ public:
StyleMarkerPayload(const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime,
UniqueProfilerBacktrace aCause,
const mozilla::ServoTraversalStatistics& aStats,
const mozilla::Maybe<nsID>& aDocShellId,
const mozilla::Maybe<uint32_t>& aDocShellHistoryId)
: ProfilerMarkerPayload(aStartTime,
aEndTime,
aDocShellId,
aDocShellHistoryId)
const mozilla::ServoTraversalStatistics& aStats)
: ProfilerMarkerPayload(aStartTime, aEndTime)
, mStats(aStats)
{
if (aCause) {

Просмотреть файл

@ -458,10 +458,7 @@ TEST(GeckoProfiler, Markers)
PROFILER_ADD_MARKER("M3");
profiler_add_marker(
"M4",
MakeUnique<TracingMarkerPayload>("C",
TRACING_EVENT,
mozilla::Nothing(),
mozilla::Nothing(),
MakeUnique<TracingMarkerPayload>("C", TRACING_EVENT,
profiler_get_backtrace()));
for (int i = 0; i < 10; i++) {