gecko-dev/tools/profiler/public/ProfilerMarkerPayload.h

303 строки
9.0 KiB
C
Исходник Обычный вид История

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 PROFILER_MARKERS_H
#define PROFILER_MARKERS_H
#include "mozilla/TimeStamp.h"
#include "mozilla/Attributes.h"
#include "mozilla/RefPtr.h"
#include "nsString.h"
#include "GeckoProfiler.h"
#include "js/Utility.h"
#include "gfxASurface.h"
namespace mozilla {
namespace layers {
class Layer;
} // namespace layers
} // namespace mozilla
class SpliceableJSONWriter;
class UniqueStacks;
/**
* This is an abstract object that can be implied to supply
* data to be attached with a profiler marker. Most data inserted
* into a profile is stored in a circular buffer. This buffer
* typically wraps around and overwrites most entries. Because
* of this, this structure is designed to defer the work of
* prepare the payload only when 'preparePayload' is called.
*
* Note when implementing that this object is typically constructed
* on a particular thread but 'preparePayload' and the destructor
* is called from the main thread.
*/
class ProfilerMarkerPayload
{
public:
explicit ProfilerMarkerPayload(UniqueProfilerBacktrace aStack = nullptr);
ProfilerMarkerPayload(const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime,
UniqueProfilerBacktrace aStack = nullptr);
/**
* Called from the main thread
*/
virtual ~ProfilerMarkerPayload();
/**
* Called from the main thread
*/
virtual void StreamPayload(SpliceableJSONWriter& aWriter,
const mozilla::TimeStamp& aStartTime,
UniqueStacks& aUniqueStacks) = 0;
mozilla::TimeStamp GetStartTime() const { return mStartTime; }
protected:
/**
* Called from the main thread
*/
void streamCommonProps(const char* aMarkerType,
SpliceableJSONWriter& aWriter,
const mozilla::TimeStamp& aStartTime,
UniqueStacks& aUniqueStacks);
void SetStack(UniqueProfilerBacktrace aStack) { mStack = mozilla::Move(aStack); }
private:
mozilla::TimeStamp mStartTime;
mozilla::TimeStamp mEndTime;
UniqueProfilerBacktrace mStack;
};
class ProfilerMarkerTracing : public ProfilerMarkerPayload
{
public:
ProfilerMarkerTracing(const char* aCategory, TracingKind aKind);
ProfilerMarkerTracing(const char* aCategory, TracingKind aKind,
UniqueProfilerBacktrace aCause);
const char *GetCategory() const { return mCategory; }
TracingKind GetKind() const { return mKind; }
virtual void StreamPayload(SpliceableJSONWriter& aWriter,
const mozilla::TimeStamp& aStartTime,
UniqueStacks& aUniqueStacks) override;
private:
const char *mCategory;
TracingKind mKind;
};
class ProfilerMarkerImagePayload : public ProfilerMarkerPayload
{
public:
explicit ProfilerMarkerImagePayload(gfxASurface *aImg);
virtual void StreamPayload(SpliceableJSONWriter& aWriter,
const mozilla::TimeStamp& aStartTime,
UniqueStacks& aUniqueStacks) override;
private:
Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat The bulk of this commit was generated with a script, executed at the top level of a typical source code checkout. The only non-machine-generated part was modifying MFBT's moz.build to reflect the new naming. CLOSED TREE makes big refactorings like this a piece of cake. # The main substitution. find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \ xargs perl -p -i -e ' s/nsRefPtr\.h/RefPtr\.h/g; # handle includes s/nsRefPtr ?</RefPtr</g; # handle declarations and variables ' # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h. perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h # Handle nsRefPtr.h itself, a couple places that define constructors # from nsRefPtr, and code generators specially. We do this here, rather # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename # things like nsRefPtrHashtable. perl -p -i -e 's/nsRefPtr/RefPtr/g' \ mfbt/nsRefPtr.h \ xpcom/glue/nsCOMPtr.h \ xpcom/base/OwningNonNull.h \ ipc/ipdl/ipdl/lower.py \ ipc/ipdl/ipdl/builtin.py \ dom/bindings/Codegen.py \ python/lldbutils/lldbutils/utils.py # In our indiscriminate substitution above, we renamed # nsRefPtrGetterAddRefs, the class behind getter_AddRefs. Fix that up. find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \ xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g' if [ -d .git ]; then git mv mfbt/nsRefPtr.h mfbt/RefPtr.h else hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h fi --HG-- rename : mfbt/nsRefPtr.h => mfbt/RefPtr.h
2015-10-18 08:24:48 +03:00
RefPtr<gfxASurface> mImg;
};
class IOMarkerPayload : public ProfilerMarkerPayload
{
public:
IOMarkerPayload(const char* aSource, const char* aFilename, const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime,
UniqueProfilerBacktrace aStack);
~IOMarkerPayload();
virtual void StreamPayload(SpliceableJSONWriter& aWriter,
const mozilla::TimeStamp& aStartTime,
UniqueStacks& aUniqueStacks) override;
private:
const char* mSource;
char* mFilename;
};
class DOMEventMarkerPayload : public ProfilerMarkerPayload
{
public:
DOMEventMarkerPayload(const nsAString& aType, uint16_t aPhase,
const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime);
~DOMEventMarkerPayload();
virtual void StreamPayload(SpliceableJSONWriter& aWriter,
const mozilla::TimeStamp& aStartTime,
UniqueStacks& aUniqueStacks) override;
private:
nsString mType;
uint16_t mPhase;
};
class UserTimingMarkerPayload : public ProfilerMarkerPayload
{
public:
UserTimingMarkerPayload(const nsAString& aName,
const mozilla::TimeStamp& aStartTime);
UserTimingMarkerPayload(const nsAString& aName,
const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime);
~UserTimingMarkerPayload();
virtual void StreamPayload(SpliceableJSONWriter& aWriter,
const mozilla::TimeStamp& aStartTime,
UniqueStacks& aUniqueStacks) override;
private:
// Either "mark" or "measure".
const char* mEntryType;
nsString mName;
};
/**
* Contains the translation applied to a 2d layer so we can
* track the layer position at each frame.
*/
class LayerTranslationPayload : public ProfilerMarkerPayload
{
public:
LayerTranslationPayload(mozilla::layers::Layer* aLayer,
mozilla::gfx::Point aPoint);
virtual void StreamPayload(SpliceableJSONWriter& aWriter,
const mozilla::TimeStamp& aStartTime,
UniqueStacks& aUniqueStacks) override;
private:
mozilla::layers::Layer* mLayer;
mozilla::gfx::Point mPoint;
};
#include "Units.h" // For ScreenIntPoint
/**
* Tracks when touch events are processed by gecko, not when
* the touch actually occured in gonk/android.
*/
class TouchDataPayload : public ProfilerMarkerPayload
{
public:
explicit TouchDataPayload(const mozilla::ScreenIntPoint& aPoint);
virtual ~TouchDataPayload() {}
virtual void StreamPayload(SpliceableJSONWriter& aWriter,
const mozilla::TimeStamp& aStartTime,
UniqueStacks& aUniqueStacks) override;
private:
mozilla::ScreenIntPoint mPoint;
};
/**
* Tracks when a vsync occurs according to the HardwareComposer.
*/
class VsyncPayload : public ProfilerMarkerPayload
{
public:
explicit VsyncPayload(mozilla::TimeStamp aVsyncTimestamp);
virtual ~VsyncPayload() {}
virtual void StreamPayload(SpliceableJSONWriter& aWriter,
const mozilla::TimeStamp& aStartTime,
UniqueStacks& aUniqueStacks) override;
private:
mozilla::TimeStamp mVsyncTimestamp;
};
class GPUMarkerPayload : public ProfilerMarkerPayload
{
public:
GPUMarkerPayload(const mozilla::TimeStamp& aCpuTimeStart,
const mozilla::TimeStamp& aCpuTimeEnd,
uint64_t aGpuTimeStart,
uint64_t aGpuTimeEnd);
~GPUMarkerPayload() {}
virtual void StreamPayload(SpliceableJSONWriter& aWriter,
const mozilla::TimeStamp& aStartTime,
UniqueStacks& aUniqueStacks) override;
private:
mozilla::TimeStamp mCpuTimeStart;
mozilla::TimeStamp mCpuTimeEnd;
uint64_t mGpuTimeStart;
uint64_t mGpuTimeEnd;
};
class GCSliceMarkerPayload : public ProfilerMarkerPayload
{
public:
GCSliceMarkerPayload(const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime,
JS::UniqueChars&& aTimingJSON)
: ProfilerMarkerPayload(aStartTime, aEndTime, nullptr),
mTimingJSON(mozilla::Move(aTimingJSON))
{}
virtual ~GCSliceMarkerPayload() {}
void StreamPayload(SpliceableJSONWriter& aWriter,
const mozilla::TimeStamp& aStartTime,
UniqueStacks& aUniqueStacks) override;
private:
JS::UniqueChars mTimingJSON;
};
class GCMajorMarkerPayload : public ProfilerMarkerPayload
{
public:
GCMajorMarkerPayload(const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime,
JS::UniqueChars&& aTimingJSON)
: ProfilerMarkerPayload(aStartTime, aEndTime, nullptr),
mTimingJSON(mozilla::Move(aTimingJSON))
{}
virtual ~GCMajorMarkerPayload() {}
void StreamPayload(SpliceableJSONWriter& aWriter,
const mozilla::TimeStamp& aStartTime,
UniqueStacks& aUniqueStacks) override;
private:
JS::UniqueChars mTimingJSON;
};
class GCMinorMarkerPayload : public ProfilerMarkerPayload
{
public:
GCMinorMarkerPayload(const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime,
JS::UniqueChars&& aTimingData)
: ProfilerMarkerPayload(aStartTime, aEndTime, nullptr),
mTimingData(mozilla::Move(aTimingData))
{}
virtual ~GCMinorMarkerPayload() {};
void StreamPayload(SpliceableJSONWriter& aWriter,
const mozilla::TimeStamp& aStartTime,
UniqueStacks& aUniqueStacks) override;
private:
JS::UniqueChars mTimingData;
};
#endif // PROFILER_MARKERS_H